diff --git a/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php index 16e42cdc..a87c8807 100644 --- a/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php @@ -63,6 +63,7 @@ class CreateProformaInvoiceTransactionProcessor /** @var FetchesCompanyPaymentAttemptLimit */ private $fetchesCompanyPaymentAttemptLimit; + /** * CreateProformaInvoiceTransactionProcessor constructor. * @param CreatesTransaction $createsTransaction @@ -106,15 +107,26 @@ class CreateProformaInvoiceTransactionProcessor ->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED]) ->first(); - $billNumber = $this->generatesTransactionBillNumber->execute('PROFORMA-'); - $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); - $this->generatesBookingQuotation->execute( - $this->fetchesBookingQuotation->execute($booking->company, $conversionObject), - $this->fetchesCompanyPaymentAttemptLimit->execute($booking->company) - ); + + $configurations = $this->fetchesBookingQuotation->execute($booking->company, $conversionObject); + + $paymentAttemptLimit = $this->fetchesCompanyPaymentAttemptLimit->execute($booking->company); + + $billNumber = $this->generatesTransactionBillNumber->execute('PYMT-'); + + + $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); + + $billNumber = $this->generatesTransactionBillNumber->execute('PROFORMA-'); $payable_amount = $this->calculatesBookingPayableAmount->execute($booking, $booking->fix_currency_id); $booking_amount = $booking->fix_amount;