Skip to content

Commit

Permalink
Closing 4.3.1
Browse files Browse the repository at this point in the history
- Updated : display item price when a product has a single unit
  • Loading branch information
Blair2004 committed Jun 16, 2021
1 parent 9f43430 commit caae6c2
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 25 deletions.
18 changes: 11 additions & 7 deletions app/Console/Commands/ResetCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,6 @@ public function __construct(
*/
public function handle()
{
if ( $this->option( 'user' ) === 'default' ) {
$user = Role::namespace( 'admin' )->users->first();
Auth::loginUsingId( $user->id );
} else {
Auth::loginUsingId( $this->option( 'user' ) );
}

switch( $this->option( 'mode' ) ) {
case 'soft':
return $this->softReset();
Expand All @@ -76,12 +69,23 @@ public function handle()
break;
case 'grocery':
$this->softReset();
$this->initializeRole();
$this->demoService->run();
$this->info( __( 'The demo has been enabled.' ) );
break;
}
}

private function initializeRole()
{
if ( $this->option( 'user' ) === 'default' ) {
$user = Role::namespace( 'admin' )->users->first();
Auth::loginUsingId( $user->id );
} else {
Auth::loginUsingId( $this->option( 'user' ) );
}
}

/**
* Proceed hard reset
* @return void
Expand Down
9 changes: 8 additions & 1 deletion app/Http/Controllers/Dashboard/CategoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,14 @@ public function getCategories( $id = '0' )
->with( 'galleries' )
->searchable()
->trackingDisabled()
->get(),
->get()
->map( function( $product ) {
if ( $product->unit_quantities()->count() === 1 ) {
$product->load( 'unit_quantities.unit' );
}

return $product;
}),
'categories' => $category
->subCategories()
->displayOnPOS()
Expand Down
1 change: 1 addition & 0 deletions app/Services/MenuService.php
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ public function buildMenus()
'nexopos.reports.yearly',
'nexopos.reports.customers',
'nexopos.reports.inventory',
'nexopos.reports.payment-types',
],
'childrens' => [
'sales' => [
Expand Down
3 changes: 2 additions & 1 deletion resources/ts/pages/dashboard/pos/ns-pos-grid.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@
<i v-if="! data.galleries || data.galleries.filter( i => i.featured === 1 ).length === 0" class="las la-image text-gray-600 text-6xl"></i>
</div>
<div class="h-0 w-full">
<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%)">
<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%)">
<h3 class="text-sm text-gray-700 text-center w-full">{{ data.name }}</h3>
<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>
</div>
</div>
</div>
Expand Down
39 changes: 23 additions & 16 deletions resources/ts/popups/ns-pos-units.vue
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
<template>
<div class="bg-white w-2/3-screen lg:w-1/3-screen overflow-hidden flex flex-col" v-if="loadsUnits">
<div id="header" class="h-16 flex justify-center items-center flex-shrink-0">
<h3 class="font-bold text-gray-700">{{ __( 'Choose Selling Unit' ) }}</h3>
</div>
<div v-if="unitsQuantities.length > 0" class="grid grid-flow-row grid-cols-2 overflow-y-auto">
<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">
<div class="h-40 w-full flex items-center justify-center overflow-hidden">
<img v-if="unitQuantity.preview_url" :src="unitQuantity.preview_url" class="object-cover h-full" :alt="unitQuantity.unit.name">
<div class="h-40 flex items-center justify-center" v-if="! unitQuantity.preview_url">
<i class="las la-image text-gray-600 text-6xl"></i>
<div class="h-full w-full flex items-center justify-center">
<div class="bg-white w-2/3-screen lg:w-1/3-screen overflow-hidden flex flex-col" v-if="unitsQuantities.length > 0">
<div id="header" class="h-16 flex justify-center items-center flex-shrink-0">
<h3 class="font-bold text-gray-700">{{ __( 'Choose Selling Unit' ) }}</h3>
</div>
<div v-if="unitsQuantities.length > 0" class="grid grid-flow-row grid-cols-2 overflow-y-auto">
<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">
<div class="h-40 w-full flex items-center justify-center overflow-hidden">
<img v-if="unitQuantity.preview_url" :src="unitQuantity.preview_url" class="object-cover h-full" :alt="unitQuantity.unit.name">
<div class="h-40 flex items-center justify-center" v-if="! unitQuantity.preview_url">
<i class="las la-image text-gray-600 text-6xl"></i>
</div>
</div>
</div>
<div class="h-0 w-full">
<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%)">
<h3 class="font-bold text-gray-700 py-2 text-center">{{ unitQuantity.unit.name }} ({{ unitQuantity .quantity }})</h3>
<p class="text-sm font-medium text-gray-600">{{ unitQuantity.sale_price | currency }}</p>
<div class="h-0 w-full">
<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%)">
<h3 class="font-bold text-gray-700 py-2 text-center">{{ unitQuantity.unit.name }} ({{ unitQuantity .quantity }})</h3>
<p class="text-sm font-medium text-gray-600">{{ unitQuantity.sale_price | currency }}</p>
</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -60,6 +62,11 @@ export default {
*/
if ( this.$popupParams.product.$original().selectedUnitQuantity !== undefined ) {
this.selectUnit( this.$popupParams.product.$original().selectedUnitQuantity );
} else if (
this.$popupParams.product.$original().unit_quantities !== undefined &&
this.$popupParams.product.$original().unit_quantities.length === 1
) {
this.selectUnit( this.$popupParams.product.$original().unit_quantities[0] );
} else {
this.loadsUnits = true;
this.loadUnits();
Expand All @@ -73,7 +80,7 @@ export default {
if ( result.length === 0 ) {
this.$popup.close();
return nsSnackBar.error( __( 'This product doesn\'t has any unit defined for selling.' ) ).subscribe();
return nsSnackBar.error( __( 'This product doesn\'t have any unit defined for selling.' ) ).subscribe();
}
this.unitsQuantities = result;
Expand Down
2 changes: 2 additions & 0 deletions resources/ts/pos-init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,8 @@ export class POS {
*/
async addToCart( product ) {

console.log( product );

/**
* This is where all the mutation made by the
* queue promises are stored.
Expand Down

0 comments on commit caae6c2

Please sign in to comment.