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
itzArtha committed Feb 13, 2025
2 parents 8bcc324 + 3e11383 commit bcf1296
Show file tree
Hide file tree
Showing 28 changed files with 681 additions and 96 deletions.
7 changes: 5 additions & 2 deletions app/Actions/Fulfilment/Pallet/BookInPallet.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use App\Enums\Fulfilment\Pallet\PalletStateEnum;
use App\Http\Resources\Fulfilment\PalletResource;
use App\Models\Fulfilment\Pallet;
use App\Models\Inventory\Location;
use Illuminate\Validation\Rule;
use Lorisleiva\Actions\ActionRequest;

Expand Down Expand Up @@ -73,11 +74,13 @@ public function asController(Pallet $pallet, ActionRequest $request): Pallet
return $this->handle($pallet, $this->validatedData);
}

public function fromApi(Pallet $pallet, ActionRequest $request): Pallet
public function usingLocationSlug(Pallet $pallet, Location $location,ActionRequest $request): Pallet
{
$this->initialisationFromWarehouse($pallet->warehouse, $request);

return $this->handle($pallet, $this->validatedData);
return $this->handle($pallet, [
'location_id' => $location->id
]);
}

public function action(Pallet $pallet, array $modelData): Pallet
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

/*
* Author: Raul Perusquia <[email protected]>
* Created: Thu, 11 Jul 2024 13:54:36 Malaysia Time, Kuala Lumpur, Malaysia
* Copyright (c) 2024, Raul A Perusquia Flores
*/

namespace App\Actions\Fulfilment\PalletDelivery\Json;

use App\Actions\OrgAction;
use App\Http\Resources\Fulfilment\PalletDeliveryStatusResource;
use App\Models\Fulfilment\PalletDelivery;
use Lorisleiva\Actions\ActionRequest;

