E-Invoice - Reinstate some old code to handle 202508 Credit Note Import

This commit is contained in:
Dillon Ngo
2025-10-08 10:57:05 +08:00
parent 6ba76f336a
commit 2fafac04d1
@@ -72,22 +72,7 @@ class ProcessCreditNoteReportV2CommandJob implements ShouldQueue
'EInvoiceValidationLink' => $eInvoiceValidationLink,
]);
// $booking = Booking::where('marking', $ref)->first();
// if($booking){
// if($docNo != "" && $docNo != "<<New>>"){
// $payments = $booking->transactions()->payments()->get();
// foreach ($payments as $payment) {
// $refundTransaction = $payment->transactions()->refunds()->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->latest()->first();
// if($refundTransaction){
// $this->updateOrCreateKeyValuePair($refundTransaction, KVPKey::AUTOCOUNT_DOCNO_CREDIT_NOTE, $docNo);
// if($eInvoiceValidationLink){
// $this->updateOrCreateKeyValuePair($refundTransaction, KVPKey::AUTOCOUNT_EINVOICE_VALIDATION_LINK_CREDIT_NOTE, $eInvoiceValidationLink);
// }
// break;
// }
// }
// }
// }
$transaction = Transaction::where('bill_no', $ref)->first();
if($transaction){
@@ -98,6 +83,24 @@ class ProcessCreditNoteReportV2CommandJob implements ShouldQueue
}
}
}
else {
$booking = Booking::where('marking', $ref)->first();
if($booking){
if($docNo != "" && $docNo != "<<New>>"){
$payments = $booking->transactions()->payments()->get();
foreach ($payments as $payment) {
$refundTransaction = $payment->transactions()->refunds()->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->latest()->first();
if($refundTransaction){
$this->updateOrCreateKeyValuePair($refundTransaction, KVPKey::AUTOCOUNT_DOCNO_CREDIT_NOTE, $docNo);
if($eInvoiceValidationLink){
$this->updateOrCreateKeyValuePair($refundTransaction, KVPKey::AUTOCOUNT_EINVOICE_VALIDATION_LINK_CREDIT_NOTE, $eInvoiceValidationLink);
}
break;
}
}
}
}
}
$end = new Carbon();
$elapsedTime = $start->diff($end)->format('%H:%I:%S');