Skip to content

Commit 3549119

Browse files
committed
Fixed #657
1 parent 530a3a4 commit 3549119

File tree

7 files changed

+29
-10
lines changed

7 files changed

+29
-10
lines changed

app/Services/CashRegistersService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function closeRegister( Register $register, $amount, $description )
6363
);
6464
}
6565

66-
if ( ( float ) $register->balance !== ( float ) $amount ) {
66+
if ( ns()->currency->getRounded( $register->balance ) !== ns()->currency->getRounded( $amount ) ) {
6767
throw new NotAllowedException(
6868
sprintf(
6969
__( 'The specified amount %s doesn\'t match the cash register balance %s.' ),

app/Services/CurrencyService.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,28 @@ public function get()
191191
return $this->getRaw( $this->value );
192192
}
193193

194+
/**
195+
* Will return the full Raw value
196+
* @param int|float $value
197+
* @param bool $precision
198+
* @return float
199+
*/
194200
public function getRaw( $value = null, $precision = true )
195201
{
196202
return $this->newRound( $value === null ? $this->value : $value );
197203
}
198204

205+
/**
206+
* Will return the rounded
207+
* value for a specific amount
208+
* @param int|float $value
209+
* @return float
210+
*/
211+
public function getRounded( $value )
212+
{
213+
return $this->newRound( $value, ns()->option->get( 'ns_currency_precision' ) );
214+
}
215+
199216
public function newRound( $value, $precision = 5 )
200217
{
201218
$fix = "5";

public/css/app.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/js/pos-init.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/mix-manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
"/js/dashboard.min.js": "/js/dashboard.min.js?id=60d188cff1ed0691282e5d7f40bde2cf",
66
"/js/cashier.min.js": "/js/cashier.min.js?id=1627a9d8690738259612634520689750",
77
"/js/update.min.js": "/js/update.min.js?id=810856cd8846b40a37e1762ee8756caa",
8-
"/js/pos-init.min.js": "/js/pos-init.min.js?id=4d4555fc50f2560f8c59141d46360051",
8+
"/js/pos-init.min.js": "/js/pos-init.min.js?id=ff4c3c8eec30a0943d22ef6c158c19fa",
99
"/js/pos.min.js": "/js/pos.min.js?id=bf28aff4de3a611d81beba515fbd51cd",
1010
"/js/auth.min.js": "/js/auth.min.js?id=eac1bf2c20cb551578ec89e7754bf595",
1111
"/js/setup.min.js": "/js/setup.min.js?id=fdb1d69240540e03f08207dc3e92df8f",
1212
"/js/popups.min.js": "/js/popups.min.js?id=650f47e7e1dbb8b6b2f3be967786326e",
1313
"/js/manifest.js": "/js/manifest.js?id=98d0d5bf30a419e7d32bb8a49007ef77",
14-
"/css/app.css": "/css/app.css?id=cc094825ef739b17fd48064c077b6632",
14+
"/css/app.css": "/css/app.css?id=b344d0459a938aa6738e9b8c29b9c673",
1515
"/js/vendor.js": "/js/vendor.js?id=ca667ecee33937a4e775c11e3bbd9f6d"
1616
}

resources/ts/popups/ns-pos-cash-registers-options-popup.vue

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,14 @@ export default {
7373
}
7474
},
7575
76-
async cashIn() {
76+
async cashIn( register ) {
7777
try {
7878
const response = await new Promise( ( resolve, reject ) => {
7979
Popup.show( nsPosCashRegistersActionPopupVue, {
8080
title: __( 'Cash In' ),
8181
action: 'register-cash-in',
8282
identifier: 'ns.cash-registers-cashing',
83+
register,
8384
resolve,
8485
reject
8586
})
@@ -98,13 +99,14 @@ export default {
9899
}
99100
},
100101
101-
async cashOut() {
102+
async cashOut( register ) {
102103
try {
103104
const response = await new Promise( ( resolve, reject ) => {
104105
Popup.show( nsPosCashRegistersActionPopupVue, {
105106
title: __( 'Cash Out' ),
106107
action: 'register-cash-out',
107108
identifier: 'ns.cash-registers-cashout',
109+
register,
108110
resolve,
109111
reject
110112
})
@@ -163,11 +165,11 @@ export default {
163165
<i class="las la-sign-out-alt text-6xl"></i>
164166
<h3 class="text-xl font-bold">{{ __( 'Close' ) }}</h3>
165167
</div>
166-
<div @click="cashIn()" class="hover:bg-green-100 border-gray-200 border-r border-b py-4 cursor-pointer px-2 flex items-center justify-center flex-col">
168+
<div @click="cashIn( register )" class="hover:bg-green-100 border-gray-200 border-r border-b py-4 cursor-pointer px-2 flex items-center justify-center flex-col">
167169
<i class="las la-plus-circle text-6xl"></i>
168170
<h3 class="text-xl font-bold">{{ __( 'Cash In' ) }}</h3>
169171
</div>
170-
<div @click="cashOut()" class="hover:bg-red-100 border-gray-200 border-r border-b py-4 cursor-pointer px-2 flex items-center justify-center flex-col">
172+
<div @click="cashOut( register )" class="hover:bg-red-100 border-gray-200 border-r border-b py-4 cursor-pointer px-2 flex items-center justify-center flex-col">
171173
<i class="las la-minus-circle text-6xl"></i>
172174
<h3 class="text-xl font-bold">{{ __( 'Cash Out' ) }}</h3>
173175
</div>

resources/ts/popups/ns-pos-cash-registers-popup.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export default {
5050
const action = 'open';
5151
const register_id = register.id;
5252
const identifier = 'ns.cash-registers-opening'; // fields identifier
53-
Popup.show( nsPosCashRegistersActionPopupVue, { resolve, reject, title, identifier, action, register_id })
53+
Popup.show( nsPosCashRegistersActionPopupVue, { resolve, reject, title, identifier, action, register_id, register })
5454
});
5555
5656
this.popupResolver( response );

0 commit comments

Comments
 (0)