Skip to content

Commit

Permalink
feat(agedDebtors): implement client-side skeleton
Browse files Browse the repository at this point in the history
This commit implements the client-side skeleton services/controllers
around the aged debtors report.
  • Loading branch information
Jonathan Niles committed Sep 17, 2016
1 parent d6e7f5e commit 7513239
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 2 deletions.
4 changes: 4 additions & 0 deletions client/src/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,10 @@ function constantConfig() {
CREDIT_NOTE : 10,
INCOME : 'income',
EXPENSE : 'expense'
},
reports : {
AGED_DEBTOR : 'AGED_DEBTOR',
CASHFLOW : 'CASHFLOW'
}
};
}
Expand Down
33 changes: 33 additions & 0 deletions client/src/partials/finance/reports/agedDebtors/agedDebtors.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<div class="flex-header static">
<div class="bhima-title">
<ol class="headercrumb">
<li class="static">{{ "TREE.FINANCE" | translate }}</li>
<li class="static">{{ "TREE.REPORTS" | translate }}</li>
<li class="title">{{ "TREE.AGED_DEBTORS" | translate }}</li>
</ol>

<div class="toolbar">
<div class="toolbar-item">
<button type="button" class="btn btn-default" ng-click="AgedDebtorsCtrl.create()">
<i class="fa fa-plus"></i> {{ "FORM.BUTTONS.NEW_REPORT" | translate }}
</button>
</div>
</div>
</div>
</div>

<div class="flex-content">
<div class="container-fluid">
<div
id="report-grid"
class="grid-full-height"
ui-grid="AgedDebtorsCtrl.gridOptions">

<bh-grid-loading-indicator
loading-state="AgedDebtorsCtrl.loading"
empty-state="AgedDebtorsCtrl.gridOptions.data.length === 0"
error-state="AgedDebtorsCtrl.hasError">
</bh-grid-loading-indicator>
</div>
</div>
</div>
36 changes: 36 additions & 0 deletions client/src/partials/finance/reports/agedDebtors/agedDebtors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
angular.module('bhima.controllers')
.controller('AgedDebtorsController', AgedDebtorsController);

AgedDebtorsController.$inject = [
'NotifyService', 'AgedDebtorReportService'
];

function AgedDebtorsController(Notify, AgedDebtorReports) {
var vm = this;

// basic grid options
vm.gridOptions = {
fastWatch: true,
flatEntityAccess: true,
appScopeProvider: vm
};

// report column definitions
vm.gridOptions.columnDefs = [
{ field: 'label', displayName: 'FORM.LABELS.LABEL', headerCellFilter: 'translate' },
{ field: 'timestamp', displayName: 'FORM.LABELS.DATE', headerCellFilter: 'translate', cellFilter: 'date' },
{ field: 'user', displayName: 'FORM.LABELS.USER', headerCellFilter: 'translate' },
{ field: 'actions', displayName: 'FORM.LABELS.ACTIONS', headerCellFilter: 'translate' }
];

AgedDebtorReports.read()
.then(function (reports) {
vm.gridOptions.data = reports;
})
.catch(Notify.handleError);

// open the configuration modal for a new Aged Debtors report
vm.create = function create() {
AgedDebtorReports.openCreateModal();
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
angular.module('bhima.services')
.service('AgedDebtorReportService', AgedDebtorReportService);

AgedDebtorReportService.$inject = [ 'PrototypeApiService', 'bhConstants' ];

function AgedDebtorReportService(Api, bhConstants) {
var service = new Api('/finance/reports/');

// bind the report type to the service
service.REPORT_TYPE = bhConstants.reports.AGED_DEBTOR;

return service;
}
3 changes: 1 addition & 2 deletions server/config/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,6 @@ exports.configure = function configure(app) {

// Patient invoice API

// TODO Decide if the route should be named patient invoice
app.get('/invoices', patientInvoice.list);
app.post('/invoices', patientInvoice.create);
app.get('/invoices/search', patientInvoice.search);
Expand Down Expand Up @@ -501,7 +500,7 @@ exports.configure = function configure(app) {
app.get('/vouchers/reports/', vouchers.report);
app.get('/vouchers/receipts/:uuid', vouchers.receipt);
app.get('/vouchers/:uuid', vouchers.detail);
app.get('/vouchers/reports/:uuid', vouchers.report);
// app.get('/vouchers/reports/:uuid', vouchers.report);
app.post('/vouchers', vouchers.create);

// suppliers api
Expand Down
14 changes: 14 additions & 0 deletions server/models/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1448,6 +1448,20 @@ CREATE TABLE `reference_group` (
FOREIGN KEY (`section_bilan_id`) REFERENCES `section_bilan` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

DROP TABLE IF EXISTS `report`;

CREATE TABLE `report` (
`uuid` BINARY(16) NOT NULL,
`label` TEXT NOT NULL,
`parameters` TEXT, /* query string parameters, if they will be displayed on the report (such as filters, etc) */
`link` TEXT NOT NULL,
`timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`user_id` SMALLINT(5) UNSIGNED NOT NULL,
PRIMARY KEY (`uuid`),
KEY `user_id` (`user_id`),
FOREIGN KEY (`user_id`) REFERENCES `user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

DROP TABLE IF EXISTS `rubric`;

CREATE TABLE `rubric` (
Expand Down

0 comments on commit 7513239

Please sign in to comment.