|
|
@@ -197,16 +197,19 @@ class Document extends Model {
|
|
|
return AruStatuses::enumToText($this->aru_status);
|
|
|
}
|
|
|
|
|
|
- public function getDisplayTotal(): string {
|
|
|
- $formatter = new NumberFormatter("en_GB", NumberFormatter::CURRENCY);
|
|
|
+ public function getDisplaySubtotal(): string {
|
|
|
+ return (new NumberFormatter("en_GB", NumberFormatter::CURRENCY))->formatCurrency($this->getSubtotal(), $this->currency);
|
|
|
+ }
|
|
|
|
|
|
- $subtotal = "0.00";
|
|
|
+ public function getDisplayTax(): string {
|
|
|
+ return (new NumberFormatter("en_GB", NumberFormatter::CURRENCY))->formatCurrency($this->getTax(), $this->currency);
|
|
|
+ }
|
|
|
|
|
|
- foreach($this->getItems() as $item) {
|
|
|
- $subtotal = bcadd($item->getAmount(), $subtotal, 2);
|
|
|
- }
|
|
|
+ public function getDisplayTotal(): string {
|
|
|
+ $formatter = new NumberFormatter("en_GB", NumberFormatter::CURRENCY);
|
|
|
|
|
|
- $tax = bcmul($subtotal, $this->tax_rate / 100, 2);
|
|
|
+ $subtotal = $this->getSubtotal();
|
|
|
+ $tax = $this->getTax();
|
|
|
$total = bcadd($subtotal, $tax, 2);
|
|
|
|
|
|
return $formatter->formatCurrency($total, $this->currency);
|
|
|
@@ -345,6 +348,10 @@ class Document extends Model {
|
|
|
return $subtotal;
|
|
|
}
|
|
|
|
|
|
+ public function getTax(): string {
|
|
|
+ return bcmul($this->getSubtotal(), $this->tax_rate / 100, 2);
|
|
|
+ }
|
|
|
+
|
|
|
public function getNotesHtml(): string {
|
|
|
return nl2br(htmlspecialchars($this->notes));
|
|
|
}
|