Compare commits

..

2 Commits

Author SHA1 Message Date
Dillon Ngo 295072153d Merge branch 'dillon/70-laravel-vapor' into 'master'
Laravel Vapor - Disable all schedule commands

See merge request CIEFWorldwideSdnBhd/shipping-portal!237
2024-09-13 17:43:28 +00:00
Dillon Ngo e90aebd107 Laravel Vapor - Disable all schedule commands 2024-09-14 00:03:22 +08:00
8 changed files with 72 additions and 137 deletions
@@ -21,7 +21,6 @@ use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor;
use App\Classes\Modules\Orders\Processors\UpdateDoFromYDPortalProcessor;
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
use Illuminate\Support\Facades\Log;
use App\Classes\Modules\Wallets\Processors\CreditWalletProcessor;
class CreatePaymentTransactionProcessor
{
@@ -50,9 +49,6 @@ class CreatePaymentTransactionProcessor
/** @var UpdatesTransactionStatus */
private $updatesTransactionStatus ;
/** @var CreditWalletProcessor */
private $creditWalletProcessor ;
/**
* @param FetchesTransaction $fetchesTransaction,
* @param GeneratesTransactionBillNumber $generatesTransactionBillNumber,
@@ -64,7 +60,6 @@ class CreatePaymentTransactionProcessor
* @param UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor
* @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor
* @param UpdatesTransactionStatus $updatesTransactionStatus
* @param CreditWalletProcessor $creditWalletProcessor
*/
public function __construct(
GeneratesTransactionBillNumber $generatesTransactionBillNumber,
@@ -74,7 +69,6 @@ class CreatePaymentTransactionProcessor
UpdatesWalletBalance $updatesWalletBalance,
UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor,
UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor,
CreditWalletProcessor $creditWalletProcessor,
UpdatesTransactionStatus $updatesTransactionStatus
)
{
@@ -85,7 +79,6 @@ class CreatePaymentTransactionProcessor
$this->updatesWalletBalance = $updatesWalletBalance;
$this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor;
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
$this->creditWalletProcessor = $creditWalletProcessor;
$this->updatesTransactionStatus = $updatesTransactionStatus;
}
@@ -181,11 +174,6 @@ class CreatePaymentTransactionProcessor
$payment_transaction = $this->createsPaymentTransaction->execute($invoice, $object);
// cief coins
if ($approvalStatus == ApprovalStatus::APPROVED) {
$wallet = $this->creditWalletProcessor->execute($company_module, transactionType::CIEF_COINS_CREDIT, $amount, 'Cief Coins Credit', 3); // TODO-cief-coins: pls confirm the reference
}
return $payment_transaction;
}
}
@@ -3,12 +3,16 @@
namespace App\Classes\Modules\Wallets\ControllersLogic;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
use App\Classes\Modules\Wallets\Services\ListsWallet;
use App\Classes\Modules\Wallets\Standards\Rules\CanListWallet;
use App\Http\Resources\WalletResource;
use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use App\Classes\Modules\Wallets\Services\ListsWallets;
use Illuminate\Support\Facades\DB;
class ListWalletLogic extends AbstractControllerLogic
{
@@ -22,8 +26,8 @@ class ListWalletLogic extends AbstractControllerLogic
];
}
/** @var ListsWallets */
private $listsWallets;
/** @var ListWallet */
private $listsWallet;
/** @var CanCreateCompanyWallet */
private $canListWallet;
@@ -34,10 +38,10 @@ class ListWalletLogic extends AbstractControllerLogic
* @param GeneratesWalletCode $generatesWalletCode
* @param CanCreateCompanyWallet $canCreateCompanyWallet
*/
public function __construct(CanListWallet $canListWallet, ListsWallets $listsWallets)
public function __construct(CanListWallet $canListWallet, ListsWallet $listsWallet)
{
$this->canListWallet = $canListWallet;
$this->listsWallets = $listsWallets;
$this->listsWallet = $listsWallet;
}
/**
@@ -49,7 +53,7 @@ class ListWalletLogic extends AbstractControllerLogic
{
//$this->canListWallet->passes();
$query = $this->listsWallets->execute($this->listsWallets->deserializeFilters($request->input('filters')));
$query = $this->listsWallet->execute($this->listsWallet->deserializeFilters($request->input('filters')));
return $this->collectionResponse(WalletResource::collection($query));
}
@@ -79,40 +79,19 @@ class CreditWalletProcessor
* @return \Illuminate\Database\Eloquent\Model
* @throws \App\Classes\Exceptions\MalformedRequestException
*/
public function execute(CompanyModule $companyModule, int $transactionType, float $amount, string $reference, ?int $currencyId = 1)
public function execute(CompanyModule $companyModule, int $transactionType, float $amount, string $reference)
{
/** @var Wallet $wallet */
$wallet = $companyModule->wallets()->where('currency_id', $currencyId)->first();
if (!$wallet) {
$object = new WalletObject($companyModule->id, $currencyId, $this->generatesWalletCode->execute());
if (!$companyModule->wallets()->first()) {
$object = new WalletObject($companyModule->id, 1, $this->generatesWalletCode->execute());
$this->createsWallet->execute($object, $companyModule);
$wallet = $companyModule->wallets()->where('currency_id', $currencyId)->first();
}
$billNumberPrefix = null;
$transaction_object_transaction_type = $transactionType;
switch ($transactionType) {
case TransactionType::PAYMENT:
$billNumberPrefix = 'DEBIT-NOTE-';
$transaction_object_transaction_type = TransactionType::DEBIT_NOTE;
break;
case TransactionType::CIEF_COINS_CREDIT:
$billNumberPrefix = 'COINS-CREDIT-'; // TODO-cief-coins: pls confirm the prefix
break;
case TransactionType::CIEF_COINS_DEBIT:
$billNumberPrefix = 'COINS-DEBIT-'; // TODO-cief-coins: pls confirm the prefix
break;
default:
$billNumberPrefix = 'CREDIT-NOTE-';
$transaction_object_transaction_type = TransactionType::CREDIT_NOTE;
break;
}
/** @var Wallet $wallet */
$wallet = $companyModule->wallets()->first();
$billNumber = $this->generatesTransactionBillNumber->execute($billNumberPrefix);
$transaction_object = new TransactionObject($billNumber, $transaction_object_transaction_type, 1, $wallet->owner->id, 1, PaymentMethodType::CASH, $amount, $amount, 1, 1, 1, 0, 0, null, ApprovalStatus::APPROVED, [], $reference);
$billNumber = $this->generatesTransactionBillNumber->execute($transactionType === 2 ? 'DEBIT-NOTE-' : 'CREDIT-NOTE-');
$transaction_object = new TransactionObject($billNumber, $transactionType === 2 ? TransactionType::DEBIT_NOTE : TransactionType::CREDIT_NOTE, 1, $wallet->owner->id, 1, PaymentMethodType::CASH, $amount, $amount, 1, 1, 1, 0, 0, null, ApprovalStatus::APPROVED, [], $reference);
$transaction = $this->createsTransactionableTransaction->execute($wallet, $transaction_object);
$this->updatesWalletBalance->execute($wallet, $transaction->amount);
@@ -2,31 +2,28 @@
namespace App\Classes\Modules\Wallets\Services;
use App\Classes\General\Eloquent\AbstractListRecord;
use Illuminate\Database\Eloquent\Builder;
use App\Classes\General\Eloquent\AbstractListRecord;
use App\Models\Wallet;
class ListsWallets extends AbstractListRecord
class ListsWallet extends AbstractListRecord
{
/** @var Wallet */
/** @var Booking */
private $repository;
/**
* Wallet constructor.
* @param Wallet $repository
* ListsBookings constructor.
* @param Booking $repository
*/
public function __construct(Wallet $repository)
{
$this->repository = $repository;
}
/**
* @return Builder
*/
function getRepository(): Builder
public function getRepository(): Builder
{
return $this->repository->newQuery();
}
@@ -27,15 +27,11 @@ class UpdatesWalletBalance extends AbstractUpdateRecord
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::GROUP_PAYMENT) $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;
// cief coins
if ((int) $transaction->type === TransactionType::CIEF_COINS_CREDIT) $credit += (float) $transaction->amount;
if ((int) $transaction->type === TransactionType::CIEF_COINS_DEBIT) $debit += (float) $transaction->amount;
if ((int) $transaction->type === TransactionType::TOP_UP) $topups += (float) $transaction->amount;
if ((int) $transaction->type === TransactionType::GROUP_PAYMENT) $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);
@@ -42,9 +42,4 @@ final class TransactionType {
];
public const STORAGE_INVOICE = 16;
public const CIEF_COINS_DEBIT = 17;
public const CIEF_COINS_CREDIT = 18;
}
+36 -36
View File
@@ -28,50 +28,50 @@ class Kernel extends ConsoleKernel
protected function schedule(Schedule $schedule)
{
$schedule->command('command:curlVTCommand')
->cron('0 8 * * *')
->withoutOverlapping()
->appendOutputTo (storage_path().'/logs/curlvt.log');
$schedule->command('command:curlYdOrderListCommand')
->cron('0 9-18/3 * * *')
->withoutOverlapping()
->appendOutputTo (storage_path().'/logs/curlyd.log');
$schedule->command('fix-packinglist')
->cron('30 9-18/3 * * *')
->withoutOverlapping()
->appendOutputTo (storage_path().'/logs/fix_packinglist.log');
// $schedule->command('command:curlVTCommand')
// ->cron('0 8 * * *')
// ->withoutOverlapping()
// ->appendOutputTo (storage_path().'/logs/curlvt.log');
// $schedule->command('command:curlYdOrderListCommand')
// ->cron('0 9 * * *')
// ->cron('0 9-18/3 * * *')
// ->withoutOverlapping()
// ->appendOutputTo (storage_path().'/logs/departure_email.log');
// ->appendOutputTo (storage_path().'/logs/curlyd.log');
$schedule->command('fix-duplicate-container-reference')
->cron('0 1 * * *')
->withoutOverlapping()
->appendOutputTo (storage_path().'/logs/fix_duplicate_container_reference.log');
// $schedule->command('fix-packinglist')
// ->cron('30 9-18/3 * * *')
// ->withoutOverlapping()
// ->appendOutputTo (storage_path().'/logs/fix_packinglist.log');
$schedule->command('invoice:generate')
->hourly()
->withoutOverlapping()
->appendOutputTo (storage_path().'/logs/auto_generate_invoice.log');
// // $schedule->command('command:curlYdOrderListCommand')
// // ->cron('0 9 * * *')
// // ->withoutOverlapping()
// // ->appendOutputTo (storage_path().'/logs/departure_email.log');
$schedule->command('billplz-failed-callback:fix')
->hourly()
->withoutOverlapping()
->appendOutputTo (storage_path().'/logs/fix_failed_callback_from_billplz.log');
// $schedule->command('fix-duplicate-container-reference')
// ->cron('0 1 * * *')
// ->withoutOverlapping()
// ->appendOutputTo (storage_path().'/logs/fix_duplicate_container_reference.log');
$schedule->command('check-storage-invoices-group-transactions')
->dailyAt('0:01')
->withoutOverlapping()
->appendOutputTo(storage_path().'/logs/check_storage_invoices.log');
// $schedule->command('invoice:generate')
// ->hourly()
// ->withoutOverlapping()
// ->appendOutputTo (storage_path().'/logs/auto_generate_invoice.log');
$schedule->command('permitsReminder:send')
->dailyAt('09:30')
->withoutOverlapping()
->appendOutputTo(storage_path().'/logs/permits-reminder-send.log');
// $schedule->command('billplz-failed-callback:fix')
// ->hourly()
// ->withoutOverlapping()
// ->appendOutputTo (storage_path().'/logs/fix_failed_callback_from_billplz.log');
// $schedule->command('check-storage-invoices-group-transactions')
// ->dailyAt('0:01')
// ->withoutOverlapping()
// ->appendOutputTo(storage_path().'/logs/check_storage_invoices.log');
// $schedule->command('permitsReminder:send')
// ->dailyAt('09:30')
// ->withoutOverlapping()
// ->appendOutputTo(storage_path().'/logs/permits-reminder-send.log');
}
/**
@@ -3,7 +3,7 @@
<div class="col">
<loading-component style="height: 300px; top: 0;" key="1" color="success" v-show="isLoading" ></loading-component>
<!-- <div class="row parentContainer" v-if="item.status === 2"> -->
<div class="row parentContainer" v-if="!isLoading && wallet.cashWallet">
<div class="row parentContainer" v-if="!isLoading">
<div class="col">
<div class="row" v-if="!reload && section !== 'customerPaidInvoiceComponent'">
<div class="col">
@@ -11,7 +11,7 @@
<div class="row align-items-end">
<div class="col-auto">
<div class="text-primary-lighter fs-10 text-uppercase">Wallet Balance</div>
<h5 class="text-white no-margin bold">MYR {{ wallet.cashWallet ? (Math.round((wallet.cashWallet.amount + Number.EPSILON) * 100) / 100).toFixed(2) : '0.00'}}</h5>
<h5 class="text-white no-margin bold">MYR {{ wallet ? (Math.round((wallet.amount + Number.EPSILON) * 100) / 100).toFixed(2) : '0.00'}}</h5>
</div>
</div>
<div class="row m-t-10 d-flex align-items-center">
@@ -19,9 +19,9 @@
<div class="btn btn-xs p-l-15 p-r-20 b-rad-none font-heading btn-rounded bg-white" @click="reload = true"><i class="fa fa-plus fs-8 m-r-5"></i> Reload</div>
</div>
<div class="col-auto p-l-0" v-else="$store.getters.isSuperAdmin"></div>
<div class="col-auto p-l-0" v-if="!mini && wallet.cashWallet && section!=='CompanyWalletTransactionSection'">
<!-- <a class="text-white fs-10" :href="route('wallet.details', wallet.cashWallet.company_module_marking)" target="_blank">Transaction History<i class="fa fa-angle-right p-l-5"></i></a> -->
<a class="text-white fs-10" :href="route('wallet.details', wallet.cashWallet.company_module_marking)">Transaction History<i class="fa fa-angle-right p-l-5"></i></a>
<div class="col-auto p-l-0" v-if="!mini && wallet && section!=='CompanyWalletTransactionSection'">
<!-- <a class="text-white fs-10" :href="route('wallet.details', wallet.company_module_marking)" target="_blank">Transaction History<i class="fa fa-angle-right p-l-5"></i></a> -->
<a class="text-white fs-10" :href="route('wallet.details', wallet.company_module_marking)">Transaction History<i class="fa fa-angle-right p-l-5"></i></a>
</div>
</div>
</div>
@@ -34,25 +34,7 @@
<label class="fs-10 text-white m-b-0 text-uppercase cursor" @click="reload = false"><i class="fa fa-angle-left p-r-15"></i>Top Up Wallet</label>
</div>
</div>
<wallet-top-up-form-component :company_module_id="company_module_id" :amount="(!wallet.cashWallet ? amount : (Math.round((((amount - wallet.cashWallet.amount) < '0.00' ? '0.00' : (amount - wallet.cashWallet.amount)) + Number.EPSILON) * 100) / 100).toFixed(2))" :creditable="creditable"></wallet-top-up-form-component>
</div>
</div>
</div>
</div>
<br>
<div class="row parentContainer" v-if="!isLoading && wallet.coinWallet">
<div class="col">
<div class="row" v-if="!reload && section !== 'customerPaidInvoiceComponent'">
<div class="col">
<div style="background-color:#1fa67a !important" :class="[{'padding-25': !mini}, {'padding-15': mini}]">
<div class="row align-items-end">
<div class="col-auto">
<div class="text-primary-lighter fs-10 text-uppercase">Coins Balance</div>
<h5 class="text-white no-margin bold"><i class="fa fa-creative-commons m-r-5"></i> {{ wallet.coinWallet ? wallet.coinWallet.amount : '0.00'}}</h5>
</div>
</div>
</div>
<wallet-top-up-form-component :company_module_id="company_module_id" :amount="(!wallet ? amount : (Math.round((((amount - wallet.amount) < '0.00' ? '0.00' : (amount - wallet.amount)) + Number.EPSILON) * 100) / 100).toFixed(2))" :creditable="creditable"></wallet-top-up-form-component>
</div>
</div>
</div>
@@ -117,18 +99,12 @@
methods: {
fetchCompany(){
this.isLoading = true;
var filters = {'owner_id': this.company_module_id};
this.submit(route('api.wallet.list') + '?filters=' + JSON.stringify(filters), 'get', this.section, false, false);
// this.submit(route('api.wallet.company_module.show', this.company_module_id), 'get', this.section, false, false);
this.submit(route('api.wallet.company_module.show', this.company_module_id), 'get', this.section, false, false);
},
successHandler(response){
this.$store.dispatch('completeList', {'name': this.section, 'data': []});
this.isLoading = false;
this.wallet = response.payload.data.reduce((acc, item) => {
if (item.currency_id === 1) acc.cashWallet = item;
else if (item.currency_id === 3) acc.coinWallet = item;
return acc;
}, {});
this.wallet = response.payload.data;
},
errorHandler(error){
this.isLoading = false;