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
KirinZero0 committed Feb 12, 2025
2 parents ca07b6f + 47bf45b commit 431fe1c
Show file tree
Hide file tree
Showing 4 changed files with 174 additions and 171 deletions.
171 changes: 88 additions & 83 deletions app/Actions/Fulfilment/PalletDelivery/UI/ShowPalletDelivery.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,12 @@ public function htmlResponse(PalletDelivery $palletDelivery, ActionRequest $requ
'tooltip' => __('Upload pallets via spreadsheet'),
],
[
'type' => 'button',
'style' => 'secondary',
'icon' => ['far', 'fa-layer-plus'],
'label' => 'multiple',
'key' => 'multiple',
'route' => [
'type' => 'button',
'style' => 'secondary',
'icon' => ['far', 'fa-layer-plus'],
'label' => 'multiple',
'key' => 'multiple',
'route' => [
'name' => 'grp.models.pallet-delivery.multiple-pallets.store',
'parameters' => [
'palletDelivery' => $palletDelivery->id
Expand Down Expand Up @@ -335,10 +335,10 @@ public function htmlResponse(PalletDelivery $palletDelivery, ActionRequest $requ
'method' => 'get',
'name' => 'grp.org.fulfilments.show.crm.customers.show.pallet_deliveries.edit',
'parameters' => [
'organisation' => $palletDelivery->organisation->slug,
'fulfilment' => $palletDelivery->fulfilment->slug,
'organisation' => $palletDelivery->organisation->slug,
'fulfilment' => $palletDelivery->fulfilment->slug,
'fulfilmentCustomer' => $palletDelivery->fulfilmentCustomer->slug,
'palletDelivery' => $palletDelivery->slug
'palletDelivery' => $palletDelivery->slug
]
]
],
Expand Down Expand Up @@ -503,20 +503,23 @@ public function htmlResponse(PalletDelivery $palletDelivery, ActionRequest $requ
])) {
$actions = array_merge($actions, [$pdfButton]);
} else {
$actions = array_merge([[
'type' => 'button',
'style' => 'delete',
'tooltip' => __('delete'),
'label' => __('delete'),
'key' => 'delete_delivery',
'route' => [
'method' => 'patch',
'name' => 'grp.models.pallet-delivery.delete',
'parameters' => [
'palletDelivery' => $palletDelivery->id
$actions = array_merge([
[
'type' => 'button',
'style' => 'delete',
'tooltip' => __('delete'),
'label' => __('delete'),
'key' => 'delete_delivery',
'ask_why' => true,
'route' => [
'method' => 'patch',
'name' => 'grp.models.pallet-delivery.delete',
'parameters' => [
'palletDelivery' => $palletDelivery->id
]
]
]
]], $actions);
], $actions);
}
}

Expand Down Expand Up @@ -559,25 +562,25 @@ public function htmlResponse(PalletDelivery $palletDelivery, ActionRequest $requ

$recurringBillData = null;
if ($palletDelivery->recurringBill) {
$recurringBill = $palletDelivery->recurringBill;
$recurringBill = $palletDelivery->recurringBill;
$recurringBillRoute = null;
if ($this->parent instanceof Fulfilment) {
$recurringBillRoute = [
'name' => 'grp.org.fulfilments.show.operations.recurring_bills.current.show',
'name' => 'grp.org.fulfilments.show.operations.recurring_bills.current.show',
'parameters' => [
'organisation' => $recurringBill->organisation->slug,
'fulfilment' => $this->parent->slug,
'organisation' => $recurringBill->organisation->slug,
'fulfilment' => $this->parent->slug,
'recurringBill' => $recurringBill->slug
]
];
} elseif ($this->parent instanceof FulfilmentCustomer) {
$recurringBillRoute = [
'name' => 'grp.org.fulfilments.show.crm.customers.show.recurring_bills.show',
'name' => 'grp.org.fulfilments.show.crm.customers.show.recurring_bills.show',
'parameters' => [
'organisation' => $recurringBill->organisation->slug,
'fulfilment' => $this->parent->fulfilment->slug,
'organisation' => $recurringBill->organisation->slug,
'fulfilment' => $this->parent->fulfilment->slug,
'fulfilmentCustomer' => $this->parent->slug,
'recurringBill' => $recurringBill->slug
'recurringBill' => $recurringBill->slug
]
];
}
Expand Down Expand Up @@ -605,26 +608,26 @@ public function htmlResponse(PalletDelivery $palletDelivery, ActionRequest $requ
],
'pageHead' => [
// 'container' => $container,
'title' => $palletDelivery->reference,
'icon' => [
'title' => $palletDelivery->reference,
'icon' => [
'icon' => ['fal', 'fa-truck-couch'],
'title' => $palletDelivery->reference
],
'subNavigation' => $subNavigation,
'model' => __('pallet delivery'),
'iconRight' => $palletDelivery->state->stateIcon()[$palletDelivery->state->value],
'edit' => $this->canEdit ? [
'model' => __('pallet delivery'),
'iconRight' => $palletDelivery->state->stateIcon()[$palletDelivery->state->value],
'edit' => $this->canEdit ? [
'route' => [
'name' => preg_replace('/show$/', 'edit', $request->route()->getName()),
'parameters' => array_values($request->route()->originalParameters())
]
] : false,
'actions' => $actions,
'actions' => $actions,
],

'can_edit_transactions' => true,

'interest' => [
'interest' => [
'pallets_storage' => $palletDelivery->fulfilmentCustomer->pallets_storage,
'items_storage' => $palletDelivery->fulfilmentCustomer->items_storage,
'dropshipping' => $palletDelivery->fulfilmentCustomer->dropshipping,
Expand Down Expand Up @@ -652,23 +655,23 @@ public function htmlResponse(PalletDelivery $palletDelivery, ActionRequest $requ
],

'upload_spreadsheet' => [
'event' => 'action-progress',
'channel' => 'grp.personal.' . $this->organisation->id,
'required_fields' => ['customer_reference', 'notes', 'stored_items', 'type'],
'template' => [
'event' => 'action-progress',
'channel' => 'grp.personal.'.$this->organisation->id,
'required_fields' => ['customer_reference', 'notes', 'stored_items', 'type'],
'template' => [
'label' => 'Download template (.xlsx)',
],
'route' => [
'upload' => [
'route' => [
'upload' => [
'name' => 'grp.models.pallet-delivery.pallet.upload',
'parameters' => [
'palletDelivery' => $palletDelivery->id
]
],
'history' => [
'history' => [
'name' => 'grp.json.pallet_delivery.recent_uploads',
'parameters' => [
'palletDelivery' => $palletDelivery->id
'palletDelivery' => $palletDelivery->id
]
],
'download' => [
Expand All @@ -685,18 +688,18 @@ public function htmlResponse(PalletDelivery $palletDelivery, ActionRequest $requ

'attachmentRoutes' => [
'attachRoute' => [
'name' => 'grp.models.pallet-delivery.attachment.attach',
'name' => 'grp.models.pallet-delivery.attachment.attach',
'parameters' => [
'palletDelivery' => $palletDelivery->id,
],
'method' => 'post'
'method' => 'post'
],
'detachRoute' => [
'name' => 'grp.models.pallet-delivery.attachment.detach',
'name' => 'grp.models.pallet-delivery.attachment.detach',
'parameters' => [
'palletDelivery' => $palletDelivery->id,
],
'method' => 'delete'
'method' => 'delete'
]
],

Expand Down Expand Up @@ -790,7 +793,7 @@ public function htmlResponse(PalletDelivery $palletDelivery, ActionRequest $requ
'data' => PalletDeliveryResource::make($palletDelivery),
'box_stats' => [
'fulfilment_customer' => FulfilmentCustomerResource::make($palletDelivery->fulfilmentCustomer)->getArray(),
'delivery_state' => PalletDeliveryStateEnum::stateIcon()[$palletDelivery->state->value],
'delivery_state' => PalletDeliveryStateEnum::stateIcon()[$palletDelivery->state->value],
'recurring_bill' => $recurringBillData,
'order_summary' => [
[
Expand All @@ -816,47 +819,49 @@ public function htmlResponse(PalletDelivery $palletDelivery, ActionRequest $requ

$showGrossAndDiscount ? [
[
'label' => __('Gross'),
'information' => '',
'price_total' => $palletDelivery->gross_amount
'label' => __('Gross'),
'information' => '',
'price_total' => $palletDelivery->gross_amount
],
[
'label' => __('Discounts'),
'information' => '',
'price_total' => $palletDelivery->discount_amount
'label' => __('Discounts'),
'information' => '',
'price_total' => $palletDelivery->discount_amount
],
] : [],
$showGrossAndDiscount ? [
$showGrossAndDiscount
? [
[
'label' => __('Net'),
'information' => '',
'price_total' => $palletDelivery->net_amount
'label' => __('Net'),
'information' => '',
'price_total' => $palletDelivery->net_amount
],
[
'label' => __('Tax').' '.$palletDelivery->taxCategory->rate * 100 . '%',
'information' => '',
'price_total' => $palletDelivery->tax_amount
'label' => __('Tax').' '.$palletDelivery->taxCategory->rate * 100 .'%',
'information' => '',
'price_total' => $palletDelivery->tax_amount
],
] : [
]
: [
[
'label' => __('Net'),
'information' => '',
'price_total' => $palletDelivery->net_amount
'label' => __('Net'),
'information' => '',
'price_total' => $palletDelivery->net_amount
],
[
'label' => __('Tax').' '.$palletDelivery->taxCategory->rate * 100 . '%',
'information' => '',
'price_total' => $palletDelivery->tax_amount
'label' => __('Tax').' '.$palletDelivery->taxCategory->rate * 100 .'%',
'information' => '',
'price_total' => $palletDelivery->tax_amount
],
],
[
[
'label' => __('Total'),
'price_total' => $palletDelivery->total_amount
'label' => __('Total'),
'price_total' => $palletDelivery->total_amount
],
],

'currency' => CurrencyResource::make($palletDelivery->currency),
'currency' => CurrencyResource::make($palletDelivery->currency),
// // 'number_pallets' => $palletDelivery->stats->number_pallets,
// // 'number_services' => $palletDelivery->stats->number_services,
// // 'number_physical_goods' => $palletDelivery->stats->number_physical_goods,
Expand Down Expand Up @@ -901,28 +906,28 @@ public function htmlResponse(PalletDelivery $palletDelivery, ActionRequest $requ
],
],

'option_attach_file' => [
'option_attach_file' => [
[
'name' => __('Other'),
'code' => 'Other'
'name' => __('Other'),
'code' => 'Other'
]
],

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))),
fn() => PalletsResource::collection(IndexPalletsInDelivery::run($palletDelivery, PalletDeliveryTabsEnum::PALLETS->value))
: Inertia::lazy(fn() => PalletsResource::collection(IndexPalletsInDelivery::run($palletDelivery, PalletDeliveryTabsEnum::PALLETS->value))),

PalletDeliveryTabsEnum::SERVICES->value => $this->tab == PalletDeliveryTabsEnum::SERVICES->value ?
fn () => FulfilmentTransactionsResource::collection(IndexServiceInPalletDelivery::run($palletDelivery, PalletDeliveryTabsEnum::SERVICES->value))
: Inertia::lazy(fn () => FulfilmentTransactionsResource::collection(IndexServiceInPalletDelivery::run($palletDelivery, PalletDeliveryTabsEnum::SERVICES->value))),
fn() => FulfilmentTransactionsResource::collection(IndexServiceInPalletDelivery::run($palletDelivery, PalletDeliveryTabsEnum::SERVICES->value))
: Inertia::lazy(fn() => FulfilmentTransactionsResource::collection(IndexServiceInPalletDelivery::run($palletDelivery, PalletDeliveryTabsEnum::SERVICES->value))),

PalletDeliveryTabsEnum::PHYSICAL_GOODS->value => $this->tab == PalletDeliveryTabsEnum::PHYSICAL_GOODS->value ?
fn () => FulfilmentTransactionsResource::collection(IndexPhysicalGoodInPalletDelivery::run($palletDelivery, PalletDeliveryTabsEnum::PHYSICAL_GOODS->value))
: Inertia::lazy(fn () => FulfilmentTransactionsResource::collection(IndexPhysicalGoodInPalletDelivery::run($palletDelivery, PalletDeliveryTabsEnum::PHYSICAL_GOODS->value))),
fn() => FulfilmentTransactionsResource::collection(IndexPhysicalGoodInPalletDelivery::run($palletDelivery, PalletDeliveryTabsEnum::PHYSICAL_GOODS->value))
: Inertia::lazy(fn() => FulfilmentTransactionsResource::collection(IndexPhysicalGoodInPalletDelivery::run($palletDelivery, PalletDeliveryTabsEnum::PHYSICAL_GOODS->value))),

PalletDeliveryTabsEnum::ATTACHMENTS->value => $this->tab == PalletDeliveryTabsEnum::ATTACHMENTS->value ?
fn () => AttachmentsResource::collection(IndexAttachments::run($palletDelivery, PalletDeliveryTabsEnum::ATTACHMENTS->value))
: Inertia::lazy(fn () => AttachmentsResource::collection(IndexAttachments::run($palletDelivery, PalletDeliveryTabsEnum::ATTACHMENTS->value))),
fn() => AttachmentsResource::collection(IndexAttachments::run($palletDelivery, PalletDeliveryTabsEnum::ATTACHMENTS->value))
: Inertia::lazy(fn() => AttachmentsResource::collection(IndexAttachments::run($palletDelivery, PalletDeliveryTabsEnum::ATTACHMENTS->value))),

]
)->table(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ public function htmlResponse(): Response
return Inertia::location(route('retina.fulfilment.storage.pallet_deliveries.index'));
}

public function rules()
public function rules(): array
{
return [
'delete_comment' => ['sometimes', 'required']
'delete_comment' => ['sometimes', 'nullable']
];
}

Expand All @@ -65,12 +65,4 @@ public function asController(Organisation $organisation, PalletDelivery $palletD
$this->handle($palletDelivery, $this->validatedData);
}

public function action(PalletDelivery $palletDelivery, $modelData): void
{
$this->action = true;
$this->fulfilmentCustomer = $palletDelivery->fulfilmentCustomer;
$this->initialisationFulfilmentActions($this->fulfilmentCustomer, $modelData);

$this->handle($palletDelivery, $this->validatedData);
}
}
Loading

0 comments on commit 431fe1c

Please sign in to comment.