Skip to content

Commit 304ba76

Browse files
authored
Merge pull request #2250 from Blair2004/v5.0.x
V5.0.x
2 parents 6497552 + 2f892ce commit 304ba76

File tree

120 files changed

+1077
-806
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+1077
-806
lines changed

app/Crud/ProductHistoryCrud.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ class ProductHistoryCrud extends CrudService
6161
*/
6262
public $relations = [
6363
[ 'nexopos_products as products', 'nexopos_products_histories.product_id', '=', 'products.id' ],
64-
[ 'nexopos_users as users', 'nexopos_products_histories.author', '=', 'users.id' ],
6564
[ 'nexopos_units as units', 'nexopos_products_histories.unit_id', '=', 'units.id' ],
6665
'leftJoin' => [
66+
[ 'nexopos_users as users', 'nexopos_products_histories.author', '=', 'users.id' ],
6767
[ 'nexopos_procurements as procurements', 'nexopos_products_histories.procurement_id', '=', 'procurements.id' ],
6868
[ 'nexopos_orders as orders', 'nexopos_products_histories.order_id', '=', 'orders.id' ],
6969
],

app/Http/Controllers/Dashboard/CrudController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ public function exportCrud( $namespace, Request $request )
409409
$writer->save( $fileName );
410410

411411
/**
412-
* We'll hide the asset URL behind random lettes
412+
* We'll hide the asset URL behind random letters
413413
*/
414414
$hash = Str::random( 20 );
415415

app/Http/Controllers/Dashboard/ModulesController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public function uploadModule( ModuleUploadRequest $request )
135135
} else {
136136
$validator = Validator::make( $request->all(), [] );
137137
$validator->errors()->add( 'module', $result[ 'message' ] );
138-
138+
139139
return redirect( ns()->route( 'ns.dashboard.modules-upload' ) )->withErrors( $validator );
140140
}
141141
}

app/Providers/AppServiceProvider.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
use App\Services\Validation;
3939
use App\Services\WidgetService;
4040
use Illuminate\Foundation\AliasLoader;
41+
use Illuminate\Queue\Events\JobProcessing;
4142
use Illuminate\Support\Facades\Auth;
4243
use Illuminate\Support\Facades\Blade;
4344
use Illuminate\Support\Facades\Event;
@@ -280,6 +281,14 @@ public function boot()
280281

281282
return "<?php echo ns()->moduleViteAssets( \"{$fileName}\", \"{$module}\" ); ?>";
282283
} );
284+
285+
/**
286+
* To ensure options are always refreshed
287+
* when a job is about to be processed.
288+
*/
289+
Event::listen( JobProcessing::class, function () {
290+
ns()->option->rebuild();
291+
} );
283292
}
284293

285294
/**

app/Providers/TelescopeServiceProvider.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@ protected function gate(): void
5959
{
6060
if ( Helper::installed() ) {
6161
$adminRole = Role::namespace( Role::ADMIN );
62-
$users = collect([]);
63-
62+
$users = collect( [] );
63+
6464
if ( $adminRole instanceof Role ) {
65-
$users = $adminRole->users;
65+
$users = $adminRole->users;
6666
}
67-
67+
6868
Gate::define( 'viewTelescope', function ( $user ) use ( $users ) {
6969
return in_array( $user->email, [
70-
$users->map( fn( $__user ) => $__user->email )
70+
$users->map( fn( $__user ) => $__user->email ),
7171
] );
7272
} );
7373
}

app/Services/MenuService.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -480,15 +480,15 @@ public function getMenus()
480480
$this->menus = Hook::filter( 'ns-dashboard-menus', $this->menus );
481481
$this->toggleActive();
482482

483-
return collect( $this->menus )->filter( function( $menu ) {
483+
return collect( $this->menus )->filter( function ( $menu ) {
484484
return ! isset( $menu[ 'permissions' ] ) || Gate::any( $menu[ 'permissions' ] );
485-
})->map( function( $menu ) {
486-
$menu[ 'childrens' ] = collect( $menu[ 'childrens' ] ?? [] )->filter( function( $submenu ) {
485+
} )->map( function ( $menu ) {
486+
$menu[ 'childrens' ] = collect( $menu[ 'childrens' ] ?? [] )->filter( function ( $submenu ) {
487487
return ! isset( $submenu[ 'permissions' ] ) || Gate::any( $submenu[ 'permissions' ] );
488-
})->toArray();
488+
} )->toArray();
489489

490490
return $menu;
491-
});
491+
} );
492492
}
493493

494494
/**

app/Services/ProductService.php

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ public function saveSubItems( Product $product, $subItems )
528528
$subitem->sale_price = $item[ 'sale_price' ];
529529
$subitem->quantity = $item[ 'quantity' ];
530530
$subitem->total_price = $item[ 'total_price' ] ?? (float) $item[ 'sale_price' ] * (float) $item[ 'quantity' ];
531-
$subitem->author = Auth::id();
531+
$subitem->author = $product->author;
532532
$subitem->save();
533533
} else {
534534
$subitem = ProductSubItem::find( $item[ 'id' ] );
@@ -544,7 +544,7 @@ public function saveSubItems( Product $product, $subItems )
544544
$subitem->sale_price = $item[ 'sale_price' ];
545545
$subitem->quantity = $item[ 'quantity' ];
546546
$subitem->total_price = $item[ 'total_price' ] ?? (float) $item[ 'sale_price' ] * (float) $item[ 'quantity' ];
547-
$subitem->author = Auth::id();
547+
$subitem->author = $product->author;
548548
$subitem->save();
549549
}
550550

@@ -1178,6 +1178,7 @@ public function stockAdjustment( $action, $data ): ProductHistory|EloquentCollec
11781178
* @param float $quantity
11791179
* @param string $sku
11801180
* @param string $unit_identifier
1181+
* @param int $author
11811182
*/
11821183
$product = isset( $product_id ) ? Product::find( $product_id ) : Product::usingSKU( $sku )->first();
11831184

