コード例 #1
0
 public function edit(Request $request)
 {
     // var_dump("hola");die();
     $detPayment = $this->detPaymentRepo->find($request->id);
     $manager = new DetPaymentManager($detPayment, $request->all());
     $manager->save();
     return response()->json(['estado' => true, 'nombre' => $detPayment->nombre]);
 }
コード例 #2
0
 public function edit(Request $request)
 {
     // var_dump($var=$request->input('detailOrderPurchases'));die();
     \DB::beginTransaction();
     $var = $request->input('detailOrderPurchases');
     //var_dump($request->input("warehouses_id"));die();
     $almacen_id = $request->input("warehouses_id");
     $orderPurchase = $this->orderPurchaseRepo->find($request->id);
     if ($request->Estado == 0) {
         $manager = new OrderPurchaseManager($orderPurchase, $request->except('fechaPedido', 'fechaPrevista'));
         $manager->save();
     } else {
         $manager = new OrderPurchaseManager($orderPurchase, $request->except('fechaPedido', 'fechaPrevista', 'montoBruto', 'montoTotal', 'descuento'));
         $manager->save();
     }
     if ($this->orderPurchaseRepo->validateDate(substr($request->input('fechaPedido'), 0, 10)) and $this->orderPurchaseRepo->validateDate(substr($request->input('fechaPrevista'), 0, 10))) {
         $orderPurchase->fechaPedido = substr($request->input('fechaPedido'), 0, 10);
         $orderPurchase->fechaPrevista = substr($request->input('fechaPrevista'), 0, 10);
     } else {
         $orderPurchase->fechaPedido = null;
         $orderPurchase->fechaPrevista = null;
     }
     $orderPurchase->save();
     // $verSiExiste=$this->detailOrderPurchaseRepo->Comprobar($request->id);
     //$n=0;
     //->except($request->detailOrderPurchases["id"]);
     //$orderPurchase = $this->orderPurchaseRepo->find($request->input('id'));
     //==================================Actualizando Detallles==========================
     //if(!empty($verSiExiste[0])){
     //var_dump("no deve entrar");die();
     // $orderPurchase->detPres()->detach();
     /*foreach($var as $object1){
        //$hola=$var[$n];
        if(!empty($object1["cantidad1"])){
            //var_dump("holay".$object1["cantidad1"]);die();
            //$object1["cantidad"]=$object1["Cantidad_Ll"];
            //$object1["pendiente"]=$object1["pendiente"];
            $object1["montoBruto"]=floatval($object1["cantidad"])*floatval($object1["preProducto"]);
            $object1["montoTotal"]=floatval($object1["montoBruto"])-((floatval($object1["montoBruto"])*floatval($object1["descuento"]))/100);
        }else{
            //var_dump("dos".$object1["cantidad1"]);die();
            if($object1["Cantidad_Ll"]=='0' && $object1["montoBruto"]=='0'){
              $object1["Cantidad_Ll"]=0;
              $object1["pendiente"]=$object1["cantidad"];
              $object1["montoBruto"]=floatval($object1["cantidad"])*floatval($object1["preProducto"]);
              $object1["montoTotal"]=floatval($object1["montoBruto"])-((floatval($object1["montoBruto"])*floatval($object1["descuento"]))/100);
            }else{
                if($object1["Cantidad_Ll"]>0){
                     $object1["montoBruto"]=floatval($object1["cantidad"])*floatval($object1["preProducto"]);
                     $object1["montoTotal"]=floatval($object1["montoBruto"])-((floatval($object1["montoBruto"])*floatval($object1["descuento"]))/100);
                }else{  
                     $object1["Cantidad_Ll"]=$object1["cantidad"];
                     $object1["pendiente"]=0;
                     $object1["montoBruto"]=floatval($object1["cantidad"])*floatval($object1["preProducto"]);
                     $object1["montoTotal"]=floatval($object1["montoBruto"])-((floatval($object1["montoBruto"])*floatval($object1["descuento"]))/100);
            }
          }
        }
        
        ////if($hola->cantidad1!=null){
        ////    $object1["Cantidad_Ll"]=$hola->Cantidad_Ll;
        ////    $object1["pendiente"]=$hola->pendiente;
        ////    
        ////}else{
        ////    $object1["Cantidad_Ll"]=$object1["cantidad"];
        ////    $object1["pendiente"]=0;
        ////}
        //var_dump($hola['Cantidad_Ll']);die();
        
        $detailOrderPurchaseRepox = new DetailOrderPurchaseRepo;
        $insertar=new DetailOrderPurchaseManager($detailOrderPurchaseRepox->getModel(),$object1);
        $insertar->save();
        $detailOrderPurchaseRepox = null;
        //$n++;
         $stockmodel = new StockRepo;
                  $object['warehouse_id']=$almacen_id;
                  $object["variant_id"]=$object["Codigovar"];
                  $stockac=$stockmodel->encontrar($object["variant_id"],$almacen_id);
               var_dump($stockac->porLlegar);die();  
            if(!empty($stockac)){ 
              
               // if($object["esbase"]==0){
                //  $object["porLlegar"]=$stockac->stockActual+($object["cantidad_llegado"]*$object["equivalencia"]);
               // }else{
                  $object["porLlegar"]=$stockac->porLlegar+$object["cantidad"];
                //}
                  $manager = new StockManager($stockac,$object);
                  $manager->save();
                  $stock=null;
            }else{
              //if($tipo!=$tipo2){
               // if($object["esbase"]==0)
               // {
                //    $object["stockActual"]=$object["cantidad_llegado"]*$object["equivalencia"];
                //}else{
                    $object["porLlegar"]=$object["cantidad"];
                //}
            
                  $manager = new StockManager($stockmodel->getModel(),$object);
                  $manager->save();
                  $stockmodel = null;
                  }
            //}
            $stockac=null;
       }*/
     // }
     //else{
     foreach ($var as $object) {
         $object["pendiente"] = $object["cantidad"];
         $detailOrderPurchaseRepox = new DetailOrderPurchaseRepo();
         $insertar = new DetailOrderPurchaseManager($detailOrderPurchaseRepox->getModel(), $object);
         $insertar->save();
         $detailOrderPurchaseRepox = null;
         $stockmodel = new StockRepo();
         $object['warehouse_id'] = $almacen_id;
         $object["variant_id"] = $object["Codigovar"];
         $stockac = $stockmodel->encontrar($object["variant_id"], $almacen_id);
         if (!empty($stockac)) {
             // if($object["esbase"]==0){
             //  $object["porLlegar"]=$stockac->stockActual+($object["cantidad_llegado"]*$object["equivalencia"]);
             // }else{
             $object["porLlegar"] = $stockac->porLlegar + $object["cantidad"];
             //}
             $manager = new StockManager($stockac, $object);
             $manager->save();
             $stock = null;
         } else {
             //if($tipo!=$tipo2){
             // if($object["esbase"]==0)
             // {
             //  $object["stockActual"]=$object["cantidad_llegado"]*$object["equivalencia"];
             //}else{
             $object["porLlegar"] = $object["cantidad"];
             //}
             $manager = new StockManager($stockmodel->getModel(), $object);
             $manager->save();
             $stockmodel = null;
         }
         //}
         $stockac = null;
     }
     // }
     //*************************************************************************************
     $verDeudas = $this->pendientAccountRepo->verSaldos($request->input("supplier_id"));
     //var_dump($verDeudas[0]->Saldo);die();
     $SaldoAfavor = $request->input('SaldoUtilizado');
     $provicional = null;
     if ($verDeudas != null) {
         if ($SaldoAfavor > 0) {
             foreach ($verDeudas as $verDeudas) {
                 // $verDeudas=$this->pendientAccountRepo->verSaldos($request->input("supplier_id"));
                 /* if($provicional==null){
                      $payment = $this->paymentRepo->getModel();
                      $request->merge(['montoTotal'=>$montotot]);
                      $request->merge(['Acuenta'=>$verDeudas->Saldo]);
                      $request->merge(['orderPurchase_id'=>$request->input('id')]);
                      $salc=$request->input('montoTotal')-$request->input('Acuenta');
                      $request->merge(['Saldo'=>$salc]);        
                      $manager = new PaymentManager($payment,$request->all());
                      $manager->save();
                      $provicional=$payment->id;
                    }*/
                 if ($verDeudas->Saldo > 0 && $SaldoAfavor <= $verDeudas->Saldo) {
                     $var = $request->detPayments;
                     if ($provicional == null) {
                         $payment = $this->paymentRepo->getModel();
                         // $request->merge(['montoTotal'=>$montotot]);
                         $request->merge(['Acuenta' => $SaldoAfavor]);
                         $request->merge(['orderPurchase_id' => $request->input('id')]);
                         $salc = floatval($request->input('montoTotal')) - floatval($request->input('Acuenta'));
                         //var_dump($request->input('montoTotal'));die();
                         $request->merge(['Saldo' => $salc]);
                         $manager = new PaymentManager($payment, $request->all());
                         $manager->save();
                         $provicional = $payment->id;
                     } else {
                         $saldos = $this->paymentRepo->find($provicional);
                         // $request->merge(['montoTotal'=>$montotot]);
                         $request->merge(['Acuenta' => $saldos->Acuenta + $SaldoAfavor]);
                         $request->merge(['orderPurchase_id' => $request->input('id')]);
                         $salc = floatval($request->input('montoTotal')) - floatval($request->input('Acuenta'));
                         //var_dump($request->input('montoTotal'));die();
                         $request->merge(['Saldo' => $salc]);
                         $payment = new PaymentManager($saldos, $request->all());
                         $payment->save();
                     }
                     // var_dump($var);die();
                     $detPayment = $this->detPaymentRepo->getModel();
                     $pendientAccountRepo = $this->pendientAccountRepo->getModel();
                     $request->merge(['tipoPago' => 'A']);
                     $request->merge(['payment_id' => $provicional]);
                     $request->merge(['montoPagado' => $SaldoAfavor]);
                     $request->merge(['methodPayment_id' => 4]);
                     $request->merge(['Saldo_F' => $verDeudas->id]);
                     $insertDetP = new DetPaymentManager($detPayment, $request->all());
                     $insertDetP->save();
                     $request->merge(['Saldo' => $verDeudas->Saldo - $SaldoAfavor]);
                     $request->merge(['orderPurchase_id' => $verDeudas->orderPurchase_id]);
                     $request->merge(['supplier_id' => $verDeudas->supplier_id]);
                     $updateSaldoF = new pendientAccountManager($verDeudas, $request->all());
                     $updateSaldoF->save();
                     break;
                     //$SaldoAfavor=$verDeudas->Saldo-$request->input('SaldoUtilizado');
                 } else {
                     if ($verDeudas->Saldo > 0) {
                         $var = $request->detPayments;
                         // var_dump($var);die();
                         $SaldoAfavor = $SaldoAfavor - $verDeudas->Saldo;
                         if (!empty($provicional)) {
                             $payment = $this->paymentRepo->getModel();
                             //$request->merge(['montoTotal'=>$montotot]);
                             $request->merge(['Acuenta' => $SaldoAfavor]);
                             $request->merge(['orderPurchase_id' => $request->input('id')]);
                             $salc = floatval($request->input('montoTotal')) - $request->input('Acuenta');
                             //var_dump($request->input('montoTotal'));die();
                             $request->merge(['Saldo' => $salc]);
                             $manager = new PaymentManager($payment, $request->all());
                             $manager->save();
                             $provicional = $payment->id;
                         } else {
                             $saldos = $this->paymentRepo->fine($provicional);
                             // $request->merge(['montoTotal'=>$montotot]);
                             $request->merge(['Acuenta' => $saldos->Acuenta + $SaldoAfavor]);
                             $request->merge(['orderPurchase_id' => $request->input('id')]);
                             $salc = floatval($request->input('montoTotal')) - $request->input('Acuenta');
                             //var_dump($request->input('montoTotal'));die();
                             $request->merge(['Saldo' => $salc]);
                             $payment = new PaymentManager($saldos, $request->all());
                             $payment->save();
                         }
                         $detPayment = $this->detPaymentRepo->getModel();
                         $pendientAccountRepo = $this->pendientAccountRepo->getModel();
                         $request->merge(['tipoPago' => 'A']);
                         $request->merge(['payment_id' => $provicional]);
                         $request->merge(['montoPagado' => $verDeudas->Saldo]);
                         $request->merge(['methodPayment_id' => 4]);
                         $request->merge(['Saldo_F' => $verDeudas->id]);
                         $insertDetP = new DetPaymentManager($detPayment, $request->all());
                         $insertDetP->save();
                         $request->merge(['Saldo' => 0]);
                         $request->merge(['orderPurchase_id' => $verDeudas->orderPurchase_id]);
                         $request->merge(['supplier_id' => $verDeudas->supplier_id]);
                         $updateSaldoF = new pendientAccountManager($verDeudas, $request->all());
                         $updateSaldoF->save();
                     }
                     //fin else
                 }
                 //fin segundo if
             }
             //fin for
         }
         //fin primer if
     }
     //fin if primeross
     //**************************************************************************************
     if ($orderPurchase->Estado === 2) {
         $payment1 = $this->paymentRepo->paymentById($request->input('id'));
         $pendientAccount = $this->pendientAccountRepo->getModel();
         //$pendientAcc=$this->pendientAccountRepo->verSaldos($payment1->id);
         if ($payment1 != null) {
             $detPayment = $this->detPaymentRepo->verPagosAdelantados($payment1->id);
             if ($detPayment != null) {
                 foreach ($detPayment as $detPayment) {
                     $SaldosTemporales = $this->pendientAccountRepo->find2($detPayment['Saldo_F']);
                     if ($SaldosTemporales != null) {
                         $request->merge(['Saldo' => $SaldosTemporales->Saldo + $detPayment['montoPagado']]);
                         $request->merge(['orderPurchase_id' => $SaldosTemporales->orderPurchase_id]);
                         $request->merge(['supplier_id' => $SaldosTemporales->supplier_id]);
                         $insercount = new PendientAccountManager($SaldosTemporales, $request->all());
                         $insercount->save();
                     } else {
                         $request->merge(['orderPurchase_id' => $request->input('id')]);
                         $request->merge(['Saldo' => $payment1->Acuenta]);
                         $insercount = new PendientAccountManager($pendientAccount, $request->all());
                         $insercount->save();
                     }
                 }
             } else {
                 $request->merge(['orderPurchase_id' => $request->input('id')]);
                 $request->merge(['Saldo' => $payment1->Acuenta]);
                 $insercount = new PendientAccountManager($pendientAccount, $request->all());
                 $insercount->save();
                 $provicional = $request->idpayment;
             }
         }
     }
     \DB::commit();
     return response()->json(['estado' => true, 'nombres' => $orderPurchase->nombres]);
 }
