mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
Merge branch 'master' of gitlab.com:CIEFWorldwideSdnBhd/exchange-2.0 into dillon/accounting-bank-mapping
This commit is contained in:
@@ -25,6 +25,7 @@ use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Classes\Modules\Wallets\Services\RecalculatesWalletBalance;
|
||||
|
||||
class CallbackBillplzLogic
|
||||
{
|
||||
@@ -45,20 +46,25 @@ class CallbackBillplzLogic
|
||||
/** @var CreateCashBackTransactionProcessor */
|
||||
private $createCashBackTransactionProcessor;
|
||||
|
||||
/** @var RecalculatesWalletBalance */
|
||||
private $recalculatesWalletBalance;
|
||||
|
||||
/**
|
||||
* CallbackBillplzLogic constructor.
|
||||
* @param GetBillplzBill $getBillplzBill
|
||||
* @param FetchesTransaction $fetchesTransaction
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
* @param UpdatesWalletBalance $updatesWalletBalance
|
||||
* @param RecalculatesWalletBalance $recalculatesWalletBalance
|
||||
*/
|
||||
public function __construct(GetBillplzBill $getBillplzBill, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, UpdatesWalletBalance $updatesWalletBalance, CreateCashBackTransactionProcessor $createCashBackTransactionProcessor)
|
||||
public function __construct(GetBillplzBill $getBillplzBill, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, UpdatesWalletBalance $updatesWalletBalance, CreateCashBackTransactionProcessor $createCashBackTransactionProcessor, RecalculatesWalletBalance $recalculatesWalletBalance)
|
||||
{
|
||||
$this->getBillplzBill = $getBillplzBill;
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
$this->updatesWalletBalance = $updatesWalletBalance;
|
||||
$this->createCashBackTransactionProcessor = $createCashBackTransactionProcessor;
|
||||
$this->recalculatesWalletBalance = $recalculatesWalletBalance;
|
||||
}
|
||||
|
||||
|
||||
@@ -92,12 +98,11 @@ class CallbackBillplzLogic
|
||||
}
|
||||
|
||||
if($transaction->status !== ApprovalStatus::COMPLETED && $transaction->status !== ApprovalStatus::APPROVED){
|
||||
|
||||
if($transaction->owner instanceof Wallet && $transaction->status !== ApprovalStatus::APPROVED && $status === ApprovalStatus::APPROVED) {
|
||||
$this->updatesWalletBalance->execute($transaction->owner, $transaction->amount);
|
||||
}
|
||||
$this->updatesTransactionStatus->execute($transaction, $status);
|
||||
}
|
||||
|
||||
if($transaction->owner instanceof Wallet) {
|
||||
$this->updatesWalletBalance->execute($transaction->owner, $transaction->amount);
|
||||
}
|
||||
|
||||
// if ($transaction->type == TransactionType::PAYMENT) {
|
||||
|
||||
@@ -65,7 +65,7 @@ class AutoPurchaseOrderFillLogic extends AbstractControllerLogic
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$bookings = Booking::where('service_id', '!=', 4)->where(function($query){
|
||||
return $query->whereMonth('created_at', '<', 03)->whereYear('created_at', 2023);
|
||||
return $query->whereMonth('created_at', '=', 04)->whereYear('created_at', 2023);
|
||||
})->whereDoesntHave('transactions', function($q){
|
||||
$q->where('type', TransactionType::PURCHASE_ORDER);
|
||||
$q->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED]);
|
||||
|
||||
@@ -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-');
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\Modules\Wallets\Services\UpdatesWalletBalance;
|
||||
use App\Models\Wallet;
|
||||
|
||||
class RecalculatesWalletBalance extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
private $updatesWalletBalance;
|
||||
|
||||
public function __construct(UpdatesWalletBalance $updatesWalletBalance)
|
||||
{
|
||||
$this->updatesWalletBalance = $updatesWalletBalance;
|
||||
}
|
||||
/**
|
||||
* @param Wallet $model
|
||||
* @param $amount
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Wallet $wallet)
|
||||
{
|
||||
|
||||
$i = 0;
|
||||
$topups = 0;
|
||||
$credit = 0;
|
||||
$payments = 0;
|
||||
$debit = 0;
|
||||
|
||||
foreach ($wallet->transactions as $transaction) {
|
||||
if (!in_array((int) $transaction->status, [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])) continue;
|
||||
if ((int) $transaction->type === TransactionType::TOP_UP) {
|
||||
$topups += (float) $transaction->amount;
|
||||
}
|
||||
if ((int) $transaction->type === TransactionType::CREDIT_NOTE) $credit += (float) $transaction->amount;
|
||||
if ((int) $transaction->type === TransactionType::PAYMENT) $payments += (float) $transaction->amount;
|
||||
if ((int) $transaction->type === TransactionType::DEBIT_NOTE) $debit += (float) $transaction->amount;
|
||||
}
|
||||
$auditBalance = ($topups + $credit) - ($payments + $debit);
|
||||
|
||||
return $auditBalance;
|
||||
}
|
||||
}
|
||||
@@ -3,10 +3,9 @@
|
||||
namespace App\Classes\Modules\Wallets\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Wallet;
|
||||
use App\Models\Company;
|
||||
|
||||
class UpdatesWalletBalance extends AbstractUpdateRecord
|
||||
{
|
||||
@@ -16,10 +15,24 @@ class UpdatesWalletBalance extends AbstractUpdateRecord
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Wallet $model, $amount) {
|
||||
public function execute(Wallet $model, $amount)
|
||||
{
|
||||
$i = 0;
|
||||
$topups = 0;
|
||||
$credit = 0;
|
||||
$payments = 0;
|
||||
$debit = 0;
|
||||
|
||||
$model->amount = $model->amount + $amount;
|
||||
foreach ($model->transactions as $transaction) {
|
||||
if (!in_array((int) $transaction->status, [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])) continue;
|
||||
if ((int) $transaction->type === TransactionType::TOP_UP) $topups += (float) $transaction->amount;
|
||||
if ((int) $transaction->type === TransactionType::CREDIT_NOTE) $credit += (float) $transaction->amount;
|
||||
if ((int) $transaction->type === TransactionType::PAYMENT) $payments += (float) $transaction->amount;
|
||||
if ((int) $transaction->type === TransactionType::DEBIT_NOTE) $debit += (float) $transaction->amount;
|
||||
}
|
||||
$auditBalance = ($topups + $credit) - ($payments + $debit);
|
||||
|
||||
$model->amount = $auditBalance;
|
||||
return $this->handler($model);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\SeasonalSegment;
|
||||
use Illuminate\Console\Command;
|
||||
use Carbon\Carbon;
|
||||
use App\Classes\Modules\Companies\Services\RemovesCompanyFromSegment;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Wallet;
|
||||
|
||||
class AuditAndUpdateWallletBalance extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'auditWalletBalance';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Audit and Update Wallet Balance';
|
||||
|
||||
/** @var RemovesCompanyFromSegment */
|
||||
private $removesCompanyFromSegment;
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(RemovesCompanyFromSegment $removesCompanyFromSegment)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->removesCompanyFromSegment = $removesCompanyFromSegment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$wallets = Wallet::all();
|
||||
|
||||
$i = 0;
|
||||
foreach ($wallets as $wallet) {
|
||||
$topups = 0;
|
||||
$credit = 0;
|
||||
$payments = 0;
|
||||
$debit = 0;
|
||||
|
||||
foreach ($wallet->transactions as $transaction) {
|
||||
if (!in_array((int) $transaction->status, [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])) continue;
|
||||
if ((int) $transaction->type === TransactionType::TOP_UP) {
|
||||
$topups += (float) $transaction->amount;
|
||||
}
|
||||
if ((int) $transaction->type === TransactionType::CREDIT_NOTE) $credit += (float) $transaction->amount;
|
||||
if ((int) $transaction->type === TransactionType::PAYMENT) $payments += (float) $transaction->amount;
|
||||
if ((int) $transaction->type === TransactionType::DEBIT_NOTE) $debit += (float) $transaction->amount;
|
||||
}
|
||||
$auditBalance = ($topups + $credit) - ($payments + $debit);
|
||||
$diffenrence = round((float) $wallet->amount - (($topups + $credit) - ($payments + $debit)), 2);
|
||||
if ((($diffenrence == 0) || ($diffenrence == -0)) and $wallet->amount > -0.01) continue;
|
||||
|
||||
$i++;
|
||||
|
||||
$this->info($i . ". Marking: " . $wallet->owner->reference . "(" . $wallet->id . ")" . PHP_EOL . "Current Balance: " . $wallet->amount . PHP_EOL . "Audit Balance: " . ($auditBalance) . PHP_EOL . "Difference: " . $diffenrence . PHP_EOL);
|
||||
|
||||
Wallet::where('id', $wallet->id)->update(['amount' => $auditBalance]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,9 +33,18 @@ class ImportHoneyTrapController
|
||||
$excelRows = $import->rows;
|
||||
$excelRows = $excelRows->toArray();
|
||||
|
||||
$returnArray = [];
|
||||
$returnArray = [];
|
||||
$segment_name = 'honey trap campaign';
|
||||
$segment = Segment::where('name', $segment_name)->first();
|
||||
|
||||
$segment_id = Segment::where('name', 'honey trap platinum')->first()->id;
|
||||
if (!$segment) {
|
||||
$row['status'] = 'Failed';
|
||||
$row['message'] = '"' . $segment_name . '"' . ' not found';
|
||||
$returnArray[] = $row;
|
||||
return response()->json($returnArray);
|
||||
}
|
||||
|
||||
$segment_id = $segment->id;
|
||||
|
||||
foreach ($excelRows as $row) {
|
||||
|
||||
@@ -111,6 +120,6 @@ class ImportHoneyTrapController
|
||||
{
|
||||
$unixTime = (($date - 25569) * 86400);
|
||||
$date = new DateTime("@$unixTime");
|
||||
return $date->format('d/m/Y');
|
||||
return $date->format('Y-m-d'); // Change the format to 'Y-m-d'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
@endphp
|
||||
<section id="customer-account" class="m-b-50">
|
||||
<h3>Customer Account</h3>
|
||||
<p>Company Id: <span>{{$company->id}}</span></p>
|
||||
<p>Marking: <span><a href="{{route('customer.profile', $company->reference)}}" target="_blank">{{$company->reference}}</a></span></p>
|
||||
<p>Account Type: <span>{{$company->type === 1 ? 'Business' : 'Personal'}}</span></p>
|
||||
@if($company->type === 1)<p>Company's Name: <span>{{$company->name}}</span></p>@endif
|
||||
|
||||
Reference in New Issue
Block a user