Skip to content

Commit

Permalink
Add support for money formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
danharrin committed Sep 27, 2021
1 parent 3c2843d commit cfb5064
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/currencies/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
],
"require": {
"php": "^7.2|^8.0",
"akaunting/laravel-money": "^1.2",
"illuminate/support": "^6.0 || ^7.0 || ^8.0",
"squirephp/model": "^2.0",
"squirephp/rule": "^2.0"
"squirephp/model": "self.version",
"squirephp/rule": "self.version"
},
"autoload": {
"psr-4": {
Expand Down
9 changes: 9 additions & 0 deletions packages/currencies/src/Models/Currency.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,13 @@ public function countries()
{
return $this->hasMany(Country::class);
}

public function format($number, $shouldConvert = false)
{
return (new \Akaunting\Money\Money(
$number,
(new \Akaunting\Money\Currency(strtoupper($this->id))),
$shouldConvert
))->format();
}
}

0 comments on commit cfb5064

Please sign in to comment.