Use Symfony formatter for currency symbol placement (#542)

This commit is contained in:
Sanjit Patel
2019-02-08 10:56:47 -05:00
committed by Kevin Papst
parent b2587c71b8
commit 616d514d5a
12 changed files with 58 additions and 33 deletions

View File

@@ -55,11 +55,12 @@ abstract class AbstractRenderer
/**
* @param $amount
* @return mixed
* @param $currency
* @return string
*/
protected function getFormattedMoney($amount)
protected function getFormattedMoney($amount, $currency)
{
return $this->extension->money($amount);
return $this->extension->money($amount, $currency);
}
/**

View File

@@ -53,7 +53,7 @@ trait RendererTrait
* @param $amount
* @return mixed
*/
abstract protected function getFormattedMoney($amount);
abstract protected function getFormattedMoney($amount, $currency);
/**
* @param \DateTime $date
@@ -75,6 +75,7 @@ trait RendererTrait
{
$customer = $model->getCustomer();
$project = $model->getQuery()->getProject();
$currency = $model->getCalculator()->getCurrency();
$values = [
'invoice.due_date' => $this->getFormattedDateTime($model->getDueDate()),
@@ -82,10 +83,10 @@ trait RendererTrait
'invoice.number' => $model->getNumberGenerator()->getInvoiceNumber(),
'invoice.currency' => $model->getCalculator()->getCurrency(),
'invoice.vat' => $model->getCalculator()->getVat(),
'invoice.tax' => $this->getFormattedMoney($model->getCalculator()->getTax()),
'invoice.tax' => $this->getFormattedMoney($model->getCalculator()->getTax(), $currency),
'invoice.total_time' => $this->getFormattedDuration($model->getCalculator()->getTimeWorked()),
'invoice.total' => $this->getFormattedMoney($model->getCalculator()->getTotal()),
'invoice.subtotal' => $this->getFormattedMoney($model->getCalculator()->getSubtotal()),
'invoice.total' => $this->getFormattedMoney($model->getCalculator()->getTotal(), $currency),
'invoice.subtotal' => $this->getFormattedMoney($model->getCalculator()->getSubtotal(), $currency),
'template.name' => $model->getTemplate()->getName(),
'template.company' => $model->getTemplate()->getCompany(),
@@ -156,6 +157,7 @@ trait RendererTrait
$activity = $timesheet->getActivity();
$project = $timesheet->getProject();
$customer = $project->getCustomer();
$currency = $customer->getCurrency();
$begin = $timesheet->getBegin();
$end = $timesheet->getEnd();
@@ -164,8 +166,9 @@ trait RendererTrait
'entry.row' => '',
'entry.description' => $description,
'entry.amount' => $amount,
'entry.rate' => $this->getFormattedMoney($hourlyRate),
'entry.total' => $this->getFormattedMoney($rate),
'entry.rate' => $this->getFormattedMoney($hourlyRate, $currency),
'entry.total' => $this->getFormattedMoney($rate, $currency),
'entry.currency' => $currency,
'entry.duration' => $timesheet->getDuration(),
'entry.duration_minutes' => number_format($timesheet->getDuration() / 60),
'entry.begin' => $this->getFormattedDateTime($begin),