FIX_Comm.amount 2
This commit is contained in:
parent
874476dd74
commit
8ba7fc6ccb
@ -178,12 +178,16 @@ class InvoiceController extends ResourceController
|
||||
try {
|
||||
$input = $this->request->getJSON(true);
|
||||
|
||||
// Normalize pos_id (client may send null/0/non-numeric like "w")
|
||||
$posIdRaw = $input['pos_id'] ?? 0;
|
||||
$posId = is_numeric($posIdRaw) ? (int)$posIdRaw : 0;
|
||||
|
||||
// Basic invoice data
|
||||
$invoiceData = [
|
||||
'invoice_amount' => $input['invoice_amount'] ?? 0,
|
||||
'broker_id' => $input['broker_id'] ?? 0,
|
||||
'agent_id' => json_encode($input['agent_id'] ?? []),
|
||||
'pos_id' => $input['pos_id'] ?? 0,
|
||||
'pos_id' => $posId,
|
||||
'till_date' => $input['till_date'] ? date('Y-m-d', strtotime($input['till_date'])) : null,
|
||||
'invoice_date' => $input['invoice_date'] ? date('Y-m-d', strtotime($input['invoice_date'])) : null,
|
||||
'payout_status' => 1,
|
||||
@ -197,7 +201,7 @@ class InvoiceController extends ResourceController
|
||||
if (!$invoiceId) {
|
||||
|
||||
// Generate invoice number only for CREATE
|
||||
$invoiceData['invoice_no'] = $this->generateInvoiceNo($input['pos_id']);
|
||||
$invoiceData['invoice_no'] = $this->generateInvoiceNo($posId);
|
||||
|
||||
$invoiceData['created_at'] = date('Y-m-d H:i:s');
|
||||
$invoiceData['created_by'] = $input['created_by'] ?? 0;
|
||||
@ -272,7 +276,12 @@ class InvoiceController extends ResourceController
|
||||
{
|
||||
$pos_id = !empty($pos_id) ? $pos_id : 0;
|
||||
$year = date('Y');
|
||||
$prefix = "NIIB/$pos_id/$year/";
|
||||
|
||||
// If pos_id is missing/invalid (0/null/"w"), generate invoice as MIG/Year/NNNNN
|
||||
// Otherwise generate as NIIB/{pos_id}/Year/NNNNN
|
||||
$prefix = ($pos_id > 0)
|
||||
? "NIIB/{$pos_id}/{$year}/"
|
||||
: "MIG/{$year}/";
|
||||
|
||||
// Get last invoice of current year
|
||||
$lastInvoice = $this->InvoiceModel
|
||||
|
||||
Loading…
Reference in New Issue
Block a user