Skip to content

Commit

Permalink
Balance as money auto-context
Browse files Browse the repository at this point in the history
  • Loading branch information
nikuscs committed May 27, 2024
1 parent e327e24 commit caba3bb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Wallet.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Brick\Math\Exception\NumberFormatException;
use Brick\Math\Exception\RoundingNecessaryException;
use Brick\Money\Context\AutoContext;
use Brick\Money\Exception\UnknownCurrencyException;
use Brick\Money\Money;
use Closure;
Expand Down Expand Up @@ -215,7 +216,11 @@ public function balanceRaw(bool $cached = true): mixed
*/
public function balanceAsMoney(): Money
{
return Money::of($this->balance(), $this->configuration->getCurrency());
return Money::of(
$this->balance(),
$this->configuration->getCurrency(),
new AutoContext(),
);
}

/**
Expand All @@ -234,6 +239,7 @@ public function hasBalanceFor(float|int|string $amount): bool
return true;
} catch (\Exception $e) {
report($e);

return false;
}
}
Expand Down

0 comments on commit caba3bb

Please sign in to comment.