Skip to content

Commit 6238cb6

Browse files
authored
Merge pull request #259 from Blair2004/v4.4.x
v4.4.2
2 parents d5ead66 + 72a9845 commit 6238cb6

Some content is hidden

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

44 files changed

+166
-241
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ public/export/*
2121
!public/export/index.html
2222
!public/modules/index.html
2323
public/js/*.js
24+
!public/js/*.min.js
25+
!public/js/vendor.js
26+
!public/js/manifest.js
2427
public/css/*.css
28+
!public/css/app.css
2529
public/js/*.map
2630
public/js/*.txt
2731
public/css/*.map

app/Classes/Schema.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ public static function table( $table, $callback )
1010
return parent::table( Hook::filter( 'ns-table-name', $table ), $callback );
1111
}
1212

13+
public static function rename( $previous, $new )
14+
{
15+
return parent::rename( Hook::filter( 'ns-table-name', $previous ), Hook::filter( 'ns-table-name', $new ) );
16+
}
17+
1318
public static function create( $table, $callback )
1419
{
1520
return parent::create( Hook::filter( 'ns-table-name', $table ), $callback );

app/Services/CoreService.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,4 +204,14 @@ public function purgeMissingMigrations()
204204
Migration::where( 'migration', $diff )->delete();
205205
}
206206
}
207+
208+
/**
209+
* Returns a boolean if the environment is
210+
* on production mode
211+
* @return boolean
212+
*/
213+
public function isProduction()
214+
{
215+
return in_array( env( 'NS_ENV', 'prod' ), [ 'prod', 'production' ]);
216+
}
207217
}

app/Services/CustomerService.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,9 +524,11 @@ public function updateCustomerOwedAmount( Customer $customer )
524524
* Change here will be negative, so we
525525
* want to be an absolute value.
526526
*/
527-
$change = abs( Order::whereIn( 'payment_status', [
527+
$orders = Order::whereIn( 'payment_status', [
528528
Order::PAYMENT_PARTIALLY
529-
])->sum( 'change' ) );
529+
]);
530+
531+
$change = abs( $orders->sum( 'change' ) );
530532

531533
$customer->owed_amount = ns()->currency->getRaw( $unpaid + $change );
532534
$customer->save();

app/Services/OrdersService.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ public function __checkProvidedInstalments( $fields )
289289
}
290290
}
291291

