-
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
Account statement - basic user interface #1672
Account statement - basic user interface #1672
Conversation
…into account_statement
…into account_statement
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.
This looks like a great start for the Account Statement module! I've made comments with some minor suggestions but none of them should be blocking if this needs to be merged.
.then(function (res) { | ||
if (!res) { return; } | ||
Notify.success('ACCOUNT_STATEMENT.SUCCESSFULLY_COMMENTED'); | ||
load(AccountStatement.filters.formatHTTP(true)); |
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.
Is it necessary to reload all of the data in the account statement just because comments are added? I propose that on confirmation from the server we update the data locally so that it reflects these changes.
With editing financial information I think it is important to ensure the client and the server have the same data, however with comments I think an optimistic local update should work well.
What do you think?
GeneralLedger.read(null, options) | ||
.then(function (data) { | ||
vm.gridOptions.data = data; | ||
vm.loading = false; |
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.
This should not be needed as it is included in the .finally
|
||
// DI | ||
CommentAccountStatementController.$inject = [ | ||
'$uibModalInstance', 'data', 'AccountStatementService', 'NotifyService', |
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.
What does data mean here?
I see from the context of the controller calling it that it contains the selected rows from the grid - I think the name could better reflect what is happening here!
Something like gridSelectionContext
? Whatever makes sense to you.
AccountStatement.commentAccountStatement(params) | ||
.then(function (res) { | ||
if (!res) { return; } | ||
Instance.close(res); |
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.
Again I think .finally
if this promise if resolved or rejected. Instance.close
will be called twice in the case of success.
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.
In this section the value returned is not false, in the finally clause we have .finally(Instance.close)
which return a falsy value
*/ | ||
function list(req, res, next) { | ||
function find(options) { | ||
const filters = new FilterParser(options, { tableAlias : 'gl', autoParseStatements : false }); |
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.
👍
required="0"> | ||
<bh-clear on-clear="ModalCtrl.clear('account_id')"></bh-clear> | ||
</bh-account-select> | ||
<div ng-if="!ModalCtrl.hasDefaultAccount"> |
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.
A comment explaining when this switch is used would be useful for developers working on either the Journal or the Account Statement module.
@@ -22,11 +27,30 @@ function JournalSearchModalController(Instance, Projects, Notify, Store, filters | |||
// assign already defined custom filters to searchQueries object | |||
vm.searchQueries = util.maskObjectFromKeys(filters, searchQueryOptions); | |||
|
|||
// has default account | |||
if (options.hasDefaultAccount) { |
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.
It would be useful to document the behaviour of hasDefaultAccount
somewhere in a comment. The branching logic here could be difficult to follow if you didn't see that it was used by different modules with different needs.
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.
@mbayopanda, there are some very nice features in this PR.
- Sharing the same filter modal between the Posting Journal and the Account Statement is a really good idea. Your implementation looks fine to me.
- Migrating the GL to FilterParser is a really nice improvement.
Some things to improve in the future, but are not necessarily blocking:
- We already know that this component will be used on both the Posting Journal and the Account Statement. It would be ideal if we could design this feature so that it is easily transposed to each module, potentially as a component or directive.
I've made some other comments that may need to be addressed.
|
||
// replaces current filters with filters from cache | ||
FilterList.prototype.loadCache = function loadCache(storedCache) { | ||
Object.keys(storedCache).forEach(function (key) { | ||
var cached = storedCache[key]; | ||
var currentFilter = this._filterIndex[key]; | ||
if(currentFilter) { | ||
if (currentFilter) { |
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.
👍
|
||
vm.gridOptions = { | ||
enableColumnMenus : false, | ||
enableCellEdit : false, |
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.
We don't need the enableCellEdit
option for this module.
visible : false, | ||
footerCellTemplate : '<i></i>' }, | ||
|
||
{ field : 'uuid', |
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.
Do we ever need to see the uuid?
|
||
<div class="toolbar-item"> | ||
<button data-method="comment" class="btn btn-default" ng-disabled="!AccountStateCtrl.selectedRows.length" ng-click="AccountStateCtrl.commentRows()"> | ||
<i class="fa fa-sticky-note-o"></i> <span class="hidden-xs" translate>FORM.LABELS.COMMENT</span> |
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.
👍
ui-grid-move-columns | ||
ui-grid-selection | ||
ui-grid-cellNav | ||
ui-grid-edit |
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.
Do we need ui-grid edit?
} | ||
|
||
// get rows uuid | ||
function uuids(rows) { |
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.
A better name for this function would be something like "getRowIds()" or something. It's confusing since uuid()
on the server.
* </pre> | ||
* | ||
*/ | ||
function expectCellValueMatch(gridId, row, col, value) { |
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.
👍
|
||
<div class="row"> | ||
<div class="col-xs-4"> | ||
{{translate 'TABLE.COLUMNS.TOTAL'}} {{translate 'TABLE.COLUMNS.DEBIT'}}: <strong>{{currency (sum rows 'debit_equiv')}}</strong> |
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.
Could you move this sum
function to SQL? It would be much more efficient.
</div> | ||
|
||
<div class="col-xs-4"> | ||
{{translate 'TABLE.COLUMNS.RESULT'}}: <strong>{{currency (substract (sum rows 'debit_equiv') (sum rows 'credit_equiv'))}}</strong> |
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.
Could you move this sum
function to SQL? It would be much more efficient.
LEFT JOIN document_map dm2 ON dm2.uuid = gl.reference_uuid | ||
`; | ||
|
||
filters.period('period', 'trans_date'); |
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.
Nice improvement with FilterParser 👍
…into account_statement
…into account_statement
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.
LGTM.
I've made one final comment to avoid an HTTP request and improve performance. Let me know what you think.
* if the search modal need to set account selection in default query panel we can send it | ||
* as parameters | ||
* @example | ||
* <pre> |
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.
Very nice comments 👍
vm.defaultQueries.account_id = filters.account_id; | ||
} | ||
|
||
Account.read() |
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.
You don't need this .. I don't think. The onSelectAccount()
callback should return the entire account object. Just do this:
vm.onSelectAccountCallback = function (account) {
vm.currentAccountLabel = account.hrLabel;
// other logic
});
angular.forEach(vm.searchQueries, function (value, key) {
if (angular.isDefined(value)) {
if (key === 'account_id') {
changes.post({ key : key, value : value, displayValue : vm.currentAccountLabel });
}
// ... etc ...
}
});
This way, you don't have to download the entire account list.
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.
Another way to reduce the data transfer is to do Account.read(filters.account_id)
if it exists. That way, we only load one account if we need it's hrlabel
and otherwise we do not load any accounts at all.
I'll merge this and try and implement it to see if it works.
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.
LGTM.
I've made one final comment to avoid an HTTP request and improve performance. Let me know what you think.
bors r+ |
bors r- |
Canceled |
@mbayopanda, the merge of #1667 seems to have broken this :( |
This PR is about the issue #1638