コード例 #3
0
 public function edit(Request $request)
 {
     \DB::beginTransaction();
     $var = $request->detPayments;
     $detPayment = $this->detPaymentRepo->find($request->detpId);
     $pagoTemporal = $detPayment->montoPagado;
     $detpay = new DetPaymentManager($detPayment, $var);
     $detpay->save();
     $payment = $this->paymentRepo->find($request->id);
     $montoTotalPagado = 0;
     foreach ($this->detPaymentRepo->consultDetpayments($request->id) as $object) {
         $montoTotalPagado = $montoTotalPagado + floatval($object["montoPagado"]);
     }
     //$payment1 = $this->paymentRepo->find($provicional);
     $request->merge(["Acuenta" => $montoTotalPagado]);
     if (floatval($payment->MontoTotal) - $montoTotalPagado >= 0) {
         $request->merge(["Saldo" => floatval($payment->MontoTotal) - $montoTotalPagado]);
     } else {
         return response()->json('error');
     }
     $manager = new PaymentManager($payment, $request->only("Acuenta", "Saldo"));
     $manager->save();
     // $manager = new PaymentManager($payment,$request->only("Acuenta","Saldo"));
     // $manager->save();
     //=======================================================
     //var_dump($request->input('Saldo_F'));die();
     if (intval($request->input('Saldo_F')) > 0) {
         //var_dump($request->input("fecha"));die();
         $SaldosTemporales = $this->pendientAccountRepo->find2($detPayment['Saldo_F']);
         if ($SaldosTemporales != null) {
             //  var_dump($SaldosTemporales->Saldo);die();
             $request->merge(['Saldo' => floatval($SaldosTemporales->Saldo) + floatval($pagoTemporal)]);
             $request->merge(['Saldo' => floatval($request->input('Saldo')) - floatval($detPayment['montoPagado'])]);
             //var_dump($request->input("Saldo"));die();
             $request->merge(['orderPurchase_id' => $SaldosTemporales->orderPurchase_id]);
             $request->merge(['supplier_id' => $SaldosTemporales->supplier_id]);
             $request->merge(['estado' => 0]);
             $request->merge(["fecha" => $SaldosTemporales->fecha]);
             $insercount = new PendientAccountManager($SaldosTemporales, $request->all());
             $insercount->save();
         }
     }
     //=====================================================================
     //$provicional;
     if (intval($request->input('detCash_id')) > 0) {
         $detCash = $this->detCashRepo->find($request->input('detCash_id'));
         $cash = $this->cashRepo->find($detCash["cash_id"]);
         $request->merge(['montoCaja' => floatval($cash->montoBruto) + floatval($pagoTemporal)]);
         //var_dump(floatval($request->input('montoCaja')));
         $request->merge(['montoMovimientoEfectivo' => floatval($var["montoPagado"])]);
         $totalCajaACtual = $request->input('montoMovimientoEfectivo');
         //var_dump(floatval($totalCajaACtual));
         //$request->merge(['montoMovimientoEfectivo'=>floatval($totalCajaACtual)+floatval($var['montoPagado'])]);
         //$totalCajaACtual=$request->input('montoMovimientoEfectivo');
         //var_dump(floatval($totalCajaACtual));die();
         //$request->merge(["montoBruto"=>floatval($request->input('montoCaja')-floatval($pagoTemporal)])
         $request->merge(['montoFinal' => floatval($request->input('montoCaja')) - floatval($totalCajaACtual)]);
         $request->merge(['montoBruto' => floatval($request->input("montoFinal"))]);
         // var_dump(floatval($request->input('montoBruto')));die();
         $request->merge(["gastos" => floatval($cash->gastos) - floatval($pagoTemporal)]);
         $request->merge(["gastos" => floatval($request->input("gastos") + floatval($var["montoPagado"]))]);
         // var_dump($request->all());
         $request->merge(['fecha' => $detCash->fecha]);
         $request->merge(['montoMovimientoTarjeta' => 0]);
         $request->merge(['hora' => $detCash->hora]);
         $request->merge(['estado' => 1]);
         $request->merge(['cashMotive_id' => $detCash->cashMotive_id]);
         if ($cash->user_id == auth()->user()->id && $cash->estado == 1) {
             $request->merge(['user_id' => $cash->user_id]);
         } else {
             return response()->json(['estado' => 'Usted no tiene permisos sobre esta caja o la caja esta cerrada??']);
         }
         //   var_dump($request->all());die();
         $detcash = new DetCashManager($detCash, $request->all());
         $detcash->save();
         $request->merge(['fechaInicio' => $cash->fechaInicio]);
         $request->merge(['fechaFin' => $cash->fechaFin]);
         $request->merge(['montoInicial' => $cash->montoInicial]);
         $request->merge(['ingresos' => $cash->ingresos]);
         $request->merge(['montoReal' => $cash->montoReal]);
         $request->merge(['descuadre' => $cash->descuadre]);
         $request->merge(['estado' => $cash->estado]);
         $request->merge(['notas' => $cash->notas]);
         $request->merge(['cashHeader_id' => $cash->cashHeader_id]);
         $cashr = new CashManager($cash, $request->all());
         $cashr->save();
     }
     if (intval($request->input('cashMonthly_id')) > 0) {
         $cashMontly = $this->cashMonthlyRepo->find($request->input("cashMonthly_id"));
         //var_dump($año["id"]);die();
         $request->merge(["years_id" => $cashMontly->years_id]);
         $request->merge(["amount" => $var["montoPagado"]]);
         $request->merge(['descripcion' => "Pago a Proveedores"]);
         $request->merge(['expenseMonthlys_id' => 1]);
         $request->merge(['fecha' => $var["fecha"]]);
         $request->merge(['months_id' => $cashMontly->months_id]);
         $cashMontl = new CashMonthlyManager($cashMontly, $request->all());
         $cashMontl->save();
         //$var['cashMonthly_id']=$cashMonthly->id;
     }
     \DB::commit();
     //==============================
     return response()->json(['estado' => true, 'nombre' => $payment->nombre]);
 }