Skip to content

Commit

Permalink
feature(Monthly Balance Analysis)
Browse files Browse the repository at this point in the history
- Add new report for Analysis Monthly Balance of accounts

closes #3803
  • Loading branch information
lomamech committed Jul 31, 2019
1 parent 87edd98 commit 06d9f60
Show file tree
Hide file tree
Showing 13 changed files with 486 additions and 2 deletions.
4 changes: 4 additions & 0 deletions client/src/i18n/en/report.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@
"PROFIT_AND_LOSS_BY_YEAR": "Profit and Loss Statement By Fiscal Year",
"INCOME_REPORT": "Income Report",
"MONTHLY_BALANCE": "Monthly Balance",
"MONTHLY_ACCOUNT_ANALYSIS": {
"DESCRIPTION": "This report allows for monthly analysis of accounts",
"TITLE": "Monthly Balance analysis"
},
"OPEN_DEBTORS": {
"DESCRIPTION": "This report shows the debtors that have a standing debt with the institution, and gives some control over the sort order. For advanced analysis, the report can add in the last invoice date and last payment date, as well as limit the scope of the search by a date.",
"TITLE": "Debtors with Unpaid Debts",
Expand Down
1 change: 1 addition & 0 deletions client/src/i18n/en/tree.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"IPR_TAX_CONFIGURATION" : "IPR Tax Configuration",
"JOURNAL_VOUCHER" : "Journal Voucher",
"LOCATION" : "Location Management",
"MONTHLT_ACCOUNT_ANALYSIS": "Monthly Balance analysis",
"MULTI_PAYROLL" : "Multiple Payroll",
"OHADA_BILAN":"[OHADA] Bilan",
"OHADA_PROFIT_LOSS" : "[OHADA] Profit and Loss",
Expand Down
4 changes: 4 additions & 0 deletions client/src/i18n/fr/report.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@
"PROFIT_AND_LOSS_BY_YEAR": "Rapport des Produit et des Charges par Années",
"INCOME_REPORT" : "Rapport des Recettes",
"MONTHLY_BALANCE" : "Balance Mensuelle",
"MONTHLY_ACCOUNT_ANALYSIS": {
"DESCRIPTION": "Ce rapport permet de faire l'analyse mensuel des comptes",
"TITLE": "Analyse mensuel de la Balance"
},
"OPEN_DEBTORS": {
"TITLE" : "Débiteurs endettés",
"TREE" : "Dettes des Débiteurs",
Expand Down
1 change: 1 addition & 0 deletions client/src/i18n/fr/tree.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"IPR_TAX_CONFIGURATION": "Configuration de la taxe IPR",
"JOURNAL_VOUCHER":"Ajout Transactions",
"LOCATION":"Localisations",
"MONTHLT_ACCOUNT_ANALYSIS": "Analyse mensuel de la Balance",
"MULTI_PAYROLL" : "Payroll Multiple",
"OFFDAYS_MANAGEMENT" : "Gestion des jours fériés",
"OHADA_BILAN":"[OHADA] Bilan",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
angular.module('bhima.controllers')
.controller('monthlyBalanceAnalysisController', MonthlyBalanceAnalysisController);

MonthlyBalanceAnalysisController.$inject = [
'$sce', 'NotifyService', 'BaseReportService', 'AppCache', 'reportData', '$state', 'AccountService',
];

function MonthlyBalanceAnalysisController($sce, Notify, SavedReports, AppCache, reportData, $state, Accounts) {
const vm = this;
const cache = new AppCache('monthlyBalance');
const reportUrl = 'reports/finance/monthly_balance';

vm.previewGenerated = false;
vm.reportDetails = {};

Accounts.read()
.then(elements => {
// bind the accounts to the controller
let accounts = Accounts.order(elements);
vm.accounts = accounts;
});

vm.onSelectFiscalYear = (fiscalYear) => {
vm.reportDetails.fiscal_id = fiscalYear.id;
};

vm.onSelectPeriod = (period) => {
vm.reportDetails.period_id = period.id;
vm.reportDetails.periodLabel = period.hrLabel;
};

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

vm.resetAnalysis = () => {
if (!vm.reportDetails.monthlyAnalysis) {
vm.reportDetails = {};
vm.reportDetails.fiscal_id = null;
}
}

vm.preview = function preview(form) {
if (form.$invalid) {
Notify.danger('FORM.ERRORS.RECORD_ERROR');
return 0;
}

if (vm.account) {
vm.reportDetails.accountNumber = vm.account.number;
vm.reportDetails.accountLabel = vm.account.label;
vm.reportDetails.accountId = vm.account.id;
}

if (vm.reportDetails.allAccount) {
vm.reportDetails.accountNumber = null;
vm.reportDetails.accountLabel = null;
vm.reportDetails.accountId = null;
}

// update cached configuration
cache.reportDetails = angular.copy(vm.reportDetails);

return SavedReports.requestPreview(reportUrl, reportData.id, angular.copy(vm.reportDetails))
.then(result => {
vm.previewGenerated = true;
vm.previewResult = $sce.trustAsHtml(result);
})
.catch(Notify.handleError);
};

vm.requestSaveAs = function requestSaveAs() {
const options = {
url : reportUrl,
report : reportData,
reportOptions : angular.copy(vm.reportDetails),
};

return SavedReports.saveAsModal(options)
.then(() => {
$state.go('reportsBase.reportsArchive', { key : options.report.report_key });
})
.catch(Notify.handleError);
};

checkCachedConfiguration();

function checkCachedConfiguration() {
if (cache.reportDetails) {
vm.reportDetails = angular.copy(cache.reportDetails);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<bh-report-preview
ng-if="ReportConfigCtrl.previewGenerated"
source-document="ReportConfigCtrl.previewResult"
on-clear-callback="ReportConfigCtrl.clearPreview()"
on-save-callback="ReportConfigCtrl.requestSaveAs()">
</bh-report-preview>

<div ng-show="!ReportConfigCtrl.previewGenerated">
<div class="row">
<div class="col-md-12">
<h3 class="text-capitalize" translate>REPORT.MONTHLY_ACCOUNT_ANALYSIS.TITLE</h3>
<p class="text-info" translate>REPORT.MONTHLY_ACCOUNT_ANALYSIS.DESCRIPTION</p>
</div>
</div>

<div class="row" style="margin-top : 10px">
<div class="col-md-6">
<div class="panel panel-default">
<div class="panel-heading">
<span translate>REPORT.UTIL.OPTIONS</span>
</div>
<div class="panel-body">
<form name="ConfigForm" bh-submit="ReportConfigCtrl.preview(ConfigForm)" novalidate>

<bh-fiscal-year-select
fiscal-id="ReportConfigCtrl.reportDetails.fiscal_id"
on-select-fiscal-callback="ReportConfigCtrl.onSelectFiscalYear(fiscalYear)">
</bh-fiscal-year-select>

<bh-period-selection
fiscal-year-id="ReportConfigCtrl.reportDetails.fiscal_id"
period-id="ReportConfigCtrl.reportDetails.period_id"
on-select-callback="ReportConfigCtrl.onSelectPeriod(period)">
</bh-period-selection>
<hr>
<div class="panel-body" ng-class="{'has-error' : ConfigForm.$submitted && ConfigForm.allAccount.$invalid }">
<div class="radio">
<label class="radio-inline">
<input
type="radio"
name="allAccount"
ng-value="1"
ng-model="ReportConfigCtrl.reportDetails.allAccount"
id="use_patient_visit"
required>
<strong translate>
ACCOUNT.ALL_ACCOUNT
</strong>
</label>
</div>
<div class="radio">
<label class="radio-inline">
<input
type="radio"
name="allAccount"
ng-value="0"
ng-model="ReportConfigCtrl.reportDetails.allAccount"
id="use_dashboard"
required>
<strong translate>
FORM.SELECT.ACCOUNT
</strong>
</label>
<div class="help-block" ng-messages="ConfigForm.allAccount.$error" ng-show="ConfigForm.$submitted">
<div ng-messages-include="modules/templates/messages.tmpl.html"></div>
</div>
</div>
</div>

<div ng-if="ReportConfigCtrl.reportDetails.allAccount === 0">
<div class="form-group"
ng-class="{'has-error' : ConfigForm.account_id.$invalid && ConfigForm.$submitted}">
<label class="control-label" translate>FORM.LABELS.ACCOUNT</label>

<ui-select
name="account_id"
ng-model="ReportConfigCtrl.account"
required>
<ui-select-match placeholder="{{ 'FORM.LABELS.ACCOUNT' | translate }}">
<span><strong>{{$select.selected.number}}</strong> {{$select.selected.label}}</span>
</ui-select-match>
<ui-select-choices ui-select-focus-patch repeat="account in ReportConfigCtrl.accounts | filter:{ 'hrlabel' : $select.search}">
<span ng-bind-html="account.number | highlight:$select.search"></span>
<small ng-bind-html="account.label | highlight:$select.search"></small>
</ui-select-choices>
</ui-select>

<div class="help-block" ng-messages="ConfigForm.account_id.$error" ng-show="ConfigForm.$submitted">
<div ng-messages-include="modules/templates/messages.tmpl.html"></div>
</div>
</div>
</div>
<hr>

<bh-loading-button loading-state="ConfigForm.$loading">
<span translate>REPORT.UTIL.PREVIEW</span>
</bh-loading-button>
</form>
</div>
</div>
</div>
</div>
</div>
1 change: 1 addition & 0 deletions client/src/modules/reports/reports.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ angular.module('bhima.routes')
'breakEvenFeeCenter',
'indicatorsReport',
'visit_report',
'monthlyBalanceAnalysis',
];

$stateProvider
Expand Down
1 change: 1 addition & 0 deletions server/config/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ exports.configure = function configure(app) {
app.get('/reports/finance/income_expense_by_year', financeReports.income_expense_by_year.document);
app.get('/reports/finance/cash_report', financeReports.cashReport.document);
app.get('/reports/finance/balance', financeReports.balance.document);
app.get('/reports/finance/monthly_balance', financeReports.monthlyBalance.document);
app.get('/reports/finance/account_report', financeReports.reportAccounts.document);
app.get('/reports/finance/account_report_multiple', financeReports.reportAccountsMultiple.document);
app.get('/reports/finance/journal', financeReports.journal.postingReport);
Expand Down
1 change: 1 addition & 0 deletions server/controllers/finance/reports/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ exports.annualClientsReport = require('./debtors/annual-clients-report').annualC
exports.breakEven = require('./break_even');
exports.breakEvenFeeCenter = require('./break_even_fee_center');
exports.operating = require('./operating');
exports.monthlyBalance = require('./monthlyBalance');
Loading

0 comments on commit 06d9f60

Please sign in to comment.