-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/inikoo/aiku into main
- Loading branch information
Showing
9 changed files
with
335 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
155 changes: 155 additions & 0 deletions
155
app/Actions/Fulfilment/PalletReturnItem/UI/IndexPalletStoredItemsInReturn.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
<?php | ||
|
||
/* | ||
* Author: Raul Perusquia <raul@inikoo.com> | ||
* Created: Wed, 19 Feb 2025 17:18:03 Central Indonesia Time, Sanur, Bali, Indonesia | ||
* Copyright (c) 2025, Raul A Perusquia Flores | ||
*/ | ||
|
||
namespace App\Actions\Fulfilment\PalletReturnItem\UI; | ||
|
||
use App\Actions\OrgAction; | ||
use App\Actions\Traits\Authorisations\WithFulfilmentAuthorisation; | ||
use App\Enums\Fulfilment\PalletReturn\PalletReturnStateEnum; | ||
use App\Http\Resources\Fulfilment\PalletStoredItemsInPalletReturnResource; | ||
use App\Models\Fulfilment\Fulfilment; | ||
use App\Models\Fulfilment\FulfilmentCustomer; | ||
use App\Models\Fulfilment\PalletReturn; | ||
use App\Models\Fulfilment\PalletReturnItem; | ||
use Closure; | ||
use Illuminate\Contracts\Pagination\LengthAwarePaginator; | ||
use App\InertiaTable\InertiaTable; | ||
use App\Models\Inventory\Warehouse; | ||
use App\Models\SysAdmin\Organisation; | ||
use Lorisleiva\Actions\ActionRequest; | ||
use Spatie\QueryBuilder\AllowedFilter; | ||
use App\Services\QueryBuilder; | ||
use Illuminate\Http\Resources\Json\AnonymousResourceCollection; | ||
|
||
class IndexPalletStoredItemsInReturn extends OrgAction | ||
{ | ||
use WithFulfilmentAuthorisation; | ||
private Fulfilment|Warehouse $parent; | ||
|
||
public function handle(PalletReturn $palletReturn, $prefix = null): LengthAwarePaginator | ||
{ | ||
$globalSearch = AllowedFilter::callback('global', function ($query, $value) { | ||
$query->where(function ($query) use ($value) { | ||
$query->whereAnyWordStartWith('stored_items.reference', $value); | ||
}); | ||
}); | ||
|
||
if ($prefix) { | ||
InertiaTable::updateQueryBuilderParameters($prefix); | ||
} | ||
|
||
$queryBuilder = QueryBuilder::for(PalletReturnItem::class) | ||
->leftJoin('pallet_stored_items', function ($join) { | ||
$join->on('pallet_return_items.pallet_stored_item_id', '=', 'pallet_stored_items.id'); | ||
}) | ||
->leftJoin('pallets', function ($join) { | ||
$join->on('pallets.id', '=', 'pallet_return_items.pallet_id'); | ||
}) | ||
->leftJoin('locations', function ($join) { | ||
$join->on('locations.id', '=', 'pallet_return_items.picking_location_id'); | ||
}) | ||
->leftJoin('stored_items', function ($join) { | ||
$join->on('stored_items.id', '=', 'pallet_return_items.stored_item_id'); | ||
}) | ||
->where('pallet_return_items.pallet_return_id', $palletReturn->id); | ||
|
||
|
||
$queryBuilder | ||
->defaultSort('pallet_return_items.quantity_ordered') | ||
->select( | ||
[ | ||
'pallet_return_items.id as id', | ||
'pallet_return_items.quantity_ordered', | ||
'pallet_return_items.quantity_dispatched', | ||
'pallet_return_items.quantity_fail', | ||
'pallet_return_items.quantity_cancelled', | ||
'pallet_return_items.state', | ||
|
||
'locations.code as location_code', | ||
'locations.id as location_id', | ||
'locations.slug as location_slug', | ||
|
||
'stored_items.reference as stored_items_reference', | ||
'stored_items.id as stored_items_id', | ||
'stored_items.slug as stored_items_slug', | ||
'stored_items.name as stored_items_name', | ||
|
||
|
||
'pallets.reference as pallets_reference', | ||
'pallets.customer_reference as pallets_customer_reference', | ||
'pallets.id as pallets_id', | ||
'pallets.slug as pallets_slug', | ||
|
||
] | ||
); | ||
|
||
return $queryBuilder->allowedSorts(['pallet_return_items.quantity_ordered']) | ||
->allowedFilters([$globalSearch]) | ||
->withPaginator($prefix, tableName: request()->route()->getName()) | ||
->withQueryString(); | ||
} | ||
|
||
public function tableStructure(PalletReturn $palletReturn, $request, $prefix = null, $modelOperations = []): Closure | ||
{ | ||
return function (InertiaTable $table) use ($prefix, $modelOperations, $request, $palletReturn) { | ||
if ($prefix) { | ||
$table | ||
->name($prefix) | ||
->pageName($prefix.'Page'); | ||
} | ||
|
||
$emptyStateData = [ | ||
|
||
]; | ||
|
||
|
||
if ($palletReturn instanceof Fulfilment) { | ||
$emptyStateData['description'] = __("There is no stored items this fulfilment shop"); | ||
} | ||
if ($palletReturn instanceof FulfilmentCustomer) { | ||
$emptyStateData['description'] = __("This customer don't have any pallets"); | ||
} | ||
|
||
$table->withGlobalSearch(); | ||
|
||
|
||
$table->withEmptyState($emptyStateData) | ||
->withModelOperations($modelOperations); | ||
|
||
|
||
$table->column(key: 'state', label: ['fal', 'fa-yin-yang'], type: 'icon'); | ||
|
||
$table->column(key: 'reference', label: __('reference'), canBeHidden: false, sortable: true, searchable: true); | ||
$table->column(key: 'total_quantity', label: __('Current stock'), canBeHidden: false, sortable: true, searchable: true); | ||
$table->column(key: 'pallet_stored_items', label: __('Pallets [location]'), canBeHidden: false, sortable: true, searchable: true); | ||
|
||
$table->column(key: 'total_quantity_ordered', label: __('requested quantity'), canBeHidden: false, sortable: true, searchable: true); | ||
if ($palletReturn->state === PalletReturnStateEnum::PICKING) { | ||
$table->column(key: 'actions', label: __('action'), canBeHidden: false, sortable: true, searchable: true); | ||
} | ||
|
||
|
||
$table->defaultSort('pallet_return_items.quantity_ordered'); | ||
}; | ||
} | ||
|
||
|
||
public function asController(Organisation $organisation, Warehouse $warehouse, PalletReturn $palletReturn, ActionRequest $request): LengthAwarePaginator | ||
{ | ||
$this->parent = $warehouse; | ||
$this->initialisationFromWarehouse($warehouse, $request); | ||
|
||
return $this->handle($palletReturn); | ||
} | ||
|
||
public function jsonResponse(LengthAwarePaginator $storedItems): AnonymousResourceCollection | ||
{ | ||
return PalletStoredItemsInPalletReturnResource::collection($storedItems); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
app/Http/Resources/Fulfilment/PalletStoredItemsInPalletReturnResource.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
/* | ||
* Author: Raul Perusquia <raul@inikoo.com> | ||
* Created: Wed, 19 Feb 2025 17:18:03 Central Indonesia Time, Sanur, Bali, Indonesia | ||
* Copyright (c) 2025, Raul A Perusquia Flores | ||
*/ | ||
|
||
namespace App\Http\Resources\Fulfilment; | ||
|
||
use Illuminate\Http\Resources\Json\JsonResource; | ||
|
||
/** | ||
* @property mixed $id | ||
* *@property mixed $quantity_ordered | ||
* @property mixed $quantity_dispatched | ||
* @property mixed $quantity_fail | ||
* @property mixed $quantity_cancelled | ||
* @property mixed $state | ||
* @property mixed $location_code | ||
* @property mixed $location_id | ||
* @property mixed $location_slug | ||
* @property mixed $stored_items_reference | ||
* @property mixed $stored_items_id | ||
* @property mixed $stored_items_slug | ||
* @property mixed $stored_items_name | ||
* @property mixed $pallets_reference | ||
* @property mixed $pallets_customer_reference | ||
* @property mixed $pallets_id | ||
* @property mixed $pallets_slug | ||
*/ | ||
class PalletStoredItemsInPalletReturnResource extends JsonResource | ||
{ | ||
public function toArray($request): array | ||
{ | ||
return [ | ||
'id' => $this->id, | ||
'quantity_ordered' => $this->quantity_ordered, | ||
'quantity_dispatched' => $this->quantity_dispatched, | ||
'quantity_fail' => $this->quantity_fail, | ||
'quantity_cancelled' => $this->quantity_cancelled, | ||
|
||
|
||
'state' => $this->state, | ||
'state_icon' => $this->state->stateIcon()[$this->state->value], | ||
'location_code' => $this->location_code, | ||
'location_id' => $this->location_id, | ||
'location_slug' => $this->location_slug, | ||
|
||
|
||
'stored_items_reference' => $this->stored_items_reference, | ||
'stored_items_id' => $this->stored_items_id, | ||
'stored_items_slug' => $this->stored_items_slug, | ||
'stored_items_name' => $this->stored_items_name, | ||
|
||
'pallets_reference' => $this->pallets_reference, | ||
'pallets_customer_reference' => $this->pallets_customer_reference, | ||
'pallets_id' => $this->pallets_id, | ||
'pallets_slug' => $this->pallets_slug, | ||
|
||
|
||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.