Skip to content

Commit

Permalink
Fixed #657
Browse files Browse the repository at this point in the history
  • Loading branch information
Blair2004 committed Apr 11, 2022
1 parent 530a3a4 commit 3549119
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/Services/CashRegistersService.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function closeRegister( Register $register, $amount, $description )
);
}

if ( ( float ) $register->balance !== ( float ) $amount ) {
if ( ns()->currency->getRounded( $register->balance ) !== ns()->currency->getRounded( $amount ) ) {
throw new NotAllowedException(
sprintf(
__( 'The specified amount %s doesn\'t match the cash register balance %s.' ),
Expand Down
17 changes: 17 additions & 0 deletions app/Services/CurrencyService.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,28 @@ public function get()
return $this->getRaw( $this->value );
}

/**
* Will return the full Raw value
* @param int|float $value
* @param bool $precision
* @return float
*/
public function getRaw( $value = null, $precision = true )
{
return $this->newRound( $value === null ? $this->value : $value );
}

/**
* Will return the rounded
* value for a specific amount
* @param int|float $value
* @return float
*/
public function getRounded( $value )
{
return $this->newRound( $value, ns()->option->get( 'ns_currency_precision' ) );
}

public function newRound( $value, $precision = 5 )
{
$fix = "5";
Expand Down
2 changes: 1 addition & 1 deletion public/css/app.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/js/pos-init.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions public/mix-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
"/js/dashboard.min.js": "/js/dashboard.min.js?id=60d188cff1ed0691282e5d7f40bde2cf",
"/js/cashier.min.js": "/js/cashier.min.js?id=1627a9d8690738259612634520689750",
"/js/update.min.js": "/js/update.min.js?id=810856cd8846b40a37e1762ee8756caa",
"/js/pos-init.min.js": "/js/pos-init.min.js?id=4d4555fc50f2560f8c59141d46360051",
"/js/pos-init.min.js": "/js/pos-init.min.js?id=ff4c3c8eec30a0943d22ef6c158c19fa",
"/js/pos.min.js": "/js/pos.min.js?id=bf28aff4de3a611d81beba515fbd51cd",
"/js/auth.min.js": "/js/auth.min.js?id=eac1bf2c20cb551578ec89e7754bf595",
"/js/setup.min.js": "/js/setup.min.js?id=fdb1d69240540e03f08207dc3e92df8f",
"/js/popups.min.js": "/js/popups.min.js?id=650f47e7e1dbb8b6b2f3be967786326e",
"/js/manifest.js": "/js/manifest.js?id=98d0d5bf30a419e7d32bb8a49007ef77",
"/css/app.css": "/css/app.css?id=cc094825ef739b17fd48064c077b6632",
"/css/app.css": "/css/app.css?id=b344d0459a938aa6738e9b8c29b9c673",
"/js/vendor.js": "/js/vendor.js?id=ca667ecee33937a4e775c11e3bbd9f6d"
}
10 changes: 6 additions & 4 deletions resources/ts/popups/ns-pos-cash-registers-options-popup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,14 @@ export default {
}
},
async cashIn() {
async cashIn( register ) {
try {
const response = await new Promise( ( resolve, reject ) => {
Popup.show( nsPosCashRegistersActionPopupVue, {
title: __( 'Cash In' ),
action: 'register-cash-in',
identifier: 'ns.cash-registers-cashing',
register,
resolve,
reject
})
Expand All @@ -98,13 +99,14 @@ export default {
}
},
async cashOut() {
async cashOut( register ) {
try {
const response = await new Promise( ( resolve, reject ) => {
Popup.show( nsPosCashRegistersActionPopupVue, {
title: __( 'Cash Out' ),
action: 'register-cash-out',
identifier: 'ns.cash-registers-cashout',
register,
resolve,
reject
})
Expand Down Expand Up @@ -163,11 +165,11 @@ export default {
<i class="las la-sign-out-alt text-6xl"></i>
<h3 class="text-xl font-bold">{{ __( 'Close' ) }}</h3>
</div>
<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">
<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">
<i class="las la-plus-circle text-6xl"></i>
<h3 class="text-xl font-bold">{{ __( 'Cash In' ) }}</h3>
</div>
<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">
<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">
<i class="las la-minus-circle text-6xl"></i>
<h3 class="text-xl font-bold">{{ __( 'Cash Out' ) }}</h3>
</div>
Expand Down
2 changes: 1 addition & 1 deletion resources/ts/popups/ns-pos-cash-registers-popup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default {
const action = 'open';
const register_id = register.id;
const identifier = 'ns.cash-registers-opening'; // fields identifier
Popup.show( nsPosCashRegistersActionPopupVue, { resolve, reject, title, identifier, action, register_id })
Popup.show( nsPosCashRegistersActionPopupVue, { resolve, reject, title, identifier, action, register_id, register })
});
this.popupResolver( response );
Expand Down

0 comments on commit 3549119

Please sign in to comment.