Beispiel #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  CashInRequest  $request
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function store(CashInRequest $request)
 {
     CashIn::create($request->all());
     $data = ['date' => $request['date'], 'client' => $request['client'], 'description' => $request['for'], 'reference' => $request['voucher'], 'credit' => $request['amount']];
     Ledger::create($data);
     Session::flash('success_message', 'Transaction Saved Successfully!');
     return redirect('cashIn');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  InvoiceRequest  $request
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function store(InvoiceRequest $request)
 {
     Invoice::create($request->all());
     $isExist = Ledger::query()->get()->contains('reference', $request['invoiceNumber']);
     $data = ['date' => $request['date'], 'client' => $request['client'], 'description' => $request['comment'], 'reference' => $request['invoiceNumber'], 'debit' => $request['bill'] + $request['ot_bill']];
     if ($isExist == true) {
         $ledger = Ledger::query()->where('reference', $request['invoiceNumber']);
         $data = ['debit' => $ledger->get(['debit'])->sum('debit') + $request['ot_bill'] + $request['bill']];
         $ledger->update($data);
     } else {
         Ledger::create($data);
     }
     Session::flash('success_message', 'Invoice Updated Successfully! If you have more vehicle to add in this Invoice, go to Create and do the same with same Invoice Number and Date!');
     return redirect('invoice');
 }