Skip to content

Commit

Permalink
fix(journal): ensure col aggregates are displayed
Browse files Browse the repository at this point in the history
This commit ensures that the column aggregates for debits, credits,
descriptions, and dates are shown on the grid group headers.  Because of
careless cell template design, these values were not substituted into
the templates in a previous iteration.

Closes #626.
  • Loading branch information
Jonathan Niles committed Aug 15, 2016
1 parent 8c1a5de commit 2ab5ff2
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 14 deletions.
2 changes: 1 addition & 1 deletion client/src/js/components/bhInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ angular.module('bhima.components')
' uib-popover-template="$ctrl.template" ' +
' popover-placement="right" ' +
' popover-append-to-body="true" ' +
' popover-trigger="mouseenter"> ' +
' popover-trigger="\'mouseenter\'"> ' +
'</span> ',
bindings : {
template: '@',
Expand Down
29 changes: 22 additions & 7 deletions client/src/js/services/grid/GridGrouping.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,45 @@ function GridGroupingService(uiGridGroupingConstants, $filter, Session, $timeout
// cache the currency filter for later lookup
var $currency = $filter('currency');

// alias copy
var copy = angular.copy;

/** @const renders any currencied amount */
var DEFAULT_COST_AGGREGATOR = {

// used to render amounts in the aggregate columns
// TODO - this should render the currency from the row set.
customTreeAggregationFinalizerFn : function amountRenderer(aggregation) {
customTreeAggregationFinalizerFn : function (aggregation) {
aggregation.rendered = $currency(aggregation.value, currencyId);
},

treeAggregationType : uiGridGroupingConstants.aggregation.SUM,
};

/** @const aggregates quantities as needed */
var DEFAULT_QUANTITY_AGGREGATOR= {
var DEFAULT_QUANTITY_AGGREGATOR = {
treeAggregationType : uiGridGroupingConstants.aggregation.SUM,
};

/** @const aggregates by choosing a single item to display */
/** @todo - this currently defaults to MAX, should be implemented as its own custom aggregator */
var DEFAULT_SINGLE_AGGREGATOR = {
treeAggregationType: uiGridGroupingConstants.aggregation.MAX,
customTreeAggregationFinalizerFn: function (aggregation) {
aggregation.rendered = aggregation.value;
}
};

/** @const aggregators assigned by column ids */
var DEFAULT_AGGREGATORS = {
'debit_equiv' : DEFAULT_COST_AGGREGATOR,
'credit_equiv' : DEFAULT_COST_AGGREGATOR,
'cost' : DEFAULT_COST_AGGREGATOR,
'quantity' : DEFAULT_QUANTITY_AGGREGATOR,
'amount' : DEFAULT_QUANTITY_AGGREGATOR
'debit_equiv' : copy(DEFAULT_COST_AGGREGATOR),
'credit_equiv' : copy(DEFAULT_COST_AGGREGATOR),
'cost' : copy(DEFAULT_COST_AGGREGATOR),
'quantity' : copy(DEFAULT_QUANTITY_AGGREGATOR),
'amount' : copy(DEFAULT_QUANTITY_AGGREGATOR),
'description' : copy(DEFAULT_SINGLE_AGGREGATOR),
'date' : copy(DEFAULT_SINGLE_AGGREGATOR),
'trans_date' : copy(DEFAULT_SINGLE_AGGREGATOR), // TODO - eliminate this in favor of "date"
};

/**
Expand Down
8 changes: 6 additions & 2 deletions client/src/partials/journal/templates/credit.cell.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<div class="ui-grid-cell-contents">
{{ row.entity.credit_equiv | currency:row.entity.currency_id }}
<div class="ui-grid-cell-contents" title="TOOLTIP" ng-if="!row.groupHeader">
{{ row.entity.credit | currency:row.entity.currency_id }}
</div>

<div class="ui-grid-cell-contents" title="TOOLTIP" ng-if="row.groupHeader">
{{ COL_FIELD CUSTOM_FILTERS }}
</div>
6 changes: 5 additions & 1 deletion client/src/partials/journal/templates/credit_equiv.cell.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<div class="ui-grid-cell-contents">
<div class="ui-grid-cell-contents" title="TOOLTIP" ng-if="!row.groupHeader">
{{ row.entity.credit_equiv | currency:grid.appScope.enterprise.currency_id }}
</div>

<div class="ui-grid-cell-contents" title="TOOLTIP" ng-if="row.groupHeader">
{{ COL_FIELD CUSTOM_FILTERS }}
</div>
10 changes: 8 additions & 2 deletions client/src/partials/journal/templates/debit.cell.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<div class="ui-grid-cell-contents">
{{ row.entity.debit_equiv | currency:row.entity.currency_id }}
<div class="ui-grid-cell-contents" title="TOOLTIP" ng-if="!row.groupHeader">
{{ row.entity.debit | currency:row.entity.currency_id }}
</div>

<div class="ui-grid-cell-contents" title="TOOLTIP" ng-if="row.groupHeader">
{{COL_FIELD CUSTOM_FILTERS}}
</div>


6 changes: 5 additions & 1 deletion client/src/partials/journal/templates/debit_equiv.cell.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<div class="ui-grid-cell-contents">
<div class="ui-grid-cell-contents" title="TOOLTIP" ng-if="!row.groupHeader">
{{ row.entity.debit_equiv | currency:grid.appScope.enterprise.currency_id }}
</div>

<div class="ui-grid-cell-contents" title="TOOLTIP" ng-if="row.groupHeader">
{{ COL_FIELD CUSTOM_FILTERS }}
</div>

0 comments on commit 2ab5ff2

Please sign in to comment.