add payment received date in import invoice result and fix structure export receipts to autocount

This commit is contained in:
Steve Ng
2023-12-03 18:58:55 +08:00
parent ef37185259
commit cad933ed59
4 changed files with 112 additions and 36 deletions
@@ -42,16 +42,20 @@ class ImportStatementInvoiceController
foreach (['exchange','izyim'] as $system) {
$returnReference = $this->mappingTopUp($row, $system);
if ($returnReference) {
// $row['mapped_result_reference'] = $data['owner_reference'];
// $row['payment_received_date'] = date('Y-m-d', strtotime($data['created_at']));
$row['mapped_result_reference'] = $returnReference;
$row['payment_received_date'] = '';
$row['mapped_status'] = 'success';
return $row;
}
}
}
$returnReference = $this->mappingExchange($row);
[$returnReference, $transactionDate] = $this->mappingExchange($row);
if ($returnReference) {
$row['mapped_result_reference'] = $returnReference;
$row['payment_received_date'] = date('d-m-Y', strtotime($transactionDate));
$row['mapped_status'] = 'success';
return $row;
}
@@ -88,6 +92,7 @@ class ImportStatementInvoiceController
$data = [];
foreach ($excelRows as $row) {
$row['mapped_result_reference'] = null;
$row['payment_received_date'] = null;
$row['mapped_status'] = 'failed';
$row['date'] = in_array(gettype($row['date']), ['integer', 'double']) ? $this->changeExcelDate($row['date']) : date('Y-m-d', strtotime($row['date']));
@@ -144,6 +149,7 @@ class ImportStatementInvoiceController
private function mappingTopUp(Array $row, String $system) {
try {
if ($data = (App()->make(ChecksBillNumber::class))->execute($row['shipping_info'], $system)) {
// if ($system == 'izyim' && isset($data['owner_reference'])) return $data;
if ($system == 'izyim' && isset($data['owner_reference'])) return $data['owner_reference'];
if ($system == 'exchange') return $this->updateTransactionOwnerReference($data, $row['doc_no']);
@@ -168,7 +174,7 @@ class ImportStatementInvoiceController
if ($transaction && $transaction->count() > 0) {
return $this->updateTransactionOwnerReference($transaction, $row['doc_no']);
}
return false;
return [false, false];
}
public function updateTransactionOwnerReference($transaction, String $docNo) {
@@ -178,9 +184,9 @@ class ImportStatementInvoiceController
'invoice_reference'=>$docNo,
'status'=>ApprovalStatus::COMPLETED
]);
return $transactionOwner->owner_reference;
return [$transactionOwner->owner_reference, $transaction->created_at];
}
return false;
return [false, false];
}
public function changeExcelDate($date)