diff --git a/app/Http/Controllers/Reports/TaxSummary.php b/app/Http/Controllers/Reports/TaxSummary.php index fbee9ccc3..1907ac90d 100644 --- a/app/Http/Controllers/Reports/TaxSummary.php +++ b/app/Http/Controllers/Reports/TaxSummary.php @@ -104,7 +104,7 @@ class TaxSummary extends Controller private function setAmount(&$items, &$totals, $rows, $type, $date_field) { foreach ($rows as $row) { - if ($row['table'] == 'bill_payments' || $row['table'] == 'invoice_payments') { + if ($row->getTable() == 'bill_payments' || $row->getTable() == 'invoice_payments') { $type_row = $row->$type; $row->category_id = $type_row->category_id; @@ -127,7 +127,14 @@ class TaxSummary extends Controller continue; } - $amount = $this->convert($row_total->amount, $row->currency_code, $row->currency_rate); + if ($date_field == 'paid_at') { + $rate = ($row->amount * 100) / $type_row->amount; + $row_amount = ($row_total->amount / 100) * $rate; + } else { + $row_amount = $row_total->amount; + } + + $amount = $this->convert($row_amount, $row->currency_code, $row->currency_rate); $items[$row_total->name][$date]['amount'] += $amount;