Skip to content

Commit

Permalink
fix(vouchers): sync voucher currency w/ footer
Browse files Browse the repository at this point in the history
This commit fixes the voucher footer aggregation, keeping it in sync
with the form's selected currency.

Closes #1286.
  • Loading branch information
Jonathan Niles authored and sfount committed Mar 14, 2017
1 parent 8f10e5d commit c4c817e
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 56 deletions.
18 changes: 9 additions & 9 deletions client/src/partials/vouchers/complex.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<div
class="form-group"
ng-class="{ 'has-error' : ComplexVoucherForm.$submitted && ComplexVoucherForm.description.$invalid }">
<label class="control-label">{{ "FORM.LABELS.DESCRIPTION" | translate }}</label>
<label class="control-label" translate>FORM.LABELS.DESCRIPTION</label>
<textarea
class="form-control"
name="description"
Expand All @@ -45,7 +45,7 @@

<div class="form-group" ng-class="{ 'has-error' : ComplexVoucherForm.$submitted && ComplexVoucherForm.type_id.$invalid }">
<label class="control-label">
{{ 'FORM.LABELS.TRANSACTION_TYPE' | translate }}
<span translate>FORM.LABELS.TRANSACTION_TYPE</span>
<span uib-popover="{{ 'VOUCHERS.GLOBAL.TRANSFER_TYPE_INFO' | translate }}"
popover-trigger="'mouseenter'"
popover-placement="bottom"
Expand All @@ -62,7 +62,7 @@
append-to-body="true">

<ui-select-match placeholder="{{ 'FORM.SELECT.TRANSFER_TYPE' | translate }}">
<span>{{$select.selected.text | translate }}</span>
<span translate>{{$select.selected.text}}</span>
</ui-select-match>

<ui-select-choices
Expand All @@ -75,7 +75,7 @@

<div class="help-block" ng-show="ComplexVoucherCtrl.Voucher.hasCashboxAccount">
<p class="text-info">
<i class="fa fa-info-circle"></i> {{ 'VOUCHERS.GLOBAL.USE_FINANCIAL_ACCOUNT' | translate }}
<i class="fa fa-info-circle"></i> <span translate>VOUCHERS.GLOBAL.USE_FINANCIAL_ACCOUNT</span>
</p>
</div>

Expand Down Expand Up @@ -105,7 +105,7 @@
ng-class="{ 'btn-primary' : ComplexVoucherCtrl.Voucher.hasCacheAvailable() }"
ng-click="ComplexVoucherCtrl.Voucher.readCache()"
ng-disabled="!ComplexVoucherCtrl.Voucher.hasCacheAvailable() || ComplexVoucherCtrl.Voucher.hasRecoveredCache || ComplexVoucherForm.$submitted">
<i class="fa fa-recycle"></i> {{ "FORM.BUTTONS.RECOVER_ITEMS" | translate }}
<i class="fa fa-recycle"></i> <span translate>FORM.BUTTONS.RECOVER_ITEMS</span>
</button>
</div>

Expand All @@ -117,7 +117,7 @@
id="btn-add-rows"
class="btn btn-default"
ng-click="ComplexVoucherCtrl.Voucher.addItems(ComplexVoucherCtrl.itemIncrement)">
<i class="fa fa-plus-circle"></i> {{ "FORM.BUTTONS.ADD" | translate }}
<i class="fa fa-plus-circle"></i> <span translate>FORM.BUTTONS.ADD</span>
</button>
</span>
<input
Expand All @@ -137,17 +137,17 @@
<div class="row" style="margin-top: 5px;">
<div class="col-md-6">
<p ng-if="ComplexVoucherCtrl.Voucher._error" class="text-danger">
<i class="fa fa-warning"></i> {{ ComplexVoucherCtrl.Voucher._error | translate }}
<i class="fa fa-warning"></i> <span translate>{{ ComplexVoucherCtrl.Voucher._error }}</span>
</p>
</div>

<div class="col-md-6 text-right">
<button class="btn btn-default" ng-click="ComplexVoucherCtrl.clear(ComplexVoucherForm)" type="button">
{{ "FORM.BUTTONS.CLEAR" | translate }}
<span translate>FORM.BUTTONS.CLEAR</span>
</button>

<bh-loading-button loading-state="ComplexVoucherForm.$loading">
{{ "FORM.BUTTONS.SUBMIT" | translate }}
<span translate>FORM.BUTTONS.SUBMIT</span>
</bh-loading-button>
</div>
</div>
Expand Down
95 changes: 48 additions & 47 deletions client/src/partials/vouchers/complex.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ComplexJournalVoucherController.$inject = [
'VoucherService', '$translate', 'CurrencyService', 'SessionService',
'FindEntityService', 'FindReferenceService', 'NotifyService',
'VoucherToolkitService', 'ReceiptModal', 'bhConstants', 'GridAggregatorService',
'uiGridConstants', 'VoucherForm'
'uiGridConstants', 'VoucherForm',
];

