/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function edit(Request $request) { \DB::beginTransaction(); $varDetOrders = $request->detOrder; $varPayment = $request->payment; $movimiento = $request->movimiento; if ($movimiento['montoMovimientoEfectivo'] > 0) { //---create movimiento--- //var_dump($request->movimiento);die(); $detCashrepo; $movimiento['observacion'] = "temporal"; $movimiento['fecha'] = date('Y-m-d'); $movimiento['hora'] = date('H:i:s'); $detCashrepo = new DetCashRepo(); $movimientoSave = $detCashrepo->getModel(); $insertarMovimiento = new DetCashManager($movimientoSave, $movimiento); $insertarMovimiento->save(); //---Autualizar Caja--- $cajaAct = $request->caja; $cashrepo; $cashrepo = new CashRepo(); $cajaSave = $cashrepo->getModel(); $cash1 = $cashrepo->find($cajaAct["id"]); $manager1 = new CashManager($cash1, $cajaAct); $manager1->save(); //---------------- $salePaymentRepo; $salePaymentRepo = new SalePaymentRepo(); //$payment = $salePaymentRepo->find($varPayment['id']); $payment = $salePaymentRepo->find($varPayment['idPAY']); $manager = new SalePaymentManager($payment, $varPayment); $manager->save(); } $HeadStockRepo; $codigoHeadIS = 0; //$detOrderSaleRepo; foreach ($varDetOrders as $object) { //$detOrderSaleRepo = new DetSaleRepo; //$detorderSale = $detOrderSaleRepo->find($object['id']); //$manager = new DetSaleManager($detorderSale,$object); //$manager->save(); if (!empty($object['idStock'])) { $stokRepo; $stokRepo = new StockRepo(); $cajaSave = $stokRepo->getModel(); $stockOri = $stokRepo->find($object['id']); $stock = $stokRepo->find($object['idStock']); //+++if ($object['estad']==true) { $stock->stockActual = $stock->stockActual + $object['cantidad']; //+++}else{ //+++$stock->stockPedidos= $stock->stockPedidos+$object['canPendiente']; //+++} $stock->save(); //--------------reporte stock------------ $object["variant_id"] = $object['vari']; if ($codigoHeadIS === 0) { $object["warehouses_id"] = $object['idAlmacen']; //$object["cantidad_llegado"]=$cantidaCalculada; //$object['descripcion']='Entrada por compra'; //$object['tipo']='Entrada Venta'; $object['tipo'] = 'Entrada-Anulado'; $object["user_id"] = auth()->user()->id; //$object["Fecha"]=$request->input("fechaPedido"); $object["Fecha"] = date('Y-m-d H:i:s'); $HeadStockRepo = new HeadInputStockRepo(); $HeadStock = $HeadStockRepo->getModel(); $HeadStockinsert = new HeadInputStockManager($HeadStock, $object); $HeadStockinsert->save(); $codigoHeadIS = $HeadStock->id; } $object['headInputStock_id'] = $codigoHeadIS; $object["producto"] = $object['nameProducto'] . "(" . $object['NombreAtributos'] . ")"; $object["cantidad_llegado"] = $object['cantidad']; $object['descripcion'] = 'Entrada-Venta-Anulada'; $inputRepo; $inputRepo = new InputStockRepo(); $inputstock = $inputRepo->getModel(); $inputInsert = new InputStockManager($inputstock, $object); $inputInsert->save(); } //--------------------------------------- } $orderSale = $this->saleRepo->find($request->id); if ($request->input('estado') == '3') { $request->merge(array('fechaAnulado' => date('Y-m-d H:i:s'))); } $manager = new SaleManager($orderSale, $request->all()); $manager->save(); $serviceID = $orderSale->service_id; if (!empty($serviceID)) { $servicio = $this->serviceRepo->find($serviceID); $request->merge(["estado" => 4]); $request->merge(["numeroServicio" => $servicio->numeroServicio]); $request->merge(["fechaServicio" => $servicio->fechaServicio]); $request->merge(["tipo" => $servicio->tipo]); $request->merge(["cliente" => $servicio->cliente]); $request->merge(["ruc" => $servicio->ruc]); $request->merge(["direcion" => $servicio->direcion]); $request->merge(["telefono" => $servicio->telefono]); $request->merge(["empresa" => $servicio->empresa]); $request->merge(["descripcion" => $servicio->descripcion]); $request->merge(["modelo" => $servicio->modelo]); $request->merge(["serie" => $servicio->serie]); $request->merge(["accesorios" => $servicio->accesorios]); $request->merge(["diagnostico" => $servicio->diagnostico]); $request->merge(["accionCorrectiva" => $servicio->accionCorrectiva]); $request->merge(["ordenTrabajo" => $servicio->ordenTrabajo]); $request->merge(["customer_id" => $servicio->customer_id]); $request->merge(["employee_id" => $servicio->employee_id]); $request->merge(["user_id" => $servicio->user_id]); $manager = new ServiceManager($servicio, $request->all()); $manager->save(); } \DB::commit(); return response()->json(['estado' => true, 'nombre' => $orderSale->nombre]); }
public function edit(Request $request) { $varDetOrders = $request->detOrder; $varPayment = $request->payment; $movimiento = $request->movimiento; if ($movimiento['montoMovimientoEfectivo'] > 0) { //---create movimiento--- //var_dump($request->movimiento);die(); $detCashrepo; $movimiento['observacion'] = "temporal"; $detCashrepo = new DetCashRepo(); $movimientoSave = $detCashrepo->getModel(); $insertarMovimiento = new DetCashManager($movimientoSave, $movimiento); $insertarMovimiento->save(); //---Autualizar Caja--- $cajaAct = $request->caja; $cashrepo; $cashrepo = new CashRepo(); $cajaSave = $cashrepo->getModel(); $cash1 = $cashrepo->find($cajaAct["id"]); $manager1 = new CashManager($cash1, $cajaAct); $manager1->save(); //---------------- $salePaymentRepo; $salePaymentRepo = new SalePaymentRepo(); $payment = $salePaymentRepo->find($varPayment['id']); $manager = new SalePaymentManager($payment, $varPayment); $manager->save(); } $detOrderSaleRepo; foreach ($varDetOrders as $object) { $detOrderSaleRepo = new DetOrderSaleRepo(); $detorderSale = $detOrderSaleRepo->find($object['id']); $manager = new DetOrderSaleManager($detorderSale, $object); $manager->save(); $stokRepo; $stokRepo = new StockRepo(); $cajaSave = $stokRepo->getModel(); $stockOri = $stokRepo->find($object['id']); $stock = $stokRepo->find($object['idStock']); if ($object['estad'] == true) { $stock->stockPedidos = $stock->stockPedidos - $object['canPendiente']; } else { $stock->stockPedidos = $stock->stockPedidos + $object['canPendiente']; } $stock->save(); } $orderSale = $this->orderSaleRepo->find($request->id); $manager = new OrderSaleManager($orderSale, $request->all()); $manager->save(); return response()->json(['estado' => true, 'nombre' => $orderSale->nombre]); }
public function create(Request $request) { $orderSale = $this->separateSaleRepo->getModel(); $var = $request->detOrders; $payment = $request->salePayment; $saledetPayments = $request->saledetPayments; $manager = new SeparateSaleManager($orderSale, $request->all()); $manager->save(); /* if($this->purchaseRepo->validateDate(substr($request->input('fechaEntrega'),0,10))){ $order->fechaEntrega = substr($request->input('fechaEntrega'),0,10); }else{ $order->fechaEntrega = null; }*/ $orderSale->save(); $temporal = $orderSale->id; //---create movimiento--- $movimiento = $request->movimiento; $detCashrepo; $movimiento['observacion'] = $temporal; $detCashrepo = new DetCashRepo(); $movimientoSave = $detCashrepo->getModel(); $insertarMovimiento = new DetCashManager($movimientoSave, $movimiento); $insertarMovimiento->save(); $detCash_id = $movimientoSave->id; //---Autualizar Caja--- $cajaAct = $request->caja; $cashrepo; $cashrepo = new CashRepo(); $cajaSave = $cashrepo->getModel(); $cash1 = $cashrepo->find($cajaAct["id"]); $manager1 = new CashManager($cash1, $cajaAct); $manager1->save(); //---------------- $salePaymentrepo; $payment['separateSale_id'] = $temporal; $salePaymentrepo = new SalePaymentRepo(); $paymentSave = $salePaymentrepo->getModel(); $insertarpayment = new SalePaymentManager($paymentSave, $payment); $insertarpayment->save(); $paymentSave->save(); $temporal1 = $paymentSave->id; //-------------------------- $saledetPaymentrepo; foreach ($saledetPayments as $object1) { $object1['salePayment_id'] = $temporal1; $object1['detCash_id'] = $detCash_id; $saledetPaymentrepo = new SaleDetPaymentRepo(); $insertar = new SaleDetPaymentManager($saledetPaymentrepo->getModel(), $object1); $insertar->save(); $saledetPaymentrepo = null; } $detOrderrepox; foreach ($var as $object) { $object['separateSale_id'] = $temporal; $detOrderrepox = new DetSeparateSaleRepo(); $insertar = new DetSeparateSaleManager($detOrderrepox->getModel(), $object); $insertar->save(); $detOrderrepox = null; //------------------------------------- $stockmodel = new StockRepo(); $object['warehouse_id'] = $object['idAlmacen']; $object["variant_id"] = $object['vari']; $stockac = $stockmodel->encontrar($object["variant_id"], $object['warehouse_id']); if (!empty($stockac)) { if ($object["equivalencia"] == null) { $object["stockSeparados"] = $stockac->stockSeparados + $object["cantidad"]; // } else { $object["stockSeparados"] = $stockac->stockSeparados + $object["cantidad"] * $object["equivalencia"]; } $manager = new StockManager($stockac, $object); $manager->save(); } else { } $stockac = null; //----------------------------------------------------- } return response()->json(['estado' => true, 'nombres' => $orderSale->nombres]); }