Skip to content

Commit

Permalink
fix(journal): typos and commenting on posted recs
Browse files Browse the repository at this point in the history
This commit fixes a few typos, consolidates a few CSS rules and removes
unused code.  It fixes a bug that disallowed posted records from being
commented, as this path was never tested before.
  • Loading branch information
jniles committed Sep 25, 2017
1 parent ecc163d commit fbfdacc
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 75 deletions.
3 changes: 2 additions & 1 deletion .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ SESS_UNSET='destroy'

LOG_LEVEL='warn'
# LOG_LEVEL='debug'
# UPLOAD_DIR='client/upload'

UPLOAD_DIR='client/upload'

# this will toggle all MYSQL errors to be reflected to the client.
LOG_ALL_MYSQL_ERRORS=0
Expand Down
9 changes: 9 additions & 0 deletions client/src/less/bhima-bootstrap.less
Original file line number Diff line number Diff line change
Expand Up @@ -305,3 +305,12 @@ input[type=number] {-moz-appearance: textfield;}
.ui-grid-exporter-csv-link {
display : none;
}

.pad-alert {
border-radius : 0px;
padding-left : 5px;
padding-right : 5px;
padding-top : 10px;
padding-bottom : 10px;
margin-bottom : 10px;
}
5 changes: 2 additions & 3 deletions client/src/modules/journal/modals/editTransaction.modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
<span class="badge badge-primary" ng-if="!ModalCtrl.readOnly"><i class="fa fa-pencil"></i> <span translate>POSTING_JOURNAL.EDITING</span></span>
</ol>
</div>

<div class="modal-body">
<!-- warn user that standard users cannot edit posted transactions -->
<div class="alert alert-warning" ng-if="ModalCtrl.validation.blockedPostedTransactionEdit" style="border-radius : 0px; padding-left : 5px; padding-right : 5px; padding-top : 10px; padding-bottom : 10px; margin-bottom : 10px;">
<div class="alert alert-warning pad-alert" ng-if="ModalCtrl.validation.blockedPostedTransactionEdit">
<i class="fa fa-warning"></i> <span translate>POSTING_JOURNAL.ERRORS.USER_CANNOT_EDIT_POSTED_TRANSACTION</span>
</div>

Expand Down Expand Up @@ -90,7 +89,7 @@
</div>
</div>

<div class="alert alert-danger" id="validation-errored-alert" ng-if="ModalCtrl.validation.errored" style="border-radius : 0px; padding-left : 5px; padding-right : 5px; padding-top : 10px; padding-bottom : 10px; margin-bottom : 10px;">
<div class="alert alert-danger pad-alert" id="validation-errored-alert" ng-if="ModalCtrl.validation.errored">
<i class="fa fa-exclamation-circle"></i> <span translate>{{ModalCtrl.validation.message}}</span>
</div>

Expand Down
2 changes: 0 additions & 2 deletions client/src/modules/journal/modals/editTransaction.modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,6 @@ function JournalEditTransactionController(
return ERROR_NEGATIVE_NUMBERS;
}

window.util = util;

var hasSingleNumericValue = !util.xor(Boolean(row.debit_equiv), Boolean(row.credit_equiv));
if (hasSingleNumericValue) {
return ERROR_INVALID_DEBITS_AND_CREDITS;
Expand Down
2 changes: 1 addition & 1 deletion client/src/modules/journal/trial-balance/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ angular.module('bhima.controllers')
TrialBalanceErrorsController.$inject = ['TrialBalanceService', 'NotifyService'];

/**
* @module TrialBalanceErrorsController
* @overview TrialBalanceErrorsController
*
* @description
* This controller provides a view of the errors in the selected transactions
Expand Down
60 changes: 0 additions & 60 deletions client/src/modules/journal/trial-balance/overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ function TrialBalanceOverviewController(Session, TrialBalance, Notify, uiGridCon
var currencyId = Session.enterprise.currency_id;

var columns;
var subGridColumns;

var GRID_HEADER_ERROR_CLASS = 'ui-grid-header-cell-error';
var GRID_HEADER_DEFAULT_CLASS = 'ui-grid-header-cell-primary';
Expand Down Expand Up @@ -79,73 +78,14 @@ function TrialBalanceOverviewController(Session, TrialBalance, Notify, uiGridCon
fastWatch : true,
flatEntityAccess : true,
columnDefs : columns,
expandableRowTemplate : '/modules/journal/trial-balance/overview.subgrid.html',
expandableRowScope : vm,
enableColumnResizing : true,
onRegisterApi : onRegisterApi,
};

function onRegisterApi(api) {
vm.gridApi = api;

// TODO - should we really cache the trial balance transactions?
// api.expandable.on.rowExpandedStateChanged(null, loadSubGridRecords);
}

/*
function loadSubGridRecords(row) {
var accountId = row.entity.accountId;
// turn on the subgrid loading indicator
vm.loadingSubGrid = true;
TrialBalance.fetchSubGridRecords(accountId)
.then(function (data) {
vm.subGridOptions.data = data;
})
.catch(function () {
vm.hasSubGridErrors = true;
})
.finally(function () {
vm.loadingSubGrid = false;
});
}
*/

subGridColumns = [{
field : 'trans_id',
displayName : 'TABLE.COLUMNS.TRANSACTION',
headerCellFilter : 'translate',
}, {
field : 'credit_equiv',
type : 'number',
displayName : 'TABLE.COLUMNS.CREDIT',
headerCellFilter : 'translate',
cellFilter : 'currency:'.concat(currencyId),
cellClass : 'text-right',
}, {
field : 'debit_equiv',
type : 'number',
displayName : 'TABLE.COLUMNS.DEBIT',
headerCellFilter : 'translate',
cellFilter : 'currency:'.concat(currencyId),
cellClass : 'text-right',
}, {
field : 'actions',
displayName : '',
headerCellFilter : 'translate',
enableSorting : false,
cellTemplate : '/modules/journal/trial-balance/.html',
}];

vm.subGridOptions = {
enableColumnMenus : false,
showColumnFooter : false,
fastWatch : true,
flatEntityAccess : true,
columnDefs : subGridColumns,
};

// FIXME(@jniles) - this is kind of hacky
TrialBalance.bindGridExporter(
new GridExport(vm.gridOptions, 'all', 'visible')
Expand Down
21 changes: 13 additions & 8 deletions server/controllers/finance/journal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -530,21 +530,26 @@ function getTransactionDate(changedRows = {}, oldRows) {

/**
* PUT /journal/comments
*
* @function commentPostingJournal
*
* @description
* This function will put a comment on both the posting journal and general ledger.
*
* @param {object} params - { uuids: [...], comment: '' }
*/
function commentPostingJournal(req, res, next) {
const { uuids, comment } = req.body.params;
const uids = uuids.map(db.bid);
const sql = 'UPDATE posting_journal SET comment = ? WHERE uuid IN ?';

db.exec(sql, [comment, [uids]])
.then((rows) => {
const updatedWithSuccess = rows.affectedRows && rows.affectedRows === uids.length;

if (!updatedWithSuccess) {
throw new BadRequest('Error on update posting journal comment.');
}
const journalUpdate = 'UPDATE posting_journal SET comment = ? WHERE uuid IN ?';
const ledgerUpdate = 'UPDATE general_ledger SET comment = ? WHERE uuid IN ?';

q.all([
db.exec(journalUpdate, [comment, [uids]]),
db.exec(ledgerUpdate, [comment, [uids]]),
])
.then(() => {
res.sendStatus(200);
})
.catch(next)
Expand Down

0 comments on commit fbfdacc

Please sign in to comment.