item tax amounts

This commit is contained in:
David Bomba 2022-11-10 19:16:22 +11:00
parent 14569d2d79
commit d0178d22ae
6 changed files with 22 additions and 9 deletions

View File

@ -44,6 +44,8 @@ class InvoiceItem
public $line_total = 0;
public $gross_line_total = 0;
public $gross_tax_total = 0;
public $date = '';
@ -75,6 +77,7 @@ class InvoiceItem
'sort_id' => 'string',
'line_total' => 'float',
'gross_line_total' => 'float',
'gross_tax_total' => 'float',
'date' => 'string',
'custom_value1' => 'string',
'custom_value2' => 'string',

View File

@ -30,6 +30,8 @@ class InvoiceItemSum
private $gross_line_total;
private $gross_tax_total;
private $currency;
private $total_taxes;
@ -111,14 +113,10 @@ class InvoiceItemSum
$this->setLineTotal($this->getLineTotal() - $this->formatValue($this->item->discount, $this->currency->precision));
} else {
/*Test 16-08-2021*/
$discount = ($this->item->line_total * ($this->item->discount / 100));
$this->setLineTotal($this->formatValue(($this->getLineTotal() - $discount), $this->currency->precision));
/*Test 16-08-2021*/
//replaces the following
// $this->setLineTotal($this->getLineTotal() - $this->formatValue(round($this->item->line_total * ($this->item->discount / 100), 2), $this->currency->precision));
}
$this->item->is_amount_discount = $this->invoice->is_amount_discount;
@ -160,6 +158,8 @@ class InvoiceItemSum
$this->item->gross_line_total = $this->getLineTotal() + $item_tax;
$this->item->gross_tax_total = $item_tax;
return $this;
}

View File

@ -40,6 +40,8 @@ class InvoiceItemSumInclusive
private $tax_collection;
private $gross_tax_total;
public function __construct($invoice)
{
$this->tax_collection = collect([]);
@ -144,6 +146,8 @@ class InvoiceItemSumInclusive
$this->groupTax($this->item->tax_name3, $this->item->tax_rate3, $item_tax_rate3_total);
}
$this->item->gross_tax_total = $this->formatValue($item_tax, $this->currency->precision);
$this->setTotalTaxes($this->formatValue($item_tax, $this->currency->precision));
return $this;

View File

@ -485,6 +485,7 @@ class HtmlEngine
$data['$product.tax_name3'] = ['value' => '', 'label' => ctrans('texts.tax')];
$data['$product.line_total'] = ['value' => '', 'label' => ctrans('texts.line_total')];
$data['$product.gross_line_total'] = ['value' => '', 'label' => ctrans('texts.gross_line_total')];
$data['$product.gross_tax_total'] = ['value' => '', 'label' => ctrans('texts.tax')];
$data['$product.description'] = ['value' => '', 'label' => ctrans('texts.description')];
$data['$product.unit_cost'] = ['value' => '', 'label' => ctrans('texts.unit_cost')];
$data['$product.product1'] = ['value' => '', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'product1')];

View File

@ -161,8 +161,6 @@ trait MakesInvoiceValues
if (strlen($user_columns) > 1) {
foreach ($items as $key => $item) {
// $tmp = str_replace(array_keys($data), array_values($data), $user_columns);
// $tmp = str_replace(array_keys($item), array_values($item), $tmp);
$tmp = strtr($user_columns, $data);
$tmp = strtr($tmp, $item);
@ -178,8 +176,6 @@ trait MakesInvoiceValues
$table_row .= '</tr>';
foreach ($items as $key => $item) {
// $tmp = str_replace(array_keys($item), array_values($item), $table_row);
// $tmp = str_replace(array_keys($data), array_values($data), $tmp);
$tmp = strtr($table_row, $item);
$tmp = strtr($tmp, $data);
@ -210,11 +206,13 @@ trait MakesInvoiceValues
'tax_name1',
'tax_name2',
'tax_name3',
'gross_tax_total',
],
[
'tax',
'tax',
'tax',
'tax',
],
$columns
);
@ -329,6 +327,12 @@ trait MakesInvoiceValues
$data[$key][$table_type.'.gross_line_total'] = '';
}
if (property_exists($item, 'gross_tax_total')) {
$data[$key][$table_type.'.gross_tax_total'] = ($item->gross_tax_total == 0) ? '' : Number::formatMoney($item->gross_tax_total, $entity);
} else {
$data[$key][$table_type.'.gross_tax_total'] = '';
}
if (isset($item->discount) && $item->discount > 0) {
if ($item->is_amount_discount) {
$data[$key][$table_type.'.discount'] = Number::formatMoney($item->discount, $entity);

View File

@ -355,6 +355,7 @@ class VendorHtmlEngine
$data['$product.tax_name3'] = ['value' => '', 'label' => ctrans('texts.tax')];
$data['$product.line_total'] = ['value' => '', 'label' => ctrans('texts.line_total')];
$data['$product.gross_line_total'] = ['value' => '', 'label' => ctrans('texts.gross_line_total')];
$data['$product.gross_tax_total'] = ['value' => '', 'label' => ctrans('texts.tax')];
$data['$product.description'] = ['value' => '', 'label' => ctrans('texts.description')];
$data['$product.unit_cost'] = ['value' => '', 'label' => ctrans('texts.unit_cost')];
$data['$product.product1'] = ['value' => '', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'product1')];