mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-28 17:03:59 +00:00
Merge branch 'development' of https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0 into development
This commit is contained in:
@@ -21,7 +21,8 @@ class ListShippingPortalTransactions
|
||||
return $data['payload']['data'];
|
||||
|
||||
} catch (\Exception $exception) {
|
||||
dd($exception->getMessage());
|
||||
// dd($exception->getMessage());
|
||||
throw new MalformedRequestException($exception->getMessage());
|
||||
// preg_match('/\{.*\}/s', $exception->getMessage(), $matches);
|
||||
// $jsonError = json_decode($matches[0]);
|
||||
// Retrieved Transactions failed
|
||||
|
||||
@@ -55,11 +55,9 @@ class ExportsInvoiceTransactions implements FromQuery, WithHeadings, WithHeading
|
||||
*/
|
||||
public function query()
|
||||
{
|
||||
$query = StatementTransactionOwner::whereNull('invoice_reference')
|
||||
return StatementTransactionOwner::whereNull('invoice_reference')
|
||||
->whereIn('type', [StatementTransactionOwnerType::SALES, StatementTransactionOwnerType::WALLET_TOP_UP])
|
||||
->whereIn('status', [ApprovalStatus::COMPLETED, ApprovalStatus::APPROVED]);
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,20 +67,21 @@ class ExportsInvoiceTransactions implements FromQuery, WithHeadings, WithHeading
|
||||
*/
|
||||
public function map($transaction): array
|
||||
{
|
||||
$row = null;
|
||||
|
||||
$logArray = [];
|
||||
$logArray['counter'] = $this->counter;
|
||||
$logArray = [
|
||||
'counter' => $this->counter,
|
||||
'system' => $transaction->system,
|
||||
'StatementTransactionOwner_id' => $transaction->id,
|
||||
'transaction_table_id' => $transaction->owner_id,
|
||||
];
|
||||
$this->counter += 1;
|
||||
$logArray['system'] = $transaction->system;
|
||||
$logArray['StatementTransactionOwner_id'] = $transaction->id;
|
||||
$logArray = json_encode($logArray);
|
||||
|
||||
$filePath = storage_path('logs/exports_invoice_transactions.log');
|
||||
$filePath = storage_path('logs/exports_invoice_transactions.log');
|
||||
$errorFilePath = storage_path('logs/exports_invoice_transactions_error.log');
|
||||
$textToAppend = Carbon::now()->format('[Y-m-d H:i:s]') . ' ' . $logArray . PHP_EOL;
|
||||
file_put_contents($filePath, $textToAppend, FILE_APPEND);
|
||||
|
||||
if($transaction->system == 'EXCHANGE') {
|
||||
if ($transaction->system == 'EXCHANGE') {
|
||||
$row = (App()->make($transaction->owner_type))->where('id', $transaction->owner_id)->first();
|
||||
$company = $row->type === TransactionType::PAYMENT ? $row->owner->company : $row->owner->owner;
|
||||
|
||||
@@ -104,30 +103,43 @@ class ExportsInvoiceTransactions implements FromQuery, WithHeadings, WithHeading
|
||||
'500-0000',
|
||||
'CIEF'
|
||||
];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$row = (App()->make(ListShippingPortalTransactions::class))->execute([
|
||||
'id' => $transaction->owner_id,
|
||||
'with_company' => true,
|
||||
])[0];
|
||||
'id' => $transaction->owner_id,
|
||||
'with_company' => true,
|
||||
]);
|
||||
|
||||
if (empty($row) || $row[0]['status'] != 'success') {
|
||||
$textToAppend = Carbon::now()->format('[Y-m-d H:i:s]') . ' Fetch Shipping Transaction Fail ' . json_encode([
|
||||
'id' => $transaction->owner_id,
|
||||
'with_company' => true,
|
||||
]) . PHP_EOL;
|
||||
file_put_contents($errorFilePath, $textToAppend, FILE_APPEND);
|
||||
|
||||
$textToAppend = Carbon::now()->format('[Y-m-d H:i:s]') . ' Shipping Portal Respnose ' . json_encode($row) . PHP_EOL;
|
||||
file_put_contents($errorFilePath, $textToAppend, FILE_APPEND);
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
$row = $row[0];
|
||||
|
||||
return [
|
||||
'<<New>>',
|
||||
'<<New>>',
|
||||
$row['updated_at'],
|
||||
$row['debtor_code'],
|
||||
$row['type'] === ShippingTransactionType::PAYMENT ? $row['order_reference'] : $row['marking'],
|
||||
'',
|
||||
'MYR',
|
||||
'MYR',
|
||||
$row['type'] === ShippingTransactionType::PAYMENT ? $row['order_reference'] : $row['bill_no'],
|
||||
$row['type'] === ShippingTransactionType::PAYMENT ? '' : 'W1',
|
||||
$row['type'] === ShippingTransactionType::PAYMENT ? 'PLEASE REFER TO THE ATTACHED APPENDIX REF `' . $row['order_reference'] : 'CREDIT SALES',
|
||||
$row['type'] === ShippingTransactionType::PAYMENT ? '' : 'W1',
|
||||
$row['type'] === ShippingTransactionType::PAYMENT ? 'PLEASE REFER TO THE ATTACHED APPENDIX REF `' . $row['order_reference'] : 'CREDIT SALES',
|
||||
'',
|
||||
1,
|
||||
round($row['amount'], 2),
|
||||
'500-0000',
|
||||
1,
|
||||
round($row['amount'], 2),
|
||||
'500-0000',
|
||||
'CIEF'
|
||||
];
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user