check if totals are in request
This commit is contained in:
parent
1a8224c0c7
commit
3317483e39
@ -112,6 +112,25 @@ class CreateBill
|
|||||||
|
|
||||||
protected function addTotals($bill, $request, $taxes, $sub_total, $discount_total, $tax_total)
|
protected function addTotals($bill, $request, $taxes, $sub_total, $discount_total, $tax_total)
|
||||||
{
|
{
|
||||||
|
// Check if totals are in request, i.e. api
|
||||||
|
if (!empty($request['totals'])) {
|
||||||
|
$sort_order = 1;
|
||||||
|
|
||||||
|
foreach ($request['totals'] as $total) {
|
||||||
|
$total['bill_id'] = $bill->id;
|
||||||
|
|
||||||
|
if (empty($total['sort_order'])) {
|
||||||
|
$total['sort_order'] = $sort_order;
|
||||||
|
}
|
||||||
|
|
||||||
|
BillTotal::create($total);
|
||||||
|
|
||||||
|
$sort_order++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$sort_order = 1;
|
$sort_order = 1;
|
||||||
|
|
||||||
// Added bill sub total
|
// Added bill sub total
|
||||||
|
@ -109,6 +109,25 @@ class UpdateBill
|
|||||||
|
|
||||||
protected function addTotals($bill, $request, $taxes, $sub_total, $discount_total, $tax_total)
|
protected function addTotals($bill, $request, $taxes, $sub_total, $discount_total, $tax_total)
|
||||||
{
|
{
|
||||||
|
// Check if totals are in request, i.e. api
|
||||||
|
if (!empty($request['totals'])) {
|
||||||
|
$sort_order = 1;
|
||||||
|
|
||||||
|
foreach ($request['totals'] as $total) {
|
||||||
|
$total['bill_id'] = $bill->id;
|
||||||
|
|
||||||
|
if (empty($total['sort_order'])) {
|
||||||
|
$total['sort_order'] = $sort_order;
|
||||||
|
}
|
||||||
|
|
||||||
|
BillTotal::create($total);
|
||||||
|
|
||||||
|
$sort_order++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$sort_order = 1;
|
$sort_order = 1;
|
||||||
|
|
||||||
// Added bill sub total
|
// Added bill sub total
|
||||||
|
@ -116,6 +116,25 @@ class CreateInvoice
|
|||||||
|
|
||||||
protected function addTotals($invoice, $request, $taxes, $sub_total, $discount_total, $tax_total)
|
protected function addTotals($invoice, $request, $taxes, $sub_total, $discount_total, $tax_total)
|
||||||
{
|
{
|
||||||
|
// Check if totals are in request, i.e. api
|
||||||
|
if (!empty($request['totals'])) {
|
||||||
|
$sort_order = 1;
|
||||||
|
|
||||||
|
foreach ($request['totals'] as $total) {
|
||||||
|
$total['invoice_id'] = $invoice->id;
|
||||||
|
|
||||||
|
if (empty($total['sort_order'])) {
|
||||||
|
$total['sort_order'] = $sort_order;
|
||||||
|
}
|
||||||
|
|
||||||
|
InvoiceTotal::create($total);
|
||||||
|
|
||||||
|
$sort_order++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$sort_order = 1;
|
$sort_order = 1;
|
||||||
|
|
||||||
// Added invoice sub total
|
// Added invoice sub total
|
||||||
|
@ -110,6 +110,25 @@ class UpdateInvoice
|
|||||||
|
|
||||||
protected function addTotals($invoice, $request, $taxes, $sub_total, $discount_total, $tax_total)
|
protected function addTotals($invoice, $request, $taxes, $sub_total, $discount_total, $tax_total)
|
||||||
{
|
{
|
||||||
|
// Check if totals are in request, i.e. api
|
||||||
|
if (!empty($request['totals'])) {
|
||||||
|
$sort_order = 1;
|
||||||
|
|
||||||
|
foreach ($request['totals'] as $total) {
|
||||||
|
$total['invoice_id'] = $invoice->id;
|
||||||
|
|
||||||
|
if (empty($total['sort_order'])) {
|
||||||
|
$total['sort_order'] = $sort_order;
|
||||||
|
}
|
||||||
|
|
||||||
|
InvoiceTotal::create($total);
|
||||||
|
|
||||||
|
$sort_order++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$sort_order = 1;
|
$sort_order = 1;
|
||||||
|
|
||||||
// Added invoice sub total
|
// Added invoice sub total
|
||||||
|
Loading…
x
Reference in New Issue
Block a user