E-Invoice - Fix booking with full refund has no Ref at Sales Report API that generates record with no autocount data

This commit is contained in:
Dillon Ngo
2025-11-25 09:49:53 +08:00
parent f0f6822b7e
commit 4c25ef660f
3 changed files with 31 additions and 6 deletions
@@ -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([]);
}
}