mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-27 00:13:59 +00:00
E-Invoice - Update business logic for downloading E-CreditNote
This commit is contained in:
@@ -46,6 +46,8 @@ class GenerateCreditNotePdfV2Logic
|
||||
{
|
||||
$pdfTemplateName = 'pages.pdfs.credit_note_v2'; //default since e-invoice implementation
|
||||
$transaction = $this->fetchesTransaction->execute(['id' => $request->route('id')]);
|
||||
$autoCountInvoiceId = '';
|
||||
$autoCountEInvoiceValidationLink = 'CIEF';
|
||||
|
||||
if($transaction->type === TransactionType::REFUND){
|
||||
//Retrieve TransactionType::CREDIT_NOTE
|
||||
@@ -91,20 +93,18 @@ class GenerateCreditNotePdfV2Logic
|
||||
|
||||
if($eInvoiceStarted) {
|
||||
$eInvoiceStarted = false; //reset to re-evaluate second time
|
||||
$autoCountInvoiceId = '';
|
||||
$autoCountEInvoiceValidationLink = '';
|
||||
|
||||
$metadata = $booking->attributesKVP()->where('key', KVPKey::AUTOCOUNT_DOCNO_INVOICE)->first();
|
||||
$metadata = $booking->attributesKVP()->where('key', KVPKey::AUTOCOUNT_DOCNO_CREDIT_NOTE)->first();
|
||||
if($metadata){
|
||||
$autoCountInvoiceId = $metadata->value;
|
||||
}
|
||||
$metadata = $booking->attributesKVP()->where('key', KVPKey::AUTOCOUNT_EINVOICE_VALIDATION_LINK)->first();
|
||||
$metadata = $booking->attributesKVP()->where('key', KVPKey::AUTOCOUNT_EINVOICE_VALIDATION_LINK_CREDIT_NOTE)->first();
|
||||
if($metadata){
|
||||
$autoCountEInvoiceValidationLink = $metadata->value;
|
||||
}
|
||||
|
||||
Log::info('autoCountInvoiceId: ' . $autoCountInvoiceId);
|
||||
Log::info('autoCountEInvoiceValidationLink: ' . $autoCountEInvoiceValidationLink);
|
||||
Log::info('AUTOCOUNT_DOCNO_CREDIT_NOTE: ' . $autoCountInvoiceId);
|
||||
Log::info('AUTOCOUNT_EINVOICE_VALIDATION_LINK_CREDIT_NOTE: ' . $autoCountEInvoiceValidationLink);
|
||||
|
||||
if($autoCountInvoiceId && $autoCountEInvoiceValidationLink){
|
||||
$eInvoiceStarted = true;
|
||||
@@ -127,7 +127,15 @@ class GenerateCreditNotePdfV2Logic
|
||||
Log::info('Based on booking created date, E-Credit Note not yet started. / Not Yet Ready.');
|
||||
}
|
||||
|
||||
$pdf = LaravelMpdf::loadView($pdfTemplateName, ['transaction' => $transaction, 'booking' => $booking, 'supplier' => $supplier, 'date' => $date, 'brn' => $brn,]);
|
||||
$pdf = LaravelMpdf::loadView($pdfTemplateName, [
|
||||
'transaction' => $transaction,
|
||||
'booking' => $booking,
|
||||
'supplier' => $supplier,
|
||||
'date' => $date,
|
||||
'brn' => $brn,
|
||||
'autocountId' => $autoCountInvoiceId,
|
||||
'autocountEInvoiceValidationLink' => $autoCountEInvoiceValidationLink,
|
||||
]);
|
||||
|
||||
$exportFileName = 'CreditNote.pdf';
|
||||
$filesystemDriver = Storage::getDefaultDriver();
|
||||
|
||||
Reference in New Issue
Block a user