/**
Expand Down Expand Up @@ -45,27 +45,27 @@ function ComplexJournalVoucherController(Vouchers, $translate, Currencies, Sessi

// bread crumb paths
vm.paths = [{
label : $translate.instant('VOUCHERS.COMPLEX.TITLE'),
current: true
label : $translate.instant('VOUCHERS.COMPLEX.TITLE'),
current : true,
}];

// breadcrumb dropdown
vm.dropdown = [{
label: 'VOUCHERS.GLOBAL.TOOLS',
color: 'btn-default',
icon: 'fa-cogs',
option: Toolkit.options
label : 'VOUCHERS.GLOBAL.TOOLS',
color : 'btn-default',
icon : 'fa-cogs',
option : Toolkit.options,
}];

// ui-grid options
vm.gridOptions = {
appScopeProvider : vm,
fastWatch : true,
flatEntityAccess : true,
flatEntityAccess : true,
enableSorting : false,
enableColumnMenus : false,
showColumnFooter : true,
onRegisterApi : onRegisterApi
onRegisterApi : onRegisterApi,
};

function onRegisterApi(api) {
Expand Down Expand Up @@ -133,13 +133,13 @@ function ComplexJournalVoucherController(Vouchers, $translate, Currencies, Sessi
function openReferenceModal(row) {
FindReference.openModal(row.entity)
.then(function (document) {
row.configure({ document : document });
row.configure({ document: document });
});
}

/** Get the selected currency symbol */
function currencySymbol(currency_id) {
if (!currency_id) { return ; }
if (!currency_id) { return; }
return Currencies.symbol(currency_id);
}

Expand All @@ -163,51 +163,52 @@ function ComplexJournalVoucherController(Vouchers, $translate, Currencies, Sessi

// grid default options
vm.gridOptions.columnDefs = [{
field : 'isValid',
displayName : '...',
cellTemplate: 'partials/vouchers/templates/status.grid.tmpl.html',
aggregationType: uiGridConstants.aggregationTypes.count,
field : 'isValid',
displayName : '...',
cellTemplate : 'partials/vouchers/templates/status.grid.tmpl.html',
aggregationType : uiGridConstants.aggregationTypes.count,
aggregationHideLabel : true,
footerCellClass : 'text-center',
width: 40,
footerCellClass : 'text-center',
width : 40,
}, {
field : 'account',
displayName : 'FORM.LABELS.ACCOUNT',
headerCellFilter: 'translate',
cellTemplate: 'partials/vouchers/templates/account.grid.tmpl.html',
width: '35%',
field : 'account',
displayName : 'FORM.LABELS.ACCOUNT',
headerCellFilter : 'translate',
cellTemplate : 'partials/vouchers/templates/account.grid.tmpl.html',
width : '35%',
}, {
field : 'debit',
displayName : 'FORM.LABELS.DEBIT',
headerCellFilter: 'translate',
cellTemplate: 'partials/vouchers/templates/debit.grid.tmpl.html',
aggregationType: uiGridConstants.aggregationTypes.sum,
field : 'debit',
displayName : 'FORM.LABELS.DEBIT',
headerCellFilter : 'translate',
cellTemplate : 'partials/vouchers/templates/debit.grid.tmpl.html',
aggregationType : uiGridConstants.aggregationTypes.sum,
aggregationHideLabel : true,
footerCellFilter: 'currency:' + Session.enterprise.currency_id,
footerCellClass : 'text-right'
footerCellFilter : 'currency:grid.appScope.Voucher.details.currency_id',
footerCellClass : 'text-right',
}, {
field : 'credit',
displayName : 'FORM.LABELS.CREDIT',
headerCellFilter: 'translate',
cellTemplate: 'partials/vouchers/templates/credit.grid.tmpl.html',
aggregationType: uiGridConstants.aggregationTypes.sum,
field : 'credit',
displayName : 'FORM.LABELS.CREDIT',
headerCellFilter : 'translate',
cellTemplate : 'partials/vouchers/templates/credit.grid.tmpl.html',
aggregationType : uiGridConstants.aggregationTypes.sum,
aggregationHideLabel : true,
footerCellFilter: 'currency:' + Session.enterprise.currency_id,
footerCellClass : 'text-right'
footerCellFilter : 'currency:grid.appScope.Voucher.details.currency_id',
footerCellClass : 'text-right',
}, {
field : 'entity',
displayName : 'FORM.LABELS.DEBTOR_CREDITOR',
headerCellFilter: 'translate',
cellTemplate: 'partials/vouchers/templates/entity.grid.tmpl.html',
field : 'entity',
displayName : 'FORM.LABELS.DEBTOR_CREDITOR',
headerCellFilter : 'translate',
cellTemplate : 'partials/vouchers/templates/entity.grid.tmpl.html',
}, {
field : 'reference',
displayName : 'FORM.LABELS.REFERENCE',
headerCellFilter: 'translate',
cellTemplate: 'partials/vouchers/templates/reference.grid.tmpl.html',
field : 'reference',
displayName : 'FORM.LABELS.REFERENCE',
headerCellFilter : 'translate',
cellTemplate : 'partials/vouchers/templates/reference.grid.tmpl.html',
}, {
field : 'action', displayName : '...',
width: 25,
cellTemplate: 'partials/vouchers/templates/remove.grid.tmpl.html',
field : 'action',
displayName : '...',
width : 25,
cellTemplate : 'partials/vouchers/templates/remove.grid.tmpl.html',
}];

/* ============================= End Grid ================================== */
Expand Down

0 comments on commit c4c817e

Please sign in to comment.