292-
if ( $total < ( float ) $fields[ 'total' ] ) {
292+
if ( $total < ns()->currency->getRaw( ( float ) $fields[ 'total' ] ) ) {
293293
throw new NotAllowedException( __( 'Unable to save an order with instalments amounts which additionnated is less than the order total.' ) );
294294
}
295295

@@ -944,7 +944,7 @@ private function __computeOrderTotal($data)
944944
/**
945945
* compute change
946946
*/
947-
$order->change = $this->currencyService->getRaw( $order->tendered - $order->total );
947+
$order->change = Currency::raw( $order->tendered - $order->total );
948948

949949
/**
950950
* compute gross total
@@ -1669,7 +1669,7 @@ public function computeOrderProduct( OrderProduct $orderProduct )
16691669
public function computeDiscountValues( $rate, $value )
16701670
{
16711671
if ( $rate > 0 ) {
1672-
return ( $value * $rate ) / 100;
1672+
return Currency::raw( ( $value * $rate ) / 100 );
16731673
}
16741674

16751675
return 0;
@@ -1847,7 +1847,7 @@ public function refreshOrder(Order $order)
18471847
$order->discount = $this->computeOrderDiscount( $order );
18481848
$order->total = ( $productTotal + $orderShipping ) - ( $order->discount + $order->total_coupons );
18491849
$order->tax_value = $productsTotalTaxes;
1850-
$order->change = $order->tendered - $order->total;
1850+
$order->change = Currency::raw( $order->tendered - $order->total );
18511851

18521852
$refunds = $order->refund;
18531853
$totalRefunds = $refunds->map( fn( $refund ) => $refund->total )->sum();

app/Services/Setup.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ public function runMigration( $fields )
201201
DotenvEditor::setKey( 'NS_SOCKET_DOMAIN', $domain[ 'basename' ] );
202202
DotenvEditor::setKey( 'SANCTUM_STATEFUL_DOMAINS', $domain[ 'basename' ] );
203203
DotenvEditor::setKey( 'NS_SOCKET_ENABLED', 'false' );
204+
DotenvEditor::setKey( 'NS_ENV', 'production' );
204205
DotenvEditor::save();
205206

206207

config/broadcasting.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
'app_id' => env('PUSHER_APP_ID'),
3838
'options' => [
3939
'cluster' => env('PUSHER_APP_CLUSTER'),
40-
'useTLS' => false, // env( 'NS_SOCKET_SECURED', false ) ? true : false,
40+
'useTLS' => env( 'NS_SOCKET_SECURED', false ) ? true : false,
4141
'host' => env( 'NS_SOCKET_DOMAIN', env( 'SESSION_DOMAIN' ) ),
4242
'port' => env( 'NS_SOCKET_PORT', 6001 ),
4343
'scheme' => env( 'NS_SOCKET_SCHEME', 'http' ),

config/nexopos.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
return [
3-
'version' => '4.4.1',
3+
'version' => '4.4.2',
44
'languages' => [
55
'en' => 'English',
66
'fr' => 'Français',

config/websockets.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Set a custom dashboard configuration
99
*/
1010
'dashboard' => [
11-
'port' => env('LARAVEL_WEBSOCKETS_PORT', 6001),
11+
'port' => env('NS_SOCKET_PORT', 6001),
1212
],
1313

1414
/*
@@ -29,6 +29,7 @@
2929
'secret' => env('PUSHER_APP_SECRET'),
3030
'path' => env('PUSHER_APP_PATH'),
3131
'capacity' => null,
32+
'host' => env( 'NS_SOCKET_DOMAIN', env( 'SESSION_DOMAIN' ) ),
3233
'enable_client_messages' => false,
3334
'enable_statistics' => true,
3435
],
@@ -118,18 +119,18 @@
118119
* certificate chain of issuers. The private key also may be contained
119120
* in a separate file specified by local_pk.
120121
*/
121-
'local_cert' => env('LARAVEL_WEBSOCKETS_SSL_LOCAL_CERT', null),
122+
'local_cert' => env('NS_SSL_LOCAL_CERT', null),
122123

123124
/*
124125
* Path to local private key file on filesystem in case of separate files for
125126
* certificate (local_cert) and private key.
126127
*/
127-
'local_pk' => env('LARAVEL_WEBSOCKETS_SSL_LOCAL_PK', null),
128+
'local_pk' => env('NS_SSL_LOCAL_PK', null),
128129

129130
/*
130131
* Passphrase for your local_cert file.
131132
*/
132-
'passphrase' => env('LARAVEL_WEBSOCKETS_SSL_PASSPHRASE', null),
133+
'passphrase' => env('NS_SSL_PASSPHRASE', null),
133134

134135
'verify_peer' => false,
135136
],

database/migrations/schema-updates/2020_12_08_221102_dec8_add_columns_to_expenses_history.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ class Dec8AddColumnsToExpensesHistory extends Migration
1414
*/
1515
public function up()
1616
{
17-
Schema::table('nexopos_expenses_history', function (Blueprint $table) {
18-
if ( ! Schema::hasColumn( 'nexopos_expenses_history', 'status' ) ) {
19-
$table->string( 'status' )->default( CashFlow::STATUS_ACTIVE );
20-
}
21-
});
17+
if ( Schema::hasTable( 'nexopos_expenses_history' ) ) {
18+
Schema::table('nexopos_expenses_history', function (Blueprint $table) {
19+
if ( ! Schema::hasColumn( 'nexopos_expenses_history', 'status' ) ) {
20+
$table->string( 'status' )->default( CashFlow::STATUS_ACTIVE );
21+
}
22+
});
23+
}
2224
}
2325

2426
/**

0 commit comments

Comments
 (0)