mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 12:33:56 +00:00
edit refund calculation to correct formulat
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class BillNo implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('bill_no', $value);
|
||||
}
|
||||
|
||||
}
|
||||
+17
-28
@@ -7,17 +7,14 @@ use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use App\Classes\Modules\Transactions\Services\FetchTransactionBillNumberFromRefundBillNumber;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyPaymentAttemptLimit;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionRefundCalculationObject;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
|
||||
use App\Classes\Modules\Transactions\Services\CalculateTransactionRefundCreditNote;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Http\Resources\TransactionResource;
|
||||
use App\Models\Booking;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -40,18 +37,9 @@ class CreateBookingRefundCreditNoteLogic extends AbstractControllerLogic
|
||||
/** @var UpdatesTransactionStatus */
|
||||
private $updatesTransactionStatus;
|
||||
|
||||
/** @var FetchTransactionBillNumberFromRefundBillNumber */
|
||||
private $fetchTransactionBillNumberFromRefundBillNumber;
|
||||
|
||||
/** @var FetchesCompanyPaymentAttemptLimit */
|
||||
private $fetchesCompanyPaymentAttemptLimit;
|
||||
|
||||
/** @var GeneratesTransactionBillNumber */
|
||||
private $generatesTransactionBillNumber;
|
||||
|
||||
/** @var CalculateTransactionRefundCreditNote */
|
||||
private $calculateTransactionRefundCreditNote;
|
||||
|
||||
/** @var CreatesTransaction */
|
||||
private $createsTransaction;
|
||||
|
||||
@@ -59,20 +47,14 @@ class CreateBookingRefundCreditNoteLogic extends AbstractControllerLogic
|
||||
* CreateBookingPaymentLogic constructor.
|
||||
* @param FetchesTransaction $fetchesTransaction
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
* @param FetchTransactionBillNumberFromRefundBillNumber $fetchTransactionBillNumberFromRefundBillNumber
|
||||
* @param FetchesCompanyPaymentAttemptLimit $fetchesCompanyPaymentAttemptLimit
|
||||
* @param GeneratesTransactionBillNumber $generatesTransactionBillNumber
|
||||
* @param CalculateTransactionRefundCreditNote $calculateTransactionRefundCreditNote
|
||||
* @param CreatesTransaction $createsTransaction
|
||||
*/
|
||||
public function __construct(FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, FetchTransactionBillNumberFromRefundBillNumber $fetchTransactionBillNumberFromRefundBillNumber, FetchesCompanyPaymentAttemptLimit $fetchesCompanyPaymentAttemptLimit, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CalculateTransactionRefundCreditNote $calculateTransactionRefundCreditNote, CreatesTransaction $createsTransaction)
|
||||
public function __construct(FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CreatesTransaction $createsTransaction)
|
||||
{
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
$this->fetchTransactionBillNumberFromRefundBillNumber = $fetchTransactionBillNumberFromRefundBillNumber;
|
||||
$this->fetchesCompanyPaymentAttemptLimit = $fetchesCompanyPaymentAttemptLimit;
|
||||
$this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
|
||||
$this->calculateTransactionRefundCreditNote = $calculateTransactionRefundCreditNote;
|
||||
$this->createsTransaction = $createsTransaction;
|
||||
}
|
||||
|
||||
@@ -90,15 +72,22 @@ class CreateBookingRefundCreditNoteLogic extends AbstractControllerLogic
|
||||
|
||||
$this->updatesTransactionStatus->execute($transaction, ApprovalStatus::APPROVED);
|
||||
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute('CRDNT-');
|
||||
|
||||
$object = new TransactionObject($billNumber, TransactionType::CREDIT_NOTE, 1, $booking->company->id,
|
||||
$booking->bank_id, $transaction->payment_method,
|
||||
$this->calculateTransactionRefundCreditNote->execute($transaction, $transaction->currency_rate), $transaction->original_amount, 1,
|
||||
$transaction->original_currency_id, $transaction->currency_rate,
|
||||
$transaction->tax, $transaction->service_charge, null, ApprovalStatus::PENDING_VERIFICATION);
|
||||
$paymentReferenceTransaction = $this->fetchesTransaction->execute(['bill_no' => $transaction->payment_reference]);
|
||||
|
||||
$transaction = $this->createsTransaction->execute($booking, $object);
|
||||
if((int) $paymentReferenceTransaction->type === TransactionType::BILL){
|
||||
$transactionRefundCalculationObject = new TransactionRefundCalculationObject($booking, $transaction, $transaction->original_amount, $paymentReferenceTransaction->currency_rate);
|
||||
$transactionRefundCalculationObject->setRefundConversionAmount();
|
||||
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute('CRDNT-');
|
||||
|
||||
$object = new TransactionObject($billNumber, TransactionType::CREDIT_NOTE, 1, $booking->company->id,
|
||||
$booking->bank_id, $paymentReferenceTransaction->payment_method,
|
||||
$transactionRefundCalculationObject->getRefundConversionAmount(), $transaction->original_amount, 1,
|
||||
$paymentReferenceTransaction->original_currency_id, $paymentReferenceTransaction->currency_rate,
|
||||
$paymentReferenceTransaction->tax, $paymentReferenceTransaction->service_charge, null, ApprovalStatus::PENDING_VERIFICATION, [], $paymentReferenceTransaction->bill_no);
|
||||
|
||||
$transaction = $this->createsTransaction->execute($booking, $object);
|
||||
}
|
||||
|
||||
return $this->resourceResponse(new TransactionResource($transaction));
|
||||
}
|
||||
|
||||
@@ -8,19 +8,14 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Bookings\Services\FetchesBookingQuotation;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use App\Classes\Modules\Transactions\Services\CalculateTransactionRefundOriginalAmount;
|
||||
use App\Classes\Modules\Transactions\Services\CalculateTransactionRefundAmount;
|
||||
use App\Classes\Modules\Transactions\Services\CalculateTransactionRefundServiceCharge;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyPaymentAttemptLimit;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
||||
use App\Classes\Modules\Currencies\DataTransferObjects\CurrencyConversionObject;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionRefundCalculationObject;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Http\Resources\TransactionResource;
|
||||
use App\Models\Booking;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -46,18 +41,6 @@ class CreateBookingRefundLogic extends AbstractControllerLogic
|
||||
/** @var UpdatesTransactionStatus */
|
||||
private $updatesTransactionStatus;
|
||||
|
||||
/** @var CalculateTransactionRefundOriginalAmount */
|
||||
private $calculateTransactionRefundOriginalAmount;
|
||||
|
||||
/** @var CalculateTransactionRefundAmount */
|
||||
private $calculateTransactionRefundAmount;
|
||||
|
||||
/** @var CalculateTransactionRefundServiceCharge */
|
||||
private $calculateTransactionRefundServiceCharge;
|
||||
|
||||
/** @var FetchesCompanyPaymentAttemptLimit */
|
||||
private $fetchesCompanyPaymentAttemptLimit;
|
||||
|
||||
/** @var GeneratesTransactionBillNumber */
|
||||
private $generatesTransactionBillNumber;
|
||||
|
||||
@@ -69,21 +52,14 @@ class CreateBookingRefundLogic extends AbstractControllerLogic
|
||||
* @param FetchesBookingQuotation $fetchBookingQuotation
|
||||
* @param FetchesTransaction $fetchesTransaction
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
* @param CalculateTransactionRefundOriginalAmount $calculateTransactionRefundOriginalAmount
|
||||
* @param CalculateTransactionRefundServiceCharge $calculateTransactionRefundServiceCharge
|
||||
* @param FetchesCompanyPaymentAttemptLimit $fetchesCompanyPaymentAttemptLimit
|
||||
* @param GeneratesTransactionBillNumber $generatesTransactionBillNumber
|
||||
* @param CreatesTransaction $createsTransaction
|
||||
*/
|
||||
public function __construct(FetchesBookingQuotation $fetchBookingQuotation, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, CalculateTransactionRefundOriginalAmount $calculateTransactionRefundOriginalAmount, CalculateTransactionRefundAmount $calculateTransactionRefundAmount, CalculateTransactionRefundServiceCharge $calculateTransactionRefundServiceCharge, FetchesCompanyPaymentAttemptLimit $fetchesCompanyPaymentAttemptLimit, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CreatesTransaction $createsTransaction)
|
||||
public function __construct(FetchesBookingQuotation $fetchBookingQuotation, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CreatesTransaction $createsTransaction)
|
||||
{
|
||||
$this->fetchBookingQuotation = $fetchBookingQuotation;
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
$this->calculateTransactionRefundOriginalAmount = $calculateTransactionRefundOriginalAmount;
|
||||
$this->calculateTransactionRefundAmount = $calculateTransactionRefundAmount;
|
||||
$this->calculateTransactionRefundServiceCharge = $calculateTransactionRefundServiceCharge;
|
||||
$this->fetchesCompanyPaymentAttemptLimit = $fetchesCompanyPaymentAttemptLimit;
|
||||
$this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
|
||||
$this->createsTransaction = $createsTransaction;
|
||||
}
|
||||
@@ -106,19 +82,14 @@ class CreateBookingRefundLogic extends AbstractControllerLogic
|
||||
$customerBooking = $booking->transactions()->payments()->complete()->where('original_amount', '=', $transaction->original_amount)->where('id', '<', $transaction->id)->orderByDesc('id')->first();
|
||||
}
|
||||
|
||||
$unrequestedAmount = $this->calculateTransactionRefundOriginalAmount->execute($transaction, $request->input('amount'));
|
||||
|
||||
$conversionObject = new CurrencyConversionObject(floatval(str_replace(',', '', $unrequestedAmount)), $booking->convertible_currency_id, $booking->service_id, $booking->fix_currency_id === 1 ? 0:1);
|
||||
|
||||
$configurations = $this->fetchBookingQuotation->execute($booking->company, $conversionObject);
|
||||
|
||||
$totalRefundAmount = $this->calculateTransactionRefundAmount->execute(((int) $transaction->type === TransactionType::BILL) ? $customerBooking : $transaction, $configurations->getTotal());
|
||||
$transactionRefundCalculationObject = new TransactionRefundCalculationObject($booking, (int) $transaction->type === TransactionType::BILL ? $customerBooking : $transaction, $request->input('amount'));
|
||||
$transactionRefundCalculationObject->init();
|
||||
|
||||
$object = new TransactionObject($billNumber, TransactionType::REFUND, 1, $booking->company->id,
|
||||
$configurations->getConfigurations()->getBankId(), $configurations->getConversionObject()->getPaymentMethod(),
|
||||
$totalRefundAmount, $request->input('amount'), 1,
|
||||
$configurations->getConversionObject()->getCurrencyId(), ((int) $transaction->type === TransactionType::BILL) ? $transaction->currency_rate : 0,
|
||||
0, 0, null, ApprovalStatus::PENDING_VERIFICATION);
|
||||
$transactionRefundCalculationObject->getConfigurations()->getConfigurations()->getBankId(), $transactionRefundCalculationObject->getConversionObject()->getPaymentMethod(),
|
||||
$transactionRefundCalculationObject->getRefundTotalAmount(), $transactionRefundCalculationObject->getAmount(), 1,
|
||||
$transactionRefundCalculationObject->getConversionObject()->getCurrencyId(), $transactionRefundCalculationObject->getTransaction()->currency_rate,
|
||||
$transactionRefundCalculationObject->getRefundTax(), $transactionRefundCalculationObject->getRefundServiceCharge(), null, ApprovalStatus::PENDING_VERIFICATION, [], $transaction->bill_no);
|
||||
|
||||
$transaction = $this->createsTransaction->execute($booking, $object);
|
||||
|
||||
|
||||
@@ -57,6 +57,9 @@ class TransactionObject implements DataTransferObject
|
||||
/** @var array|null */
|
||||
private $details;
|
||||
|
||||
/** @var string */
|
||||
private $paymentReference;
|
||||
|
||||
/**
|
||||
* TransactionObject constructor.
|
||||
* @param string $billNo
|
||||
@@ -75,8 +78,9 @@ class TransactionObject implements DataTransferObject
|
||||
* @param Carbon|null $expiresOn
|
||||
* @param int|null $status
|
||||
* @param array|null $details
|
||||
* @param string $paymentReference
|
||||
*/
|
||||
public function __construct(string $billNo, string $transactionType, int $issuer, int $receiver, int $recipientBankAccountId, int $paymentMethod, float $amount, float $originalAmount, int $currencyId, int $originalCurrencyId, float $currencyRate, float $tax, float $serviceCharge, ?Carbon $expiresOn, ?int $status = ApprovalStatus::PENDING_SUBMISSION, ?array $details = [])
|
||||
public function __construct(string $billNo, string $transactionType, int $issuer, int $receiver, int $recipientBankAccountId, int $paymentMethod, float $amount, float $originalAmount, int $currencyId, int $originalCurrencyId, float $currencyRate, float $tax, float $serviceCharge, ?Carbon $expiresOn, ?int $status = ApprovalStatus::PENDING_SUBMISSION, ?array $details = [], ?string $paymentReference = null)
|
||||
{
|
||||
$this->billNo = $billNo;
|
||||
$this->transactionType = $transactionType;
|
||||
@@ -94,6 +98,7 @@ class TransactionObject implements DataTransferObject
|
||||
$this->expiresOn = $expiresOn;
|
||||
$this->status = $status;
|
||||
$this->details = $details;
|
||||
$this->paymentReference = $paymentReference;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -226,6 +231,11 @@ class TransactionObject implements DataTransferObject
|
||||
}, $this->details);
|
||||
}
|
||||
|
||||
public function getPaymentReference(): string
|
||||
{
|
||||
return $this->paymentReference;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+176
@@ -0,0 +1,176 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Transactions\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
use App\Models\Transaction;
|
||||
use App\Models\Booking;
|
||||
use App\Classes\Modules\Currencies\DataTransferObjects\CurrencyConversionObject;
|
||||
|
||||
class TransactionRefundCalculationObject implements DataTransferObject
|
||||
{
|
||||
private $booking;
|
||||
|
||||
private $transaction;
|
||||
|
||||
private $amount;
|
||||
|
||||
private $currency_rate;
|
||||
|
||||
private $unrequested_amount;
|
||||
|
||||
private $conversionObject;
|
||||
|
||||
private $configurations;
|
||||
|
||||
private $refund_amount;
|
||||
|
||||
private $refund_service_charge;
|
||||
|
||||
private $refund_tax;
|
||||
|
||||
private $refund_total_amount;
|
||||
|
||||
private $refund_conversion_amount;
|
||||
|
||||
/**
|
||||
* TransactionRefundCalculationObject constructor.
|
||||
* @param float $price
|
||||
*/
|
||||
public function __construct(Booking $booking, Transaction $transaction, ?float $amount = 0.00, ?float $currency_rate = 0.00)
|
||||
{
|
||||
$this->booking = $booking;
|
||||
$this->transaction = $transaction;
|
||||
$this->amount = $amount;
|
||||
$this->currency_rate = $currency_rate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Booking
|
||||
*/
|
||||
public function getBooking(): Booking
|
||||
{
|
||||
return $this->booking;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Transaction
|
||||
*/
|
||||
public function getTransaction(): Transaction
|
||||
{
|
||||
return $this->transaction;
|
||||
}
|
||||
|
||||
public function getAmount(): float
|
||||
{
|
||||
return $this->amount;
|
||||
}
|
||||
|
||||
public function getCurrencyRate(): float
|
||||
{
|
||||
return $this->currency_rate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function setUnrequestedAmount()
|
||||
{
|
||||
$this->unrequested_amount = $this->transaction->original_amount == $this->amount ? $this->transaction->original_amount : $this->transaction->original_amount - $this->amount;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUnrequestedAmount()
|
||||
{
|
||||
return $this->unrequested_amount;
|
||||
}
|
||||
|
||||
public function setConversionObject()
|
||||
{
|
||||
$this->conversionObject = new CurrencyConversionObject(floatval(str_replace(',', '', $this->getUnrequestedAmount())), $this->booking->convertible_currency_id, $this->booking->service_id, $this->booking->fix_currency_id === 1 ? 0 : 1);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getConversionObject()
|
||||
{
|
||||
return $this->conversionObject;
|
||||
}
|
||||
|
||||
public function setConfigurations()
|
||||
{
|
||||
$this->configurations = app('App\Classes\Modules\Bookings\Services\FetchesBookingQuotation')->execute($this->booking->company, $this->getConversionObject());
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getConfigurations()
|
||||
{
|
||||
return $this->configurations;
|
||||
}
|
||||
|
||||
public function setRefundAmount()
|
||||
{
|
||||
$this->refund_amount = $this->transaction->amount == $this->getConfigurations()->getLocalTotal() ? $this->transaction->amount : $this->transaction->amount - $this->getConfigurations()->getLocalTotal();
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRefundAmount()
|
||||
{
|
||||
return $this->refund_amount;
|
||||
}
|
||||
|
||||
public function setRefundServiceCharge()
|
||||
{
|
||||
$this->refund_service_charge = $this->transaction->service_charge == $this->getConfigurations()->getServiceCharge() ? $this->transaction->service_charge : $this->transaction->service_charge - $this->getConfigurations()->getServiceCharge();
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRefundServiceCharge()
|
||||
{
|
||||
return $this->refund_service_charge;
|
||||
}
|
||||
|
||||
public function setRefundTax()
|
||||
{
|
||||
$this->refund_tax = $this->transaction->tax == $this->getConfigurations()->getTax() ? $this->transaction->tax : $this->transaction->tax - $this->getConfigurations()->getTax();
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRefundTax()
|
||||
{
|
||||
return $this->refund_tax;
|
||||
}
|
||||
|
||||
public function setRefundTotalAmount()
|
||||
{
|
||||
$this->refund_total_amount = $this->getRefundAmount() + $this->getRefundServiceCharge() + $this->getRefundTax();
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRefundTotalAmount()
|
||||
{
|
||||
return $this->refund_total_amount;
|
||||
}
|
||||
|
||||
public function setRefundConversionAmount()
|
||||
{
|
||||
$this->refund_conversion_amount = $this->getCurrencyRate() ? $this->transaction->original_amount * (1 / $this->getCurrencyRate()) : $this->transaction->original_amount;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRefundConversionAmount()
|
||||
{
|
||||
return $this->refund_conversion_amount;
|
||||
}
|
||||
|
||||
public function init(){
|
||||
$this->setUnrequestedAmount();
|
||||
$this->setConversionObject();
|
||||
$this->setConfigurations();
|
||||
$this->setRefundAmount();
|
||||
$this->setRefundServiceCharge();
|
||||
$this->setRefundTax();
|
||||
$this->setRefundTotalAmount();
|
||||
$this->setRefundConversionAmount();
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Transactions\Services;
|
||||
|
||||
|
||||
use App\Models\Transaction;
|
||||
|
||||
class CalculateTransactionRefundAmount
|
||||
{
|
||||
public function execute(Transaction $transaction, float $amount = 0.00){
|
||||
return $transaction->amount == $amount ? $transaction->amount : $transaction->amount - $amount;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Transactions\Services;
|
||||
|
||||
|
||||
use App\Models\Transaction;
|
||||
|
||||
class CalculateTransactionRefundCreditNote
|
||||
{
|
||||
public function execute(Transaction $transaction, float $currency_rate = 0.00){
|
||||
return $transaction->original_amount * (1/$currency_rate);
|
||||
}
|
||||
|
||||
}
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Transactions\Services;
|
||||
|
||||
|
||||
use App\Models\Transaction;
|
||||
|
||||
class CalculateTransactionRefundOriginalAmount
|
||||
{
|
||||
public function execute(Transaction $transaction, float $amount = 0.00){
|
||||
return $transaction->original_amount == $amount ? $transaction->original_amount : $transaction->original_amount - $amount;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Transactions\Services;
|
||||
|
||||
|
||||
use App\Models\Transaction;
|
||||
|
||||
class CalculateTransactionRefundServiceCharge
|
||||
{
|
||||
public function execute(Transaction $transaction, float $service_charge = 0.00){
|
||||
return $transaction->service_charge == $service_charge ? $transaction->service_charge : $transaction->service_charge - $service_charge;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -32,6 +32,7 @@ class CreatesTransaction extends AbstractUpdateRelationshipRecord
|
||||
$model->service_charge = $object->getServiceCharge();
|
||||
$model->expires_on = $object->getExpiresOn();
|
||||
$model->status = $object->getStatus();
|
||||
$model->payment_reference = $object->getPaymentReference();
|
||||
|
||||
|
||||
return $this->handler($booking->transactions(), $model);
|
||||
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Transactions\Services;
|
||||
use App\Models\Transaction;
|
||||
|
||||
class FetchTransactionBillNumberFromRefundBillNumber
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @param string $prefix
|
||||
* @return string
|
||||
*/
|
||||
public function execute(Transaction $transaction): string {
|
||||
|
||||
$array = explode('-', $transaction->bill_no);
|
||||
|
||||
return $array[3].'-'.$array[4].'-'.$array[5];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user