コード例 #1
0
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create()
 {
     //
     $proveedores = proveedores::lists('proveedor', 'id');
     $tiendas = tiendas::lists('tienda', 'id');
     $compras = productos_configurables::with('productos.marcas')->get()->toJson();
     return view('app/compras/compras_create', compact(['proveedores', 'tiendas', 'compras']));
 }
コード例 #2
0
ファイル: tiendas.php プロジェクト: vdjkelly/laravel
 public static function numero_factura($lastid)
 {
     $company = tiendas::find(Session::get('tenant.id'));
     if (!$lastid['venta'] == "") {
         $company->factura = $lastid['venta']['factura'];
     }
     if (!$lastid['remision'] == "") {
         $company->remision = $lastid['remision']['factura'];
     }
     $company->save();
 }
コード例 #3
0
ファイル: PosController.php プロジェクト: vdjkelly/laravel
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     //
     //dd($request->all());
     $lastid = ventas::separador_remision($request);
     tiendas::numero_factura($lastid);
     Bodegas::Agregar_Venta($request->items);
     ingresos::AgregarIngreso($lastid, $request->pagos);
     $factura = facturacion::AgregarFacturacion($lastid);
     return redirect('ventas/pos/' . $factura);
 }
コード例 #4
0
ファイル: VentaController.php プロジェクト: vdjkelly/laravel
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request $request
  * @return Response
  */
 public function store(Request $request)
 {
     //
     $lastid = ventas::separador_remision($request);
     tiendas::numero_factura($lastid);
     Bodegas::Agregar_Venta($request->items);
     ingresos::AgregarIngreso($lastid, $request->pagos);
     $factura = facturacion::AgregarFacturacion($lastid);
     despachos::crear_despacho($request, $factura);
     if (!$lastid['venta'] == "") {
         return redirect('ventas/' . $lastid['venta']['id']);
     } else {
         return redirect('ventas/' . $lastid['remision']['id']);
     }
 }
コード例 #5
0
ファイル: productos.php プロジェクト: vdjkelly/laravel
 public static function eliminar($id)
 {
     $configurables = productos_configurables::where('producto_id', $id)->get();
     $tiendas = tiendas::all();
     foreach ($tiendas as $tienda) {
         Session::put('bodega', $tienda->id);
         foreach ($configurables as $item) {
             Bodegas::where('codigo', $item->id)->delete();
         }
     }
     productos::find($id)->delete();
     Session::flash('mensaje', 'Producto eliminado exitosamente');
     Cache::forget('productos');
 }
コード例 #6
0
ファイル: ventas.php プロジェクト: vdjkelly/laravel
 public static function agregar_venta($datos, $items_venta)
 {
     $total = 0;
     $iva = 0;
     $valor = 0;
     $compra = 0;
     $descuento = 0;
     $subtotal = 0;
     foreach ($items_venta as $item) {
         $dto = $item['dto'] / 100 * $item['valor'] * $item['cantidad'];
         //$iva += ($item['iva'] / 100) * (($item['valor'] * $item['cantidad']) - $dto);
         $iva += $item['iva'] * $item['cantidad'];
         $subtotal += $item['valor'] * $item['cantidad'] - $iva;
         $compra += $item['compra'] * $item['cantidad'];
         $descuento += $dto;
     }
     foreach ($datos['pagos'] as $pago) {
         if ($pago['id'] == 6) {
             $valor += 0;
         } else {
             $valor += $pago['valor'];
         }
     }
     if ($descuento == 0) {
         $descuento = $datos['descuento'];
     }
     $factura = tiendas::find(Session::get('bodega'))->factura + 1;
     $venta = new ventas();
     $venta->factura = $factura;
     $venta->remision = 0;
     $venta->cliente_id = $datos['cliente_id'];
     $venta->tienda_id = Session::get('bodega');
     $venta->user_id = $datos['user_id'];
     $venta->venta = $subtotal - $descuento + $iva;
     $venta->subtotal = $subtotal;
     $venta->retefuente = $datos['retefuente'];
     $venta->iva = $iva;
     $venta->descuento = $descuento;
     $venta->compra = $compra;
     if ($valor > 0) {
         $sobrante = Session::get('sobrante');
         if ($sobrante > 0) {
             $venta->pagado = $sobrante;
         } else {
             $venta->pagado = $valor;
         }
     } else {
         $venta->pagado = 0;
     }
     $venta->save();
     venta_detalle::AgregarVentaDetalle($items_venta, $venta->id);
     return ['id' => $venta->id, 'factura' => $venta->factura];
 }