Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/inikoo/aiku into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Ganes556 committed Feb 20, 2025
2 parents 51f4e53 + aea9225 commit e40c269
Show file tree
Hide file tree
Showing 9 changed files with 335 additions and 49 deletions.
2 changes: 1 addition & 1 deletion app/Actions/Fulfilment/Pallet/StorePallet.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function rules(): array
'sometimes',
Rule::enum(PalletTypeEnum::class)
],
'notes' => ['sometimes', 'nullable', 'string', 'max:1024'],
'notes' => ['sometimes', 'nullable', 'string', 'max:16384'],


'warehouse_id' => [
Expand Down
2 changes: 1 addition & 1 deletion app/Actions/Fulfilment/Pallet/UpdatePallet.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public function rules(): array

],
'location_id' => ['sometimes', 'nullable', Rule::exists('locations', 'id')],
'notes' => ['sometimes','nullable', 'string', 'max:1024'],
'notes' => ['sometimes','nullable', 'string', 'max:16384'],
'received_at' => ['sometimes','nullable', 'date'],
'booked_in_at' => ['sometimes', 'nullable', 'date'],
'storing_at' => ['sometimes', 'nullable', 'date'],
Expand Down
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);
}

}
35 changes: 0 additions & 35 deletions app/Actions/Fulfilment/StoredItem/UI/IndexStoredItemsInReturn.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,17 @@
namespace App\Actions\Fulfilment\StoredItem\UI;

use App\Actions\OrgAction;
use App\Actions\Traits\Authorisations\WithFulfilmentAuthorisation;
use App\Enums\Fulfilment\PalletReturn\PalletReturnStateEnum;
use App\Http\Resources\Fulfilment\PalletReturnStoredItemsResource;
use App\Models\Fulfilment\Fulfilment;
use App\Models\Fulfilment\FulfilmentCustomer;
use App\Models\Fulfilment\PalletReturn;
use App\Models\Fulfilment\StoredItem;
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 IndexStoredItemsInReturn extends OrgAction
{
use WithFulfilmentAuthorisation;


private PalletReturn $palletReturn;

private bool $selectStoredPallets = false;


public function handle(PalletReturn $parent, $prefix = null): LengthAwarePaginator
{
$globalSearch = AllowedFilter::callback('global', function ($query, $value) {
Expand Down Expand Up @@ -117,12 +101,6 @@ public function tableStructure(PalletReturn $palletReturn, $request, $prefix = n
];


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();

Expand All @@ -142,23 +120,10 @@ public function tableStructure(PalletReturn $palletReturn, $request, $prefix = n
$table->column(key: 'actions', label: __('action'), canBeHidden: false, sortable: true, searchable: true);
}


$table->defaultSort('reference');
};
}



public function asController(Organisation $organisation, Warehouse $warehouse, PalletReturn $palletReturn, ActionRequest $request): LengthAwarePaginator
{
$this->initialisationFromWarehouse($warehouse, $request);

return $this->handle($palletReturn);
}

public function jsonResponse(LengthAwarePaginator $storedItems): AnonymousResourceCollection
{
return PalletReturnStoredItemsResource::collection($storedItems);
}

}
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,


];
}
}
7 changes: 3 additions & 4 deletions app/Imports/SupplyChain/SupplierProductImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use App\Models\Helpers\Upload;
use App\Models\SupplyChain\Supplier;
use Exception;
use Illuminate\Support\Arr;
use Maatwebsite\Excel\Concerns\SkipsOnFailure;
use Maatwebsite\Excel\Concerns\ToCollection;
use Maatwebsite\Excel\Concerns\WithEvents;
Expand Down Expand Up @@ -75,15 +74,15 @@ public function storeModel($row, $uploadRecord): void
protected function processExcelData($data)
{
$mappedRow = [];

foreach ($data as $row) {
foreach ($row as $key => $value) {
$mappedKey = str_replace([' ', ':', "'"], '_', strtolower($key));
$mappedRow[$mappedKey] = $value;
}
break;
break;
}

return $mappedRow;
}

Expand Down
Loading

0 comments on commit e40c269

Please sign in to comment.