Skip to content

Commit

Permalink
feat(components): bhJournalLink for linkin records
Browse files Browse the repository at this point in the history
This commit adds a component for linking record_uuids in the journal via
some display method.  Currently the display is the same one that is
shown as the display value of the filter - this may need to change.

A demonstration of this is in the Trial Balance Error Links.
  • Loading branch information
jniles committed Sep 25, 2017
1 parent bd506b4 commit 25aa4c1
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
11 changes: 11 additions & 0 deletions client/src/js/components/bhJournalLink.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
var templateStr =
'<a ui-sref="journal({ filters : [{ key : \'record_uuid\', value : $ctrl.recordUuid, displayValue: $ctrl.display }] })" ui-sref-opts="{ reload : false }">' +
'<span translate>{{ $ctrl.display }}</span>' +
'</a>';

angular.module('bhima.components')
.component('bhJournalLink', {
template : templateStr,
bindings : { recordUuid : '<', display : '@' },
});

1 change: 1 addition & 0 deletions client/src/modules/journal/journal.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ function JournalService(Api, AppCache, Filters, Periods, Modal) {
// custom filters can be optionally applied
journalFilters.registerCustomFilters([
{ key : 'trans_id', label : 'FORM.LABELS.TRANS_ID' },
{ key : 'record_uuid', label : 'FORM.LABELS.TRANS_ID' },
{ key : 'reference', label : 'FORM.LABELS.REFERENCE' },
{ key : 'user_id', label : 'FORM.LABELS.USER' },
{ key : 'account_id', label : 'FORM.LABELS.ACCOUNT' },
Expand Down
7 changes: 7 additions & 0 deletions client/src/modules/journal/trial-balance/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ TrialBalanceErrorsController.$inject = ['TrialBalanceService', 'NotifyService'];
function TrialBalanceErrorsController(TrialBalance, Notify) {
var vm = this;

// links the errors to the posting journal via their record uuid
var link =
'<div class="ui-grid-cell-contents">' +
'<bh-journal-link record-uuid="row.entity.record_uuid" display="{{row.entity.trans_id}}"></bh-journal-link>' +
'</div>';

var columns = [{
field : 'code',
displayName : 'TABLE.COLUMNS.ERROR_TYPE',
Expand All @@ -24,6 +30,7 @@ function TrialBalanceErrorsController(TrialBalance, Notify) {
displayName : 'TABLE.COLUMNS.TRANSACTION',
headerCellFilter : 'translate',
headerCellClass : 'ui-grid-header-cell-error',
cellTemplate : link,
}];

vm.gridOptions = {
Expand Down
7 changes: 6 additions & 1 deletion server/controllers/finance/journal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ function lookupTransaction(recordUuid) {
* return all items in the posting journal
*/
function find(options, source) {
// make sure hex -> binary parameters are converted properly
db.convert(options, ['uuid', 'record_uuid']);

const filters = new FilterParser(options, { tableAlias : 'p', autoParseStatements : false });

// @FIXME selected the source between the posting journal and general ledger should be carefully designed
Expand Down Expand Up @@ -129,6 +132,8 @@ function find(options, source) {
filters.equals('trans_id');
filters.equals('origin_id');

filters.equals('record_uuid');

filters.custom('amount', '(credit_equiv = ? OR debit_equiv = ?)', [options.amount, options.amount]);

filters.setOrder('ORDER BY p.trans_date DESC');
Expand Down Expand Up @@ -339,7 +344,7 @@ function editTransaction(req, res, next) {
// transaction chagnes written successfully - return latest version of transaction
return lookupTransaction(recordUuid);
})
.then((updatedTransaction) => {
.then((updatedTransaction) => {
const updatedRows = updatedTransaction.journal;
res.status(200).json(updatedRows);
})
Expand Down

0 comments on commit 25aa4c1

Please sign in to comment.