mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
fix proforma invoice
This commit is contained in:
+27
-14
@@ -24,6 +24,7 @@ use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use App\Models\Booking;
|
||||
use App\Models\Document;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
||||
|
||||
class CreateProformaInvoiceTransactionProcessor
|
||||
@@ -102,12 +103,16 @@ class CreateProformaInvoiceTransactionProcessor
|
||||
*/
|
||||
public function execute(Booking $booking)
|
||||
{
|
||||
|
||||
$po_order_transaction = $booking->transactions()
|
||||
->where('type', TransactionType::PURCHASE_ORDER)
|
||||
->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED])
|
||||
->first();
|
||||
|
||||
$transaction = $booking->transactions()
|
||||
->where('type', TransactionType::PAYMENT)
|
||||
->first();
|
||||
|
||||
if (!$transaction) {
|
||||
$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);
|
||||
@@ -118,16 +123,24 @@ class CreateProformaInvoiceTransactionProcessor
|
||||
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute('PYMT-');
|
||||
|
||||
$transaction = $booking->transactions()
|
||||
->where('type', TransactionType::PAYMENT)
|
||||
->first();
|
||||
|
||||
if (!$transaction) {
|
||||
$object = new TransactionObject($billNumber, TransactionType::PAYMENT, 1, $booking->company->id,
|
||||
$configurations->getConfigurations()->getBankId(), $configurations->getConversionObject()->getPaymentMethod(),
|
||||
$configurations->getTotal(), $configurations->getForeignTotal(), 1,
|
||||
$configurations->getConversionObject()->getCurrencyId(), $configurations->getConfigurations()->getRate(),
|
||||
$configurations->getTax(), $configurations->getServiceCharge(), Carbon::now()->addMinutes($paymentAttemptLimit), ApprovalStatus::PENDING_SUBMISSION, [], isset($billPlzBill) ? $billPlzBill->id : NULL
|
||||
$object = new TransactionObject(
|
||||
$billNumber,
|
||||
TransactionType::PAYMENT,
|
||||
1,
|
||||
$booking->company->id,
|
||||
$configurations->getConfigurations()->getBankId(),
|
||||
$configurations->getConversionObject()->getPaymentMethod(),
|
||||
$configurations->getTotal(),
|
||||
$configurations->getForeignTotal(),
|
||||
1,
|
||||
$configurations->getConversionObject()->getCurrencyId(),
|
||||
$configurations->getConfigurations()->getRate(),
|
||||
$configurations->getTax(),
|
||||
$configurations->getServiceCharge(),
|
||||
Carbon::now()->addMinutes($paymentAttemptLimit),
|
||||
ApprovalStatus::PENDING_SUBMISSION,
|
||||
[],
|
||||
isset($billPlzBill) ? $billPlzBill->id : NULL
|
||||
);
|
||||
|
||||
$this->createsTransaction->execute($booking, $object);
|
||||
@@ -148,7 +161,7 @@ class CreateProformaInvoiceTransactionProcessor
|
||||
->where('type', TransactionType::PAYMENT)
|
||||
->first();
|
||||
|
||||
$booking_currency_average_rate = $booking_amount / $booking->transactions()->payments()->where(function($query){
|
||||
$paymentAmount = $booking->transactions()->payments()->where(function ($query) {
|
||||
return $query->where(function ($query) {
|
||||
return $query->where('status', ApprovalStatus::PENDING_SUBMISSION)->whereDate('expires_on', '>=', Carbon::now())->where('expires_on', '>', Carbon::now()->toTimeString());
|
||||
})->orWhere(function ($query) {
|
||||
@@ -156,6 +169,8 @@ class CreateProformaInvoiceTransactionProcessor
|
||||
});
|
||||
})->selectRaw('sum(amount - service_charge - tax) as sub_total')->get()->sum('sub_total');
|
||||
|
||||
$booking_currency_average_rate = $booking_amount / $paymentAmount;
|
||||
|
||||
$total_service_charge = $booking->transactions()
|
||||
->where('type', TransactionType::PAYMENT)
|
||||
->whereNotIn('status', [ApprovalStatus::REJECTED, ApprovalStatus::SUSPENDED])
|
||||
@@ -205,7 +220,5 @@ class CreateProformaInvoiceTransactionProcessor
|
||||
/** @var Document $document */
|
||||
$document = $this->createsDocument->execute($po_order_transaction->booking, $document_object);
|
||||
$this->createsFile->execute($document, $document_object);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,6 +70,11 @@
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<?php
|
||||
$transaction = $invoice_transaction;
|
||||
$voucher_redemption = $voucher_redemption ?? null;
|
||||
?>
|
||||
|
||||
<!-- Invoice Table -->
|
||||
@include('pages.pdfs.purchase_order_table')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user