Skip to content

Commit

Permalink
fix(reports): render correct transaction date
Browse files Browse the repository at this point in the history
This commit fixes the patient financial activity report to use the
correct transaction date instead of using today's date.  It also makes
the patient financial activity report a little clearer for
non-accountants to read by rendering credits in red and debits in black.
  • Loading branch information
Jonathan Niles authored and jniles committed Feb 4, 2017
1 parent 7f3e5e8 commit 0cf20ce
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 18 deletions.
2 changes: 1 addition & 1 deletion client/src/less/bhima-bootstrap.less
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ input[type=number] {-moz-appearance: textfield;}
/* PDF report styles */

.table-report {
font-size: 0.8em;
font-size: 0.9em;
}

.table-report > thead > th {
Expand Down
56 changes: 39 additions & 17 deletions server/controllers/finance/reports/financial.patient.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,61 @@
<h4 class="text-center">{{translate "PATIENT_RECORDS.FINANCIAL_ACTIVITY.ACCOUNT"}} : {{ debtor.number }} </h4>

<section>
<table class="table table-condensed table-striped table-bordered table-report">
<table class="table table-condensed table-bordered table-report">
<thead>
<tr class="text-capitalize text-center" style="background-color: #ccc;" >
<th>{{translate "TABLE.COLUMNS.DATE" }}</th>
<th style="width: 5%;">{{translate "TABLE.COLUMNS.INVOICE_ID" }}</th>
<th style="width: 15%;">{{translate "TABLE.COLUMNS.TRANSACTION_ID" }}</th>
<th style="width: 15%;">{{translate "TABLE.COLUMNS.DATE" }}</th>
<th style="width: 35%;">{{translate "TABLE.COLUMNS.DESCRIPTION" }}</th>
<th style="width: 15%;">{{translate "TABLE.COLUMNS.DEBIT" }}</th>
<th style="width: 15%;">{{translate "TABLE.COLUMNS.CREDIT" }}</th>
<th style="width: 5%;">{{translate "TABLE.COLUMNS.TRANSACTION_ID" }}</th>
<th>{{translate "TABLE.COLUMNS.DESCRIPTION" }}</th>
<th style="width: 15%;" class="text-center">{{translate "TABLE.COLUMNS.AMOUNT" }}</th>
</tr>
</thead>
<tbody>
{{#each patients}}
<tr>
<td>{{date this.trans_date}}</td>
<td class="text-right">{{this.reference}}</td>
<td class="text-right">{{this.trans_id}}</td>
<td>{{date this.date}}</td>
<td>{{this.description}}</td>
<td class="text-right">{{currency this.debit ../metadata.enterprise.currency_id}}</td>
<td class="text-right">{{currency this.credit ../metadata.enterprise.currency_id}}</td>
<td class="text-right {{#if this.credit}}text-danger{{/if}}">
{{#if this.credit}}
({{currency this.credit ../metadata.enterprise.currency_id}})
{{else}}
{{currency this.debit ../metadata.enterprise.currency_id}}
{{/if}}
</td>
</tr>
{{else}}
{{>emptyTable columns=6}}
{{>emptyTable columns=5}}
{{/each}}
</tbody>
<tfoot>
<tr style="background-color: #ededed;">
<th colspan="4">{{translate "FORM.LABELS.TOTAL" }}</th>
<th class="text-right">{{currency sum.debit metadata.enterprise.currency_id}}</th>
<th class="text-right">{{currency sum.credit metadata.enterprise.currency_id}}</th>
<tfoot style="background-color: #ededed;">
<tr>
<th colspan="4" class="text-right">{{translate "FORM.LABELS.TOTAL_BILLED" }}</th>
<th class="text-right">
<span>{{currency sum.debit metadata.enterprise.currency_id}}</span>
</th>
</tr>
<tr style="background-color: #ededed;">
<th colspan="6" class="text-right">{{translate "FORM.LABELS.BALANCE" }} {{currency sum.balance metadata.enterprise.currency_id}}</th>
<tr>
<th colspan="4" class="text-right">{{translate "FORM.LABELS.TOTAL_PAID" }}</th>
<th class="text-right">
<span class="text-danger">({{currency sum.credit metadata.enterprise.currency_id}})</span>
</th>
</tr>
<tr>
<th colspan="4" class="text-right">
{{translate "FORM.LABELS.TOTAL_BALANCE_REMAINING" }}
</th>
<th class="text-right">
{{#unless sum.hasDebitBalance }}
<span class="text-danger">
({{currency sum.balance metadata.enterprise.currency_id}})
</span>
{{else}}
{{currency sum.balance metadata.enterprise.currency_id}}
{{/unless}}
</th>
</tr>
</tfoot>
</table>
Expand Down
4 changes: 4 additions & 0 deletions server/controllers/finance/reports/financial.patient.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,15 @@ function financialActivities(patientUuid) {
debit : 0,
balance: 0
};

// why does this loop through patients?
patients.forEach(function (patient) {
sum.debit += patient.debit;
sum.credit += patient.credit;
sum.balance = sum.debit - sum.credit;
sum.hasDebitBalance = sum.balance > 0;
});

const debtor = glb.debtor;
return { patients, debtor, sum };
});
Expand Down

0 comments on commit 0cf20ce

Please sign in to comment.