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
Ganes556 committed Jan 7, 2025
2 parents 9296240 + 19dadf9 commit 2034fc1
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 43 deletions.
9 changes: 7 additions & 2 deletions app/Actions/Inventory/Location/UI/IndexLocations.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ public function handle(Group|Warehouse|WarehouseArea|Organisation $parent, $pref
'locations.has_stock_slots',
'locations.has_fulfilment',
'locations.has_dropshipping_slots',
'locations.max_weight',
'locations.max_volume',
'warehouses.slug as warehouse_slug',
'warehouse_areas.slug as warehouse_area_slug',
'warehouse_area_id',
Expand Down Expand Up @@ -217,11 +219,14 @@ public function tableStructure(Group|Warehouse|WarehouseArea|Organisation $paren
default => null
}
)
->column(key: 'code', label: __('code'), canBeHidden: false, sortable: true, searchable: true)
->column(key: 'scope', label: __('scope'), canBeHidden: false);
->column(key: 'scope', label: __('scope'), canBeHidden: false)
->column(key: 'code', label: __('code'), canBeHidden: false, sortable: true, searchable: true);
if ($parent instanceof Group) {
$table->column(key: 'organisation_name', label: __('organisation'), canBeHidden: false, sortable: true, searchable: true);
}
$table->column(key: 'max_weight', label: __('weight'), canBeHidden: false);
$table->column(key: 'max_volume', label: __('volume'), canBeHidden: false);
$table->column(key: '', label: __('stock value'), canBeHidden: false);
$table->column(key: 'tags', label: __('tags'), canBeHidden: false)
->defaultSort('code');
};
Expand Down
100 changes: 61 additions & 39 deletions app/Actions/Ordering/Order/UI/ShowOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use App\Actions\CRM\Customer\UI\ShowCustomer;
use App\Actions\CRM\Customer\UI\ShowCustomerClient;
use App\Actions\Dispatching\DeliveryNote\UI\IndexDeliveryNotes;
use App\Actions\Helpers\Country\UI\GetAddressData;
use App\Actions\Helpers\Media\UI\IndexAttachments;
use App\Actions\Ordering\Purge\UI\ShowPurge;
use App\Actions\Ordering\Transaction\UI\IndexNonProductItems;
Expand Down Expand Up @@ -316,6 +317,27 @@ public function htmlResponse(Order $order, ActionRequest $request): Response

}

$customerAddressId = $order->customer->address->id;
$customerDeliveryAddressId = $order->customer->deliveryAddress->id;
$orderDeliveryAddressIds = Order::where('customer_id', $order->customer_id)
->pluck('delivery_address_id')
->unique()
->toArray();

$forbiddenAddressIds = array_merge(
$orderDeliveryAddressIds,
[$customerAddressId, $customerDeliveryAddressId]
);

$processedAddresses->each(function ($address) use ($forbiddenAddressIds) {
if (in_array($address->id, $forbiddenAddressIds, true)) {
$address->setAttribute('can_delete', false)
->setAttribute('can_edit', true);
}
});

$addressCollection = AddressResource::collection($processedAddresses);

