mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-24 15:04:19 +00:00
Merge branch 'recalculate-wallet-balance' of gitlab.com:CIEFWorldwideSdnBhd/exchange-2.0 into development
This commit is contained in:
@@ -114,14 +114,14 @@ class CallbackBillplzLogic
|
||||
$wallet = null;
|
||||
if ($transaction->owner instanceof Wallet) {
|
||||
$wallet = $transaction->owner;
|
||||
}
|
||||
|
||||
if ($transaction->owner->company->wallets()->first() instanceof Wallet) {
|
||||
} else if ($transaction->owner->company->wallets()->first() instanceof Wallet) {
|
||||
$wallet = $transaction->owner->company->wallets()->first();
|
||||
}
|
||||
|
||||
if ($wallet != null) {
|
||||
$this->recalculatesWalletBalance->execute($wallet);
|
||||
$walletBalance = $this->recalculatesWalletBalance->execute($wallet);
|
||||
|
||||
$this->updatesWalletBalance->execute($wallet, $walletBalance);
|
||||
}
|
||||
|
||||
$token = Auth::fromUser(User::find(1));
|
||||
|
||||
@@ -29,6 +29,7 @@ use App\Models\Wallet;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\Modules\Wallets\Services\RecalculatesWalletBalance;
|
||||
|
||||
class CreateBookingPaymentLogic extends AbstractControllerLogic
|
||||
{
|
||||
@@ -70,6 +71,9 @@ class CreateBookingPaymentLogic extends AbstractControllerLogic
|
||||
/** @var CreateCashBackTransactionProcessor */
|
||||
private $createCashBackTransactionProcessor;
|
||||
|
||||
/** @var RecalculatesWalletBalance */
|
||||
private $recalculatesWalletBalance;
|
||||
|
||||
/**
|
||||
* CreateBookingPaymentLogic constructor.
|
||||
* @param FetchesBookingQuotation $fetchBookingQuotation
|
||||
@@ -81,8 +85,9 @@ class CreateBookingPaymentLogic extends AbstractControllerLogic
|
||||
* @param UpdatesWalletBalance $updatesWalletBalance
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
* @param CreateCashBackTransactionProcessor $createCashBackTransactionProcessor
|
||||
* @param RecalculatesWalletBalance $recalculatesWalletBalance
|
||||
*/
|
||||
public function __construct(FetchesBookingQuotation $fetchBookingQuotation, FetchesCompanyPaymentAttemptLimit $fetchesCompanyPaymentAttemptLimit, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CreatesTransaction $createsTransaction, CalculatesBookingOutstanding $calculatesBookingOutstanding, CreatesBillplzBill $createsBillplzBill, UpdatesWalletBalance $updatesWalletBalance, UpdatesTransactionStatus $updatesTransactionStatus, CreateCashBackTransactionProcessor $createCashBackTransactionProcessor)
|
||||
public function __construct(FetchesBookingQuotation $fetchBookingQuotation, FetchesCompanyPaymentAttemptLimit $fetchesCompanyPaymentAttemptLimit, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CreatesTransaction $createsTransaction, CalculatesBookingOutstanding $calculatesBookingOutstanding, CreatesBillplzBill $createsBillplzBill, UpdatesWalletBalance $updatesWalletBalance, UpdatesTransactionStatus $updatesTransactionStatus, CreateCashBackTransactionProcessor $createCashBackTransactionProcessor, RecalculatesWalletBalance $recalculatesWalletBalance)
|
||||
{
|
||||
$this->fetchBookingQuotation = $fetchBookingQuotation;
|
||||
$this->fetchesCompanyPaymentAttemptLimit = $fetchesCompanyPaymentAttemptLimit;
|
||||
@@ -93,6 +98,7 @@ class CreateBookingPaymentLogic extends AbstractControllerLogic
|
||||
$this->updatesWalletBalance = $updatesWalletBalance;
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
$this->createCashBackTransactionProcessor = $createCashBackTransactionProcessor;
|
||||
$this->recalculatesWalletBalance = $recalculatesWalletBalance;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -138,7 +144,8 @@ class CreateBookingPaymentLogic extends AbstractControllerLogic
|
||||
|
||||
$paymentReference = $billNumber;
|
||||
|
||||
$this->updatesWalletBalance->execute($wallet, ($amount * -1));
|
||||
$walletBalance = $this->recalculatesWalletBalance->execute($wallet);
|
||||
$this->updatesWalletBalance->execute($wallet, $walletBalance);
|
||||
}
|
||||
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute('PYMT-');
|
||||
|
||||
@@ -10,13 +10,6 @@ use App\Models\Company;
|
||||
|
||||
class UpdatesWalletBalance extends AbstractUpdateRecord
|
||||
{
|
||||
private $recalculatesWalletBalance;
|
||||
|
||||
public function __construct(RecalculatesWalletBalance $recalculatesWalletBalance)
|
||||
{
|
||||
$this->recalculatesWalletBalance = $recalculatesWalletBalance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Wallet $model
|
||||
* @param $amount
|
||||
@@ -25,9 +18,7 @@ class UpdatesWalletBalance extends AbstractUpdateRecord
|
||||
*/
|
||||
public function execute(Wallet $model, $amount) {
|
||||
|
||||
$auditBalance = $this->recalculatesWalletBalance->execute($model);
|
||||
|
||||
$model->amount = $auditBalance;
|
||||
$model->amount = $model->amount + $amount;
|
||||
return $this->handler($model);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user