Skip to content

Commit

Permalink
fix(journal): block Trial Balance for posted txns
Browse files Browse the repository at this point in the history
This commit blocks the Trial Balance with a warning to the user if the
user has selected any posted records to perform a Trial Balance.  The
Trial Balance only makes sense on unposted records.
  • Loading branch information
jniles committed Sep 25, 2017
1 parent 22fdc3d commit 59b4f24
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
3 changes: 2 additions & 1 deletion client/src/i18n/en/posting_journal.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@
"WARNINGS":{
"MISSING_ENTITY":"Record without entity type and entity ID",
"NO_TRANSACTIONS_SELECTED":"No transactions selected. You must be in Transaction view to use this tool.",
"MULTIPLE_TRANSACTION_EDIT_DISABLED":"You have multiple transactions selected. Multiple transaction editing is currently disabled"
"MULTIPLE_TRANSACTION_EDIT_DISABLED":"You have multiple transactions selected. Multiple transaction editing is currently disabled.",
"TRIAL_BALANCE_HAS_POSTED_RECORDS":"You have selected posted records! The Trial Balance can only show results of unposted records."
},
"TRIAL_BALANCE" : {
"TITLE" : "Trial Balance",
Expand Down
15 changes: 13 additions & 2 deletions client/src/modules/journal/journal.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,25 @@ function JournalController(Journal, Sorting, Grouping,
// gather the selected transactions together
var selectedTransactionIds = selection.selected.groups;
var selectedRecordUuids;
var rows;
var hasPostedRecords;

// make sure a row is selected before running the trial balance
if (selectedTransactionIds.length === 0) {
Notify.warn('POSTING_JOURNAL.WARNINGS.NO_TRANSACTIONS_SELECTED');
return;
}

rows = vm.gridApi.selection.getSelectedRows();
hasPostedRecords = rows.some(function (row) {
return row.posted === 1;
});

if (hasPostedRecords) {
Notify.warn('POSTING_JOURNAL.WARNINGS.TRIAL_BALANCE_HAS_POSTED_RECORDS');
return;
}

selectedRecordUuids = selectedTransactionIds.map(lookupIntermediateRecordUuid);

// initialize the data request to the server
Expand Down Expand Up @@ -324,7 +336,6 @@ function JournalController(Journal, Sorting, Grouping,
exportation.run();
};


function errorHandler(error) {
vm.hasError = true;
Notify.handleError(error);
Expand Down Expand Up @@ -371,7 +382,7 @@ function JournalController(Journal, Sorting, Grouping,
// TODO(@jniles) - this is kind of hacky. We shouldn't have to check the $params on every
// load(), only on the initial load. Redesign?
if ($state.params.scrollTo) {
transactions.scrollIntoView($state.params.scrollTo);
// transactions.scrollIntoView($state.params.scrollTo);
delete $state.params.scrollTo;
}
})
Expand Down

0 comments on commit 59b4f24

Please sign in to comment.