Skip to content

Commit

Permalink
fix(vouchers): render the amount as currency
Browse files Browse the repository at this point in the history
This commit ensures that the voucher registry renders the amounts as
currencies.

Partially addresses #671.
  • Loading branch information
Jonathan Niles authored and jniles committed Feb 15, 2017
1 parent df912ab commit 213eb97
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 39 deletions.
97 changes: 58 additions & 39 deletions client/src/partials/vouchers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ angular.module('bhima.controllers')
VoucherController.$inject = [
'VoucherService', '$translate', 'NotifyService', 'GridFilteringService',
'uiGridGroupingConstants', 'uiGridConstants', 'ModalService', 'DateService',
'bhConstants', 'ReceiptModal', 'GridSortingService'
'bhConstants', 'ReceiptModal', 'GridSortingService',
];

/**
Expand Down Expand Up @@ -39,47 +39,66 @@ function VoucherController(Vouchers, $translate, Notify, Filtering, uiGridGroupi
vm.gridOptions = {
appScopeProvider : vm,
showColumnFooter : true,
enableFiltering : vm.filterEnabled,
rowTemplate: '/partials/templates/grid/voucher.row.html'
enableFiltering : vm.filterEnabled,
rowTemplate : '/partials/templates/grid/voucher.row.html'
};

// grid default options
vm.gridOptions.columnDefs = [
{ field : 'reference', displayName : 'TABLE.COLUMNS.REFERENCE', headerCellFilter: 'translate',
treeAggregationType: uiGridGroupingConstants.aggregation.COUNT,
sortingAlgorithm : Sorting.algorithms.sortByReference,
treeAggregationLabel: '', footerCellClass : 'text-center',
},
{ field : 'type_id', displayName : 'TABLE.COLUMNS.TYPE', headerCellFilter: 'translate',
sort: { priority: 0, direction : 'asc' },
cellTemplate: 'partials/templates/grid/voucherType.tmpl.html',
treeAggregationType: uiGridGroupingConstants.aggregation.SUM,
customTreeAggregationFinalizerFn: typeAggregation,
treeAggregationLabel : '',
groupingShowAggregationMenu: false
},
{ field : 'date', displayName : 'TABLE.COLUMNS.DATE', headerCellFilter: 'translate',
cellFilter : 'date',
filter : { condition : filtering.byDate },
customTreeAggregationFinalizerFn: timeAggregation,
treeAggregationLabel : '', type : 'date',
groupingShowAggregationMenu: false
},
{ field : 'description', displayName : 'TABLE.COLUMNS.DESCRIPTION', headerCellFilter: 'translate',
groupingShowAggregationMenu: false
},
{ field : 'amount', displayName : 'TABLE.COLUMNS.AMOUNT', headerCellFilter: 'translate',
treeAggregationType: uiGridGroupingConstants.aggregation.SUM,
treeAggregationLabel : '', footerCellClass : 'text-center',
type: 'number', groupingShowAggregationMenu: false
},
{ field : 'display_name', displayName : 'TABLE.COLUMNS.RESPONSIBLE', headerCellFilter: 'translate',
groupingShowAggregationMenu: false
},
{ field : 'action', displayName : '...', enableFiltering: false, enableColumnMenu: false,
enableSorting: false, cellTemplate: 'partials/vouchers/templates/action.cell.html'
}
];
vm.gridOptions.columnDefs = [{
field : 'reference',
displayName : 'TABLE.COLUMNS.REFERENCE',
headerCellFilter : 'translate',
treeAggregationType : uiGridGroupingConstants.aggregation.COUNT,
sortingAlgorithm : Sorting.algorithms.sortByReference,
treeAggregationLabel : '',
}, {
field : 'type_id',
displayName : 'TABLE.COLUMNS.TYPE',
headerCellFilter : 'translate',
sort : { priority: 0, direction: 'asc' },
cellTemplate : 'partials/templates/grid/voucherType.tmpl.html',
treeAggregationType : uiGridGroupingConstants.aggregation.SUM,
customTreeAggregationFinalizerFn : typeAggregation,
treeAggregationLabel : '',
groupingShowAggregationMenu : false,
}, {
field : 'date',
displayName : 'TABLE.COLUMNS.DATE',
headerCellFilter : 'translate',
cellFilter : 'date',
filter : { condition: filtering.byDate },
customTreeAggregationFinalizerFn : timeAggregation,
treeAggregationLabel : '',
type : 'date',
groupingShowAggregationMenu : false,
}, {
field : 'description',
displayName : 'TABLE.COLUMNS.DESCRIPTION',
headerCellFilter : 'translate',
groupingShowAggregationMenu : false,
}, {
field : 'amount',
displayName : 'TABLE.COLUMNS.AMOUNT',
headerCellFilter : 'translate',
treeAggregationType : uiGridGroupingConstants.aggregation.SUM,
treeAggregationLabel : '',
footerCellClass : 'text-right',
type : 'number',
groupingShowAggregationMenu : false,
cellTemplate : 'partials/vouchers/templates/amount.grid.tmpl.html',
}, {
field : 'display_name',
displayName : 'TABLE.COLUMNS.RESPONSIBLE',
headerCellFilter : 'translate',
groupingShowAggregationMenu : false,
}, {
field : 'action',
displayName : '...',
enableFiltering : false,
enableColumnMenu : false,
enableSorting : false,
cellTemplate : 'partials/vouchers/templates/action.cell.html',
}];

// register API
vm.gridOptions.onRegisterApi = onRegisterApi;
Expand Down
3 changes: 3 additions & 0 deletions client/src/partials/vouchers/templates/amount.grid.tmpl.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div class="ui-grid-cell-contents" style="text-align:right;">
{{ row.entity.amount | currency:row.entity.currency_id }}
</div>

0 comments on commit 213eb97

Please sign in to comment.