Skip to content

Commit

Permalink
fix: dropshipping hold
Browse files Browse the repository at this point in the history
  • Loading branch information
itzArtha committed Feb 19, 2025
2 parents fd4d9a0 + 9dd1105 commit adc0232
Show file tree
Hide file tree
Showing 17 changed files with 284 additions and 151 deletions.
2 changes: 2 additions & 0 deletions app/Actions/Accounting/Payment/UI/IndexPayments.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public function handle(Group|Organisation|PaymentAccount|Shop|OrgPaymentServiceP

$queryBuilder->leftjoin('organisations', 'payments.organisation_id', '=', 'organisations.id');
$queryBuilder->leftjoin('shops', 'payments.shop_id', '=', 'shops.id');
$queryBuilder->leftJoin('currencies', 'payments.currency_id', 'currencies.id');

if (!($parent instanceof Order || $parent instanceof Invoice)) {
foreach ($this->getElementGroups($parent) as $key => $elementGroup) {
Expand All @@ -104,6 +105,7 @@ public function handle(Group|Organisation|PaymentAccount|Shop|OrgPaymentServiceP
'shops.slug as shop_slug',
'organisations.name as organisation_name',
'organisations.slug as organisation_slug',
'currencies.code as currency_code',
])
->leftJoin('payment_accounts', 'payments.payment_account_id', 'payment_accounts.id')
->leftJoin('payment_service_providers', 'payment_accounts.payment_service_provider_id', 'payment_service_providers.id')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public function tableStructure(Group|Shop|Organisation|OrgPaymentServiceProvider
$table->column(key: 'number_pas_state_active', label: __('shops'), canBeHidden: false, sortable: true, searchable: true);

$table->column(key: 'number_payments', label: __('payments'), canBeHidden: false, sortable: true, searchable: true);
$table->column(key: 'org_amount_successfully_paid', label: __('amount'), canBeHidden: false, sortable: true, searchable: true);
$table->column(key: 'org_amount_successfully_paid', label: __('amount'), canBeHidden: false, sortable: true, searchable: true, type:'number');

$table->defaultSort('code');
};
Expand Down
45 changes: 23 additions & 22 deletions app/Actions/Fulfilment/PalletReturn/UI/IndexPalletReturns.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ class IndexPalletReturns extends OrgAction
private ?string $type = null;



public function authorize(ActionRequest $request): bool
{
if ($this->parent instanceof Fulfilment or $this->parent instanceof FulfilmentCustomer) {
Expand All @@ -67,61 +66,67 @@ public function authorize(ActionRequest $request): bool

public function asController(Organisation $organisation, Fulfilment $fulfilment, ActionRequest $request): LengthAwarePaginator
{
$this->parent = $fulfilment;
$this->parent = $fulfilment;
$this->restriction = 'all';
$this->initialisationFromFulfilment($fulfilment, $request)->withTab(PalletReturnsTabsEnum::values());

return $this->handle($fulfilment, PalletReturnsTabsEnum::RETURNS->value);
}

/** @noinspection PhpUnusedParameterInspection */
public function inFulfilmentConfirmed(Organisation $organisation, Fulfilment $fulfilment, ActionRequest $request): LengthAwarePaginator
{
$this->parent = $fulfilment;
$this->parent = $fulfilment;
$this->restriction = 'confirmed';
$this->initialisationFromFulfilment($fulfilment, $request)->withTab(PalletReturnsTabsEnum::values());

return $this->handle($fulfilment, PalletReturnsTabsEnum::RETURNS->value);
}

/** @noinspection PhpUnusedParameterInspection */
public function inFulfilmentNew(Organisation $organisation, Fulfilment $fulfilment, ActionRequest $request): LengthAwarePaginator
{
$this->parent = $fulfilment;
$this->parent = $fulfilment;
$this->restriction = 'new';
$this->initialisationFromFulfilment($fulfilment, $request)->withTab(PalletReturnsTabsEnum::values());

return $this->handle($fulfilment, PalletReturnsTabsEnum::RETURNS->value);
}

/** @noinspection PhpUnusedParameterInspection */
public function inFulfilmentPicking(Organisation $organisation, Fulfilment $fulfilment, ActionRequest $request): LengthAwarePaginator
{
$this->parent = $fulfilment;
$this->parent = $fulfilment;
$this->restriction = 'picking';
$this->initialisationFromFulfilment($fulfilment, $request)->withTab(PalletReturnsTabsEnum::values());

return $this->handle($fulfilment, PalletReturnsTabsEnum::RETURNS->value);
}

/** @noinspection PhpUnusedParameterInspection */
public function inFulfilmentPicked(Organisation $organisation, Fulfilment $fulfilment, ActionRequest $request): LengthAwarePaginator
{
$this->parent = $fulfilment;
$this->parent = $fulfilment;
$this->restriction = 'picked';
$this->initialisationFromFulfilment($fulfilment, $request)->withTab(PalletReturnsTabsEnum::values());

return $this->handle($fulfilment, PalletReturnsTabsEnum::RETURNS->value);
}

/** @noinspection PhpUnusedParameterInspection */
public function inFulfilmentDispatched(Organisation $organisation, Fulfilment $fulfilment, ActionRequest $request): LengthAwarePaginator
{
$this->parent = $fulfilment;
$this->parent = $fulfilment;
$this->restriction = 'dispatched';
$this->initialisationFromFulfilment($fulfilment, $request)->withTab(PalletReturnsTabsEnum::values());

return $this->handle($fulfilment, PalletReturnsTabsEnum::RETURNS->value);
}

/** @noinspection PhpUnusedParameterInspection */
public function inFulfilmentCancelled(Organisation $organisation, Fulfilment $fulfilment, ActionRequest $request): LengthAwarePaginator
{
$this->parent = $fulfilment;
$this->parent = $fulfilment;
$this->restriction = 'cancelled';
$this->initialisationFromFulfilment($fulfilment, $request)->withTab(PalletReturnsTabsEnum::values());

Expand All @@ -131,7 +136,7 @@ public function inFulfilmentCancelled(Organisation $organisation, Fulfilment $fu
/** @noinspection PhpUnusedParameterInspection */
public function inFulfilmentCustomer(Organisation $organisation, Fulfilment $fulfilment, FulfilmentCustomer $fulfilmentCustomer, ActionRequest $request): LengthAwarePaginator
{
$this->parent = $fulfilmentCustomer;
$this->parent = $fulfilmentCustomer;
$this->restriction = 'all';
$this->initialisationFromFulfilment($fulfilment, $request)->withTab(PalletReturnsTabsEnum::values());

Expand All @@ -141,7 +146,7 @@ public function inFulfilmentCustomer(Organisation $organisation, Fulfilment $ful
/** @noinspection PhpUnusedParameterInspection */
public function inWarehouse(Organisation $organisation, Warehouse $warehouse, ActionRequest $request): LengthAwarePaginator
{
$this->parent = $warehouse;
$this->parent = $warehouse;
$this->restriction = 'all';
$this->initialisationFromWarehouse($warehouse, $request)->withTab(PalletReturnsTabsEnum::values());

Expand Down Expand Up @@ -198,6 +203,7 @@ public function inWarehouseDispatched(Organisation $organisation, Warehouse $war

return $this->handle($warehouse, PalletReturnsTabsEnum::RETURNS->value);
}

/** @noinspection PhpUnusedParameterInspection */
public function inWarehouseCancelled(Organisation $organisation, Warehouse $warehouse, ActionRequest $request): LengthAwarePaginator
{
Expand Down Expand Up @@ -225,7 +231,7 @@ protected function getElementGroups(Organisation|FulfilmentCustomer|Fulfilment|W
'state' => [
'label' => __('State'),
'elements' => array_merge_recursive($allowedStates, $countStates),
'engine' => function ($query, $elements) {
'engine' => function ($query, $elements) {
$query->whereIn('pallet_returns.state', $elements);
}
],
Expand Down Expand Up @@ -289,9 +295,6 @@ public function handle(Fulfilment|Warehouse|FulfilmentCustomer|RecurringBill $pa
case 'picked':
$queryBuilder->where('state', PalletReturnStateEnum::PICKED);
break;
case 'dispatched':
$queryBuilder->where('state', PalletReturnStateEnum::DISPATCHED);
break;
case 'cancelled':
$queryBuilder->where('state', PalletReturnStateEnum::CANCEL);
break;
Expand All @@ -311,9 +314,10 @@ public function handle(Fulfilment|Warehouse|FulfilmentCustomer|RecurringBill $pa
}

$queryBuilder->defaultSort('-date');

return $queryBuilder
->select('pallet_returns.id', 'state', 'slug', 'reference', 'customer_reference', 'number_pallets', 'number_services', 'number_physical_goods', 'date', 'dispatched_at', 'type', 'total_amount', 'currencies.code as currency_code')
->allowedSorts(['reference','customer_reference','number_pallets','date','state'])
->allowedSorts(['reference', 'customer_reference', 'number_pallets', 'date', 'state'])
->allowedFilters([$globalSearch, 'type'])
->withPaginator($prefix, tableName: request()->route()->getName())
->withQueryString();
Expand Down Expand Up @@ -403,22 +407,19 @@ public function htmlResponse(LengthAwarePaginator $returns, ActionRequest $reque
'label' => __('returns')
];
} elseif ($this->parent instanceof Fulfilment) {
$model = __('Operations');
$model = __('Operations');
$subNavigation = $this->getPalletReturnSubNavigation($this->parent, $request);
} elseif ($this->parent instanceof Warehouse) {
$icon = ['fal', 'fa-arrow-from-left'];
$model = __('Goods Out');
$iconRight = ['fal', 'fa-sign-out-alt'];
$icon = ['fal', 'fa-arrow-from-left'];
$model = __('Goods Out');
$iconRight = ['fal', 'fa-sign-out-alt'];
$subNavigation = $this->getPalletReturnSubNavigation($this->parent, $request);
}


$actions = [];





if ($this->parent->number_pallets_status_storing) {
$actions[] = [
'type' => 'button',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function htmlResponse(PalletReturn $palletReturn, ActionRequest $request)
'type' => 'button',
'style' => 'save',
'tooltip' => $tooltipSubmit,
'label' => __('Confirm') . ' (' . $palletReturn->storedItems()->count() . ')',
// 'label' => __('Confirm') . ' (' . $palletReturn->storedItems()->count() . ')',
'key' => 'submit',
'route' => [
'method' => 'post',
Expand Down Expand Up @@ -624,6 +624,7 @@ public function htmlResponse(PalletReturn $palletReturn, ActionRequest $request)
'code' => 'Other'
]
],
'stored_items_count' => $palletReturn->storedItems()->count(),

PalletReturnTabsEnum::STORED_ITEMS->value => $this->tab == PalletReturnTabsEnum::STORED_ITEMS->value ?
fn () => PalletReturnItemsWithStoredItemsResource::collection(IndexStoredItemsInReturn::run($palletReturn, PalletReturnTabsEnum::STORED_ITEMS->value)) //todo idk if this is right
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,17 @@ public function htmlResponse(LengthAwarePaginator $supplier_products, ActionRequ
]
]
];
$attachRoutes = [
'importRoute' => [
'name' => 'grp.models.supplier.supplier-product.import',
'parameters' => [
'supplier' => $this->scope->id,
]
//'grp.models.supplier.supplier-product.import' import route
$spreadsheetRoute = [
'event' => 'action-progress',
'channel' => 'grp.personal.'.$this->group->id,
'route' => [
'upload' => [
'name' => 'grp.models.supplier.supplier-product.import',
'parameters' => [
'supplier' => $this->scope->id
]
],
],
];
}
Expand All @@ -258,7 +263,7 @@ public function htmlResponse(LengthAwarePaginator $supplier_products, ActionRequ
'subNavigation' => $subNavigation,
'actions' => $actions
],
'importRoutes' => $attachRoutes,
'upload_spreadsheet' => $spreadsheetRoute,
'data' => SupplierProductsResource::collection($supplier_products),
]
)->table($this->tableStructure());
Expand Down
9 changes: 9 additions & 0 deletions app/Http/Resources/Accounting/PaymentsResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ public function toArray($request): array
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
'amount' => $this->amount,
'route' => [
'name' => 'grp.org.accounting.payment-accounts.show.payments.show',
'params' => [
'organisation' => $this->organisation_slug,
'account' => $this->payment_accounts_slug,
'payment' => $this->id
]
],
'currency_code' => $this->currency_code,
'organisation_name' => $this->organisation_name,
'organisation_slug' => $this->organisation_slug,
'shop_name' => $this->shop_name,
Expand Down
2 changes: 1 addition & 1 deletion app/Models/CRM/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
* @property string|null $rejected_notes
* @property \Illuminate\Support\Carbon|null $rejected_at
* @property bool $is_vip VIP customer
* @property int|null $as_organisation_id Indicate if customer is a organisation in this group
* @property int|null $as_organisation_id Indicate customer is a organisation in this group
* @property int|null $as_employee_id Indicate customer is a employee
* @property-read Address|null $address
* @property-read Collection<int, Address> $addresses
Expand Down
2 changes: 2 additions & 0 deletions app/Models/Fulfilment/StoredItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Fulfilment\PalletReturn> $palletReturns
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Fulfilment\PalletStoredItem> $palletStoredItems
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Fulfilment\Pallet> $pallets
* @property-read Portfolio|null $portfolio
* @property-read \App\Models\Helpers\RetinaSearch|null $retinaSearch
* @property-read ShopifyUserHasProduct|null $shopifyPortfolio
* @property-read \App\Models\Helpers\UniversalSearch|null $universalSearch
* @property-read Warehouse|null $warehouse
* @method static Builder<static>|StoredItem newModelQuery()
Expand Down
4 changes: 2 additions & 2 deletions app/Models/Helpers/Upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*
* @property int $id
* @property int $group_id
* @property int $organisation_id
* @property int|null $organisation_id
* @property int|null $shop_id
* @property int|null $user_id
* @property string $model
Expand All @@ -47,7 +47,7 @@
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Helpers\Audit> $audits
* @property-read \App\Models\Helpers\TFactory|null $use_factory
* @property-read \App\Models\SysAdmin\Group $group
* @property-read \App\Models\SysAdmin\Organisation $organisation
* @property-read \App\Models\SysAdmin\Organisation|null $organisation
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Helpers\UploadRecord> $records
* @property-read \App\Models\Catalogue\Shop|null $shop
* @property-read User|null $user
Expand Down
7 changes: 6 additions & 1 deletion app/Models/ShopifyUserHasFulfilment.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property string $model_type
* @property string $state
* @property ShopifyFulfilmentStateEnum $state
* @property int|null $customer_client_id
* @property string|null $no_fulfilment_reason
* @property string|null $no_fulfilment_reason_notes
* @property ShopifyFulfilmentReasonEnum $reason
* @property-read CustomerClient|null $customerClient
* @property-read \Illuminate\Database\Eloquent\Model|\Eloquent $model
* @property-read ShopifyUser $shopifyUser
* @method static \Illuminate\Database\Eloquent\Builder<static>|ShopifyUserHasFulfilment newModelQuery()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
<?php

/*
* Author: Raul Perusquia <raul@inikoo.com>
* Created: Wed, 19 Feb 2025 13:20:43 Central Indonesia Time, Sanur, Bali, Indonesia
* Copyright (c) 2025, Raul A Perusquia Flores
*/

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class () extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
public function up(): void
{
Schema::table('shopify_user_has_fulfilments', function (Blueprint $table) {
$table->unsignedBigInteger('customer_client_id')->nullable();
$table->foreign('customer_client_id')->references('id')->on('customer_clients');
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()

public function down(): void
{
Schema::table('shopify_user_has_fulfilments', function (Blueprint $table) {
$table->dropForeign(['customer_client_id']);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
<?php

/*
* Author: Raul Perusquia <raul@inikoo.com>
* Created: Wed, 19 Feb 2025 13:28:45 Central Indonesia Time, Sanur, Bali, Indonesia
* Copyright (c) 2025, Raul A Perusquia Flores
*/

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class () extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
public function up(): void
{
Schema::table('shopify_user_has_fulfilments', function (Blueprint $table) {
$table->string('no_fulfilment_reason')->nullable();
$table->string('no_fulfilment_reason_notes')->nullable();
$table->text('no_fulfilment_reason_notes')->nullable();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()

public function down(): void
{
Schema::table('shopify_user_has_fulfilments', function (Blueprint $table) {
$table->dropColumn(['no_fulfilment_reason', 'no_fulfilment_reason_notes']);
Expand Down
Loading

0 comments on commit adc0232

Please sign in to comment.