class ShowPalletDeliveryStatus extends OrgAction
{
public function handle(PalletDelivery $palletDelivery): PalletDelivery
{
return $palletDelivery;
}

public function authorize(ActionRequest $request): bool
{
return $request->user()->authTo("fulfilment-shop.{$this->fulfilment->id}.view");
}

public function asController(PalletDelivery $palletDelivery, ActionRequest $request): PalletDelivery
{
$this->initialisationFromFulfilment($palletDelivery->fulfilment, $request);

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



public function jsonResponse(PalletDelivery $palletDelivery): PalletDeliveryStatusResource
{
return PalletDeliveryStatusResource::make($palletDelivery);
}
}
128 changes: 124 additions & 4 deletions app/Actions/Fulfilment/PalletDelivery/UI/ShowPalletDelivery.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use App\Actions\OrgAction;
use App\Actions\Traits\Authorisations\HasFulfilmentAssetsAuthorisation;
use App\Enums\Fulfilment\Pallet\PalletStateEnum;
use App\Enums\Fulfilment\Pallet\PalletTypeEnum;
use App\Enums\Fulfilment\PalletDelivery\PalletDeliveryStateEnum;
use App\Enums\UI\Fulfilment\PalletDeliveryTabsEnum;
use App\Http\Resources\Fulfilment\FulfilmentCustomerResource;
Expand Down Expand Up @@ -92,14 +93,13 @@ public function inFulfilmentCustomer(

public function htmlResponse(PalletDelivery $palletDelivery, ActionRequest $request): Response
{
// dd($palletDelivery->fulfilmentCustomer->slug);
$subNavigation = [];
if ($this->parent instanceof FulfilmentCustomer) {
$subNavigation = $this->getFulfilmentCustomerSubNavigation($this->parent, $request);
}

$palletStateReceivedCount = $palletDelivery->pallets()->where('state', PalletStateEnum::BOOKING_IN)->count();
$palletNotInRentalCount = $palletDelivery->pallets()->whereNull('rental_id')->count();
$numberPalletsStateBookingIn = $palletDelivery->pallets()->where('state', PalletStateEnum::BOOKING_IN)->count();
$numberPalletsRentalNotSet = $palletDelivery->pallets()->whereNull('rental_id')->count();

$numberPallets = $palletDelivery->fulfilmentCustomer->pallets()->count();
$numberStoredPallets = $palletDelivery->pallets()->where('state', PalletDeliveryStateEnum::BOOKED_IN->value)->count();
Expand Down Expand Up @@ -442,7 +442,7 @@ public function htmlResponse(PalletDelivery $palletDelivery, ActionRequest $requ
]
]
],
($palletStateReceivedCount == 0 and $palletNotInRentalCount == 0) ? [
($numberPalletsStateBookingIn == 0 and $numberPalletsRentalNotSet == 0) ? [
'type' => 'button',
'style' => 'primary',
'icon' => 'fal fa-check',
Expand Down Expand Up @@ -913,6 +913,126 @@ public function htmlResponse(PalletDelivery $palletDelivery, ActionRequest $requ
]
],

'upload_pallet' => [
'title' => [
'label' => __('Upload pallet'),
'information' => __('The list of column file: customer_reference, notes')
],
'progressDescription' => __('Adding Pallet Deliveries'),
'preview_template' => [
'header' =>['type', 'reference', 'name', 'quantity'],
'rows' =>[
[
'type' => PalletTypeEnum::PALLET,
'reference' => '#P12345',
'name' => 'Pallet 1',
'quantity' => 10
],
[
'type' => PalletTypeEnum::BOX,
'reference' => '#P12346',
'name' => 'Pallet 2',
'quantity' => 20
],
[
'type' => PalletTypeEnum::OVERSIZE,
'reference' => '#P12347',
'name' => 'Pallet 3',
'quantity' => 30
]
]
],
'upload_spreadsheet' => [
'event' => 'action-progress',
'channel' => 'grp.personal.'.$this->organisation->id,
'required_fields' => ['customer_reference', 'notes', 'stored_items', 'type'],
'template' => [
'label' => 'Download template (.xlsx)',
],
'route' => [
'upload' => [
'name' => 'grp.models.pallet-delivery.pallet.upload',
'parameters' => [
'palletDelivery' => $palletDelivery->id
]
],
'history' => [
'name' => 'grp.json.pallet_delivery.recent_uploads',
'parameters' => [
'palletDelivery' => $palletDelivery->id
]
],
'download' => [
'name' => 'grp.org.fulfilments.show.crm.customers.show.pallet_deliveries.pallets.uploads.templates',
'parameters' => [
'organisation' => $palletDelivery->organisation->slug,
'fulfilment' => $palletDelivery->fulfilment->slug,
'fulfilmentCustomer' => $palletDelivery->fulfilmentCustomer->slug,
'palletDelivery' => $palletDelivery->slug
]
],
],
]
],
'upload_stored_item' => [
'title' => [
'label' => __('Upload Customer\'s SKU'),
'information' => __('The list of column file: customer_reference, notes, stored_items')
],
'progressDescription' => __('Adding stored item'),
'preview_template' => [
'header' =>['reference', 'name', 'quantity'],
'rows' =>[
[
'reference' => '#C123',
'name' => 'SKU 1',
'quantity' => 10
],
[
'reference' => '#C124',
'name' => 'SKU 2',
'quantity' => 20
],
[
'reference' => '#C125',
'name' => 'SKU 3',
'quantity' => 30
]
]
],
'upload_spreadsheet' => [
'event' => 'action-progress',
'channel' => 'grp.personal.'.$this->organisation->id,
'required_fields' => ['customer_reference', 'notes', 'stored_items', 'type'],
'template' => [
'label' => 'Download template (.xlsx)',
],
'route' => [
'upload' => [
'name' => 'grp.models.pallet-delivery.pallet.upload',
'parameters' => [
'palletDelivery' => $palletDelivery->id
]
],
'history' => [
'name' => 'grp.json.pallet_delivery.recent_uploads',
'parameters' => [
'palletDelivery' => $palletDelivery->id
]
],
'download' => [
'name' => 'grp.org.fulfilments.show.crm.customers.show.pallet_deliveries.pallets.uploads.templates',
'parameters' => [
'organisation' => $palletDelivery->organisation->slug,
'fulfilment' => $palletDelivery->fulfilment->slug,
'fulfilmentCustomer' => $palletDelivery->fulfilmentCustomer->slug,
'palletDelivery' => $palletDelivery->slug
]
],
],
]
],

PalletDeliveryTabsEnum::PALLETS->value => $this->tab == PalletDeliveryTabsEnum::PALLETS->value ?
fn () => PalletsResource::collection(IndexPalletsInDelivery::run($palletDelivery, PalletDeliveryTabsEnum::PALLETS->value))
: Inertia::lazy(fn () => PalletsResource::collection(IndexPalletsInDelivery::run($palletDelivery, PalletDeliveryTabsEnum::PALLETS->value))),
Expand Down
4 changes: 2 additions & 2 deletions app/Actions/Fulfilment/PalletReturn/UI/ShowPalletReturn.php
Original file line number Diff line number Diff line change
Expand Up @@ -707,9 +707,9 @@ public function htmlResponse(PalletReturn $palletReturn, ActionRequest $request)
}


public function jsonResponse(PalletReturn $palletReturn): PalletReturnsResource
public function jsonResponse(PalletReturn $palletReturn): PalletReturnResource
{
return new PalletReturnsResource($palletReturn);
return new PalletReturnResource($palletReturn);
}

public function getBreadcrumbs(string $routeName, array $routeParameters, $suffix = ''): array
Expand Down
5 changes: 0 additions & 5 deletions app/Actions/Inventory/Location/UI/IndexLocations.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ class IndexLocations extends OrgAction
public function authorize(ActionRequest $request): bool
{

if ($this->maya) {
return true; //Idk the auth for this
}


if ($this->parent instanceof Group) {
return $request->user()->authTo("group-overview");
} elseif ($this->parent instanceof Organisation) {
Expand Down
20 changes: 8 additions & 12 deletions app/Actions/Inventory/Location/UI/ShowLocation.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,8 @@ public function handle(Location $location): Location

public function authorize(ActionRequest $request): bool
{
if ($this->maya) {
return true; //IDK for the auth, might come back here later
}

$this->canEdit = $request->user()->authTo("locations.{$this->warehouse->id}.edit");

return $request->user()->authTo("locations.{$this->warehouse->id}.view");
}

Expand Down Expand Up @@ -76,14 +72,14 @@ public function inWarehouse(Organisation $organisation, Warehouse $warehouse, Lo
return $this->handle($location);
}

public function maya(Organisation $organisation, Location $location, ActionRequest $request): Location
{
$this->maya = true;
$this->parent = $organisation;
$this->initialisation($this->parent, $request)->withTab(LocationTabsEnum::values());
return $this->handle($location);
}

// public function maya(Organisation $organisation, Location $location, ActionRequest $request): Location
// {
// $this->maya = true;
// $this->parent = $organisation;
// $this->initialisation($this->parent, $request)->withTab(LocationTabsEnum::values());
// return $this->handle($location);
// }
//



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ public function authorize(ActionRequest $request): bool
return false;
}

public function asController(PalletReturn $palletReturn, ActionRequest $request): PalletReturn
public function asController(PalletReturn $palletReturn, ActionRequest $request): void
{
$this->parent = $palletReturn;
$this->initialisation($request);

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

public function action(PalletReturn $palletReturn, array $modelData): PalletReturn
Expand Down
45 changes: 45 additions & 0 deletions app/Actions/Retina/Fulfilment/UI/ShowRetinaStorageDashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,49 @@ public function htmlResponse(FulfilmentCustomer $fulfilmentCustomer): Response
];
}

$routeActions = [
[
'type' => 'button',
'style' => 'create',
'label' => __('New Delivery'),
'fullLoading' => true,
'route' => [
'method' => 'post',
'name' => 'retina.models.pallet-delivery.store',
'parameters' => []
]
],
];

if (!app()->environment('production')) {
$routeActions[] = [
$fulfilmentCustomer->number_pallets_status_storing ? [
'type' => 'button',
'style' => 'create',
'tooltip' => $fulfilmentCustomer->number_pallets_with_stored_items_state_storing ? __('Create new return (whole pallet)') : __('Create new return'),
'label' => $fulfilmentCustomer->number_pallets_with_stored_items_state_storing ? __('Return (whole pallet)') : __('Return'),
'route' => [
'method' => 'post',
'name' => 'retina.models.pallet-return.store',
'parameters' => []
]
] : false,
$this->customer->fulfilmentCustomer->number_pallets_with_stored_items_state_storing ? [
'type' => 'button',
'style' => 'create',
'tooltip' => __('Create new return (Selected SKUs)'),
'label' => __('Return (Selected SKUs)'),
'route' => [
'method' => 'post',
'name' => 'retina.models.pallet-return-stored-items.store',
'parameters' => []
]
] : false,
];
}



return Inertia::render('Storage/RetinaStorageDashboard', [
'title' => __('Storage Dashboard'),
'breadcrumbs' => $this->getBreadcrumbs(),
Expand All @@ -59,6 +102,8 @@ public function htmlResponse(FulfilmentCustomer $fulfilmentCustomer): Response

],

'route_action' => $routeActions,

'currency' => CurrencyResource::make($fulfilmentCustomer->fulfilment->shop->currency),
'storageData' => $this->getDashboardData($fulfilmentCustomer),
'rental_agreement' => RetinaRentalAgreementResource::make($fulfilmentCustomer->rentalAgreement),
Expand Down
6 changes: 3 additions & 3 deletions app/Actions/Retina/Pricing/UI/IndexRetinaGoods.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected function getElementGroups(Fulfilment $parent): array
),

'engine' => function ($query, $elements) {
$query->whereIn('state', $elements);
$query->whereIn('products.state', $elements);
}

],
Expand Down Expand Up @@ -102,7 +102,7 @@ public function asController(ActionRequest $request): LengthAwarePaginator
{
$this->initialisation($request);

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


Expand Down Expand Up @@ -176,7 +176,7 @@ public function tableStructure(
->column(key: 'code', label: __('code'), canBeHidden: false, sortable: true, searchable: true)
->column(key: 'name', label: __('name'), canBeHidden: false, sortable: true, searchable: true)
->column(key: 'price', label: __('price'), canBeHidden: false, sortable: true, searchable: true, className: 'text-right font-mono', align: 'right')
->defaultSort('code');
->defaultSort('code');
};
}

Expand Down
Loading

0 comments on commit bcf1296

Please sign in to comment.