mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 12:33:56 +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();
|
||||
|
||||
@@ -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),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -403,7 +403,7 @@
|
||||
</modal-component>
|
||||
</div>
|
||||
</div>
|
||||
<div :class="['text-right', showDownloadCreditNote && refund.status === 2 ? 'col-3' : 'col-5']">
|
||||
<div class="text-right col-3">
|
||||
<div class="font-heading fs-10 muted all-caps">Amount</div>
|
||||
<div class="font-heading fs-10">
|
||||
<div class="font-heading fs-10">{{refund.currency.short_code}} {{(Math.round((refund.amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}</div>
|
||||
@@ -412,7 +412,7 @@
|
||||
<div class="font-heading fs-10">{{refund.original_currency.short_code}} {{(Math.round((refund.original_amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-2" v-if="showDownloadCreditNote && refund.status === 2">
|
||||
<div class="col-2" v-if="refund.status === 2">
|
||||
<div class="row no-margin justify-content-end">
|
||||
<div class="font-heading all-caps fs-10 m-b-5 text-right">Credit Note</div>
|
||||
<!-- Allow Credit Note to be downloaded for company NOT opted in E-Invoice -->
|
||||
@@ -425,7 +425,15 @@
|
||||
<i class="fa fa-file-image-o fs-10"></i>
|
||||
</div>
|
||||
</a>
|
||||
<!-- cief todo: 90 - E Credit Note incomplete (for company opted in E-Invoice)-->
|
||||
<!-- E Credit Note (for company opted in E-Invoice)-->
|
||||
<a v-else>
|
||||
<a target=”_blank” @click="downloadCreditNote(refund.id)"
|
||||
v-if="refund.e_invoice && refund.booking && refund.booking.company && refund.booking.company.e_invoice">
|
||||
<div class="icon-thumbnail fs-11 text-white icon-25 bg-primary btn-rounded float-left m-r-0 pointer">
|
||||
<i class="fa fa-file-image-o fs-10"></i>
|
||||
</div>
|
||||
</a>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -500,7 +508,6 @@
|
||||
bank_id: 1
|
||||
},
|
||||
section: 'bookingDetailSection',
|
||||
eInvoiceStartDate: window.E_INVOICE_START_DATE || ''
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -545,11 +552,6 @@
|
||||
showEditBookingAmount(){
|
||||
return this.data.booking.company.employee.status === 2 && this.data.booking.company.status === 2 && (Math.round((this.data.booking.outstanding_amount + Number.EPSILON) * 100) / 100) > 0;
|
||||
},
|
||||
showDownloadCreditNote() {
|
||||
const today = new Date();
|
||||
const einvoiceStartDate = new Date(this.eInvoiceStartDate);
|
||||
return today > einvoiceStartDate;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
clickExpand(){
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
$credit_title = 'E-Credit';
|
||||
$bill_no = $transaction->bill_no;
|
||||
@endphp
|
||||
<div class="separator"><strong><i>{{ $bill_no }}</i></strong></div>
|
||||
<div class="separator"><strong><i>{{ $autocountId }}</i></strong></div>
|
||||
</htmlpageheader>
|
||||
<table>
|
||||
<tr>
|
||||
@@ -36,6 +36,7 @@
|
||||
</div>
|
||||
|
||||
<div class="ref">Ref# {{ $booking->marking }}</div>
|
||||
<div class="ref">EI# {{ $autocountId ?? 'NONE'}}</div>
|
||||
<div class="date">Date: {{ $date->toDateString() }}</div>
|
||||
<div> </div>
|
||||
</div>
|
||||
@@ -123,12 +124,12 @@
|
||||
<tbody>
|
||||
<tr align="center">
|
||||
<td>
|
||||
<img src="{{ url(config('qr.qr_code_img_url') . 'http://e-invoice uuid link') }}" style="width: 230px; height: 230px;" />
|
||||
<img src="{{ url(config('qr.qr_code_img_url') . $autocountEInvoiceValidationLink ) }}" style="width: 230px; height: 230px;" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr align="center">
|
||||
<td>
|
||||
<h2 style="margin: 0 !important;"><strong>http://e-invoice uuid link</strong></h2>
|
||||
<h2 style="margin: 0 !important;"><strong>{{ $autocountEInvoiceValidationLink }}</strong></h2>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
-1
@@ -6,7 +6,6 @@
|
||||
})(window,document,'script','dataLayer','GTM-TQKCPCD');</script>
|
||||
<!-- End Google Tag Manager -->
|
||||
<script>
|
||||
window.E_INVOICE_START_DATE = @json(env('E_INVOICE_START_DATE', '2025-05-01 00:00:00'));
|
||||
window.LARAVEL_VAPOR_ENABLED = @json(env('LARAVEL_VAPOR_ENABLED', false));
|
||||
</script>
|
||||
<meta http-equiv="content-type" content="text/html;charset=UTF-8"/>
|
||||
|
||||
Reference in New Issue
Block a user