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/development
This commit is contained in:
@@ -8,6 +8,7 @@ use App\Classes\Modules\Bookings\Services\FetchesBooking;
|
||||
use App\Classes\Modules\Bookings\Services\CalculatesBookingOutstanding;
|
||||
use App\Classes\Modules\Bookings\Services\FetchesBookingQuotation;
|
||||
use App\Classes\Modules\Currencies\DataTransferObjects\CurrencyConversionObject;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@@ -65,8 +66,11 @@ class CanPassMustEInvoiceAmountLimitRule extends AbstractRule
|
||||
//Check if booking amount is RM10,000 or more, than must opt-in E-Invoice
|
||||
$booking = $this->fetchesBooking->execute(['id' => $object->bookingId]);
|
||||
$company = $booking->company;
|
||||
$totalPayments = 0;
|
||||
|
||||
if(isset($object->amount)){
|
||||
$totalPayments = $booking->transactions()->payments()->whereIn('transactions.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->sum('amount');
|
||||
|
||||
$conversionObject = new CurrencyConversionObject(floatval(str_replace(',', '', floatval(str_replace(',', '', $object->amount)))), $booking->convertible_currency_id, $booking->service_id, $booking->fix_currency_id === 1 ? 0:1, PaymentMethodType::PAYMENT_METHODS[$object->paymentMethod]);
|
||||
$voucherCode = $object->voucherCode ?? null;
|
||||
$configurations = $this->fetchesBookingQuotation->execute($booking->company, $conversionObject, $voucherCode, null, $booking);
|
||||
@@ -78,6 +82,7 @@ class CanPassMustEInvoiceAmountLimitRule extends AbstractRule
|
||||
}
|
||||
|
||||
$bookingAmountInMYR = $configurations->getTotal();
|
||||
$bookingAmountInMYR = $bookingAmountInMYR + $totalPayments;
|
||||
|
||||
if($bookingAmountInMYR >= 10000 && (!$company->e_invoice || !$company->tin) ){
|
||||
throw new CriteriaNotFulfilledException("RM10,000 and above must opt-in for E-Invoice.");
|
||||
|
||||
Reference in New Issue
Block a user