diff --git a/app/Helpers/Collection/BillLine.php b/app/Helpers/Collection/BillLine.php index 6a04708bd7..2d12f55da5 100644 --- a/app/Helpers/Collection/BillLine.php +++ b/app/Helpers/Collection/BillLine.php @@ -27,6 +27,9 @@ class BillLine /** @var string */ protected $min; + /** @var int */ + private $transactionJournalId; + /** * @return string */ @@ -91,6 +94,22 @@ class BillLine $this->min = $min; } + /** + * @return int + */ + public function getTransactionJournalId(): int + { + return $this->transactionJournalId ?? 0; + } + + /** + * @param int $transactionJournalId + */ + public function setTransactionJournalId(int $transactionJournalId) + { + $this->transactionJournalId = $transactionJournalId; + } + /** * @return boolean */ diff --git a/app/Helpers/Report/ReportHelper.php b/app/Helpers/Report/ReportHelper.php index 666fbcf4dc..10953f2cfa 100644 --- a/app/Helpers/Report/ReportHelper.php +++ b/app/Helpers/Report/ReportHelper.php @@ -80,11 +80,13 @@ class ReportHelper implements ReportHelperInterface $entry = $journals->filter( function (TransactionJournal $journal) use ($bill) { - return $journal->bill_id == $bill->id; + return $journal->bill_id === $bill->id; } ); - if (!is_null($entry->first())) { - $billLine->setAmount($entry->first()->journalAmount); + $first = $entry->first(); + if (!is_null($first)) { + $billLine->setTransactionJournalId($first->id); + $billLine->setAmount($first->journalAmount); $billLine->setHit(true); } else { $billLine->setHit(false); @@ -93,7 +95,6 @@ class ReportHelper implements ReportHelperInterface $collection->addBill($billLine); } - } return $collection; diff --git a/app/Repositories/Bill/BillRepository.php b/app/Repositories/Bill/BillRepository.php index 5c3d57223f..62401bbca1 100644 --- a/app/Repositories/Bill/BillRepository.php +++ b/app/Repositories/Bill/BillRepository.php @@ -82,6 +82,7 @@ class BillRepository implements BillRepositoryInterface ->get( [ 'transaction_journals.bill_id', + 'transaction_journals.id', DB::Raw('SUM(`transactions`.`amount`) as `journalAmount`'), ] ); diff --git a/resources/views/reports/partials/balance.twig b/resources/views/reports/partials/balance.twig index 54cc50ed30..4035e46521 100644 --- a/resources/views/reports/partials/balance.twig +++ b/resources/views/reports/partials/balance.twig @@ -41,6 +41,7 @@ {% if balanceEntry.getSpent != 0 %} {{ (balanceEntry.getSpent)|formatAmountPlain }} + {% endif %} {% if balanceEntry.getLeft != 0 %} {{ (balanceEntry.getLeft)|formatAmountPlain }} diff --git a/resources/views/reports/partials/bills.twig b/resources/views/reports/partials/bills.twig index 266c9b6f5b..c097c7545a 100644 --- a/resources/views/reports/partials/bills.twig +++ b/resources/views/reports/partials/bills.twig @@ -15,33 +15,30 @@ {% for line in bills.getBills %} - {% if not line.isActive %} - - {% else %} - - {% endif %} - - {{ line.getBill.name }} + + + {{ line.getBill.name }} + + {{ line.getMin|formatAmount }} + {{ line.getMax|formatAmount }} + {% if line.isHit %} + + + {{ line.getAmount|formatAmount }} + + + {% endif %} + {% if not line.isHit and line.isActive %} + {{ 'notCharged'|_ }} + {% endif %} {% if not line.isActive %} - ({{ 'inactive'|_|lower }}) +   {% endif %} - - {{ line.getMin|formatAmount }} - {{ line.getMax|formatAmount }} - {% if line.isHit %} - {{ line.getAmount|formatAmount }} - {% endif %} - {% if not line.isHit and line.isActive %} - {{ 'notCharged'|_ }} - {% endif %} - {% if not line.isActive %} -   - {% endif %} - - {% if line.isActive %} - {{ (line.getMax + line.getAmount)|formatAmount }} - {% endif %} - + + {% if line.isActive %} + {{ (line.getMax + line.getAmount)|formatAmount }} + {% endif %} + diff --git a/resources/views/reports/partials/budgets.twig b/resources/views/reports/partials/budgets.twig index 076487a1e0..0f21038bef 100644 --- a/resources/views/reports/partials/budgets.twig +++ b/resources/views/reports/partials/budgets.twig @@ -39,12 +39,13 @@ {% if budgetLine.getSpent != 0 %} - {{ budgetLine.getSpent|formatAmount }} + {{ budgetLine.getSpent|formatAmount }} {% endif %} {% if budgetLine.getSpent == 0 %} {{ budgetLine.getSpent|formatAmount }} {% endif %} + {% if(budgetLine.getOverspent == 0) %} diff --git a/resources/views/reports/partials/categories.twig b/resources/views/reports/partials/categories.twig index ee5000825e..bcaa315449 100644 --- a/resources/views/reports/partials/categories.twig +++ b/resources/views/reports/partials/categories.twig @@ -7,7 +7,7 @@ {{ 'categories'|_ }} - {{ 'spent'|_ }} + {{ 'spent'|_ }} @@ -17,6 +17,9 @@ {{ cat.name }} {{ cat.spent|formatAmount }} + + + {% endfor %} diff --git a/resources/views/reports/partials/expenses.twig b/resources/views/reports/partials/expenses.twig index 25f632fc8f..2cf8ed44f5 100644 --- a/resources/views/reports/partials/expenses.twig +++ b/resources/views/reports/partials/expenses.twig @@ -15,7 +15,10 @@ {{ expense.name }} {% if expense.count > 1 %}
- {{ expense.count }} {{ 'transactions'|_|lower }} + + {{ expense.count }} {{ 'transactions'|_|lower }} + + {% endif %} {{ (expense.amount)|formatAmount }}