Merge pull request #1447 from denisdulici/master

Including tax in profit & loss
This commit is contained in:
Denis Duliçi 2020-05-16 11:38:48 +03:00 committed by GitHub
commit 3d012792b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 9 deletions

View File

@ -329,7 +329,7 @@ abstract class Report
event(new RowsShowing($this)); event(new RowsShowing($this));
} }
public function setTotals($items, $date_field, $check_type = false, $table = 'default') public function setTotals($items, $date_field, $check_type = false, $table = 'default', $with_tax = true)
{ {
foreach ($items as $item) { foreach ($items as $item) {
// Make groups extensible // Make groups extensible
@ -347,7 +347,7 @@ abstract class Report
continue; continue;
} }
$amount = $item->getAmountConvertedToDefault(); $amount = $item->getAmountConvertedToDefault(false, $with_tax);
$type = (($item instanceof Invoice) || (($item instanceof Transaction) && ($item->type == 'income'))) ? 'income' : 'expense'; $type = (($item instanceof Invoice) || (($item instanceof Transaction) && ($item->type == 'income'))) ? 'income' : 'expense';

View File

@ -47,33 +47,33 @@ class ProfitLoss extends Report
case 'cash': case 'cash':
// Revenues // Revenues
$revenues = $income_transactions->get(); $revenues = $income_transactions->get();
$this->setTotals($revenues, 'paid_at', true, $this->tables['income']); $this->setTotals($revenues, 'paid_at', true, $this->tables['income'], false);
// Payments // Payments
$payments = $expense_transactions->get(); $payments = $expense_transactions->get();
$this->setTotals($payments, 'paid_at', true, $this->tables['expense']); $this->setTotals($payments, 'paid_at', true, $this->tables['expense'], false);
break; break;
default: default:
// Invoices // Invoices
$invoices = $this->applyFilters(Invoice::accrued(), ['date_field' => 'invoiced_at'])->get(); $invoices = $this->applyFilters(Invoice::accrued(), ['date_field' => 'invoiced_at'])->get();
Recurring::reflect($invoices, 'invoiced_at'); Recurring::reflect($invoices, 'invoiced_at');
$this->setTotals($invoices, 'invoiced_at', true, $this->tables['income']); $this->setTotals($invoices, 'invoiced_at', true, $this->tables['income'], false);
// Revenues // Revenues
$revenues = $income_transactions->isNotDocument()->get(); $revenues = $income_transactions->isNotDocument()->get();
Recurring::reflect($revenues, 'paid_at'); Recurring::reflect($revenues, 'paid_at');
$this->setTotals($revenues, 'paid_at', true, $this->tables['income']); $this->setTotals($revenues, 'paid_at', true, $this->tables['income'], false);
// Bills // Bills
$bills = $this->applyFilters(Bill::accrued(), ['date_field' => 'billed_at'])->get(); $bills = $this->applyFilters(Bill::accrued(), ['date_field' => 'billed_at'])->get();
Recurring::reflect($bills, 'bill', 'billed_at'); Recurring::reflect($bills, 'bill', 'billed_at');
$this->setTotals($bills, 'billed_at', true, $this->tables['expense']); $this->setTotals($bills, 'billed_at', true, $this->tables['expense'], false);
// Payments // Payments
$payments = $expense_transactions->isNotDocument()->get(); $payments = $expense_transactions->isNotDocument()->get();
Recurring::reflect($payments, 'paid_at'); Recurring::reflect($payments, 'paid_at');
$this->setTotals($payments, 'paid_at', true, $this->tables['expense']); $this->setTotals($payments, 'paid_at', true, $this->tables['expense'], false);
break; break;
} }

View File

@ -70,7 +70,7 @@ class TaxSummary extends Report
} }
} }
public function setTotals($items, $date_field, $check_type = false, $table = 'default') public function setTotals($items, $date_field, $check_type = false, $table = 'default', $with_tax = true)
{ {
foreach ($items as $item) { foreach ($items as $item) {
// Make groups extensible // Make groups extensible