From ac42d8359faf7b89e4cea0ac7af1abbef2b75a32 Mon Sep 17 00:00:00 2001 From: Raul Perusquia Date: Thu, 6 Feb 2025 16:32:05 +0800 Subject: [PATCH 1/2] improve RepairPalletDeliveriesAndReturns --- .../RepairPalletDeliveriesAndReturns.php | 43 +++++++++---------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/app/Actions/Maintenance/Fulfilment/RepairPalletDeliveriesAndReturns.php b/app/Actions/Maintenance/Fulfilment/RepairPalletDeliveriesAndReturns.php index e910fadf46..4af30b9579 100644 --- a/app/Actions/Maintenance/Fulfilment/RepairPalletDeliveriesAndReturns.php +++ b/app/Actions/Maintenance/Fulfilment/RepairPalletDeliveriesAndReturns.php @@ -42,13 +42,24 @@ public function handle(): void $this->fixPalletDeliveryRecurringBill(); $this->fixPalletDeliveryTransactionsRecurringBill(); + print "palletsStartDate\n"; $this->palletsStartDate(); + print "palletsEndDate\n"; $this->palletsEndDate(); + + + print "palletsValidateStartEndDate x\n"; $this->palletsValidateStartEndDate(); - $this->fixPalletReturnRecurringBill(); + print "fixPalletReturnTransactionsRecurringBill\n"; + $this->fixPalletReturnTransactionsRecurringBill(); + + print "fixNonRentalRecurringBillTransactions\n"; $this->fixNonRentalRecurringBillTransactions(); + + + print "last fix\n"; /** @var RecurringBill $recurringBill */ foreach (RecurringBill::where('status', RecurringBillStatusEnum::CURRENT)->get() as $recurringBill) { $transactions = $recurringBill->transactions()->get(); @@ -60,10 +71,11 @@ public function handle(): void CalculateRecurringBillTransactionCurrencyExchangeRates::run($transaction); } - CalculateRecurringBillTotals::make()->action($recurringBill); + CalculateRecurringBillTotals::dispatch($recurringBill); } } + public function palletsValidateStartEndDate(): void { /** @var RecurringBill $recurringBill */ @@ -160,19 +172,20 @@ public function palletsEndDate(): void print 'PED: '.$transaction->id.' add end day '.$pallet->dispatched_at->format('Y-m-d')."\n"; $transaction->update(['end_date' => $pallet->dispatched_at]); } else { - $currentEndDay = $transaction->end_date->startOfDay(); - $originalStartDate = $currentEndDay; + $currentEndDay = $transaction->end_date->startOfDay(); + $originalEndDate = $currentEndDay; if ($pallet->dispatched_at->startOfDay()->ne($currentEndDay)) { $currentEndDay = $pallet->dispatched_at->startOfDay(); } - if ($originalStartDate->ne($currentEndDay)) { - print 'PED: '.$transaction->id.' '.$originalStartDate->format('Y-m-d').' -> '.$currentEndDay->format('Y-m-d')."\n"; + if ($originalEndDate->ne($currentEndDay)) { + print 'PEDx: '.$transaction->id.' '.$originalEndDate->format('Y-m-d').' -> '.$currentEndDay->format('Y-m-d')."\n"; + $transaction->update(['end_date' => $pallet->dispatched_at]); } } } elseif ($transaction->end_date) { - print 'PED: '.$transaction->id.' remove end day '.$transaction->end_date->format('Y-m-d')."\n"; - $transaction->update(['end_date' => null]); + // print 'PED: '.$transaction->id.' remove end day '.$transaction->end_date->format('Y-m-d')."\n"; + $transaction->update(['end_date' => $recurringBill->end_date]); } } } @@ -271,20 +284,6 @@ public function fixPalletDeliveryRecurringBill(): void } } - public function fixPalletReturnRecurringBill(): void - { - $palletReturns = PalletReturn::whereNull('recurring_bill_id')->get(); - /** @var PalletReturn $palletReturn */ - foreach ($palletReturns as $palletReturn) { - if ($receivedDate = $palletReturn->dispatched_at and $palletReturn->fulfilmentCustomer->currentRecurringBill) { - $currentRecurringBill = $palletReturn->fulfilmentCustomer->currentRecurringBill; - if ($receivedDate->isAfter($currentRecurringBill->start_date)) { - print "Fix Pallet Return CRB: $palletReturn->id\n"; - $palletReturn->update(['recurring_bill_id' => $currentRecurringBill->id]); - } - } - } - } public function getCommandSignature(): string { From 0f5cebb9f32c8f7b454ac0267020936c2ba794d7 Mon Sep 17 00:00:00 2001 From: Ganes556 Date: Thu, 6 Feb 2025 16:44:42 +0800 Subject: [PATCH 2/2] sku customer add column in table --- app/Actions/Fulfilment/StoredItem/UI/IndexStoredItems.php | 6 ++++-- app/Http/Resources/Fulfilment/StoredItemResource.php | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/Actions/Fulfilment/StoredItem/UI/IndexStoredItems.php b/app/Actions/Fulfilment/StoredItem/UI/IndexStoredItems.php index b46f514694..9b4b04ad5a 100644 --- a/app/Actions/Fulfilment/StoredItem/UI/IndexStoredItems.php +++ b/app/Actions/Fulfilment/StoredItem/UI/IndexStoredItems.php @@ -66,7 +66,7 @@ public function handle(Group|Organisation|FulfilmentCustomer|Fulfilment $parent, $query->where('stored_items.group_id', $parent->id); } }) - ->allowedSorts(['slug', 'state']) + ->allowedSorts(['slug', 'state', 'total_quantity', 'name']) ->allowedFilters([$globalSearch, 'slug', 'state']) ->withPaginator($prefix, tableName: request()->route()->getName()) ->withQueryString(); @@ -104,8 +104,10 @@ public function tableStructure($parent, ?array $modelOperations = null, $prefix ) ->column(key: 'state', label: '', canBeHidden: false, sortable: false, searchable: false, type: 'icon') ->column(key: 'reference', label: __('reference'), canBeHidden: false, sortable: true, searchable: true) + ->column(key: 'name', label: __('name'), canBeHidden: false, sortable: true) ->column(key: 'customer_name', label: __('Customer Name'), canBeHidden: false, sortable: true, searchable: true) - ->column(key: 'pallets', label: __("Pallets"), canBeHidden: false); + ->column(key: 'pallets', label: __("Pallets"), canBeHidden: false) + ->column(key: 'total_quantity', label: __("Quantity"), canBeHidden: false, sortable: true); if (class_basename($parent) == 'Group') { $table->column(key: 'organisation_name', label: __('Organisation'), canBeHidden: false, sortable: true, searchable: true); } diff --git a/app/Http/Resources/Fulfilment/StoredItemResource.php b/app/Http/Resources/Fulfilment/StoredItemResource.php index 86b406c561..44f8f84d60 100644 --- a/app/Http/Resources/Fulfilment/StoredItemResource.php +++ b/app/Http/Resources/Fulfilment/StoredItemResource.php @@ -44,6 +44,7 @@ public function toArray($request): array 'state_icon' => $storedItem->state->stateIcon()[$storedItem->state->value], 'quantity' => (int) $storedItem->pallets?->sum('pivot.quantity'), 'total_quantity' => $storedItem->pallets?->sum('pivot.quantity'), + 'name' => $storedItem->name, 'max_quantity' => $storedItem->pallets?->sum('pivot.quantity'), 'pallets' => $storedItem->pallets->map(fn (Pallet $pallet) => [