-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit implements the server and client sides to the open debtors report. It provides a list of all debtors who have unpaid debts to the enterprise. The current implementation lacks proper translations as well as proper SQL filtering for unposted records. To complete this, there needs to be - [ ] i18n - [ ] Integration Tests - [ ] End to End Tests - [ ] General Report Refactoring (Notify should use report keys) Closes ....
- Loading branch information
Showing
11 changed files
with
309 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
angular.module('bhima.controllers') | ||
.controller('openDebtorsController', OpenDebtorsConfigController); | ||
|
||
OpenDebtorsConfigController.$inject = [ | ||
'$state', '$uibModalInstance', 'LanguageService', 'BaseReportService', 'reportDetails' | ||
]; | ||
|
||
/** | ||
* @module | ||
* Open Debtors Controller | ||
* | ||
* @description | ||
* This controller produces the Open Debtors report of debtors which have unpaid | ||
* debts to the hospital. It provides the accountant a few different ways to | ||
* investigate their institution. | ||
*/ | ||
function OpenDebtorsConfigController($state, ModalInstance, Languages, SavedReports, reportDetails) { | ||
var vm = this; | ||
var report = reportDetails; | ||
|
||
// expose to the view | ||
vm.generate = generate; | ||
vm.cancel = ModalInstance.dismiss; | ||
vm.report = report; | ||
|
||
// how the report should be ordered | ||
vm.orders = [ | ||
{ id: 'payment-date-asc', key: 'ORDER.PAYMENT_DATE_ASC' }, | ||
{ id: 'payment-date-desc', key: 'ORDER.PAYMENT_DATE_ASC' }, | ||
{ id: 'invoice-date-asc', key: 'ORDER.PAYMENT_DATE_ASC' }, | ||
{ id: 'invoice-date-desc', key: 'ORDER.PAYMENT_DATE_ASC' }, | ||
{ id: 'debt-desc', key: 'ORDER.PAYMENT_DATE_ASC' }, | ||
{ id: 'debt-asc', key: 'ORDER.PAYMENT_DATE_ASC' } | ||
]; | ||
|
||
// default order | ||
vm.order = 'payment-date-desc'; | ||
|
||
// whether the report should include posting journal records or not | ||
vm.includePostingJournal = false; | ||
|
||
function generate(form) { | ||
if (form.$invalid) { return; } | ||
|
||
var url = 'reports/finance/debtors/open'; | ||
|
||
var options = { | ||
label : vm.label, | ||
lang : Languages.key, | ||
}; | ||
|
||
return SavedReports.requestPDF(url, report, options) | ||
.then(function (result) { | ||
ModalInstance.dismiss(); | ||
$state.reload(); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<form name="ConfigForm" bh-submit="ReportConfigCtrl.generate(ConfigForm)" bh-form-defaults novalidate autocomplete="none"> | ||
|
||
<div class="modal-header"> | ||
<ol class="headercrumb"> | ||
<li class="static">{{ ::ReportConfigCtrl.report.title_key | translate }}</li> | ||
<li class="title" translate>FORM.LABELS.CREATE</li> | ||
</ol> | ||
</div> | ||
|
||
<div class="modal-body"> | ||
|
||
<div class="form-group" | ||
ng-class="{ 'has-error' : ConfigForm.$submitted && ConfigForm.label.$invalid }"> | ||
<label class="control-label" translate>FORM.LABELS.LABEL</label> | ||
<input class="form-control" name="label" autocomplete="off" ng-model="ReportConfigCtrl.label" required /> | ||
<div class="help-block" ng-messages="ConfigForm.label.$error" ng-show="ConfigForm.$submitted"> | ||
<div ng-messages-include="partials/templates/messages.tmpl.html"></div> | ||
</div> | ||
</div> | ||
|
||
<div class="form-group" | ||
ng-class="{ 'has-error' : ConfigForm.$submitted && ConfigForm.order.$invalid }"> | ||
<label class="control-label" translate>FORM.LABELS.ORDER</label> | ||
<select class="form-control" ng-model="ReportConfigCtrl.order" name="order" ng-options="order.id as order.key for order in ReportConfigCtrl.orders"> | ||
</select> | ||
</div> | ||
|
||
<!-- disabled until actually useful --> | ||
<fieldset disabled> | ||
<div class="radio"> | ||
<p class="control-label" style="margin-bottom:5px;"> | ||
<strong translate>FORM.LABELS.INCLUDE_UNPOSTED_RECORDS</strong> | ||
</p> | ||
|
||
<label class="radio-inline"> | ||
<input type="radio" name="includePostingJournal" ng-model="ReportConfigCtrl.includePostingJournal" ng-value="true"> | ||
<span translate>FORM.LABELS.YES</span> | ||
</label> | ||
|
||
<label class="radio-inline"> | ||
<input type="radio" name="includePostingJournal" ng-model="ReportConfigCtrl.includePostingJournal" ng-value="false"> | ||
<span translate>FORM.LABELS.NO</span> | ||
</label> | ||
</div> | ||
</fieldset> | ||
</div> | ||
|
||
<div class="modal-footer"> | ||
<button type="button" class="btn btn-default" ng-click="ReportConfigCtrl.cancel()" data-method="cancel"> | ||
<span translate>FORM.BUTTONS.CANCEL</span> | ||
</button> | ||
|
||
<bh-loading-button loading-state="ConfigForm.$loading"> | ||
<span translate>FORM.BUTTONS.GENERATE</span> | ||
</bh-loading-button> | ||
</div> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
server/controllers/finance/reports/debtors/openDebtors.handlebars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{{> head title="REPORT.OPEN_DEBTORS.TITLE"}} | ||
|
||
<body> | ||
<main class="container"> | ||
{{> header }} | ||
|
||
<h4 class="text-center"> | ||
{{translate "REPORT.OPEN_DEBTORS.TITLE"}} | ||
<p><small>{{date this.timestamp }}</small></p> | ||
</h4> | ||
|
||
<!-- margin is the cell size --> | ||
<section> | ||
<table class="table table-condensed table-report"> | ||
<thead> | ||
<tr> | ||
<th>{{translate "FORM.LABELS.REFERENCE"}}</th> | ||
<th>{{translate "FORM.LABELS.PATIENT"}}</th> | ||
<th>{{translate "TABLE.COLUMNS.LAST_INVOICE"}}</th> | ||
<th>{{translate "TABLE.COLUMNS.LAST_PAYMENT"}}</th> | ||
<th class="text-center">{{translate "TABLE.COLUMNS.TOTAL_DEBT"}}</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{{#each debtors as | debtor |}} | ||
<tr> | ||
<th>{{debtor.reference }}</th> | ||
<td>{{debtor.display_name }}</td> | ||
<td>{{date debtor.lastInvoiceDate}}</td> | ||
<td>{{date debtor.lastPaymentDate}}</td> | ||
<td class="text-right">{{currency debtor.debt ../metadata.enterprise.currency_id}}</td> | ||
</tr> | ||
{{else}} | ||
{{> emptyTable columns=5}} | ||
{{/each}} | ||
</tbody> | ||
{{#if aggregates}} | ||
<tfoot> | ||
<tr> | ||
<th colspan="4">{{translate "TABLE.COLUMNS.TOTAL"}} {{aggregates.numDebtors}} {{translate "TABLE.AGGREGATES.RECORDS"}}</th> | ||
<th class="text-right">{{currency aggregates.balance metadata.enterprise.currency_id}}</th> | ||
</tr> | ||
</tfoot> | ||
{{/if}} | ||
</table> | ||
</section> | ||
</main> | ||
</body> |
Oops, something went wrong.