return Inertia::render(
'Org/Ordering/Order',
[
Expand Down Expand Up @@ -390,46 +412,46 @@ public function htmlResponse(Order $order, ActionRequest $request): Response
]
],
'timelines' => $finalTimeline,
'address_update_route' => [ // TODO by BE
// 'method' => 'patch',
// 'name' => 'grp.models.fulfilment-customer.address.update',
// 'parameters' => [
// 'fulfilmentCustomer' => $fulfilmentCustomer->id
// ]
'address_update_route' => [
'method' => 'patch',
'name' => 'grp.models.customer.address.update',
'parameters' => [
'customer' => $order->customer_id
]
],
'addresses' => [ // TODO by BE
// 'isCannotSelect' => true,
// 'address_list' => $addressCollection,
// 'options' => [
// 'countriesAddressData' => GetAddressData::run()
// ],
// 'pinned_address_id' => $fulfilmentCustomer->customer->delivery_address_id,
// 'home_address_id' => $fulfilmentCustomer->customer->address_id,
// 'current_selected_address_id' => $fulfilmentCustomer->customer->delivery_address_id,
// 'selected_delivery_addresses_id' => $palletReturnDeliveryAddressIds,
// 'routes_list' => [
// 'pinned_route' => [
// 'method' => 'patch',
// 'name' => 'grp.models.customer.delivery-address.update',
// 'parameters' => [
// 'customer' => $fulfilmentCustomer->customer_id
// ]
// ],
// 'delete_route' => [
// 'method' => 'delete',
// 'name' => 'grp.models.fulfilment-customer.delivery-address.delete',
// 'parameters' => [
// 'fulfilmentCustomer' => $fulfilmentCustomer->id
// ]
// ],
// 'store_route' => [
// 'method' => 'post',
// 'name' => 'grp.models.fulfilment-customer.address.store',
// 'parameters' => [
// 'fulfilmentCustomer' => $fulfilmentCustomer->id
// ]
// ]
// ]
'addresses' => [
'isCannotSelect' => true,
'address_list' => $addressCollection,
'options' => [
'countriesAddressData' => GetAddressData::run()
],
'pinned_address_id' => $order->customer->delivery_address_id,
'home_address_id' => $order->customer->address_id,
'current_selected_address_id' => $order->customer->delivery_address_id,
'selected_delivery_addresses_id' => $orderDeliveryAddressIds,
'routes_list' => [
'pinned_route' => [
'method' => 'patch',
'name' => 'grp.models.customer.delivery-address.update',
'parameters' => [
'customer' => $order->customer_id
]
],
'delete_route' => [
'method' => 'delete',
'name' => 'grp.models.customer.delivery-address.delete',
'parameters' => [
'customer' => $order->customer_id
]
],
'store_route' => [
'method' => 'post',
'name' => 'grp.models.customer.address.store',
'parameters' => [
'customer' => $order->customer_id
]
]
]
],

'box_stats' => [
Expand Down
44 changes: 42 additions & 2 deletions app/Actions/SysAdmin/Guest/UpdateGuest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@
use App\Actions\Traits\WithActionUpdate;
use App\Http\Resources\SysAdmin\GuestResource;
use App\Models\SysAdmin\Guest;
use App\Rules\AlphaDashDot;
use App\Rules\IUnique;
use App\Rules\Phone;
use Illuminate\Support\Arr;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Rules\Password;
use Lorisleiva\Actions\ActionRequest;

class UpdateGuest extends GrpAction
Expand All @@ -29,6 +32,11 @@ class UpdateGuest extends GrpAction

public function handle(Guest $guest, array $modelData): Guest
{
$credentials = Arr::only($modelData, ['username', 'password']);

data_forget($modelData, 'username');
data_forget($modelData, 'password');

$guest = $this->update($guest, $modelData, [
'data',
]);
Expand All @@ -41,6 +49,10 @@ public function handle(Guest $guest, array $modelData): Guest
}
}

if ($user = $guest->getUser()) {
UpdateUser::run($user, $credentials);
}

return $guest;
}

Expand All @@ -61,8 +73,7 @@ public function rules(): array
$phoneValidation[] = new Phone();
}


return [
$rules = [
'code' => [
'sometimes',
'string',
Expand All @@ -80,13 +91,42 @@ public function rules(): array
),

],
'status' => ['sometimes'],
'company_name' => ['sometimes', 'nullable', 'string', 'max:255'],
'contact_name' => ['sometimes', 'required', 'string', 'max:255'],
'email' => ['sometimes', 'nullable', 'email', 'max:255'],
'phone' => $phoneValidation,
'identity_document_number' => ['sometimes', 'nullable', 'string'],
'identity_document_type' => ['sometimes', 'nullable', 'string'],
];

if ($user = $this->guest->getUser()) {
$rules['username'] = [
'sometimes',
'required',
'lowercase',
new AlphaDashDot(),

Rule::notIn(['export', 'create']),
new IUnique(
table: 'users',
extraConditions: [

[
'column' => 'id',
'operator' => '!=',
'value' => $user->id
],
]
),


];
$rules['password'] = ['sometimes', 'required', app()->isLocal() || app()->environment('testing') ? null : Password::min(8)->uncompromised()];
}


return $rules;
}


Expand Down
2 changes: 2 additions & 0 deletions app/Http/Resources/Inventory/LocationsResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public function toArray($request): array
'organisation_slug' => $location->organisation_slug,
'organisation_name' => $location->organisation_name,
'warehouse_slug' => $location->warehouse_slug,
'max_weight' => $location->max_weight,
'max_volume' => $location->max_volume,

'quantity' => $this->whenPivotLoaded(new LocationOrgStock(), function () {
return $this->pivot->quantity;
Expand Down

0 comments on commit 2034fc1

Please sign in to comment.