Skip to content

Commit e8c0c3b

Browse files
committed
Update
- Fixed : Instalment crud list using a wrong pivot attribute - Fixed : Stock adjustment issue (adding stock) fixes #207 - Fixes #208 - Fixed : unable to load the product reports. - Fixed : some adjustment on the products reports.
1 parent 8440ff4 commit e8c0c3b

File tree

6 files changed

+26
-19
lines changed

6 files changed

+26
-19
lines changed

app/Crud/OrderInstalmentCrud.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class OrderInstalmentCrud extends CrudService
5555
*/
5656
public $relations = [
5757
[ 'nexopos_orders as order', 'order.id', '=', 'nexopos_orders_instalments.order_id' ],
58-
[ 'nexopos_customers as customer', 'customer.id', '=', 'order.id' ],
58+
[ 'nexopos_customers as customer', 'customer.id', '=', 'order.customer_id' ],
5959
];
6060

6161
/**
@@ -416,7 +416,7 @@ public function getLinks()
416416
{
417417
return [
418418
'list' => ns()->url( 'dashboard/' . 'orders/instalments' ),
419-
'create' => ns()->url( 'dashboard/' . 'orders/instalments/create' ),
419+
'create' => 'javascript:void(0)',
420420
'edit' => ns()->url( 'dashboard/' . 'orders/instalments/edit/' ),
421421
'post' => ns()->url( 'api/nexopos/v4/crud/' . 'ns.orders-instalments' ),
422422
'put' => ns()->url( 'api/nexopos/v4/crud/' . 'ns.orders-instalments/{id}' . '' ),

app/Crud/RolesCrud.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ public function getForm( $entry = null )
150150
'validation' => 'required',
151151
'options' => Helper::kvToJsOptions( Hook::filter( 'ns-dashboard-identifiers', [
152152
'store' => __( 'Store Dashboard' ),
153-
'cashier' => __( 'Cashier Dashboard' )
153+
'cashier' => __( 'Cashier Dashboard' ),
154+
'default' => __( 'Default Dashboard' ),
154155
])),
155156
'description' => __( 'Define what should be the home page of the dashboard.' ),
156157
'value' => $entry->dashid ?? '',

app/Services/ReportService.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -560,10 +560,11 @@ private function getDiff( $old, $new ) {
560560
*/
561561
private function computeDiff( $old, $new, $operation )
562562
{
563-
if ( $operation === 'decrease' ) {
564-
return ( ( $old - $new ) / $old ) * 100;
563+
if ( $new == 0 ) {
564+
return 100;
565565
} else {
566-
return ( ( $new - $old ) / $old ) * 100;
566+
$change = ( ( $old - $new ) / $new ) * 100;
567+
return $operation === 'increase' ? abs( $change ) : $change;
567568
}
568569
}
569570

@@ -632,16 +633,14 @@ private function getBestRecords( $previousDates, $sort )
632633
$orderProductTable . '.unit_name as unit_name',
633634
$orderProductTable . '.product_id as product_id',
634635
$orderProductTable . '.name as name',
635-
$orderTable . '.created_at as created_at',
636636
DB::raw( 'SUM( quantity ) as quantity' ),
637637
DB::raw( 'SUM( total_price ) as total_price' ),
638638
DB::raw( 'SUM( ' . env( 'DB_PREFIX' ) . $orderProductTable . '.tax_value ) as tax_value' ),
639639
])
640640
->groupBy(
641641
$orderProductTable . '.unit_name',
642642
$orderProductTable . '.product_id',
643-
$orderProductTable . '.name',
644-
$orderTable . '.created_at',
643+
$orderProductTable . '.name'
645644
)
646645
->orderBy( $sorting[ 'column' ], $sorting[ 'direction' ] )
647646
->join( $orderTable, $orderTable . '.id', '=', $orderProductTable . '.order_id' )
@@ -657,9 +656,10 @@ private function getBestRecords( $previousDates, $sort )
657656
foreach( $previousDates[ 'current' ][ 'products' ] as $id => &$product ) {
658657
$default = new stdClass;
659658
$default->total_price = 0;
659+
$default->quantity = 0;
660660

661-
$oldProduct = collect( $previousDates[ 'previous' ][ 'products' ] )->filter( function( $product ) use ( $id ) {
662-
return $product->product_id === $id;
661+
$oldProduct = collect( $previousDates[ 'previous' ][ 'products' ] )->filter( function( $previousProduct ) use ( $product ) {
662+
return $previousProduct->product_id === $product->product_id;
663663
})->first() ?: $default;
664664

665665
$product->old_total_price = $oldProduct->total_price;
@@ -669,7 +669,7 @@ private function getBestRecords( $previousDates, $sort )
669669
$product->total_price
670670
) : 100;
671671

672-
$product->evolution = $product->total_price > $oldProduct->total_price ? 'progress' : 'regress';
672+
$product->evolution = $product->quantity > $oldProduct->quantity ? 'progress' : 'regress';
673673
}
674674

675675
$previousDates[ 'current' ][ 'total_price' ] = collect( $previousDates[ 'current' ][ 'products' ] )

resources/ts/pages/dashboard/products/ns-stock-adjustment.vue

+10-4
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,16 @@ export default {
133133
});
134134
135135
promise.then( result => {
136-
if ( product.accurate_tracking !== undefined && result.quantity > product.available_quantity ) {
137-
return nsSnackBar.error( __( 'The specified quantity exceed the available quantity.' ) ).subscribe();
138-
} else if ( result.quantity > product.adjust_unit.quantity ) {
139-
return nsSnackBar.error( __( 'The specified quantity exceed the available quantity.' ) ).subscribe();
136+
/**
137+
* will check the stock if the adjustment
138+
* reduce the stock.
139+
*/
140+
if ( ! [ 'added' ].includes( product.adjust_action ) ) {
141+
if ( product.accurate_tracking !== undefined && result.quantity > product.available_quantity ) {
142+
return nsSnackBar.error( __( 'The specified quantity exceed the available quantity.' ) ).subscribe();
143+
} else if ( result.quantity > product.adjust_unit.quantity ) {
144+
return nsSnackBar.error( __( 'The specified quantity exceed the available quantity.' ) ).subscribe();
145+
}
140146
}
141147
142148
product.adjust_quantity = result.quantity;

resources/ts/pages/dashboard/reports/ns-best-products-report.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export default {
4141
const startDate = moment( this.startDate );
4242
const endDate = moment( this.endDate );
4343
44-
nsHttpClient.post( '/api/nexopos/v4/reports/best-products', {
44+
nsHttpClient.post( '/api/nexopos/v4/reports/products-report', {
4545
startDate : startDate.format( 'YYYY/MM/DD HH:mm' ),
4646
endDate : endDate.format( 'YYYY/MM/DD HH:mm' ),
4747
sort: this.sort

resources/views/layout/dashboard.blade.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
<body>
5252
<div class="h-full w-full flex flex-col">
5353
<div id="dashboard-body" class="overflow-hidden flex flex-auto">
54-
<div id="dashboard-aside" v-cloak v-if="sidebar === 'visible'" class="w-64 z-10 absolute md:static flex-shrink-0 bg-gray-900 h-full flex-col overflow-hidden">
54+
<div id="dashboard-aside" v-cloak v-if="sidebar === 'visible'" class="w-64 z-50 absolute md:static flex-shrink-0 bg-gray-900 h-full flex-col overflow-hidden">
5555
<div class="overflow-y-auto h-full text-sm">
5656
<div class="logo py-4 flex justify-center items-center">
5757
@if ( ns()->option->get( 'ns_store_rectangle_logo' ) )
@@ -77,7 +77,7 @@
7777
</ul>
7878
</div>
7979
</div>
80-
<div id="dashboard-overlay" v-if="sidebar === 'visible'" @click="closeMenu()" class="w-full h-full md:hidden absolute" style="background: rgb(51 51 51 / 25%)"></div>
80+
<div id="dashboard-overlay" v-if="sidebar === 'visible'" @click="closeMenu()" class="z-40 w-full h-full md:hidden absolute" style="background: rgb(51 51 51 / 25%)"></div>
8181
<div class="flex flex-auto overflow-hidden bg-gray-200">
8282
<div class="overflow-y-auto flex-auto">
8383
@yield( 'layout.dashboard.body', View::make( 'common.dashboard.with-header' ) )

0 commit comments

Comments
 (0)