-
Notifications
You must be signed in to change notification settings - Fork 105
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
bors
merged 5 commits into
Third-Culture-Software:master
from
lomamech:featureMonthlyBalance
Jul 31, 2019
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which kind of analysis ?
There was a problem hiding this comment.
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