Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature(Monthly Balance Analysis) #3815

Merged
merged 5 commits into from
Jul 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion client/src/i18n/en/report.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@
"PROFIT_AND_LOSS_BY_MONTH": "Profit and Loss Statement By Month",
"PROFIT_AND_LOSS_BY_YEAR": "Profit and Loss Statement By Fiscal Year",
"INCOME_REPORT": "Income Report",
"MONTHLY_BALANCE": "Monthly Balance",
"MONTHLY_BALANCE": {
"DESCRIPTION": "This report is used to analyze the balance of accounts on a monthly basis. This analysis shows the total debits and credits as well as the total balances for each account.",
"TITLE": "Monthly Balance"
},
"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",
"MONTHLY_BALANCE": "Monthly Balance",
"MULTI_PAYROLL" : "Multiple Payroll",
"OHADA_BILAN":"[OHADA] Bilan",
"OHADA_PROFIT_LOSS" : "[OHADA] Profit and Loss",
Expand Down
5 changes: 4 additions & 1 deletion client/src/i18n/fr/report.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@
"PROFIT_AND_LOSS_BY_MONTH": "Rapport des Produit et des Charges par Mois",
"PROFIT_AND_LOSS_BY_YEAR": "Rapport des Produit et des Charges par Années",
"INCOME_REPORT" : "Rapport des Recettes",
"MONTHLY_BALANCE" : "Balance Mensuelle",
"MONTHLY_BALANCE": {
"DESCRIPTION": "Ce rapport permet de faire l'analyse mensuel de la balance des comptes, cette analyse permet de visualiser le total des debits et des des crédits ainsi que le totals des soldes pour chaque comptes",
"TITLE": "Analyse mensuel de la Balance"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which kind of analysis ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Balance par mois" or "Balance par periode" can be good as title, since the report is just the balance for a given period

},
"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",
"MONTHLY_BALANCE": "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,87 @@
angular.module('bhima.controllers')
.controller('monthlyBalanceController', MonthlyBalanceController);

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

function MonthlyBalanceController($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
const 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.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);
}
}
}
102 changes: 102 additions & 0 deletions client/src/modules/reports/generate/monthlyBalance/monthlyBalance.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<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_BALANCE.TITLE</h3>
<p class="text-info" translate>REPORT.MONTHLY_BALANCE.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>

<div class="form-group" 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>

<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',
'monthlyBalance',
];

$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