public function view($id)
 {
     if (!$this->hasPermission($this->menuPermissionName)) {
         return view($this->viewPermissiondeniedName);
     }
     $tempModel = AccountingDetail::find($id);
     $accountingdetail = (new CarPaymentController())->getforaccountingdetailbyid($tempModel->carpaymentid, 0);
     $accountingdetail->id = $tempModel->id;
     $accountingdetail->invoiceno = $tempModel->invoiceno;
     $accountingdetail->date = date('d-m-Y', strtotime($tempModel->date));
     $accountingdetail->additionalopenbill = $tempModel->additionalopenbill;
     $accountingdetail->insurancefeereceiptcondition = $tempModel->insurancefeereceiptcondition;
     if ($tempModel->payinadvanceamountreimbursementdate != null) {
         $accountingdetail->payinadvanceamountreimbursementdate = date('d-m-Y', strtotime($tempModel->payinadvanceamountreimbursementdate));
     } else {
         $accountingdetail->payinadvanceamountreimbursementdate = null;
     }
     $accountingdetail->payinadvanceamountreimbursementdocno = $tempModel->payinadvanceamountreimbursementdocno;
     $accountingdetail->insurancebilldifferent = $tempModel->insurancebilldifferent;
     if ($tempModel->insurancebilldifferent > 0) {
         $accountingdetail->note1insurancefeeincludevat = $accountingdetail->note1insurancefeeincludevat + $tempModel->insurancebilldifferent;
         $accountingdetail->note1insurancefee = $accountingdetail->note1insurancefeeincludevat * 100 / 107.0;
         $accountingdetail->note1insurancefeevat = $accountingdetail->note1insurancefeeincludevat - $accountingdetail->note1insurancefee;
         $accountingdetail->incasefinaceinsurancefee = $accountingdetail->incasefinaceinsurancefee + $tempModel->insurancebilldifferent;
         $accountingdetail->totalincasefinace = $accountingdetail->totalincasefinace + $tempModel->insurancebilldifferent;
         $accountingdetail->incasefinacereceivedcash = $accountingdetail->incasefinacereceivedcash - $tempModel->insurancebilldifferent;
         $accountingdetail->incasefinacehassubsidisereceivedcash = $accountingdetail->incasefinacehassubsidisereceivedcash - $tempModel->insurancebilldifferent;
         $accountingdetail->note2insurancefeewhtax = $accountingdetail->note1insurancefee / 100.0;
         $accountingdetail->ins = $accountingdetail->ins + $tempModel->insurancebilldifferent;
     }
     $accountingdetail->note1insurancefeereceiptcondition = $tempModel->note1insurancefeereceiptcondition;
     $accountingdetail->insurancefeepayment = $tempModel->insurancefeepayment;
     if ($tempModel->insurancefeepayment == 1) {
         $accountingdetail->note2insurancefeewhtax = 0;
         $accountingdetail->totalincasefinace = $accountingdetail->totalincasefinace - $accountingdetail->incasefinaceinsurancefee;
         $accountingdetail->incasefinacereceivedcash = $accountingdetail->incasefinacereceivedcash + $accountingdetail->incasefinaceinsurancefee;
         $accountingdetail->incasefinacehassubsidisereceivedcash = $accountingdetail->incasefinacehassubsidisereceivedcash + $accountingdetail->incasefinaceinsurancefee;
         $accountingdetail->incasefinaceinsurancefee = 0;
     }
     if ($tempModel->insurancefeepaidseparatelydate != null) {
         $accountingdetail->insurancefeepaidseparatelydate = date('d-m-Y', strtotime($tempModel->insurancefeepaidseparatelydate));
     } else {
         $accountingdetail->insurancefeepaidseparatelydate = null;
     }
     $accountingdetail->insurancepremiumnet = $tempModel->insurancepremiumnet;
     $accountingdetail->insurancepremiumcom = $tempModel->insurancepremiumcom;
     $accountingdetail->insurancefeepaidseparatelytotal = $tempModel->insurancefeepaidseparatelytotal;
     if ($tempModel->insurancefeereceiptcondition == 0 || $tempModel->insurancefeereceiptcondition == 1) {
         $accountingdetail->hasinsurancefee = 1;
         if ($tempModel->insurancefeereceiptcondition == 0) {
             $accountingdetail->note2insurancefeewhtax = 0;
             $accountingdetail->ins = 0;
         }
     } else {
         $accountingdetail->hasinsurancefee = 0;
     }
     $accountingdetail->compulsorymotorinsurancefeereceiptcondition = $tempModel->compulsorymotorinsurancefeereceiptcondition;
     $accountingdetail->note1compulsorymotorinsurancefeereceiptcondition = $tempModel->note1compulsorymotorinsurancefeereceiptcondition;
     $accountingdetail->compulsorymotorinsurancefeepayment = $tempModel->compulsorymotorinsurancefeepayment;
     if ($tempModel->compulsorymotorinsurancefeepayment == 1) {
         $accountingdetail->note2compulsorymotorinsurancefeewhtax = 0;
         $accountingdetail->totalincasefinace = $accountingdetail->totalincasefinace - $accountingdetail->incasefinacecompulsorymotorinsurancefee;
         $accountingdetail->incasefinacereceivedcash = $accountingdetail->incasefinacereceivedcash + $accountingdetail->incasefinacecompulsorymotorinsurancefee;
         $accountingdetail->incasefinacehassubsidisereceivedcash = $accountingdetail->incasefinacehassubsidisereceivedcash + $accountingdetail->incasefinacecompulsorymotorinsurancefee;
         $accountingdetail->incasefinacecompulsorymotorinsurancefee = 0;
     }
     if ($tempModel->compulsorymotorinsurancefeepaidseparatelydate != null) {
         $accountingdetail->compulsorymotorinsurancefeepaidseparatelydate = date('d-m-Y', strtotime($tempModel->compulsorymotorinsurancefeepaidseparatelydate));
     } else {
         $accountingdetail->compulsorymotorinsurancefeepaidseparatelydate = null;
     }
     $accountingdetail->compulsorymotorinsurancepremiumnet = $tempModel->compulsorymotorinsurancepremiumnet;
     $accountingdetail->compulsorymotorinsurancepremiumcom = $tempModel->compulsorymotorinsurancepremiumcom;
     $accountingdetail->compulsorymotorinsurancefeepaidseparatelytotal = $tempModel->compulsorymotorinsurancefeepaidseparatelytotal;
     if ($tempModel->compulsorymotorinsurancefeereceiptcondition == 0 || $tempModel->compulsorymotorinsurancefeereceiptcondition == 1) {
         $accountingdetail->hascompulsorymotorinsurancefee = 1;
         if ($tempModel->compulsorymotorinsurancefeereceiptcondition == 0) {
             $accountingdetail->note2compulsorymotorinsurancefeewhtax = 0;
             $accountingdetail->prb = 0;
         }
     } else {
         $accountingdetail->hascompulsorymotorinsurancefee = 0;
     }
     $note2totalwhtax = $accountingdetail->note2insurancefeewhtax + $accountingdetail->note2compulsorymotorinsurancefeewhtax + $accountingdetail->note2subsidisewhtax;
     $accountingdetail->note2totalwhtax = $note2totalwhtax;
     $accountingdetail->cashpledgeredlabelreceiptbookno = $tempModel->cashpledgeredlabelreceiptbookno;
     $accountingdetail->cashpledgeredlabelreceiptno = $tempModel->cashpledgeredlabelreceiptno;
     if ($tempModel->cashpledgeredlabelreceiptdate != null) {
         $accountingdetail->cashpledgeredlabelreceiptdate = date('d-m-Y', strtotime($tempModel->cashpledgeredlabelreceiptdate));
     } else {
         $accountingdetail->cashpledgeredlabelreceiptdate = null;
     }
     $accountingdetail->cashpledgereceiptbookno = $tempModel->cashpledgereceiptbookno;
     $accountingdetail->cashpledgereceiptno = $tempModel->cashpledgereceiptno;
     $accountingdetail->cashpledgereceiptdate = date('d-m-Y', strtotime($tempModel->cashpledgereceiptdate));
     $accountingdetail->oldcarcomamount = $tempModel->oldcarcomamount;
     if ($tempModel->oldcarcomdate != null) {
         $accountingdetail->oldcarcomdate = date('d-m-Y', strtotime($tempModel->oldcarcomdate));
     } else {
         $accountingdetail->oldcarcomdate = null;
     }
     $accountingdetail->adj = $tempModel->adj;
     $accountingdetail->incasefinacecomfinamount = $tempModel->incasefinacecomfinamount;
     $accountingdetail->incasefinacecomfinvat = $tempModel->incasefinacecomfinvat;
     $accountingdetail->incasefinacecomfinamountwithvat = $tempModel->incasefinacecomfinamountwithvat;
     $accountingdetail->incasefinacecomfinwhtax = $tempModel->incasefinacecomfinwhtax;
     $accountingdetail->incasefinacecomfintotal = $tempModel->incasefinacecomfintotal;
     $accountingdetail->systemcalincasefinacecomfinamount = $tempModel->systemcalincasefinacecomfinamount;
     $accountingdetail->systemcalincasefinacecomfinvat = $tempModel->systemcalincasefinacecomfinvat;
     $accountingdetail->systemcalincasefinacecomfinamountwithvat = $tempModel->systemcalincasefinacecomfinamountwithvat;
     $accountingdetail->systemcalincasefinacecomfinwhtax = $tempModel->systemcalincasefinacecomfinwhtax;
     $accountingdetail->systemcalincasefinacecomfintotal = $tempModel->systemcalincasefinacecomfintotal;
     $accountingdetail->receivedcashfromfinace = $tempModel->receivedcashfromfinacenet;
     $accountingdetail->receivedcashfromfinacenet = $tempModel->receivedcashfromfinacenet;
     $accountingdetail->receivedcashfromfinaceshort = $tempModel->receivedcashfromfinacenetshort;
     $accountingdetail->receivedcashfromfinacenetshort = $tempModel->receivedcashfromfinacenetshort;
     $accountingdetail->receivedcashfromfinaceover = $tempModel->receivedcashfromfinacenetover;
     $accountingdetail->receivedcashfromfinacenetover = $tempModel->receivedcashfromfinacenetover;
     $accountingdetail->totalacc1 = $tempModel->totalaccount1;
     $accountingdetail->totalaccount1 = $tempModel->totalaccount1;
     $accountingdetail->totalacc1short = $tempModel->totalaccount1short;
     $accountingdetail->totalaccount1short = $tempModel->totalaccount1short;
     $accountingdetail->totalacc1over = $tempModel->totalaccount1over;
     $accountingdetail->totalaccount1over = $tempModel->totalaccount1over;
     $accountingdetail->totalacc2 = $tempModel->totalaccount2;
     $accountingdetail->totalaccount2 = $tempModel->totalaccount2;
     $accountingdetail->totalacc2short = $tempModel->totalaccount2short;
     $accountingdetail->totalaccount2short = $tempModel->totalaccount2short;
     $accountingdetail->totalacc2over = $tempModel->totalaccount2over;
     $accountingdetail->totalaccount2over = $tempModel->totalaccount2over;
     $accountingdetail->totalaccs = $tempModel->totalaccounts;
     $accountingdetail->totalaccounts = $tempModel->totalaccounts;
     $accountingdetail->totalaccsshort = $tempModel->totalaccountsshort;
     $accountingdetail->totalaccountsshort = $tempModel->totalaccountsshort;
     $accountingdetail->totalaccsover = $tempModel->totalaccountsover;
     $accountingdetail->totalaccountsover = $tempModel->totalaccountsover;
     $finalopenbill = $accountingdetail->openbill;
     if ($accountingdetail->additionalopenbill != null && $accountingdetail->additionalopenbill > 0) {
         $finalopenbill = $finalopenbill + $accountingdetail->additionalopenbill;
     }
     if ($finalopenbill == 0) {
         $accountingdetail->finalopenbill = 0;
         $accountingdetail->vatoffinalopenbill = 0;
         $accountingdetail->finalopenbillwithoutvat = 0;
         $accountingdetail->realsalespricewithoutvat = $accountingdetail->realsalesprice;
     } else {
         $accountingdetail->finalopenbill = $finalopenbill;
         $vat = $finalopenbill * 7.0 / 107.0;
         $accountingdetail->vatoffinalopenbill = $vat;
         $accountingdetail->finalopenbillwithoutvat = $finalopenbill - $vat;
         $realsalesprice = $accountingdetail->realsalesprice;
         $accountingdetail->realsalespricewithoutvat = $realsalesprice - $vat;
     }
     $incasefinacereceivedcash = $accountingdetail->incasefinacereceivedcash;
     $tradereceivableaccount1amount = $finalopenbill - $incasefinacereceivedcash;
     $accountingdetail->tradereceivableaccount1amount = $tradereceivableaccount1amount;
     $accountingdetail->ar = $tradereceivableaccount1amount;
     $cash = $tradereceivableaccount1amount - $accountingdetail->ins - $accountingdetail->prb - $accountingdetail->dc + $accountingdetail->adj;
     $accountingdetail->cash = $cash;
     $carpayment = CarPayment::where('id', $tempModel->carpaymentid)->with('carpreemption')->first();
     $carpaymentselectlist = array();
     $carpaymentselectlist[$carpayment->id] = $carpayment->carpreemption->bookno . '/' . $carpayment->carpreemption->no;
     $banks = Bank::orderBy('accountgroup', 'asc')->orderBy('name', 'asc')->get();
     $bankselectlist = array();
     $bankselectlist[null] = 'เลือกบัญชี';
     foreach ($banks as $item) {
         $bankselectlist[$item->id] = $item->name . ' ' . substr($item->accountno, -4);
     }
     $bankselectlist2 = array();
     array_push($bankselectlist2, ':เลือกบัญชี');
     foreach ($banks as $item) {
         array_push($bankselectlist2, $item->id . ':' . $item->name . ' ' . substr($item->accountno, -4));
     }
     $receiveAndPayDatas0 = array();
     $receiveAndPayData0 = SupportRequest::old('receiveAndPayData0');
     if ($receiveAndPayData0 != null && $receiveAndPayData0 != '') {
         $receiveAndPayData0 = json_decode($receiveAndPayData0, true);
         foreach ($receiveAndPayData0 as $data) {
             $obj = (object) array("id" => $data["id"], "date" => $data["date"], "type" => $data["type"], "amount" => $data["amount"], "accountgroup" => $data["accountgroup"], "bankid" => $data["bankid"], "note" => $data["note"]);
             array_push($receiveAndPayDatas0, $obj);
         }
     } else {
         $receiveAndPays0 = AccountingDetailReceiveAndPay::where('accountingdetailid', $id)->where('sectiontype', 0)->get(['id', 'date', 'type', 'amount', 'accountgroup', 'bankid', 'note']);
         foreach ($receiveAndPays0 as $data) {
             $obj = (object) array("id" => $data->id, "date" => $data->date, "type" => $data->type, "amount" => $data->amount, "accountgroup" => $data->accountgroup, "bankid" => $data->bankid, "note" => $data->note);
             array_push($receiveAndPayDatas0, $obj);
         }
     }
     $receiveAndPayDatas1 = array();
     $receiveAndPayData1 = SupportRequest::old('receiveAndPayData1');
     if ($receiveAndPayData1 != null && $receiveAndPayData1 != '') {
         $receiveAndPayData1 = json_decode($receiveAndPayData1, true);
         foreach ($receiveAndPayData1 as $data) {
             $obj = (object) array("id" => $data["id"], "date" => $data["date"], "type" => $data["type"], "amount" => $data["amount"], "accountgroup" => $data["accountgroup"], "bankid" => $data["bankid"], "note" => $data["note"]);
             array_push($receiveAndPayDatas1, $obj);
         }
     } else {
         $receiveAndPays1 = AccountingDetailReceiveAndPay::where('accountingdetailid', $id)->where('sectiontype', 1)->get(['id', 'date', 'type', 'amount', 'accountgroup', 'bankid', 'note']);
         foreach ($receiveAndPays1 as $data) {
             $obj = (object) array("id" => $data->id, "date" => $data->date, "type" => $data->type, "amount" => $data->amount, "accountgroup" => $data->accountgroup, "bankid" => $data->bankid, "note" => $data->note);
             array_push($receiveAndPayDatas1, $obj);
         }
     }
     foreach ($accountingdetail->toArray() as $key => $value) {
         if (!in_array($key, $this->arrNotFormatted)) {
             if (is_numeric($value) && (double) $value != 0.0) {
                 $value = number_format($value, 2, '.', ',');
             } else {
                 if ($value == null || $value == '' || is_numeric($value) && (double) $value == 0.0) {
                     $value = '-';
                 }
             }
             $accountingdetail->{$key} = $value;
         }
     }
     return view('accountingdetailform', ['oper' => 'view', 'pathPrefix' => '../../', 'accountingdetail' => $accountingdetail, 'carpaymentselectlist' => $carpaymentselectlist, 'bankselectlist' => $bankselectlist, 'bankselectlist2' => implode(";", $bankselectlist2), 'receiveAndPayDatas0' => $receiveAndPayDatas0, 'receiveAndPayDatas1' => $receiveAndPayDatas1]);
 }
示例#2
0
 /**
  * Fungsi untuk menampilkan seluruh daftar bank
  * @return [type] [description]
  */
 public function index()
 {
     $banks = Bank::orderBy('id', 'desc')->get();
     return ['status' => 'success', 'banks' => $banks];
 }