diff --git a/app/Classes/Modules/Rules/Standards/Rules/CanPassMustEInvoiceAmountLimitRule.php b/app/Classes/Modules/Rules/Standards/Rules/CanPassMustEInvoiceAmountLimitRule.php index fa3d66be..0e925f6c 100644 --- a/app/Classes/Modules/Rules/Standards/Rules/CanPassMustEInvoiceAmountLimitRule.php +++ b/app/Classes/Modules/Rules/Standards/Rules/CanPassMustEInvoiceAmountLimitRule.php @@ -66,27 +66,35 @@ 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'); + // $totalPayments = 0; - $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); - } - else{ - $outstanding = $this->calculatesBookingOutstanding->execute($booking); - $conversionObject = new CurrencyConversionObject(floatval(str_replace(',', '', $outstanding)), $booking->convertible_currency_id, $booking->service_id, $booking->fix_currency_id === 1 ? 0 : 1, PaymentMethodType::CASH); - $configurations = $this->fetchesBookingQuotation->execute($booking->company, $conversionObject); + // 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); + // } + // else{ + // $outstanding = $this->calculatesBookingOutstanding->execute($booking); + // $conversionObject = new CurrencyConversionObject(floatval(str_replace(',', '', $outstanding)), $booking->convertible_currency_id, $booking->service_id, $booking->fix_currency_id === 1 ? 0 : 1, PaymentMethodType::CASH); + // $configurations = $this->fetchesBookingQuotation->execute($booking->company, $conversionObject); + // } + + // $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."); + // } + + if((($booking->fix_amount >= 17000 && $booking->fix_currency_id === 2) || + ($booking->fix_amount >= 4000 && $booking->fix_currency_id === 3)) + && (!$company->e_invoice || !$company->tin) ){ + throw new CriteriaNotFulfilledException("Booking amount above limit, must opt-in for E-Invoice."); } - $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."); - } return true; } }