diff --git a/app/Classes/Modules/Transactions/ControllersLogic/GenerateCreditNotePdfV2Logic.php b/app/Classes/Modules/Transactions/ControllersLogic/GenerateCreditNotePdfV2Logic.php index 0d74ec3d..22366236 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/GenerateCreditNotePdfV2Logic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/GenerateCreditNotePdfV2Logic.php @@ -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(); diff --git a/app/Http/Resources/TransactionResource.php b/app/Http/Resources/TransactionResource.php index 46c1f29b..d5655dec 100644 --- a/app/Http/Resources/TransactionResource.php +++ b/app/Http/Resources/TransactionResource.php @@ -4,6 +4,7 @@ namespace App\Http\Resources; use App\Classes\Modules\Bookings\Services\CalculatesBookingRefundAmount; use App\Classes\ValueObjects\Constants\ApprovalStatus; +use App\Classes\ValueObjects\Constants\KVPKey; use App\Classes\ValueObjects\Constants\TransactionType; use App\Models\Booking; use Carbon\Carbon; @@ -37,6 +38,14 @@ class TransactionResource extends JsonResource } //Check if Transaction of type PAYMENT has an override for recipient bank - ends + $eInvoice = false; + if($booking && $this->type === TransactionType::REFUND){ + $kvp = $booking->attributesKVP()->where('key', KVPKey::AUTOCOUNT_DOCNO_CREDIT_NOTE)->first(); + if($kvp){ + $eInvoice = true; + } + } + $days = $this->created_at->endOfDay()->addWeekdays($booking->service_id === 3 ? 3 : 1); return [ 'id' => $this->id, @@ -72,7 +81,8 @@ class TransactionResource extends JsonResource 'remarks' => RemarkResource::collection($this->remarks), 'redemption' => new VoucherRedemptionResource($this->voucherRedemption), 'bank' => ((int) $this->type === TransactionType::PAYMENT) ? new BankResource($bank) : null, //When a transaction (of type payment) has an override recipient bank details on booking, this is NOT null - 'bank_recipient_edited' => $isEditedBankRecipient + 'bank_recipient_edited' => $isEditedBankRecipient, + 'e_invoice' => $this->when($this->type === TransactionType::REFUND, $eInvoice), ]; } } diff --git a/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue b/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue index c5cb9b96..dadbbdd0 100644 --- a/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue +++ b/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue @@ -403,7 +403,7 @@ -
|
- |
- http://e-invoice uuid link+{{ $autocountEInvoiceValidationLink }} |