Skip to content

Commit

Permalink
Merge pull request #259 from Blair2004/v4.4.x
Browse files Browse the repository at this point in the history
v4.4.2
  • Loading branch information
Blair2004 authored Aug 11, 2021
2 parents d5ead66 + 72a9845 commit 6238cb6
Show file tree
Hide file tree
Showing 44 changed files with 166 additions and 241 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ public/export/*
!public/export/index.html
!public/modules/index.html
public/js/*.js
!public/js/*.min.js
!public/js/vendor.js
!public/js/manifest.js
public/css/*.css
!public/css/app.css
public/js/*.map
public/js/*.txt
public/css/*.map
Expand Down
5 changes: 5 additions & 0 deletions app/Classes/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ public static function table( $table, $callback )
return parent::table( Hook::filter( 'ns-table-name', $table ), $callback );
}

public static function rename( $previous, $new )
{
return parent::rename( Hook::filter( 'ns-table-name', $previous ), Hook::filter( 'ns-table-name', $new ) );
}

public static function create( $table, $callback )
{
return parent::create( Hook::filter( 'ns-table-name', $table ), $callback );
Expand Down
10 changes: 10 additions & 0 deletions app/Services/CoreService.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,14 @@ public function purgeMissingMigrations()
Migration::where( 'migration', $diff )->delete();
}
}

/**
* Returns a boolean if the environment is
* on production mode
* @return boolean
*/
public function isProduction()
{
return in_array( env( 'NS_ENV', 'prod' ), [ 'prod', 'production' ]);
}
}
6 changes: 4 additions & 2 deletions app/Services/CustomerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -524,9 +524,11 @@ public function updateCustomerOwedAmount( Customer $customer )
* Change here will be negative, so we
* want to be an absolute value.
*/
$change = abs( Order::whereIn( 'payment_status', [
$orders = Order::whereIn( 'payment_status', [
Order::PAYMENT_PARTIALLY
])->sum( 'change' ) );
]);

$change = abs( $orders->sum( 'change' ) );

$customer->owed_amount = ns()->currency->getRaw( $unpaid + $change );
$customer->save();
Expand Down
8 changes: 4 additions & 4 deletions app/Services/OrdersService.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ public function __checkProvidedInstalments( $fields )
}
}

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

Expand Down Expand Up @@ -944,7 +944,7 @@ private function __computeOrderTotal($data)
/**
* compute change
*/
$order->change = $this->currencyService->getRaw( $order->tendered - $order->total );
$order->change = Currency::raw( $order->tendered - $order->total );

/**
* compute gross total
Expand Down Expand Up @@ -1669,7 +1669,7 @@ public function computeOrderProduct( OrderProduct $orderProduct )
public function computeDiscountValues( $rate, $value )
{
if ( $rate > 0 ) {
return ( $value * $rate ) / 100;
return Currency::raw( ( $value * $rate ) / 100 );
}

return 0;
Expand Down Expand Up @@ -1847,7 +1847,7 @@ public function refreshOrder(Order $order)
$order->discount = $this->computeOrderDiscount( $order );
$order->total = ( $productTotal + $orderShipping ) - ( $order->discount + $order->total_coupons );
$order->tax_value = $productsTotalTaxes;
$order->change = $order->tendered - $order->total;
$order->change = Currency::raw( $order->tendered - $order->total );

$refunds = $order->refund;
$totalRefunds = $refunds->map( fn( $refund ) => $refund->total )->sum();
Expand Down
1 change: 1 addition & 0 deletions app/Services/Setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ public function runMigration( $fields )
DotenvEditor::setKey( 'NS_SOCKET_DOMAIN', $domain[ 'basename' ] );
DotenvEditor::setKey( 'SANCTUM_STATEFUL_DOMAINS', $domain[ 'basename' ] );
DotenvEditor::setKey( 'NS_SOCKET_ENABLED', 'false' );
DotenvEditor::setKey( 'NS_ENV', 'production' );
DotenvEditor::save();


Expand Down
2 changes: 1 addition & 1 deletion config/broadcasting.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'cluster' => env('PUSHER_APP_CLUSTER'),
'useTLS' => false, // env( 'NS_SOCKET_SECURED', false ) ? true : false,
'useTLS' => env( 'NS_SOCKET_SECURED', false ) ? true : false,
'host' => env( 'NS_SOCKET_DOMAIN', env( 'SESSION_DOMAIN' ) ),
'port' => env( 'NS_SOCKET_PORT', 6001 ),
'scheme' => env( 'NS_SOCKET_SCHEME', 'http' ),
Expand Down
2 changes: 1 addition & 1 deletion config/nexopos.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
return [
'version' => '4.4.1',
'version' => '4.4.2',
'languages' => [
'en' => 'English',
'fr' => 'Français',
Expand Down
9 changes: 5 additions & 4 deletions config/websockets.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Set a custom dashboard configuration
*/
'dashboard' => [
'port' => env('LARAVEL_WEBSOCKETS_PORT', 6001),
'port' => env('NS_SOCKET_PORT', 6001),
],

