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 21, 2025
2 parents df230b9 + 78d6af2 commit 4e15500
Show file tree
Hide file tree
Showing 10 changed files with 310 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function handle(PalletReturnItem $palletReturnItem, array $modelData): Pa
return DB::transaction(function () use ($palletReturnItem, $modelData) {
$quantity = Arr::get($modelData, 'quantity_picked');
$palletStoredItemQuantity = $palletReturnItem->palletStoredItem->quantity;

$this->update($palletReturnItem, $modelData);

StoreStoredItemMovementFromPicking::run($palletReturnItem, [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* author Arya Permana - Kirin
* created on 21-02-2025-14h-59m
Expand All @@ -14,7 +15,6 @@
use App\InertiaTable\InertiaTable;
use App\Models\Fulfilment\FulfilmentCustomer;
use App\Models\Fulfilment\Pallet;
use App\Models\Fulfilment\StoredItem;
use App\Models\Fulfilment\StoredItemAudit;
use App\Models\Fulfilment\StoredItemAuditDelta;
use App\Services\QueryBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@
use App\Actions\Traits\Authorisations\WithFulfilmentAuthorisation;
use App\Enums\Fulfilment\StoredItemAudit\StoredItemAuditStateEnum;
use App\Http\Resources\Fulfilment\FulfilmentCustomerResource;
use App\Http\Resources\Fulfilment\NewStoredItemDeltasInProcessForPalletResource;
use App\Http\Resources\Fulfilment\StoredItemAuditDeltasResource;
use App\Http\Resources\Fulfilment\StoredItemAuditResource;
use App\Http\Resources\Fulfilment\StoredItemDeltasInProcessForPalletResource;
use App\Models\Fulfilment\Fulfilment;
use App\Models\Fulfilment\FulfilmentCustomer;
use App\Models\Fulfilment\Pallet;
Expand Down Expand Up @@ -84,8 +82,46 @@ public function htmlResponse(StoredItemAudit $storedItemAudit, ActionRequest $re
'label' => __('Add SKU'),
]
];
$editDeltas = StoredItemDeltasInProcessForPalletResource::collection(IndexStoredItemDeltasInProcessForPallet::run($storedItemAudit, 'edit_stored_item_deltas'));
$editNewDeltas = NewStoredItemDeltasInProcessForPalletResource::collection(IndexNewStoredItemDeltasInProcessForPallet::run($storedItemAudit, 'new_stored_item_deltas'));
$editDeltas = $pallet->getEditStoredItemDeltasQuery($pallet->id, $storedItemAudit->id)
->where('pallet_stored_items.pallet_id', $this->id)
->get()->map(fn ($item) => [
'stored_item_audit_id' => $storedItemAudit->id,
'pallet_id' => $item->pallet_id,
'stored_item_id' => $item->stored_item_id,
'reference' => $item->stored_item_reference,
'quantity' => (int)$item->quantity,
'audited_quantity' => (int)$item->audited_quantity,
'audit_notes' => $item->audit_notes,
'stored_item_audit_delta_id' => $item->stored_item_audit_delta_id,
'audit_type' => $item->audit_type,
'update_routes' => [
'name' => 'grp.models.stored_item_audit_delta.update',
'parameters' => [
$item->stored_item_audit_delta_id
]
],
'type' => 'current_item',
]);
$editNewDeltas = $pallet->getEditNewStoredItemDeltasQuery($pallet->id)
->where('stored_item_audit_deltas.pallet_id', $pallet->id)
->where('stored_item_audit_deltas.stored_item_audit_id', $storedItemAudit->id)
->get()->map(fn ($item) => [
'stored_item_audit_id' => $storedItemAudit->id,
'stored_item_id' => $item->stored_item_id,
'reference' => $item->stored_item_reference,
'quantity' => 0,
'audited_quantity' => (int)$item->audited_quantity,
'stored_item_audit_delta_id' => $item->audit_id,
'audit_type' => $item->audit_type,
'update_routes' => [
'name' => 'grp.models.stored_item_audit_delta.update',
'parameters' => [
$item->audit_id
]
],
'audit_notes' => $item->audit_notes,
'type' => 'new_item'
]);
} else {
$deltas = StoredItemAuditDeltasResource::collection(IndexStoredItemAuditDeltas::run($storedItemAudit, 'stored_item_deltas'));
}
Expand Down Expand Up @@ -165,8 +201,8 @@ public function htmlResponse(StoredItemAudit $storedItemAudit, ActionRequest $re
],

'data' => StoredItemAuditResource::make($storedItemAudit),
'edit_stored_item_deltas' => $editDeltas,
'edit_new_stored_item_deltas' => $editNewDeltas,
'xstored_items' => $editDeltas,
'xnew_stored_items' => $editNewDeltas,
'stored_item_deltas' => $deltas,
'fulfilment_customer' => FulfilmentCustomerResource::make($storedItemAudit->fulfilmentCustomer)->getArray()
]
Expand Down
55 changes: 55 additions & 0 deletions app/Actions/HumanResources/Timesheet/Pdf/PdfTimesheet.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

/*
* Author: Raul Perusquia <raul@inikoo.com>
* Created: Thu, 25 Jul 2024 14:54:12 Malaysia Time, Kuala Lumpur, Malaysia
* Copyright (c) 2024, Raul A Perusquia Flores
*/

namespace App\Actions\HumanResources\Timesheet\Pdf;

use App\Actions\Traits\WithExportData;
use App\Models\SysAdmin\Organisation;
use Lorisleiva\Actions\ActionRequest;
use Lorisleiva\Actions\Concerns\AsAction;
use Lorisleiva\Actions\Concerns\WithAttributes;
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf as PDF;
use Symfony\Component\HttpFoundation\Response;

class PdfTimesheet
{
use AsAction;
use WithAttributes;
use WithExportData;

/**
* @throws \Mpdf\MpdfException
*/
public function handle(Organisation $organisation)
{
$filename = __('Timesheets - ') . $organisation->name . '.pdf';
$config = [
'title' => $filename,
'margin_left' => 8,
'margin_right' => 8,
'margin_top' => 2,
'margin_bottom' => 2,
'auto_page_break' => true,
'auto_page_break_margin' => 10
];

return PDF::chunkLoadView('<html-separator/>', 'hr.timesheets', [
'filename' => $filename,
'organisation' => $organisation,
'employees' => $organisation->employees()->limit(10)->get(),
], [], $config)->stream($filename);
}

/**
* @throws \Mpdf\MpdfException
*/
public function asController(Organisation $organisation, ActionRequest $request): Response
{
return $this->handle($organisation);
}
}
21 changes: 19 additions & 2 deletions app/Actions/HumanResources/Timesheet/UI/IndexTimesheets.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function handle(Group|Organisation|Employee|Guest $parent, ?string $prefi
$query->whereDate('timesheets.date', now()->format('Y-m-d'));
}

$query->withFilterPeriod('created_at');
$query->withFilterPeriod('date');
$query->select([
'timesheets.id',
'timesheets.date',
Expand Down Expand Up @@ -228,7 +228,24 @@ public function htmlResponse(LengthAwarePaginator $timesheets, ActionRequest $re
'afterTitle' => $afterTitle,
'iconRight' => $iconRight,
'subNavigation' => $subNavigation,
],
'actions' => [
[
'type' => 'button',
'style' => 'tertiary',
'label' => 'PDF',
'target' => '_blank',
'icon' => 'fal fa-file-pdf',
'key' => 'action',
'route' => [
'name' => 'grp.org.hr.timesheets.export',
'parameters' => [
'organisation' => $this->parent->slug,
...$request->query,
]
]
]
]
],

'tabs' => [
'current' => $this->tab,
Expand Down
1 change: 1 addition & 0 deletions app/Actions/Traits/WithDashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ protected function getIntervalPercentage($intervalData, string $prefix, $key, $t

public function getDateIntervalFilter($interval): string
{
// TODO: #1461
$intervals = [
'1y' => now()->subYear(),
'1q' => now()->subQuarter(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* author Arya Permana - Kirin
* created on 21-02-2025-15h-04m
Expand Down
15 changes: 10 additions & 5 deletions app/Services/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,14 @@ public function whereRadioFilter(

public function withFilterPeriod($column, ?string $prefix = null): static
{
$table = $this->getModel()->getTable();
$periodType = array_key_first(request()->input(($prefix ? $prefix.'_' : '').'period') ?? []);

if ($periodType) {
$periodData = $this->validatePeriod($periodType, $prefix);

if ($periodData) {
$this->whereBetween($column, [$periodData['start'], $periodData['end']]);
$this->whereBetween($table.'.'.$column, [$periodData['start'], $periodData['end']]);
}
}

Expand Down Expand Up @@ -184,10 +185,14 @@ public function withBetweenDates(array $allowedColumns, ?string $prefix = null):

if (count($parts) === 2) {
[$start, $end] = $parts;

// Normalize the start and end dates
$start = trim($start) . ' 00:00:00';
$end = trim($end) . ' 23:59:59';
// TODO: #1461
if ($start == $end) {
$start = trim($start) . ' 00:00:00';
$end = trim($end) . ' ' . now()->format('H:i:s');
} else {
$start = trim($start) . ' ' . now()->format('H:i:s');
$end = trim($end) . ' ' . now()->format('H:i:s');
}

$this->whereBetween("$table.$column", [$start, $end]);
}
Expand Down
Loading

0 comments on commit 4e15500

Please sign in to comment.