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-e-1' into vapor/production
This commit is contained in:
@@ -7,6 +7,8 @@ use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Bookings\Services\FetchesBooking;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyPaymentAttemptLimit;
|
||||
use App\Classes\Modules\Transactions\Services\CalculatesTransactionExpiryDateTime;
|
||||
use App\Classes\Modules\Bookings\Services\CalculatesBookingOutstanding;
|
||||
use App\Classes\Modules\Bookings\Services\CalculatesBookingPaidAmount;
|
||||
use App\Classes\Modules\Billplzs\Services\DeletesBillplzBill;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
@@ -32,6 +34,12 @@ class CanPassOrderDurationLimitRule extends AbstractRule
|
||||
/** @var FetchesTransaction */
|
||||
private $fetchesTransaction;
|
||||
|
||||
/** @var CalculatesBookingOutstanding */
|
||||
private $calculatesBookingOutstanding;
|
||||
|
||||
/** @var CalculatesBookingPaidAmount */
|
||||
private $calculatesBookingPaidAmount;
|
||||
|
||||
/**
|
||||
* CanPassOrderDurationLimitRule constructor.
|
||||
* @param FetchesBooking $fetchesBooking
|
||||
@@ -39,14 +47,18 @@ class CanPassOrderDurationLimitRule extends AbstractRule
|
||||
* @param CalculatesTransactionExpiryDateTime $calculatesTransactionExpiryDateTime
|
||||
* @param DeletesBillplzBill $deletesBillplzBill
|
||||
* @param FetchesTransaction $fetchesTransaction
|
||||
* @param CalculatesBookingOutstanding $calculatesBookingOutstanding
|
||||
* @param CalculatesBookingPaidAmount $calculatesBookingPaidAmount
|
||||
*/
|
||||
public function __construct(FetchesBooking $fetchesBooking, FetchesCompanyPaymentAttemptLimit $fetchesCompanyPaymentAttemptLimit, CalculatesTransactionExpiryDateTime $calculatesTransactionExpiryDateTime, DeletesBillplzBill $deletesBillplzBill, FetchesTransaction $fetchesTransaction)
|
||||
public function __construct(FetchesBooking $fetchesBooking, FetchesCompanyPaymentAttemptLimit $fetchesCompanyPaymentAttemptLimit, CalculatesTransactionExpiryDateTime $calculatesTransactionExpiryDateTime, DeletesBillplzBill $deletesBillplzBill, FetchesTransaction $fetchesTransaction, CalculatesBookingOutstanding $calculatesBookingOutstanding, CalculatesBookingPaidAmount $calculatesBookingPaidAmount)
|
||||
{
|
||||
$this->fetchesBooking = $fetchesBooking;
|
||||
$this->fetchesCompanyPaymentAttemptLimit = $fetchesCompanyPaymentAttemptLimit;
|
||||
$this->calculatesTransactionExpiryDateTime = $calculatesTransactionExpiryDateTime;
|
||||
$this->deletesBillplzBill = $deletesBillplzBill;
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
$this->calculatesBookingOutstanding = $calculatesBookingOutstanding;
|
||||
$this->calculatesBookingPaidAmount = $calculatesBookingPaidAmount;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,8 +88,18 @@ class CanPassOrderDurationLimitRule extends AbstractRule
|
||||
//Check if order is still valid (within duration limit, reused PAYMENT_ATTEMPT_DURATION_LIMIT)
|
||||
$expiresOn = $this->calculatesTransactionExpiryDateTime->execute($object->bookingId);
|
||||
$isExpired = Carbon::now()->greaterThan($expiresOn);
|
||||
if($isExpired){
|
||||
|
||||
if($isExpired) {
|
||||
$booking = $this->fetchesBooking->execute(['id' => $object->bookingId]);
|
||||
$amountOutstanding = $this->calculatesBookingOutstanding->execute($booking);
|
||||
$amountPaid = $this->calculatesBookingPaidAmount->execute($booking);
|
||||
if($amountPaid > 0.01 && $amountOutstanding > 0){
|
||||
Log::info("Transfer already expired but has paid amount: {$amountPaid} and outstanding amount: {$amountOutstanding}, Booking ID: {$object->bookingId}");
|
||||
$isExpired = false;
|
||||
}
|
||||
}
|
||||
|
||||
if($isExpired){
|
||||
if($object->paymentReference){
|
||||
$transaction = $this->fetchesTransaction->execute(['payment_reference' => $object->paymentReference]);
|
||||
if($transaction->status === ApprovalStatus::PENDING_SUBMISSION && $transaction->payment_method == PaymentMethodType::PAYMENT_GATEWAY){
|
||||
|
||||
Reference in New Issue
Block a user