mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-29 01:13:59 +00:00
E-Invoice - Automapping Issues, Credit Note Report (Import) Partial Completion
This commit is contained in:
@@ -124,6 +124,15 @@ class ImportExcelLogic extends AbstractControllerLogic
|
||||
'data' => $result
|
||||
];
|
||||
}
|
||||
else if ($reportType === 'Credit Note Report') {
|
||||
$result = $this->processCreditNoteReport($sheet);
|
||||
$result = [
|
||||
'message' => empty($result)
|
||||
? ''
|
||||
: 'Some data are unprocessed: ',
|
||||
'data' => $result
|
||||
];
|
||||
}
|
||||
else{
|
||||
throw new MalformedRequestException('Cannot process report type: ' . $reportType);
|
||||
}
|
||||
@@ -145,7 +154,7 @@ class ImportExcelLogic extends AbstractControllerLogic
|
||||
}
|
||||
|
||||
private function processSalesInvoiceReport($sheet){
|
||||
$rows = $sheet->skip(1);
|
||||
$rows = $sheet->skip(1);
|
||||
|
||||
foreach ($rows as $index => $details) {
|
||||
$docNo = $details[0] ?? null;
|
||||
@@ -242,4 +251,58 @@ class ImportExcelLogic extends AbstractControllerLogic
|
||||
|
||||
return $unprocessedKnockOffs;
|
||||
}
|
||||
|
||||
private function processCreditNoteReport($sheet){
|
||||
$unprocessedDocNos = [];
|
||||
$rows = $sheet->skip(1);
|
||||
|
||||
foreach ($rows as $index => $details) {
|
||||
$docNo = $details[0] ?? null;
|
||||
$docDate = $details[1] ?? null;
|
||||
$debtorCode = $details[2] ?? null;
|
||||
$ref = $details[3] ?? null;
|
||||
$description = $details[4] ?? null;
|
||||
$reason = $details[5] ?? null;
|
||||
$deptNo = $details[6] ?? null;
|
||||
$qty = $details[7] ?? null;
|
||||
$unitPrice = $details[8] ?? null;
|
||||
$accNo = $details[9] ?? null;
|
||||
$submitEinvoice = $details[10] ?? null;
|
||||
$einvoiceIssueDateTime = $details[11] ?? null;
|
||||
$consolidatedEinvoice = $details[12] ?? null;
|
||||
$eInvoiceValidationLink = $details[13] ?? null;
|
||||
|
||||
Log::info("Row {$index} processCreditNoteReport:", [
|
||||
'DocNo' => $docNo,
|
||||
'DocDate' => $docDate,
|
||||
'DebtorCode' => $debtorCode,
|
||||
'Ref' => $ref,
|
||||
'Description' => $description,
|
||||
'Reason' => $reason,
|
||||
'DeptNo' => $deptNo,
|
||||
'Qty' => $qty,
|
||||
'UnitPrice' => $unitPrice,
|
||||
'AccNo' => $accNo,
|
||||
'SubmitEinvoice' => $submitEinvoice,
|
||||
'EInvoiceIssueDateTime' => $einvoiceIssueDateTime,
|
||||
'ConsolidatedEinvoice' => $consolidatedEinvoice,
|
||||
'EInvoiceValidationLink' => $eInvoiceValidationLink,
|
||||
]);
|
||||
|
||||
$booking = Booking::where('marking', $ref)->first();
|
||||
if($booking){
|
||||
if($docNo != "" && $docNo != "<<New>>"){
|
||||
$this->updateOrCreateKeyValuePair($booking, KVPKey::AUTOCOUNT_DOCNO_CREDIT_NOTE, $docNo);
|
||||
if($eInvoiceValidationLink){
|
||||
$this->updateOrCreateKeyValuePair($booking, KVPKey::AUTOCOUNT_EINVOICE_VALIDATION_LINK_CREDIT_NOTE, $eInvoiceValidationLink);
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
$unprocessedDocNos[] = $docNo;
|
||||
}
|
||||
}
|
||||
|
||||
return $unprocessedDocNos;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,12 @@ class KVPKey
|
||||
|
||||
public const AUTOCOUNT_DOCNO_OFFICIAL_RECEIPT = 'AUTOCOUNT_DOCNO_OR';
|
||||
|
||||
public const AUTOCOUNT_DOCNO_CREDIT_NOTE = 'AUTOCOUNT_DOCNO_CN';
|
||||
|
||||
public const AUTOCOUNT_EINVOICE_VALIDATION_LINK = 'AUTOCOUNT_EINVOICE_VALIDATION_LINK';
|
||||
|
||||
public const AUTOCOUNT_EINVOICE_VALIDATION_LINK_CREDIT_NOTE = 'AUTOCOUNT_EINVOICE_VALIDATION_LINK_CN';
|
||||
|
||||
public const CREDIT_NOTE_APPROVAL_DATE = 'CREDIT_NOTE_APPROVAL_DATE';
|
||||
|
||||
public const TRANSACTION_MODEL_CLASS = 'App\Models\Transaction';
|
||||
|
||||
@@ -14,7 +14,12 @@ class ImportController extends Controller
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
public function officialReceipt(Request $request, ImportExcelLogic $logic): JsonResponse
|
||||
public function officialReceipt(Request $request, ImportExcelLogic $logic): JsonResponse
|
||||
{
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
public function creditNote(Request $request, ImportExcelLogic $logic): JsonResponse
|
||||
{
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
@@ -106,6 +106,7 @@ export default {
|
||||
allowedReportTypes: [
|
||||
'Sales Invoice Report',
|
||||
'01R - RECEIVE PAYMENT (FULL PAYMENT) [AR RECEIVE PAYMENT]',
|
||||
'Credit Note Report'
|
||||
]
|
||||
}
|
||||
},
|
||||
@@ -129,6 +130,7 @@ export default {
|
||||
const importRoutesMap = {
|
||||
'Sales Invoice Report': route('api.import.sales_invoices'),
|
||||
'01R - RECEIVE PAYMENT (FULL PAYMENT) [AR RECEIVE PAYMENT]': route('api.import.official_receipt'),
|
||||
'Credit Note Report': route('api.import.credit_note'),
|
||||
};
|
||||
|
||||
return importRoutesMap[reportType] || '';
|
||||
|
||||
@@ -22,4 +22,5 @@ Route::group(['prefix' => 'export', 'as' => 'export.', 'namespace' => 'Exports']
|
||||
Route::group(['prefix' => 'import', 'as' => 'import.', 'namespace' => 'Imports'], function () {
|
||||
Route::post('/import/sales-invoice', [ImportController::class, 'salesInvoices'])->name('sales_invoices');
|
||||
Route::post('/import/offical-receipt', [ImportController::class, 'officialReceipt'])->name('official_receipt');
|
||||
Route::post('/import/credit-note', [ImportController::class, 'creditNote'])->name('credit_note');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user