mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange.git
synced 2026-08-19 04:14:04 +00:00
validate total and save
This commit is contained in:
@@ -93,9 +93,13 @@ class InvoiceController extends Controller
|
||||
function ($line) { return $line['total']; },
|
||||
$validatedData['lines']
|
||||
);
|
||||
$total = array_reduce($subtotalArray, function ($v1, $v2) {
|
||||
$subtotal = array_reduce($subtotalArray, function ($v1, $v2) {
|
||||
return $v1 + $v2;
|
||||
});
|
||||
$adjustment = $request->adjustment;
|
||||
$billing_charges = $booking->billing_charge;
|
||||
$total = $subtotal + $adjustment + $billing_charges;
|
||||
|
||||
if ($total !== $booking->bia) {
|
||||
return response()->json([
|
||||
'message' => 'Booking amount expected is '.$booking->bia.'. Your Invoice amount is '.$total
|
||||
@@ -121,6 +125,7 @@ class InvoiceController extends Controller
|
||||
$invoice->address = $validatedData['address'];
|
||||
$invoice->contact_no = $validatedData['contact_no'];
|
||||
$invoice->po_number = $po_number;
|
||||
$invoice->adjustment = $adjustment;
|
||||
$invoice->save();
|
||||
|
||||
if (!$invoice) {
|
||||
@@ -215,10 +220,14 @@ class InvoiceController extends Controller
|
||||
function ($line) { return $line['total']; },
|
||||
$validatedData['lines']
|
||||
);
|
||||
$total = array_reduce($subtotalArray, function ($v1, $v2) {
|
||||
$subtotal = array_reduce($subtotalArray, function ($v1, $v2) {
|
||||
return $v1 + $v2;
|
||||
});
|
||||
if ($total != $booking->bia) {
|
||||
$adjustment = $request->adjustment;
|
||||
$billing_charges = $booking->billing_charge;
|
||||
$total = $subtotal + $adjustment + $billing_charges;
|
||||
|
||||
if ($total !== $booking->bia) {
|
||||
return response()->json([
|
||||
'message' => 'Booking amount expected is '.$booking->bia.'. Your Invoice amount is '.$total
|
||||
], 400);
|
||||
@@ -235,6 +244,7 @@ class InvoiceController extends Controller
|
||||
$invoice->address = $validatedData['address'];
|
||||
$invoice->contact_no = $validatedData['contact_no'];
|
||||
$invoice->po_number = $po_number;
|
||||
$invoice->adjustment = $adjustment;
|
||||
$invoice->save();
|
||||
|
||||
if (!$invoice) {
|
||||
|
||||
Reference in New Issue
Block a user