Bill create and update tax changes finished
This commit is contained in:
@ -654,64 +654,4 @@ class Invoices extends Controller
|
||||
|
||||
return $invoice;
|
||||
}
|
||||
|
||||
protected function addTotals($invoice, $request, $taxes, $sub_total, $discount_total, $tax_total)
|
||||
{
|
||||
$sort_order = 1;
|
||||
|
||||
// Added invoice sub total
|
||||
InvoiceTotal::create([
|
||||
'company_id' => $request['company_id'],
|
||||
'invoice_id' => $invoice->id,
|
||||
'code' => 'sub_total',
|
||||
'name' => 'invoices.sub_total',
|
||||
'amount' => $sub_total,
|
||||
'sort_order' => $sort_order,
|
||||
]);
|
||||
|
||||
$sort_order++;
|
||||
|
||||
// Added invoice discount
|
||||
if ($discount_total) {
|
||||
InvoiceTotal::create([
|
||||
'company_id' => $request['company_id'],
|
||||
'invoice_id' => $invoice->id,
|
||||
'code' => 'discount',
|
||||
'name' => 'invoices.discount',
|
||||
'amount' => $discount_total,
|
||||
'sort_order' => $sort_order,
|
||||
]);
|
||||
|
||||
// This is for total
|
||||
$sub_total = $sub_total - $discount_total;
|
||||
|
||||
$sort_order++;
|
||||
}
|
||||
|
||||
// Added invoice taxes
|
||||
if (isset($taxes)) {
|
||||
foreach ($taxes as $tax) {
|
||||
InvoiceTotal::create([
|
||||
'company_id' => $request['company_id'],
|
||||
'invoice_id' => $invoice->id,
|
||||
'code' => 'tax',
|
||||
'name' => $tax['name'],
|
||||
'amount' => $tax['amount'],
|
||||
'sort_order' => $sort_order,
|
||||
]);
|
||||
|
||||
$sort_order++;
|
||||
}
|
||||
}
|
||||
|
||||
// Added invoice total
|
||||
InvoiceTotal::create([
|
||||
'company_id' => $request['company_id'],
|
||||
'invoice_id' => $invoice->id,
|
||||
'code' => 'total',
|
||||
'name' => 'invoices.total',
|
||||
'amount' => $sub_total + $tax_total,
|
||||
'sort_order' => $sort_order,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user