/*
Expand All @@ -29,6 +29,7 @@
'secret' => env('PUSHER_APP_SECRET'),
'path' => env('PUSHER_APP_PATH'),
'capacity' => null,
'host' => env( 'NS_SOCKET_DOMAIN', env( 'SESSION_DOMAIN' ) ),
'enable_client_messages' => false,
'enable_statistics' => true,
],
Expand Down Expand Up @@ -118,18 +119,18 @@
* certificate chain of issuers. The private key also may be contained
* in a separate file specified by local_pk.
*/
'local_cert' => env('LARAVEL_WEBSOCKETS_SSL_LOCAL_CERT', null),
'local_cert' => env('NS_SSL_LOCAL_CERT', null),

/*
* Path to local private key file on filesystem in case of separate files for
* certificate (local_cert) and private key.
*/
'local_pk' => env('LARAVEL_WEBSOCKETS_SSL_LOCAL_PK', null),
'local_pk' => env('NS_SSL_LOCAL_PK', null),

/*
* Passphrase for your local_cert file.
*/
'passphrase' => env('LARAVEL_WEBSOCKETS_SSL_PASSPHRASE', null),
'passphrase' => env('NS_SSL_PASSPHRASE', null),

'verify_peer' => false,
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ class Dec8AddColumnsToExpensesHistory extends Migration
*/
public function up()
{
Schema::table('nexopos_expenses_history', function (Blueprint $table) {
if ( ! Schema::hasColumn( 'nexopos_expenses_history', 'status' ) ) {
$table->string( 'status' )->default( CashFlow::STATUS_ACTIVE );
}
});
if ( Schema::hasTable( 'nexopos_expenses_history' ) ) {
Schema::table('nexopos_expenses_history', function (Blueprint $table) {
if ( ! Schema::hasColumn( 'nexopos_expenses_history', 'status' ) ) {
$table->string( 'status' )->default( CashFlow::STATUS_ACTIVE );
}
});
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use App\Classes\Schema;

class UpdateExpenseCategoryAug1 extends Migration
{
Expand Down
11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
"scripts": {
"dev": "npm run development",
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "npm run development -- --watch",
"watch-poll": "npm run watch -- --watch-poll",
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --disable-host-check --config=node_modules/laravel-mix/setup/webpack.config.js",
"prod": "npm run production",
"watch-ts": "tsc --watch",
"webpack": "webpack",
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
"watch": "mix watch",
"watch-poll": "mix watch -- --watch-options-poll=1000",
"production": "npx mix --production"
},
"devDependencies": {
"@types/node": "^16.0.1",
"axios": "^0.21.0",
"babel-loader": "^8.1.0",
"cross-env": "^7.0.2",
"laravel-echo": "^1.10.0",
"laravel-mix": "^5.0.5",
"laravel-mix": "^6.0.27",
"lodash": "^4.17.20",
"pusher-js": "^7.0.3",
"resolve-url-loader": "^4.0.0",
Expand All @@ -28,7 +28,7 @@
"typescript": "^4.0.3",
"vue-loader": "^15.9.3",
"vue-template-compiler": "^2.6.12",
"webpack": "^4.44.2"
"webpack": "^5.50.0"
},
"dependencies": {
"@ckeditor/ckeditor5-build-classic": "^29.0.0",
Expand All @@ -51,7 +51,6 @@
"rxjs": "^7.0.1",
"tailwindcss": "^2.0.4",
"twitter_cldr": "^2.2.0",
"uglifyjs-webpack-plugin": "^2.2.0",
"vue": "^2.6.12",
"vue-apexcharts": "^1.6.0",
"vue-html-to-paper": "1.3.0",
Expand Down
7 changes: 7 additions & 0 deletions public/css/app.css

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions public/js/app.min.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions public/js/auth.min.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions public/js/bootstrap.min.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions public/js/cashier.min.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions public/js/dashboard.min.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions public/js/lang-loader.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions public/js/manifest.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions public/js/popups.min.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions public/js/pos-init.min.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions public/js/pos.min.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions public/js/setup.min.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions public/js/update.min.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions public/js/vendor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion resources/ts/pages/dashboard/modules.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export default {
return Object.values( this.modules ).length === 0;
},
noModuleMessage() {
return this.$slots[ 'no-modules-message' ] ? this.$slots[ 'no-modules-message' ][0].text : 'No message provided for "no-module-message"';
return this.$slots[ 'no-modules-message' ] ? this.$slots[ 'no-modules-message' ][0].text : __( `No module has been updated yet.` );
}
},
methods: {
Expand Down
4 changes: 1 addition & 3 deletions resources/ts/popups/ns-pos-layaway-popup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,7 @@ export default {
return nsSnackBar.error( __( 'One or more instalments has a date prior to the current date.' ) ).subscribe();
}
// console.log( totalInstalments, this.order.total );
if ( totalInstalments != this.order.total ) {
if ( totalInstalments < nsRawCurrency( this.order.total ) ) {
return nsSnackBar.error( __( 'Total instalments must be equal to the order total.' ) ).subscribe();
}
Expand Down
12 changes: 10 additions & 2 deletions resources/views/common/footer.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,22 @@
];
?>
<script type="text/javascript">
ns.currency = @json( $json );
ns.authentication = @json( $authentication );
ns.currency = <?php echo json_encode( $json );?>;
ns.authentication = <?php echo json_encode( $authentication );?>;
ns.base_url = '{{ url( "/" ) }}';
</script>

@if ( ns()->isProduction() )
<script src="{{ asset( 'js/manifest.js' ) }}"></script>
<script src="{{ asset( 'js/vendor.js' ) }}"></script>
<script src="{{ asset( 'js/bootstrap.min.js' ) }}"></script>
<script src="{{ asset( 'js/popups.min.js' ) }}"></script>
@else
<script src="{{ asset( 'js/manifest.js' ) }}"></script>
<script src="{{ asset( 'js/vendor.js' ) }}"></script>
<script src="{{ asset( 'js/bootstrap.js' ) }}"></script>
<script src="{{ asset( 'js/popups.js' ) }}"></script>
@endif
<?php
$output = new Output;
Hook::action( 'ns-dashboard-footer', $output );
Expand Down
2 changes: 1 addition & 1 deletion resources/views/layout/base.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
'NexoPOS' => asset( "/lang/" . app()->getLocale() . ".json" ),
]));?>
</script>
<script src="{{ asset( 'js/lang-loader.js' ) }}"></script>
<script src="{{ asset( ns()->isProduction() ? 'js/lang-loader.min.js' : 'js/lang-loader.js' ) }}"></script>
@include( 'common.header-socket' )
</head>
<body>
Expand Down
4 changes: 2 additions & 2 deletions resources/views/layout/dashboard.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
'NexoPOS' => asset( "/lang/" . app()->getLocale() . ".json" ),
]));?>
</script>
<script src="{{ asset( 'js/lang-loader.js' ) }}"></script>
<script src="{{ asset( ns()->isProduction() ? 'js/lang-loader.min.js' : 'js/lang-loader.js' ) }}"></script>
@include( 'common.header-socket' )
</head>
<body>
Expand Down Expand Up @@ -90,7 +90,7 @@
</div>
@section( 'layout.dashboard.footer' )
@include( '../common/footer' )
<script defer src="{{ asset( 'js/app.js' ) }}"></script>
<script defer src="{{ asset( ns()->isProduction() ? 'js/app.min.js' : 'js/app.js' ) }}"></script>
@show
</body>
</html>
4 changes: 2 additions & 2 deletions resources/views/pages/dashboard/home.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

