Skip to content

Commit caae6c2

Browse files
committed
Closing 4.3.1
- Updated : display item price when a product has a single unit
1 parent 9f43430 commit caae6c2

File tree

6 files changed

+47
-25
lines changed

6 files changed

+47
-25
lines changed

app/Console/Commands/ResetCommand.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,6 @@ public function __construct(
6060
*/
6161
public function handle()
6262
{
63-
if ( $this->option( 'user' ) === 'default' ) {
64-
$user = Role::namespace( 'admin' )->users->first();
65-
Auth::loginUsingId( $user->id );
66-
} else {
67-
Auth::loginUsingId( $this->option( 'user' ) );
68-
}
69-
7063
switch( $this->option( 'mode' ) ) {
7164
case 'soft':
7265
return $this->softReset();
@@ -76,12 +69,23 @@ public function handle()
7669
break;
7770
case 'grocery':
7871
$this->softReset();
72+
$this->initializeRole();
7973
$this->demoService->run();
8074
$this->info( __( 'The demo has been enabled.' ) );
8175
break;
8276
}
8377
}
8478

79+
private function initializeRole()
80+
{
81+
if ( $this->option( 'user' ) === 'default' ) {
82+
$user = Role::namespace( 'admin' )->users->first();
83+
Auth::loginUsingId( $user->id );
84+
} else {
85+
Auth::loginUsingId( $this->option( 'user' ) );
86+
}
87+
}
88+
8589
/**
8690
* Proceed hard reset
8791
* @return void

app/Http/Controllers/Dashboard/CategoryController.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,14 @@ public function getCategories( $id = '0' )
223223
->with( 'galleries' )
224224
->searchable()
225225
->trackingDisabled()
226-
->get(),
226+
->get()
227+
->map( function( $product ) {
228+
if ( $product->unit_quantities()->count() === 1 ) {
229+
$product->load( 'unit_quantities.unit' );
230+
}
231+
232+
return $product;
233+
}),
227234
'categories' => $category
228235
->subCategories()
229236
->displayOnPOS()

app/Services/MenuService.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ public function buildMenus()
350350
'nexopos.reports.yearly',
351351
'nexopos.reports.customers',
352352
'nexopos.reports.inventory',
353+
'nexopos.reports.payment-types',
353354
],
354355
'childrens' => [
355356
'sales' => [

resources/ts/pages/dashboard/pos/ns-pos-grid.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@
6969
<i v-if="! data.galleries || data.galleries.filter( i => i.featured === 1 ).length === 0" class="las la-image text-gray-600 text-6xl"></i>
7070
</div>
7171
<div class="h-0 w-full">
72-
<div class="relative w-full flex flex-col items-start justify-center -top-10 h-20 p-2" style="background:rgb(255 255 255 / 73%)">
72+
<div class="relative w-full flex flex-col items-center justify-center -top-10 h-20 p-2" style="background:rgb(255 255 255 / 73%)">
7373
<h3 class="text-sm text-gray-700 text-center w-full">{{ data.name }}</h3>
74+
<span class="text-sm text-gray-600" v-if="data.unit_quantities && data.unit_quantities.length === 1">{{ data.unit_quantities[0].sale_price | currency }}</span>
7475
</div>
7576
</div>
7677
</div>

resources/ts/popups/ns-pos-units.vue

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
<template>
2-
<div class="bg-white w-2/3-screen lg:w-1/3-screen overflow-hidden flex flex-col" v-if="loadsUnits">
3-
<div id="header" class="h-16 flex justify-center items-center flex-shrink-0">
4-
<h3 class="font-bold text-gray-700">{{ __( 'Choose Selling Unit' ) }}</h3>
5-
</div>
6-
<div v-if="unitsQuantities.length > 0" class="grid grid-flow-row grid-cols-2 overflow-y-auto">
7-
<div @click="selectUnit( unitQuantity )" :key="unitQuantity.id" v-for="unitQuantity of unitsQuantities" class="hover:bg-gray-200 cursor-pointer border flex-shrink-0 border-gray-200 flex flex-col items-center justify-center">
8-
<div class="h-40 w-full flex items-center justify-center overflow-hidden">
9-
<img v-if="unitQuantity.preview_url" :src="unitQuantity.preview_url" class="object-cover h-full" :alt="unitQuantity.unit.name">
10-
<div class="h-40 flex items-center justify-center" v-if="! unitQuantity.preview_url">
11-
<i class="las la-image text-gray-600 text-6xl"></i>
2+
<div class="h-full w-full flex items-center justify-center">
3+
<div class="bg-white w-2/3-screen lg:w-1/3-screen overflow-hidden flex flex-col" v-if="unitsQuantities.length > 0">
4+
<div id="header" class="h-16 flex justify-center items-center flex-shrink-0">
5+
<h3 class="font-bold text-gray-700">{{ __( 'Choose Selling Unit' ) }}</h3>
6+
</div>
7+
<div v-if="unitsQuantities.length > 0" class="grid grid-flow-row grid-cols-2 overflow-y-auto">
8+
<div @click="selectUnit( unitQuantity )" :key="unitQuantity.id" v-for="unitQuantity of unitsQuantities" class="hover:bg-gray-200 cursor-pointer border flex-shrink-0 border-gray-200 flex flex-col items-center justify-center">
9+
<div class="h-40 w-full flex items-center justify-center overflow-hidden">
10+
<img v-if="unitQuantity.preview_url" :src="unitQuantity.preview_url" class="object-cover h-full" :alt="unitQuantity.unit.name">
11+
<div class="h-40 flex items-center justify-center" v-if="! unitQuantity.preview_url">
12+
<i class="las la-image text-gray-600 text-6xl"></i>
13+
</div>
1214
</div>
13-
</div>
14-
<div class="h-0 w-full">
15-
<div class="relative w-full flex items-center justify-center -top-10 h-20 py-2 flex-col" style="background:rgb(255 255 255 / 73%)">
16-
<h3 class="font-bold text-gray-700 py-2 text-center">{{ unitQuantity.unit.name }} ({{ unitQuantity .quantity }})</h3>
17-
<p class="text-sm font-medium text-gray-600">{{ unitQuantity.sale_price | currency }}</p>
15+
<div class="h-0 w-full">
16+
<div class="relative w-full flex items-center justify-center -top-10 h-20 py-2 flex-col" style="background:rgb(255 255 255 / 73%)">
17+
<h3 class="font-bold text-gray-700 py-2 text-center">{{ unitQuantity.unit.name }} ({{ unitQuantity .quantity }})</h3>
18+
<p class="text-sm font-medium text-gray-600">{{ unitQuantity.sale_price | currency }}</p>
19+
</div>
1820
</div>
1921
</div>
2022
</div>
@@ -60,6 +62,11 @@ export default {
6062
*/
6163
if ( this.$popupParams.product.$original().selectedUnitQuantity !== undefined ) {
6264
this.selectUnit( this.$popupParams.product.$original().selectedUnitQuantity );
65+
} else if (
66+
this.$popupParams.product.$original().unit_quantities !== undefined &&
67+
this.$popupParams.product.$original().unit_quantities.length === 1
68+
) {
69+
this.selectUnit( this.$popupParams.product.$original().unit_quantities[0] );
6370
} else {
6471
this.loadsUnits = true;
6572
this.loadUnits();
@@ -73,7 +80,7 @@ export default {
7380
7481
if ( result.length === 0 ) {
7582
this.$popup.close();
76-
return nsSnackBar.error( __( 'This product doesn\'t has any unit defined for selling.' ) ).subscribe();
83+
return nsSnackBar.error( __( 'This product doesn\'t have any unit defined for selling.' ) ).subscribe();
7784
}
7885
7986
this.unitsQuantities = result;

resources/ts/pos-init.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,8 @@ export class POS {
981981
*/
982982
async addToCart( product ) {
983983

984+
console.log( product );
985+
984986
/**
985987
* This is where all the mutation made by the
986988
* queue promises are stored.

0 commit comments

Comments
 (0)