@@ -1225,7 +1226,8 @@ public function stockAdjustment( $action, $data ): ProductHistory|EloquentCollec
12251226
orderProductQuantity: $quantity,
12261227
product: $product,
12271228
orderProduct: isset( $orderProduct ) ? $orderProduct : null,
1228-
parentUnit: $unit
1229+
parentUnit: $unit,
1230+
author: $author ?? 0,
12291231
);
12301232
} else {
12311233
return $this->handleStockAdjustmentRegularProducts(
@@ -1236,7 +1238,8 @@ public function stockAdjustment( $action, $data ): ProductHistory|EloquentCollec
12361238
total_price: $total_price,
12371239
unit_price: $unit_price,
12381240
orderProduct: isset( $orderProduct ) ? $orderProduct : null,
1239-
procurementProduct: isset( $procurementProduct ) ? $procurementProduct : null
1241+
procurementProduct: isset( $procurementProduct ) ? $procurementProduct : null,
1242+
author: $author ?? 0,
12401243
);
12411244
}
12421245
}
@@ -1256,6 +1259,7 @@ private function handleStockAdjustmentsForGroupedProducts(
12561259
$orderProductQuantity,
12571260
Product $product,
12581261
Unit $parentUnit,
1262+
int $author = 0,
12591263
?OrderProduct $orderProduct = null ): EloquentCollection
12601264
{
12611265
$product->load( 'sub_items' );
@@ -1264,7 +1268,7 @@ private function handleStockAdjustmentsForGroupedProducts(
12641268
throw new Exception( __( 'Adjusting grouped product inventory must result of a create, update, delete sale operation.' ) );
12651269
}
12661270

1267-
$products = $product->sub_items->map( function ( ProductSubItem $subItem ) use ( $action, $orderProductQuantity, $parentUnit, $orderProduct ) {
1271+
$products = $product->sub_items->map( function ( ProductSubItem $subItem ) use ( $author, $action, $orderProductQuantity, $parentUnit, $orderProduct ) {
12681272
$finalQuantity = $this->computeSubItemQuantity(
12691273
subItemQuantity: $subItem->quantity,
12701274
parentUnit: $parentUnit,
@@ -1314,6 +1318,7 @@ private function handleStockAdjustmentsForGroupedProducts(
13141318
return $this->recordStockHistory(
13151319
product_id: $subItem->product_id,
13161320
action: $action,
1321+
author: $author,
13171322
unit_id: $subItem->unit_id,
13181323
unit_price: $subItem->sale_price,
13191324
quantity: $finalQuantity,
@@ -1332,6 +1337,7 @@ private function handleStockAdjustmentsForGroupedProducts(
13321337
$this->recordStockHistory(
13331338
product_id: $product->id,
13341339
action: $action,
1340+
author: $author,
13351341
unit_id: $orderProduct->unit_id,
13361342
unit_price: $orderProduct->unit_price,
13371343
quantity: $orderProductQuantity,
@@ -1382,7 +1388,7 @@ private function preventNegativity( $oldQuantity, $quantity )
13821388
* @param ProcurementProduct $procurementProduct
13831389
* @return ProductHistory
13841390
*/
1385-
private function handleStockAdjustmentRegularProducts( $action, $quantity, $product_id, $unit_id, $orderProduct = null, $unit_price = 0, $total_price = 0, $procurementProduct = null )
1391+
private function handleStockAdjustmentRegularProducts( $action, $quantity, $product_id, $unit_id, $author = 0, $orderProduct = null, $unit_price = 0, $total_price = 0, $procurementProduct = null )
13861392
{
13871393
/**
13881394
* we would like to verify if
@@ -1433,6 +1439,7 @@ private function handleStockAdjustmentRegularProducts( $action, $quantity, $prod
14331439

14341440
return $this->recordStockHistory(
14351441
product_id: $product_id,
1442+
author: $author,
14361443
action: $action,
14371444
unit_id: $unit_id,
14381445
unit_price: $unit_price,
@@ -1478,6 +1485,7 @@ private function handleStockAdjustmentRegularProducts( $action, $quantity, $prod
14781485
return $this->recordStockHistory(
14791486
product_id: $product_id,
14801487
action: $action,
1488+
author: $author,
14811489
unit_id: $unit_id,
14821490
unit_price: $unit_price,
14831491
quantity: $adjustQuantity,
@@ -1518,6 +1526,7 @@ public function recordStockHistory(
15181526
$unit_price,
15191527
$quantity,
15201528
$total_price,
1529+
$author = 0,
15211530
$order_id = null,
15221531
$order_product_id = null,
15231532
$procurement_product_id = null,
@@ -1539,7 +1548,7 @@ public function recordStockHistory(
15391548
$history->before_quantity = $old_quantity; // if the stock management is 0, it shouldn't change
15401549
$history->quantity = abs( $quantity );
15411550
$history->after_quantity = $new_quantity; // if the stock management is 0, it shouldn't change
1542-
$history->author = Auth::id();
1551+
$history->author = $author ?: Auth::id();
15431552
$history->save();
15441553

15451554
event( new ProductAfterStockAdjustmentEvent( $history ) );
@@ -1839,7 +1848,7 @@ public function createProductVariation( Product $parent, $fields )
18391848
$this->__fillProductFields( $product, compact( 'field', 'value', 'mode', 'fields' ) );
18401849
}
18411850

1842-
$product->author = Auth::id();
1851+
$product->author = $parent->author;
18431852
$product->parent_id = $parent->id;
18441853
$product->type = $parent->type;
18451854
$product->category_id = $parent->category_id;
@@ -1848,11 +1857,6 @@ public function createProductVariation( Product $parent, $fields )
18481857

18491858
event( new ProductAfterCreatedEvent( $product ) );
18501859

1851-
/**
1852-
* compute product tax
1853-
*/
1854-
// $this->taxService->computeTax( $product, $fields[ 'tax_group_id' ] ?? null );
1855-
18561860
return [
18571861
'status' => 'success',
18581862
'message' => __( 'The product variation has been successfully created.' ),
@@ -1884,7 +1888,7 @@ public function updateProductVariation( $parent, $id, $fields )
18841888
$this->__fillProductFields( $product, compact( 'field', 'value', 'mode', 'fields' ) );
18851889
}
18861890

1887-
$product->author = Auth::id();
1891+
$product->author = $parent->author;
18881892
$product->parent_id = $parent->id;
18891893
$product->type = $parent->type;
18901894
$product->product_type = 'variation';

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@
7777
"post-install-cmd": [
7878
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\"",
7979
"@php artisan key:generate --ansi",
80-
"@php -r \"file_exists('public/storage');\" || artisan storage:link --ansi"
80+
"@php -r \"file_exists('public/storage');\" || artisan storage:link --ansi",
81+
"@php artisan ns:translate --symlink"
8182
],
8283
"post-update-cmd": [
8384
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"

config/nexopos.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* This is the core version of NexoPOS. This is used to displays on the
1010
* dashboard and to ensure a compatibility with the modules.
1111
*/
12-
'version' => '5.3.6',
12+
'version' => '5.3.7',
1313

1414
/**
1515
* --------------------------------------------------------------------

config/sanctum.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
|
1616
*/
1717

18-
'stateful' => explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf(
18+
'stateful' => explode( ',', env( 'SANCTUM_STATEFUL_DOMAINS', sprintf(
1919
'%s%s',
2020
'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1',
2121
Sanctum::currentApplicationUrlWithPort()
22-
))),
22+
) ) ),
2323

2424
/*
2525
|--------------------------------------------------------------------------
@@ -61,7 +61,7 @@
6161
|
6262
*/
6363

64-
'token_prefix' => env('SANCTUM_TOKEN_PREFIX', ''),
64+
'token_prefix' => env( 'SANCTUM_TOKEN_PREFIX', '' ),
6565

6666
/*
6767
|--------------------------------------------------------------------------

0 commit comments

Comments
 (0)