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

Account statement - basic user interface #1672

Merged
merged 19 commits into from
May 26, 2017

Conversation

mbayopanda
Copy link
Collaborator

This PR is about the issue #1638

@sfount sfount self-requested a review May 24, 2017 09:59
Copy link
Contributor

@sfount sfount left a 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));
Copy link
Contributor

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;
Copy link
Contributor

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',
Copy link
Contributor

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);
Copy link
Contributor

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.

Copy link
Collaborator Author

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 });
Copy link
Contributor

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">
Copy link
Contributor

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) {
Copy link
Contributor

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.

Copy link
Collaborator

@jniles jniles left a 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.

  1. Sharing the same filter modal between the Posting Journal and the Account Statement is a really good idea. Your implementation looks fine to me.
  2. Migrating the GL to FilterParser is a really nice improvement.

Some things to improve in the future, but are not necessarily blocking:

  1. 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) {
Copy link
Collaborator

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,
Copy link
Collaborator

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',
Copy link
Collaborator

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>
Copy link
Collaborator

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
Copy link
Collaborator

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) {
Copy link
Collaborator

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) {
Copy link
Collaborator

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>
Copy link
Collaborator

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>
Copy link
Collaborator

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');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice improvement with FilterParser 👍

Copy link
Collaborator

@jniles jniles left a 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>
Copy link
Collaborator

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()
Copy link
Collaborator

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.

Copy link
Collaborator

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.

Copy link
Collaborator

@jniles jniles left a 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.

@jniles
Copy link
Collaborator

jniles commented May 25, 2017

bors r+

bors bot added a commit that referenced this pull request May 25, 2017
1672: Account statement - basic user interface r=jniles
This PR is about the issue #1638
@jniles
Copy link
Collaborator

jniles commented May 25, 2017

bors r-

@bors
Copy link
Contributor

bors bot commented May 25, 2017

Canceled

@jniles
Copy link
Collaborator

jniles commented May 25, 2017

@mbayopanda, the merge of #1667 seems to have broken this :(

@jniles jniles merged commit 43a989e into Third-Culture-Software:master May 26, 2017
@mbayopanda mbayopanda deleted the account_statement branch August 22, 2017 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants