Skip to content

Commit f72b65e

Browse files
committed
Update
- Fix: float number accuracy.
1 parent 2eed95c commit f72b65e

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

app/Http/Controllers/AuthController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ public function postSignUp( SignUpRequest $request )
327327
return [
328328
'status' => 'success',
329329
'message' => $registration_validated === 'no' ?
330-
__( 'Your Account has been successfully creaetd.' ) :
330+
__( 'Your Account has been successfully created.' ) :
331331
__( 'Your Account has been created but requires email validation.' ),
332332
'data' => [
333333
'redirectTo' => ns()->route( 'ns.login' ),
@@ -337,7 +337,7 @@ public function postSignUp( SignUpRequest $request )
337337
return redirect()->route( 'ns.login', [
338338
'status' => 'success',
339339
'message' => $registration_validated === 'no' ?
340-
__( 'Your Account has been successfully creaetd.' ) :
340+
__( 'Your Account has been successfully created.' ) :
341341
__( 'Your Account has been created but requires email validation.' ),
342342
]);
343343
}

app/Services/CurrencyService.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,17 @@ public function get()
217217
return $this->getRaw( $this->value );
218218
}
219219

220+
/**
221+
* return a raw value for the provided number
222+
* @param float $value
223+
* @return float
224+
*/
220225
public function getRaw( $value = null )
221226
{
222-
return floatval( $value !== null ? (string) BigDecimal::of( $value ) : (string) $this->value );
227+
$value = $value !== null ? (string) BigDecimal::of( $value )->dividedBy(1, $this->decimal_precision, RoundingMode::UP ) : null;
228+
$main = $value === null ? (string) $this->value->dividedBy(1, $this->decimal_precision, RoundingMode::UP ) : 0;
229+
230+
return floatval( $value !== null ? $value : $main );
223231
}
224232

225233
/**

tests/Traits/WithOrderTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ protected function attemptCreateOrderOnRegister( $data = [] )
246246

247247
$this->assertEquals(
248248
ns()->currency->getRaw( $cashRegister->balance ),
249-
ns()->currency->getRaw( $totalTransactions ),
249+
$totalTransactions,
250250
__( 'The transaction aren\'t reflected on the register balance' )
251251
);
252252

@@ -470,6 +470,7 @@ public function attemptUpdateOrderOnRegister()
470470
* @var array $response
471471
* @var Register $cashRegister
472472
*/
473+
473474
$order = Order::find( $response[ 'data' ][ 'order' ][ 'id' ] );
474475
$orderService->makeOrderSinglePayment([
475476
'identifier' => OrderPayment::PAYMENT_CASH,

0 commit comments

Comments
 (0)