@section( 'layout.dashboard.footer.inject' )
@if ( $dashid === 'store' )
<script src="{{ asset( '/js/dashboard.js' ) }}"></script>
<script src="{{ asset( ns()->isProduction() ? '/js/dashboard.min.js' : '/js/dashboard.js' ) }}"></script>
@elseif ( $dashid === 'cashier' )
<script src="{{ asset( '/js/cashier.js' ) }}"></script>
<script src="{{ asset( ns()->isProduction() ? '/js/cashier.min.js' : '/js/cashier.js' ) }}"></script>
@endif
@endsection
13 changes: 6 additions & 7 deletions resources/views/pages/dashboard/orders/pos.blade.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<?php
use App\Models\User;
?>
@extends( 'layout.base' )

@section( 'layout.base.header' )
Expand All @@ -21,13 +24,9 @@

@section( 'layout.base.footer' )
@parent
<script src="{{ asset( 'js/pos-init.js' ) }}"></script>
<script src="{{ asset( ns()->isProduction() ? 'js/pos-init.min.js' : 'js/pos-init.js' ) }}"></script>
<script>
POS.defineTypes( <?php
use App\Models\User;
echo json_encode( $orderTypes );?>);
POS.defineTypes(<?php echo json_encode( $orderTypes );?>);
POS.defineOptions( <?php echo json_encode( $options );?>);
POS.defineSettings({
barcode_search : true,
Expand Down Expand Up @@ -55,5 +54,5 @@
POS.reset();
});
</script>
<script src="{{ asset( 'js/pos.js' ) }}"></script>
<script src="{{ asset( ns()->isProduction() ? 'js/pos.min.js' : 'js/pos.js' ) }}"></script>
@endsection
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@extends( 'layout.base' )
@section( 'layout.base.body' )
@include( 'pages.dashboard.orders.templates._receipt' )
@endsection
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
<td colspan="2" class="p-2 border-b border-gray-800 text-sm font-semibold">{{ __( 'Sub Total' ) }}</td>
<td class="p-2 border-b border-gray-800 text-sm text-right">{{ ns()->currency->define( $order->subtotal ) }}</td>
</tr>
@if ( $order->discount > 0 )
<tr>
<td colspan="2" class="p-2 border-b border-gray-800 text-sm font-semibold">
<span>{{ __( 'Discount' ) }}</span>
Expand All @@ -51,6 +52,7 @@
</td>
<td class="p-2 border-b border-gray-800 text-sm text-right">{{ ns()->currency->define( $order->discount ) }}</td>
</tr>
@endif
@if ( $order->total_coupons > 0 )
<tr>
<td colspan="2" class="p-2 border-b border-gray-800 text-sm font-semibold">
Expand All @@ -59,18 +61,20 @@
<td class="p-2 border-b border-gray-800 text-sm text-right">{{ ns()->currency->define( $order->total_coupons ) }}</td>
</tr>
@endif
@if ( $order->payment_status !== 'refunded' && $order->tax_value > 0 )
@if ( $order->tax_value > 0 )
<tr>
<td colspan="2" class="p-2 border-b border-gray-800 text-sm font-semibold">
<span>{{ __( 'Taxes' ) }}</span>
</td>
<td class="p-2 border-b border-gray-800 text-sm text-right">{{ ns()->currency->define( $order->tax_value ) }}</td>
</tr>
@endif
@if ( $order->shipping > 0 )
<tr>
<td colspan="2" class="p-2 border-b border-gray-800 text-sm font-semibold">{{ __( 'Shipping' ) }}</td>
<td class="p-2 border-b border-gray-800 text-sm text-right">{{ ns()->currency->define( $order->shipping ) }}</td>
</tr>
@endif
<tr>
<td colspan="2" class="p-2 border-b border-gray-800 text-sm font-semibold">{{ __( 'Total' ) }}</td>
<td class="p-2 border-b border-gray-800 text-sm text-right">{{ ns()->currency->define( $order->total ) }}</td>
Expand Down
Loading

0 comments on commit 6238cb6

Please sign in to comment.