-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
3815: feature(Monthly Balance Analysis) r=mbayopanda a=lomamech - Add new report for Analysis Monthly Balance of accounts closes #3803 Co-authored-by: Chris Lomame <lomamech@gmail.com>
- Loading branch information
Showing
13 changed files
with
452 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
client/src/modules/reports/generate/monthlyBalance/monthlyBalance.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
102
client/src/modules/reports/generate/monthlyBalance/monthlyBalance.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.