Skip to content

Commit

Permalink
fix(trial_balance): ensure client works with server
Browse files Browse the repository at this point in the history
This commit updates the client TrialBalance service to use the new server API.  It removes the
warning case and ensures that only the error cases are reported.
  • Loading branch information
Jonathan Niles authored and jniles committed Apr 15, 2017
1 parent 5efcd8e commit 1d3b7b2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 25 deletions.
33 changes: 9 additions & 24 deletions client/src/modules/journal/modals/trialBalance.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,45 +16,30 @@ function TrialBalanceService(util, $http, $translate) {
service.getRelatedTransaction = getRelatedTransaction;
service.parseErrorRecord = parseErrorRecord;

function parseErrorRecord (records){
var list = [];

function parseErrorRecord(records) {
/**
* records is an array of items representing checks,
* if there is an error or warning the item will be defined
* with some descriptions about the errors or warnings
*/
records.forEach(function (record) {
var line = [];
var codeTranslated = null;

codeTranslated = $translate.instant(record.code);
line = record.transactions.map(function (item) {
return {code : codeTranslated, transaction : item};
});

list = list.concat(line);
return records.map(function (record) {
record.code = $translate.instant(record.code);
return record;
});

return list;
}

function getCSSClass (feedBack) {
return feedBack.hasError ? 'grid-error' : feedBack.hasWarning ? 'grid-warning' : 'grid-success';
function getCSSClass(feedBack) {
return feedBack.hasError ? 'grid-error' : 'grid-success';
}

function getFeedBack(errors) {
var feedBack = {};

feedBack.hasError = errors.some(function (error) {
return error && error.fatal;
});

feedBack.hasWarning = errors.some(function (error) {
return error && !error.fatal;
return error;
});

feedBack.hasSuccess = (!feedBack.hasWarning && !feedBack.hasError) ? true : false;
feedBack.hasSuccess = !feedBack.hasError;

return feedBack;
}
Expand All @@ -75,7 +60,7 @@ function TrialBalanceService(util, $http, $translate) {

/** extract only an unique trans_id property and put it in an array*/
lines.forEach(function (line) {
if(transactions.indexOf(line.trans_id) === -1){
if (transactions.indexOf(line.trans_id) === -1) {
transactions.push(line.trans_id);
}
});
Expand Down
2 changes: 1 addition & 1 deletion test/integration/trialBalance.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('(/trial) API endpoint', () => {
.catch(helpers.handler);
});

it.skip('POST /trial_balance/post_transactions posts the a transaction to general_ledger and remove it form the posting_general', () => {
it('POST /trial_balance/post_transactions posts the a transaction to general_ledger and remove it form the posting_general', () => {
return agent.post('/trial_balance/post_transactions')
.send(formatParams(POSTING_TXNS))
.then((res) => {
Expand Down

0 comments on commit 1d3b7b2

Please sign in to comment.