Use bcmath to calculate correct prices.

This commit is contained in:
Jan Böhmer 2019-09-01 13:56:14 +02:00
parent 43c439bc9e
commit 4391be448d
9 changed files with 82 additions and 98 deletions

View file

@ -32,11 +32,13 @@ namespace App\Twig;
use App\Entity\Attachments\Attachment;
use App\Entity\Base\DBElement;
use App\Entity\Parts\MeasurementUnit;
use App\Entity\PriceInformations\Currency;
use App\Services\AmountFormatter;
use App\Services\EntityURLGenerator;
use App\Services\MoneyFormatter;
use App\Services\SIFormatter;
use App\Services\TreeBuilder;
use Money\Currencies;
use Symfony\Component\Cache\Adapter\AdapterInterface;
use Symfony\Component\Serializer\SerializerInterface;
use Twig\Extension\AbstractExtension;
@ -123,9 +125,9 @@ class AppExtension extends AbstractExtension
return $item->get();
}
public function formatCurrency($amount, $currency = "")
public function formatCurrency($amount, Currency $currency = null, int $decimals = 5)
{
return $this->moneyFormatter->format($amount, $currency);
return $this->moneyFormatter->format($amount, $currency, $decimals);
}
public function siFormat($value, $unit, $decimals = 2)