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 f2cc75a898
commit 1c29e45744
4 changed files with 112 additions and 36 deletions
@@ -39,7 +39,8 @@ class ExportsImportedInvoiceMappeds implements FromQuery, WithHeadings, WithHead
'Net Total',
'Cancelled',
'Mapped Status',
'Mapped Reference No'
'Mapped Reference No',
'MapPayment Received Date'
];
}
@@ -72,6 +73,7 @@ class ExportsImportedInvoiceMappeds implements FromQuery, WithHeadings, WithHead
Arr::get($data,'cancelled'),
Arr::get($data,'mapped_status'),
Arr::get($data,'mapped_result_reference'),
Arr::get($data,'payment_received_date'),
];
}
@@ -15,8 +15,11 @@ use Illuminate\Support\Facades\Log;
use App\Classes\General\Eloquent\ApplyFiltersToQuery;
use App\Models\StatementTransaction;
use App\Models\Company;
use Maatwebsite\Excel\Concerns\WithEvents;
use Maatwebsite\Excel\Concerns\WithCustomStartCell;
use Maatwebsite\Excel\Events\AfterSheet;
class ExportsReceiptTransactions implements FromQuery, WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize
class ExportsReceiptTransactions implements FromQuery, WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize, WithEvents, WithCustomStartCell
{
use Exportable;
@@ -28,37 +31,101 @@ class ExportsReceiptTransactions implements FromQuery, WithHeadings, WithHeading
$this->request = $request;
}
public function startCell(): string
{
return 'A2';
}
public function registerEvents(): array {
return [
AfterSheet::class => function(AfterSheet $event) {
$sheet = $event->sheet;
$sheet->mergeCells('A1:A1');
$sheet->setCellValue('A1', '"');
$sheet->mergeCells('M1:Y1');
$sheet->setCellValue('M1', "Payment Detail Column");
$sheet->mergeCells('Z1:AB1');
$sheet->setCellValue('Z1', "Knock Off Detail");
$styleArray = [
'alignment' => [
'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
],
];
$cellRange = 'A1:AB1';
$event->sheet->getDelegate()->getStyle($cellRange)->applyFromArray($styleArray);
},
];
}
public function headings(): array
{
$header = [
'DocNo',
'DocDate',
'DebtorCode',
'Description',
'DocNo2',
'ProjNo',
'DeptNo',
'CurrencyCode',
'ToHomeRate',
'ToDebtorRate',
'Note',
'PaymentMethod',
'ChequeNo',
'PaymentAmt',
'BankCharge',
'ToBankRate',
'BankChargeTaxType',
'BankChargeTaxRefNo',
'BankChargeProjNo',
'BankChargeDeptNo',
'PaymentBy',
'FloatDay',
'IsRCHQ',
'RCHQDate',
'KnockOffDocType',
'KnockOffDocNo',
'KnockOffAmt',
'',
[
' ',
'(20 chars)',
'(Date: dd/MM/yyyy)',
'(12 chars)',
'(40 chars)',
'(25 chars)',
'(10 chars)',
'(10 chars)',
'(5 chars)',
'(Number, use System Currency Rate Decimal)',
'(Number, use System Currency Rate Decimal)',
'(Rich Text)',
'(20 chars)',
'(20 chars)',
'(Number, use System Currency Decimal)',
'(Number, use System Currency Decimal)',
'(Number, use System Currency Rate Decimal)',
'(14 chars)',
'(30 chars)',
'(10 chars)',
'(10 chars)',
'(20 chars)',
'(Integer)',
'(Boolean. Indicate T for stock control or F for non stock control)',
'(Returned Cheque Date: dd/MM/yyyy)',
'(2 chars, RI for Invoice, RD for D/N)',
'',
'(Number, use System Currency Decimal)',
],
[
'DocNo',
'DocDate',
'DebtorCode',
'Description',
'DocNo2',
'ProjNo',
'DeptNo',
'CurrencyCode',
'ToHomeRate',
'ToDebtorRate',
'Note',
'PaymentMethod',
'ChequeNo',
'PaymentAmt',
'BankCharge',
'ToBankRate',
'BankChargeTaxType',
'BankChargeTaxRefNo',
'BankChargeProjNo',
'BankChargeDeptNo',
'PaymentBy',
'FloatDay',
'IsRCHQ',
'RCHQDate',
'KnockOffDocType',
'KnockOffDocNo',
'KnockOffAmt',
'',
]
];
return $header;
}
@@ -102,7 +169,7 @@ class ExportsReceiptTransactions implements FromQuery, WithHeadings, WithHeading
'<<New>>',
Carbon::parse($transaction->posting_date)->format('d/m/Y'),
($company ? $company->debtor : null),
$transaction->transaction_description,
'Payment for '.$transaction->transaction_description,
'',
'',
'',
@@ -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)
@@ -39,6 +39,7 @@
<td>{{item.cancelled}}</td>
<td>{{item.mapped_status}}</td>
<td>{{item.mapped_result_reference}}</td>
<td>{{item.payment_received_date}}</td>
</tr>
</tbody>
</table>
@@ -101,7 +102,7 @@
},
appendComponentTableHeader() {
if (this.section == 'importInvoiceMapping') {
this.tableHeaders = ['No','Doc No','Date','Debtor Code','Debtor Name','Shipping Info','Net Total','Cancelled','Mapped Status','Mapped Reference No'];
this.tableHeaders = ['No','Doc No','Date','Debtor Code','Debtor Name','Shipping Info','Net Total','Cancelled','Mapped Status','Mapped Reference No','Payment Received Date'];
} else {
this.tableHeaders = ['No','OR No','Date','Creditor Code','Creditor Name','Shipping Info','Net Total','Cancelled','Mapped Status','Mapped Reference No'];
}