E-Invoice - Fix a problem reported by Eileen about Generate Proforma Invoice somehow can bypass filling up E-Invoice info

This commit is contained in:
Dillon Ngo
2025-07-19 14:41:50 +08:00
parent c64ebeddde
commit b67a85a95c
3 changed files with 62 additions and 8 deletions
@@ -151,7 +151,8 @@ class CreateProformaInvoiceTransactionProcessor
$payable_amount = $booking->transactions()->payments()->where(function ($query) {
return $query->where(function ($query) {
return $query->where('status', ApprovalStatus::PENDING_SUBMISSION)->whereDate('expires_on', '>=', Carbon::now())->where('expires_on', '>', Carbon::now()->toTimeString());
// return $query->where('status', ApprovalStatus::PENDING_SUBMISSION)->whereDate('expires_on', '>=', Carbon::now())->where('expires_on', '>', Carbon::now()->toTimeString());
return $query->where('status', ApprovalStatus::PENDING_SUBMISSION)->where('expires_on', '>=', Carbon::now());
})->orWhere(function ($query) {
return $query->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
});
@@ -164,7 +165,8 @@ class CreateProformaInvoiceTransactionProcessor
$paymentAmount = $booking->transactions()->payments()->where(function ($query) {
return $query->where(function ($query) {
return $query->where('status', ApprovalStatus::PENDING_SUBMISSION)->whereDate('expires_on', '>=', Carbon::now())->where('expires_on', '>', Carbon::now()->toTimeString());
// return $query->where('status', ApprovalStatus::PENDING_SUBMISSION)->whereDate('expires_on', '>=', Carbon::now())->where('expires_on', '>', Carbon::now()->toTimeString());
return $query->where('status', ApprovalStatus::PENDING_SUBMISSION)->where('expires_on', '>=', Carbon::now());
})->orWhere(function ($query) {
return $query->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
});
@@ -202,7 +202,19 @@
</div>
<button class="btn btn-xs all-caps b-rad-none btn-default bg-master-lightest w-100" @click="submitted = false" v-if="allowPOEditing">Edit Purchase Order</button>
<!-- <button class="btn btn-xs all-caps b-rad-none btn-default bg-master-lightest w-100" @click="submitted = false" >Edit Purchase Order</button> -->
<button class="btn btn-xs all-caps b-rad-none btn-complete w-100 m-t-5" v-if="!data.documents.proforma_invoice && data.outstanding_amount != 0" @click="submit(route('api.booking.proforma.create', data.id), 'post', section, true, true)">Generate Proforma Invoice</button>
<button class="btn btn-xs all-caps b-rad-none btn-complete w-100 m-t-5" v-if="!data.documents.proforma_invoice && data.outstanding_amount != 0" @click="handleGenerateProformaInvoice">Generate Proforma Invoice</button>
<modal-component
id="modal-einvoice-info"
class="animate__animated animate__fast animate__fadeIn"
styleType="fill-in" type="requestEInvoiceB" size="large">
<e-invoice-info-form-component
:section="section"
:company-id="data.company.id"
:company-type="data.company.type"
v-on:eInvoiceInfoUpdated="updatedEInvoiceInfo($event)"
v-on:eInvoiceChangeOfMindRequest="changeOfMindEInvoiceRequest()">
</e-invoice-info-form-component>
</modal-component>
</div>
</div>
</div>
@@ -321,11 +333,26 @@
this.submit(route('api.transaction.po.import', this.data.id), 'post', this.section, true, true);
},
successHandler(){
if((Math.round((this.poTotal + Number.EPSILON) * 1000) / 1000).toFixed(3) === (Math.round((this.data.amount + Number.EPSILON) * 1000) / 1000).toFixed(3)){
this.submitted = true;
successHandler(response, section){
if(section === this.section + 'CheckTransferRule'){
this.checkEInvoiceRule();
}
else if(section === this.section + 'CheckEInvoiceRule'){
if(response.payload.data.isPassed){
this.submit(route('api.booking.proforma.create', this.data.id), 'post', this.section, true, true);
}
}
else{
if((Math.round((this.poTotal + Number.EPSILON) * 1000) / 1000).toFixed(3) === (Math.round((this.data.amount + Number.EPSILON) * 1000) / 1000).toFixed(3)){
this.submitted = true;
}
this.updateList()
}
},
errorHandler(error, statusCode, section) { //E-Invoice
if(section === this.section + 'CheckEInvoiceRule' && statusCode === 422){
$('#modal-einvoice-info').modal('show');
}
this.updateList()
},
addProduct(){
this.products.push({
@@ -354,6 +381,31 @@
},
removeProduct(index){
this.products.splice(index, 1);
},
handleGenerateProformaInvoice(){
this.checkTransferRule();
},
checkTransferRule(){
this.error = '';
this.parameters = {
booking_id: this.data.id,
company_id: this.data.company.id,
};
this.submit(route('api.rule.check.transfer'), 'post', this.section + 'CheckTransferRule', false, true);
},
checkEInvoiceRule(){
this.error = '';
this.parameters = {
company_id: this.data.company.id,
};
this.submit(route('api.rule.check.einvoice'), 'post', this.section + 'CheckEInvoiceRule', false, true);
},
updatedEInvoiceInfo(info){
this.$store.dispatch('reloadList', {'name': "bookingDetailSection"});
},
changeOfMindEInvoiceRequest(){
this.parameters.e_invoice_request = false;
this.submit((this.route('api.company.einvoice.request.change')), 'post', this.section + 'ChangeOfMind', true, true);
}
},
mixins: [formHandler]
+1 -1
View File
@@ -3,7 +3,7 @@
<div class="container-fluid">
<div class="row no-margin">
<div class="col p-l-0 p-t-20 p-b-20 sm-text-center">
<small class="small no-margin pull-left sm-pull-reset all-caps fs-10 muted" style=" letter-spacing: 1px; ">Copyright © {{ date('Y') }} CIEF Exchange. All rights reserved. Powered by Laravel Vapor.</small>
<small class="small no-margin pull-left sm-pull-reset all-caps fs-10 muted" style=" letter-spacing: 1px; ">Copyright © {{ date('Y') }} CIEF Exchange. All rights reserved.</small>
</div>
</div>
</div>