diff --git a/app/Actions/Accounting/Invoice/UI/IndexInvoices.php b/app/Actions/Accounting/Invoice/UI/IndexInvoices.php index 682a2c0568..681139c80b 100644 --- a/app/Actions/Accounting/Invoice/UI/IndexInvoices.php +++ b/app/Actions/Accounting/Invoice/UI/IndexInvoices.php @@ -9,6 +9,8 @@ namespace App\Actions\Accounting\Invoice\UI; use App\Actions\Accounting\Invoice\WithInvoicesSubNavigation; +use App\Actions\Accounting\InvoiceCategory\UI\ShowInvoiceCategory; +use App\Actions\Accounting\InvoiceCategory\WithInvoiceCategorySubNavigation; use App\Actions\CRM\Customer\UI\ShowCustomer; use App\Actions\CRM\Customer\UI\ShowCustomerClient; use App\Actions\CRM\Customer\UI\WithCustomerSubNavigation; @@ -25,6 +27,7 @@ use App\Http\Resources\Accounting\InvoicesResource; use App\InertiaTable\InertiaTable; use App\Models\Accounting\Invoice; +use App\Models\Accounting\InvoiceCategory; use App\Models\Catalogue\Shop; use App\Models\CRM\Customer; use App\Models\CRM\WebUser; @@ -48,11 +51,13 @@ class IndexInvoices extends OrgAction use WithFulfilmentCustomerSubNavigation; use WithCustomerSubNavigation; use WithInvoicesSubNavigation; + use WithInvoiceCategorySubNavigation; - private Group|Organisation|Fulfilment|Customer|CustomerClient|FulfilmentCustomer|Shop $parent; + + private Group|Organisation|Fulfilment|Customer|CustomerClient|FulfilmentCustomer|InvoiceCategory|Shop $parent; private string $bucket = ''; - public function handle(Group|Organisation|Fulfilment|Customer|CustomerClient|FulfilmentCustomer|Shop|Order $parent, $prefix = null): LengthAwarePaginator + public function handle(Group|Organisation|Fulfilment|Customer|CustomerClient|FulfilmentCustomer|InvoiceCategory|Shop|Order $parent, $prefix = null): LengthAwarePaginator { $globalSearch = AllowedFilter::callback('global', function ($query, $value) { @@ -93,6 +98,8 @@ public function handle(Group|Organisation|Fulfilment|Customer|CustomerClient|Ful $queryBuilder->where('invoices.order_id', $parent->id); } elseif ($parent instanceof Group) { $queryBuilder->where('invoices.group_id', $parent->id); + } elseif ($parent instanceof InvoiceCategory) { + $queryBuilder->where('invoices.invoice_category_id', $parent->id); } else { abort(422); } @@ -142,7 +149,7 @@ public function handle(Group|Organisation|Fulfilment|Customer|CustomerClient|Ful ->withQueryString(); } - public function tableStructure(Group|Organisation|Fulfilment|Customer|CustomerClient|FulfilmentCustomer|Shop|Order $parent, $prefix = null): Closure + public function tableStructure(Group|Organisation|Fulfilment|Customer|CustomerClient|FulfilmentCustomer|InvoiceCategory|Shop|Order $parent, $prefix = null): Closure { return function (InertiaTable $table) use ($prefix, $parent) { if ($prefix) { @@ -163,6 +170,9 @@ public function tableStructure(Group|Organisation|Fulfilment|Customer|CustomerCl } elseif ($parent instanceof Group) { $stats = $parent->orderingStats; $noResults = __("This group hasn't been invoiced"); + } elseif ($parent instanceof InvoiceCategory) { + $stats = $parent->stats; + $noResults = __("This invoice category hasn't been invoiced"); } else { $stats = $parent->salesStats; } @@ -226,6 +236,8 @@ public function authorize(ActionRequest $request): bool ); } elseif ($this->parent instanceof Group) { return $request->user()->authTo("group-overview"); + } elseif ($this->parent instanceof InvoiceCategory) { + return $request->user()->authTo("accounting.{$this->organisation->id}.view"); } return false; @@ -252,6 +264,8 @@ public function htmlResponse(LengthAwarePaginator $invoices, ActionRequest $requ $subNavigation = $this->getFulfilmentCustomerSubNavigation($this->parent, $request); } elseif ($this->parent instanceof Shop || $this->parent instanceof Fulfilment || $this->parent instanceof Organisation) { $subNavigation = $this->getInvoicesNavigation($this->parent); + } elseif ($this->parent instanceof InvoiceCategory) { + $subNavigation = $this->getInvoiceCategoryNavigation($this->parent); } @@ -274,7 +288,6 @@ public function htmlResponse(LengthAwarePaginator $invoices, ActionRequest $requ 'icon' => 'fal fa-file-invoice-dollar', ]; $afterTitle = [ - 'label' => __('invoices') ]; } elseif ($this->parent instanceof CustomerClient) { @@ -299,6 +312,14 @@ public function htmlResponse(LengthAwarePaginator $invoices, ActionRequest $requ 'icon' => ['fal', 'fa-user'], 'title' => __('customer') ]; + } elseif ($this->parent instanceof InvoiceCategory) { + $iconRight = null; + $model = __('Invoices'); + $title = $this->parent->name; + $icon = [ + 'icon' => ['fal', 'fa-file-invoice-dollar'], + 'title' => __('invoice category') + ]; } $routeName = $request->route()->getName(); @@ -443,6 +464,14 @@ public function inGroup(ActionRequest $request): LengthAwarePaginator return $this->handle(group()); } + public function inInvoiceCategory(Organisation $organisation, InvoiceCategory $invoiceCategory, ActionRequest $request): LengthAwarePaginator + { + $this->parent = $invoiceCategory; + $this->initialisation($invoiceCategory->organisation, $request)->withTab(InvoicesTabsEnum::values()); + + return $this->handle($invoiceCategory, InvoicesTabsEnum::INVOICES->value); + } + /** @noinspection PhpUnusedParameterInspection */ public function inFulfilmentCustomer(Organisation $organisation, Fulfilment $fulfilment, FulfilmentCustomer $fulfilmentCustomer, ActionRequest $request): LengthAwarePaginator { @@ -616,6 +645,16 @@ public function getBreadcrumbs(string $routeName, array $routeParameters): array ] ) ), + 'grp.org.accounting.invoice-categories.show.invoices.index' => + array_merge( + ShowInvoiceCategory::make()->getBreadcrumbs($this->parent, $routeName, $routeParameters), + $headCrumb( + [ + 'name' => $routeName, + 'parameters' => $routeParameters + ], + ) + ), 'grp.overview.ordering.invoices.index' => array_merge( diff --git a/app/Actions/Accounting/Invoice/UI/IndexRefunds.php b/app/Actions/Accounting/Invoice/UI/IndexRefunds.php index 1f97057595..40e41e30c2 100644 --- a/app/Actions/Accounting/Invoice/UI/IndexRefunds.php +++ b/app/Actions/Accounting/Invoice/UI/IndexRefunds.php @@ -23,6 +23,7 @@ use App\Http\Resources\Accounting\InvoicesResource; use App\InertiaTable\InertiaTable; use App\Models\Accounting\Invoice; +use App\Models\Accounting\InvoiceCategory; use App\Models\Catalogue\Shop; use App\Models\CRM\Customer; use App\Models\Dropshipping\CustomerClient; @@ -46,10 +47,10 @@ class IndexRefunds extends OrgAction use WithCustomerSubNavigation; use WithInvoicesSubNavigation; - private Invoice|Group|Organisation|Fulfilment|Customer|CustomerClient|FulfilmentCustomer|Shop $parent; + private Invoice|Group|Organisation|Fulfilment|Customer|CustomerClient|FulfilmentCustomer|InvoiceCategory|Shop $parent; private string $bucket; - public function handle(Invoice|Group|Organisation|Fulfilment|Customer|CustomerClient|FulfilmentCustomer|Shop|Order $parent, $prefix = null): LengthAwarePaginator + public function handle(Invoice|Group|Organisation|Fulfilment|Customer|CustomerClient|FulfilmentCustomer|InvoiceCategory|Shop|Order $parent, $prefix = null): LengthAwarePaginator { $globalSearch = AllowedFilter::callback('global', function ($query, $value) { $query->where(function ($query) use ($value) { @@ -84,6 +85,8 @@ public function handle(Invoice|Group|Organisation|Fulfilment|Customer|CustomerCl $queryBuilder->where('invoices.group_id', $parent->id); } elseif ($parent instanceof Invoice) { $queryBuilder->where('invoices.invoice_id', $parent->id); + } elseif ($parent instanceof InvoiceCategory) { + $queryBuilder->where('invoices.invoice_category_id', $parent->id); } else { abort(422); } @@ -133,7 +136,7 @@ public function handle(Invoice|Group|Organisation|Fulfilment|Customer|CustomerCl ->withQueryString(); } - public function tableStructure(Invoice|Group|Organisation|Fulfilment|Customer|CustomerClient|FulfilmentCustomer|Shop|Order $parent, $prefix = null): Closure + public function tableStructure(Invoice|Group|Organisation|Fulfilment|Customer|CustomerClient|FulfilmentCustomer|InvoiceCategory|Shop|Order $parent, $prefix = null): Closure { return function (InertiaTable $table) use ($prefix, $parent) { if ($prefix) { @@ -156,6 +159,9 @@ public function tableStructure(Invoice|Group|Organisation|Fulfilment|Customer|Cu } elseif ($parent instanceof Group) { $stats = $parent->orderingStats; $noResults = __("This group hasn't been invoiced"); + } elseif ($parent instanceof InvoiceCategory) { + $stats = $parent->stats; + $noResults = __("This invoice category hasn't been invoiced"); } else { $stats = $parent->salesStats; } @@ -220,6 +226,8 @@ public function authorize(ActionRequest $request): bool return $request->user()->authTo("fulfilment-shop.{$this->fulfilment->id}.view"); } elseif ($this->parent instanceof Group) { return $request->user()->authTo("group-overview"); + } elseif ($this->parent instanceof InvoiceCategory) { + return $request->user()->authTo("accounting.{$this->organisation->id}.view"); } return false; diff --git a/app/Actions/Accounting/InvoiceCategory/UI/IndexInvoiceCategories.php b/app/Actions/Accounting/InvoiceCategory/UI/IndexInvoiceCategories.php index 582b9ad403..eac861cce4 100644 --- a/app/Actions/Accounting/InvoiceCategory/UI/IndexInvoiceCategories.php +++ b/app/Actions/Accounting/InvoiceCategory/UI/IndexInvoiceCategories.php @@ -55,7 +55,7 @@ public function handle(Organisation $parent, $prefix = null): LengthAwarePaginat 'invoice_category_stats.number_invoices_type_invoice as number_type_invoices', 'invoice_category_stats.number_invoices_type_refund as number_type_refunds', ]) - ->allowedSorts(['name', 'state', 'number_type_invoices', 'amount', 'number_type_refunds']) + ->allowedSorts(['name', 'id' ,'state', 'number_type_invoices', 'amount', 'number_type_refunds']) ->allowedFilters([$globalSearch]) ->withPaginator($prefix, tableName: request()->route()->getName()) ->withQueryString(); diff --git a/app/Actions/Accounting/InvoiceCategory/UI/ShowInvoiceCategory.php b/app/Actions/Accounting/InvoiceCategory/UI/ShowInvoiceCategory.php index e0d9d5fa82..eadfe9b021 100644 --- a/app/Actions/Accounting/InvoiceCategory/UI/ShowInvoiceCategory.php +++ b/app/Actions/Accounting/InvoiceCategory/UI/ShowInvoiceCategory.php @@ -65,7 +65,7 @@ public function htmlResponse(InvoiceCategory $invoiceCategory, ActionRequest $re 'subNavigation' => $this->getInvoiceCategoryNavigation($invoiceCategory), 'model' => __('Invoice Category'), 'icon' => [ - 'icon' => ['fal', 'fa-money-check-alt'], + 'icon' => ['fal', 'fa-sitemap'], 'title' => __('invoice category') ], 'title' => $invoiceCategory->name, @@ -144,6 +144,26 @@ public function getBreadcrumbs(InvoiceCategory $invoiceCategory, string $routeNa $suffix ), ), + 'grp.org.accounting.invoice-categories.show.invoices.index' => array_merge( + ShowAccountingDashboard::make()->getBreadcrumbs( + 'grp.org.accounting.dashboard', + Arr::only($routeParameters, ['organisation']) + ), + $headCrumb( + $invoiceCategory, + [ + 'index' => [ + 'name' => 'grp.org.accounting.invoice-categories.index', + 'parameters' => Arr::only($routeParameters, ['organisation']) + ], + 'model' => [ + 'name' => 'grp.org.accounting.invoice-categories.show', + 'parameters' => Arr::only($routeParameters, ['organisation', 'invoiceCategory']) + ] + ], + $suffix + ), + ), default => [] }; } diff --git a/app/Actions/Accounting/InvoiceCategory/WithInvoiceCategorySubNavigation.php b/app/Actions/Accounting/InvoiceCategory/WithInvoiceCategorySubNavigation.php index 2093de2587..bfb1d9d7b3 100644 --- a/app/Actions/Accounting/InvoiceCategory/WithInvoiceCategorySubNavigation.php +++ b/app/Actions/Accounting/InvoiceCategory/WithInvoiceCategorySubNavigation.php @@ -27,6 +27,20 @@ protected function getInvoiceCategoryNavigation(InvoiceCategory $invoiceCategory ], ], ], + [ + "label" => __('Invoices'), + "route" => [ + "name" => 'grp.org.accounting.invoice-categories.show.invoices.index', + "parameters" => [ + 'organisation' => $invoiceCategory->organisation->slug, + 'invoiceCategory' => $invoiceCategory->slug + ], + ], + 'leftIcon' => [ + 'icon' => ['fal', 'fa-file-invoice-dollar'], + 'tooltip' => __('Invoices') + ] + ], // [ // "number" => $numberUnpaid, diff --git a/app/Actions/Fulfilment/Pallet/UI/IndexPalletsInDelivery.php b/app/Actions/Fulfilment/Pallet/UI/IndexPalletsInDelivery.php index a2bc0ff165..7f5b3a6f0a 100644 --- a/app/Actions/Fulfilment/Pallet/UI/IndexPalletsInDelivery.php +++ b/app/Actions/Fulfilment/Pallet/UI/IndexPalletsInDelivery.php @@ -72,7 +72,7 @@ public function handle(PalletDelivery $palletDelivery, $prefix = null): LengthAw 'pallets.pallet_delivery_id', 'pallets.pallet_return_id', 'locations.slug as location_slug', - 'locations.slug as location_code', + 'locations.code as location_code', ); diff --git a/app/Actions/Fulfilment/PalletReturn/IndexPalletsInReturnPalletWholePallets.php b/app/Actions/Fulfilment/PalletReturn/IndexPalletsInReturnPalletWholePallets.php index abe0f38717..6c23a25d8e 100644 --- a/app/Actions/Fulfilment/PalletReturn/IndexPalletsInReturnPalletWholePallets.php +++ b/app/Actions/Fulfilment/PalletReturn/IndexPalletsInReturnPalletWholePallets.php @@ -72,7 +72,12 @@ public function handle(PalletReturn $palletReturn, $prefix = null): LengthAwareP }); if ($palletReturn->state !== PalletReturnStateEnum::DISPATCHED) { - $query->where('pallets.status', '!=', PalletStatusEnum::RETURNED); + $query->whereNotIn('pallets.status', [ + PalletStatusEnum::RETURNED, + PalletStatusEnum::IN_PROCESS, + PalletStatusEnum::RECEIVING, + PalletStatusEnum::NOT_RECEIVED + ]); } elseif ($palletReturn->state === PalletReturnStateEnum::IN_PROCESS) { $query->where('pallets.status', PalletStatusEnum::STORING); } diff --git a/app/Actions/Fulfilment/PalletReturn/UI/ShowPalletReturn.php b/app/Actions/Fulfilment/PalletReturn/UI/ShowPalletReturn.php index 3dda3bbd37..ae412f3b8f 100644 --- a/app/Actions/Fulfilment/PalletReturn/UI/ShowPalletReturn.php +++ b/app/Actions/Fulfilment/PalletReturn/UI/ShowPalletReturn.php @@ -105,13 +105,13 @@ public function htmlResponse(PalletReturn $palletReturn, ActionRequest $request) } else { $tooltipSubmit = __('Submit'); } - + $buttonSubmit = [ 'type' => 'button', 'style' => 'save', 'tooltip' => $tooltipSubmit, 'label' => __('Submit') . ' (' . $palletReturn->stats->number_pallets . ')', - 'key' => 'submit', + 'key' => 'submit-pallet', 'route' => [ 'method' => 'post', 'name' => 'grp.models.fulfilment-customer.pallet-return.submit_and_confirm', diff --git a/app/Actions/Fulfilment/PalletReturn/UI/ShowStoredItemReturn.php b/app/Actions/Fulfilment/PalletReturn/UI/ShowStoredItemReturn.php index 669dd0d0cb..4aeb37e1b8 100644 --- a/app/Actions/Fulfilment/PalletReturn/UI/ShowStoredItemReturn.php +++ b/app/Actions/Fulfilment/PalletReturn/UI/ShowStoredItemReturn.php @@ -106,7 +106,7 @@ public function htmlResponse(PalletReturn $palletReturn, ActionRequest $request) 'style' => 'save', 'tooltip' => $tooltipSubmit, // 'label' => __('Confirm') . ' (' . $palletReturn->storedItems()->count() . ')', - 'key' => 'submit', + 'key' => 'submit-stored-items', 'route' => [ 'method' => 'post', 'name' => 'grp.models.fulfilment-customer.pallet-return.submit_and_confirm', diff --git a/resources/js/Components/LocationFieldDelivery.vue b/resources/js/Components/LocationFieldDelivery.vue index c6393dc404..8260d3467d 100644 --- a/resources/js/Components/LocationFieldDelivery.vue +++ b/resources/js/Components/LocationFieldDelivery.vue @@ -26,6 +26,9 @@ library.add( faTrashAlt, faSignOutAlt, faPaperPlane, faInventory, faTruckLoading const props = defineProps<{ pallet: Pallet locationRoute?: routeType + noButton?: boolean + noFetchOnMounted?: boolean + initOptions?: {}[] }>() const emits = defineEmits<{ @@ -48,7 +51,7 @@ const error = ref({}) // } const isLoading = ref(false) -const onChangeLocation = (closeModal: Function) => { +const onChangeLocation = (closeModal?: Function) => { router.patch( route(props.pallet['bookInRoute'].name, props.pallet['bookInRoute'].parameters), { location_id: location.data().location_id}, @@ -56,7 +59,9 @@ const onChangeLocation = (closeModal: Function) => { preserveScroll: true, onStart: () => { isLoading.value = true }, onSuccess: () => { - closeModal() + if (closeModal) { + closeModal() + } emits('renderTableKey') error.value = {} }, @@ -76,9 +81,27 @@ const onChangeLocation = (closeModal: Function) => {