mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
Merge branch 'dillon/90-e-invoice-f-2' into vapor/development
This commit is contained in:
+17
-1
@@ -15,6 +15,7 @@ use App\Classes\Modules\Wallets\Processors\CreditWalletProcessor;
|
||||
use App\Classes\Modules\Bookings\Services\CalculatesBookingPayableAmount;
|
||||
use App\Classes\Modules\Bookings\Services\CalculatesBookingRefundAmount;
|
||||
use App\Classes\Modules\Transactions\Standards\Rules\CanUpdateRefundTransactionStatus;
|
||||
use App\Classes\Modules\Transactions\Processors\CreateInvoiceTransactionV2Processor;
|
||||
use App\Classes\ValueObjects\Constants\RemarkRefundReason;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@@ -59,6 +60,9 @@ class UpdateRefundTransactionStatusLogic extends AbstractControllerLogic
|
||||
/** @var CanUpdateRefundTransactionStatus */
|
||||
private $canUpdateRefundTransactionStatus;
|
||||
|
||||
/** @var CreateInvoiceTransactionV2Processor */
|
||||
private $createInvoiceTransactionV2Processor;
|
||||
|
||||
/**
|
||||
* CreatePaymentVerificationDocumentLogic constructor.
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
@@ -70,8 +74,9 @@ class UpdateRefundTransactionStatusLogic extends AbstractControllerLogic
|
||||
* @param CalculatesBookingRefundAmount $calculatesBookingRefundAmount
|
||||
* @param UpdateBookingAmountLogic $updateBookingAmountLogic
|
||||
* @param CanUpdateRefundTransactionStatus $canUpdateRefundTransactionStatus
|
||||
* @param CreateInvoiceTransactionV2Processor $createInvoiceTransactionV2Processor
|
||||
*/
|
||||
public function __construct(FetchesCompany $fetchesCompany, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, DeletesDocument $deletesDocument, CreditWalletProcessor $creditWalletProcessor, CalculatesBookingPayableAmount $calculatesBookingPayableAmount, CalculatesBookingRefundAmount $calculatesBookingRefundAmount, UpdateBookingAmountLogic $updateBookingAmountLogic, CanUpdateRefundTransactionStatus $canUpdateRefundTransactionStatus)
|
||||
public function __construct(FetchesCompany $fetchesCompany, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, DeletesDocument $deletesDocument, CreditWalletProcessor $creditWalletProcessor, CalculatesBookingPayableAmount $calculatesBookingPayableAmount, CalculatesBookingRefundAmount $calculatesBookingRefundAmount, UpdateBookingAmountLogic $updateBookingAmountLogic, CanUpdateRefundTransactionStatus $canUpdateRefundTransactionStatus, CreateInvoiceTransactionV2Processor $createInvoiceTransactionV2Processor)
|
||||
{
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
@@ -82,6 +87,7 @@ class UpdateRefundTransactionStatusLogic extends AbstractControllerLogic
|
||||
$this->calculatesBookingRefundAmount = $calculatesBookingRefundAmount;
|
||||
$this->updateBookingAmountLogic = $updateBookingAmountLogic;
|
||||
$this->canUpdateRefundTransactionStatus = $canUpdateRefundTransactionStatus;
|
||||
$this->createInvoiceTransactionV2Processor = $createInvoiceTransactionV2Processor;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -140,6 +146,16 @@ class UpdateRefundTransactionStatusLogic extends AbstractControllerLogic
|
||||
$this->updatesTransactionStatus->execute($paymentTransaction, ApprovalStatus::REFUNDED);
|
||||
}
|
||||
|
||||
//A full refund will need invoice generated
|
||||
if($refundAmount === $booking->fix_amount){
|
||||
$this->createInvoiceTransactionV2Processor->execute($booking, "", null, [
|
||||
'generateEInvoice' => false,
|
||||
'generateEInvoiceWithNormalInvoiceTemplate' => false,
|
||||
'generateEInvoiceRefund' => true,
|
||||
'bookingOriginalStatus' => $booking->status
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->response([]);
|
||||
}
|
||||
}
|
||||
|
||||
+14
-5
@@ -106,11 +106,7 @@ class CreateInvoiceTransactionV2Processor
|
||||
$generateEInvoiceRefund = $options['generateEInvoiceRefund'] ?? false;
|
||||
$bookingOriginalStatus = $options['bookingOriginalStatus'] ?? ApprovalStatus::COMPLETED;
|
||||
|
||||
if($generateEInvoiceRefund){
|
||||
$generateEInvoice = true; //With or without refund, these 2 flags are meant to Generate E-Invoice, so cannot have opposite indicator
|
||||
}
|
||||
|
||||
if ($booking->status === ApprovalStatus::COMPLETED && !$generateEInvoice) {
|
||||
if ($booking->status === ApprovalStatus::COMPLETED && !$generateEInvoiceRefund) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -240,6 +236,19 @@ class CreateInvoiceTransactionV2Processor
|
||||
|
||||
$voucherRedemption = $transaction->voucherRedemption;
|
||||
|
||||
if($generateEInvoiceRefund){
|
||||
$metadata = $booking->attributesKVP()->where('key', KVPKey::AUTOCOUNT_DOCNO_INVOICE)->first();
|
||||
if($metadata){
|
||||
$generateEInvoice = true;
|
||||
}
|
||||
else{
|
||||
$metadata = $transaction->attributesKVP()->where('key', KVPKey::AUTOCOUNT_DOCNO_INVOICE)->first();
|
||||
if($metadata){
|
||||
$generateEInvoice = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// purchase order
|
||||
if(!$generateEInvoiceRefund){
|
||||
$this->invoiceDocumentProcessor->execute($invoice_transaction, $purchaseOrder, $supplier, DocumentType::PURCHASE_ORDER, $voucherRedemption, $generateEInvoiceWithNormalInvoiceTemplate);
|
||||
|
||||
+1
-1
@@ -148,7 +148,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col" v-else>
|
||||
<div class="col" v-else> <!-- Show only single E-Invoice button-->
|
||||
<div class="row m-b-50">
|
||||
<div class="col no-padding">
|
||||
<div class="row m-t-20">
|
||||
|
||||
Reference in New Issue
Block a user