Skip to content

Commit

Permalink
fix(journal): misc errors
Browse files Browse the repository at this point in the history
This commit fixes various miscellaneous usability errors and typos in
the journal, trial balance, and transaction editing process.
Specifically:
 1. Better French translation in the Journal Search Modal (thanks
 @mbayopanda)
 2. Description is automatically copied onto new modal line when adding
 a new lint (thanks @lomamech)
 3. Caught a typo that prevented commenting from working (@mbayopanda).
 4. Caught a bug that prevents editing a row when clicking on its group
 header (@lomamech).
  • Loading branch information
jniles committed Sep 25, 2017
1 parent 67c3b7e commit 60eba0d
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ SESS_RESAVE=0
SESS_UNSET='destroy'

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

# this will toggle all MYSQL errors to be reflected to the client.
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"angular-messages": "1.6.5",
"angular-bootstrap": "2.5.0",
"angular-ui-router": "1.0.0-rc.1",
"angular-ui-grid": "4.0.6",
"angular-ui-grid": "4.0.4",
"angular-translate": "2.15.2",
"angular-translate-loader-static-files": "2.15.2",
"angular-translate-loader-url": "2.15.2",
Expand Down
4 changes: 2 additions & 2 deletions client/src/i18n/fr/transactions.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"TRANSACTIONS": {
"VERIFIED_TRANSACTIONS": "Transactions vérifiées",
"VERIFIED_TRANSACTIONS": "Transactions Postées",
"INCLUDE_POSTED_TRANSACTIONS_DETAIL": "Inclure les transactions affichées dans la recherche",
"INCLUDE_POSTED_TRANSACTIONS_SHORT": "Transactions posté",
"INCLUDE_POSTED_TRANSACTIONS_SHORT": "Transactions Postées",
"SINGLE_ACCOUNT_TRANSACTION" : "Cette transaction contient un seul compte. Veuillez sélectionner plusieurs comptes pour compléter la transaction.",
"MISSING_TRANSACTION_TYPE" : "Les transactions impliquant des comptes de trésorerie (banques ou caisses) doivent avoir un type de transaction spécifié pour les différencier dans le rapport de trésorerie. Veuillez sélectionner un type de transaction.",
"IMBALANCED_TRANSACTION" : "Les débits et les crédits de cette transaction doivent être équilibrés. Veuillez corriger les déséquilibres avant de les soumettre.",
Expand Down
37 changes: 33 additions & 4 deletions client/src/js/services/grid/GridSelection.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ angular.module('bhima.services')
GridSelectionService.$inject = ['util'];

function GridSelectionService(util) {

function GridSelection(gridOptions) {
// key used to determine if multiple selected rows are in the same group
this._uniqueKey = 'trans_id';
Expand All @@ -16,18 +15,48 @@ function GridSelectionService(util) {

util.after(gridOptions, 'onRegisterApi', function onRegisterApi(api) {
this._gridApi = api;

this._gridApi.selection.on.rowSelectionChanged(null, selectedHook.bind(this));
this._gridApi.selection.on.rowSelectionChangedBatch(null, selectedHook.bind(this));
this._gridApi.selection.on.rowSelectionChangedBatch(null, selectedHookBatch.bind(this));
}.bind(this));
}

function selectedHook() {
function updateSelectedGroups() {
var currentSelection = this._gridApi.selection.getSelectedRows();
var currentGroups = collapseRowsToGroups.bind(this)(currentSelection);
this.selected.groups = currentGroups;
}

function selectedHookBatch() {
updateSelectedGroups.call(this);
}

function isHeaderRow(row) {
return angular.isDefined(row.groupHeader);
}

function selectedHook(row) {
var isHeaderSelected;
var children;

var getRowChildren = this._gridApi.treeBase.getRowChildren.bind(this);
var toggleRowSelectionFn = this._gridApi.selection.toggleRowSelection.bind(this);

// special treatment to header rows:
// if the header is selected, select all children.
// if the header is unselected, unselect all children.
if (isHeaderRow(row)) {
isHeaderSelected = row.isSelected;
children = getRowChildren(row);
children.forEach(function (child) {
if (child.isSelected !== isHeaderSelected) {
toggleRowSelectionFn(child.entity);
}
});
}

updateSelectedGroups.call(this);
}

function collapseRowsToGroups(rows) {
var groups = {};

Expand Down
6 changes: 3 additions & 3 deletions client/src/modules/journal/modals/editTransaction.modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ function JournalEditTransactionController(
vm.shared = sharedDetails(vm.rows.data[0]);
vm.gridOptions.data = vm.rows.data;
})
.catch(function (error) {
console.error(error);
.catch(function () {
vm.hasError = true;
})
.finally(function () {
Expand Down Expand Up @@ -201,6 +200,7 @@ function JournalEditTransactionController(
Journal.saveChanges(transactionRequest, changes)
.then(function (resultUpdatedTransaction) {
var transaction = new Store({ identifier : 'uuid' });

transaction.setData(resultUpdatedTransaction);

// collapse information for the module that might expect to apply optimistic updates
Expand Down Expand Up @@ -285,7 +285,7 @@ function JournalEditTransactionController(
function sharedDetails(row) {
var columns = [
'hrRecord', 'record_uuid', 'project_name', 'trans_id', 'origin_id', 'display_name', 'trans_date',
'project_id', 'fiscal_year_id', 'currency_id', 'user_id', 'posted', 'period_id',
'project_id', 'fiscal_year_id', 'currency_id', 'user_id', 'posted', 'period_id', 'description',
];

var shared = {};
Expand Down
8 changes: 4 additions & 4 deletions server/controllers/finance/journal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -533,13 +533,13 @@ function getTransactionDate(changedRows = {}, oldRows) {
* @param {object} params - { uuids: [...], comment: '' }
*/
function commentPostingJournal(req, res, next) {
const { uids, comment } = req.body.params;
const uuids = uids.map(db.bid);
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, [uuids]])
db.exec(sql, [comment, [uids]])
.then((rows) => {
const updatedWithSuccess = rows.affectedRows && rows.affectedRows === uuids.length;
const updatedWithSuccess = rows.affectedRows && rows.affectedRows === uids.length;

if (!updatedWithSuccess) {
throw new BadRequest('Error on update posting journal comment.');
Expand Down

0 comments on commit 60eba0d

Please sign in to comment.