mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
E-Invoice - Automapping Issues, Sales Invoice Report (Import)
This commit is contained in:
@@ -39,7 +39,28 @@ class ImportExcelLogic extends AbstractControllerLogic
|
||||
foreach ($object->getFiles() as $file){
|
||||
$collection = Excel::toCollection(null, json_decode($file)->file_info->original->file, null, null, true);
|
||||
|
||||
$rows = $collection->first()->skip(1);
|
||||
$sheet = $collection->first();
|
||||
$header = $sheet->first()->toArray();
|
||||
|
||||
$normalizedHeader = array_map(fn($h) => strtolower(trim($h)), $header);
|
||||
$salesInvoiceHeader = [
|
||||
'docno', 'docdate', 'debtorcode', 'ref', 'shipinfo', 'accno',
|
||||
'detaildescription', 'furtherdescription', 'classification',
|
||||
'deptno', 'qty', 'unitprice', 'submiteinvoice', 'consolidatedeinvoice'
|
||||
];
|
||||
$customersReportHeader = [
|
||||
'tin', 'identityno', 'name', 'identitytype', 'taxclassification', 'msiccode',
|
||||
'businessactivitydesc', 'debtorcode', 'tradename', 'address', 'postcode',
|
||||
'phone', 'emailaddress', 'city', 'countrycode', 'statecode'
|
||||
];
|
||||
if (
|
||||
($reportType === 'Sales Invoice Report' && $normalizedHeader !== $salesInvoiceHeader) ||
|
||||
($reportType === 'Customers Report' && $normalizedHeader !== $customersReportHeader)
|
||||
) {
|
||||
throw new MalformedRequestException('Uploaded Excel file format is incorrect. Column headers do not match expected format.');
|
||||
}
|
||||
$rows = $sheet->skip(1);
|
||||
|
||||
foreach ($rows as $index => $details) {
|
||||
$docNo = $details[0] ?? null;
|
||||
$docDate = $details[1] ?? null;
|
||||
|
||||
Reference in New Issue
Block a user