Skip to content

Commit

Permalink
Merge branch 'main' of github.com:inikoo/aiku
Browse files Browse the repository at this point in the history
  • Loading branch information
dandiAW committed Feb 20, 2025
2 parents 452f4cd + 8374075 commit c79e357
Show file tree
Hide file tree
Showing 17 changed files with 161 additions and 32 deletions.
47 changes: 43 additions & 4 deletions app/Actions/Accounting/Invoice/UI/IndexInvoices.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
Expand All @@ -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);
}


Expand All @@ -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) {
Expand All @@ -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();
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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(
Expand Down
14 changes: 11 additions & 3 deletions app/Actions/Accounting/Invoice/UI/IndexRefunds.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 => []
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
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 @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
31 changes: 27 additions & 4 deletions resources/js/Components/LocationFieldDelivery.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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<{
Expand All @@ -48,15 +51,17 @@ const error = ref({})
// }

const isLoading = ref<string | boolean>(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},
{
preserveScroll: true,
onStart: () => { isLoading.value = true },
onSuccess: () => {
closeModal()
if (closeModal) {
closeModal()
}
emits('renderTableKey')
error.value = {}
},
Expand All @@ -76,9 +81,27 @@ const onChangeLocation = (closeModal: Function) => {
</script>

<template>
<div class="relative">
<div class="relative w-64">
<!-- <pre>{{ pallet.state }}</pre> -->
<Popover >
<SelectQuery
v-if="props.noButton"
:urlRoute="route(locationRoute?.name, locationRoute?.parameters)"
:value="location"
:placeholder="'Select location'"
:required="true"
:trackBy="'code'"
:label="'code'"
:valueProp="'id'"
:closeOnSelect="true"
:clearOnSearch="false"
:fieldName="'location_id'"
@updateVModel="() => (onChangeLocation(), error.location_id = '')"
:loadingCaret="!!isLoading"
noFetchOnMounted
:initOptions="initOptions"
/>

<Popover v-else >
<template #button>
<!-- <Button :type="pallet.state == 'booked_in' ? 'primary' : 'tertiary'" :icon="['fal', 'inventory']"
tooltip="Set location for pallet" :key="pallet.index" :size="'xs'" /> -->
Expand Down
Loading

0 comments on commit c79e357

Please sign in to comment.