Skip to content

Commit

Permalink
feat(General Ledger): use Account Statement Report
Browse files Browse the repository at this point in the history
This commit removes the old Account Slip report link and replaces it
with the account statement report link from the General Ledger.

Closes #1706.
  • Loading branch information
jniles committed Jan 26, 2018
1 parent ceec405 commit a2096d1
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 26 deletions.
18 changes: 11 additions & 7 deletions client/src/modules/general-ledger/general-ledger-accounts.ctrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,17 @@ function GeneralLedgerAccountsController(
}

vm.download = GeneralLedger.download;
vm.slip = GeneralLedger.slip;
vm.openAccountReport = function openAccountReport(accountId) {
var opts = {
account_id : accountId,
dateFrom : vm.year.start_date,
dateTo : vm.year.end_date,
limit : 1000,
renderer : 'pdf',
};

return GeneralLedger.openAccountReport(opts);
};

// loads data for the general Ledger
function load(options) {
Expand All @@ -276,12 +286,6 @@ function GeneralLedgerAccountsController(
fiscal_year_label : vm.year.label,
};

vm.filtersSlip = {
dateFrom : vm.year.start_date,
dateTo : vm.year.end_date,
limit : 1000,
};

load(vm.filters);
}

Expand Down
19 changes: 9 additions & 10 deletions client/src/modules/general-ledger/general-ledger.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@ angular.module('bhima.services')

GeneralLedgerService.$inject = [
'PrototypeApiService', '$httpParamSerializer', 'LanguageService',
'SessionService',
];

/**
* General Ledger Service
* This service is responsible of all process with the General ledger
*/
function GeneralLedgerService(Api, $httpParamSerializer, Languages) {
function GeneralLedgerService(Api, $httpParamSerializer, Languages, Session) {
var service = new Api('/general_ledger/');

service.accounts = new Api('/general_ledger/accounts');

service.download = download;
service.slip = slip;
service.openAccountReport = openAccountReport;

function download(type, filters) {
var filterOpts = filters;
Expand All @@ -28,19 +29,17 @@ function GeneralLedgerService(Api, $httpParamSerializer, Languages) {
return $httpParamSerializer(options);
}

function slip(type, filters, account) {
var filterOpts = filters;
function openAccountReport(options) {
var defaultOpts = {
renderer : type,
lang : Languages.key,
account_id : account,
source : 3,
currency_id : Session.enterprise.currency_id,
};

// combine options
var options = angular.merge(defaultOpts, filterOpts);
// return serialized options
return $httpParamSerializer(options);
var opts = angular.merge(defaultOpts, options);

// return serialized options
return $httpParamSerializer(opts);
}

return service;
Expand Down
4 changes: 2 additions & 2 deletions client/src/modules/general-ledger/templates/action.cell.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

<ul class="dropdown-menu-right" bh-dropdown-menu-auto-dropup uib-dropdown-menu>
<li>
<a ng-href="/reports/finance/account_report/?{{ grid.appScope.slip('pdf', grid.appScope.filtersSlip, row.entity.id) }}" download="{{ GENERAL_LEDGER.ACCOUNT_SLIP | translate }}">
<span class="fa fa-file-pdf-o"></span> <span translate>GENERAL_LEDGER.ACCOUNT_SLIP</span>
<a ng-href="/reports/finance/account_report/?{{ grid.appScope.openAccountReport(row.entity.id) }}" download="{{ TREE.REPORT_ACCOUNTS | translate }}">
<span class="fa fa-file-pdf-o"></span> <span translate>TREE.REPORT_ACCOUNTS</span>
</a>
</li>
</ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,12 @@ function AccountReportConfigController(
vm.reportDetails.account_id = account.id;
};

vm.selectSource = function selectSource(source) {
vm.reportDetails.source = source;
};

vm.clearPreview = function clearPreview() {
vm.previewGenerated = false;
vm.previewResult = null;
};

vm.setCurrency = function (currencyId) {
vm.setCurrency = function setCurrency(currencyId) {
vm.reportDetails.currency_id = currencyId;
};

Expand Down Expand Up @@ -68,8 +64,6 @@ function AccountReportConfigController(
cache.reportDetails = angular.copy(vm.reportDetails);

var sendDetails = sanitiseDateStrings(vm.reportDetails);
sendDetails.dateTo = Moment(sendDetails.dateTo).format('YYYY-MM-DD');
sendDetails.dateFrom = Moment(sendDetails.dateFrom).format('YYYY-MM-DD');

return SavedReports.requestPreview(reportUrl, reportData.id, sendDetails)
.then(function (result) {
Expand Down

0 comments on commit a2096d1

Please sign in to comment.