Skip to content

Commit

Permalink
add hrRecord for deleted transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
mbayopanda committed Jul 22, 2021
1 parent bec2127 commit 75c3d9c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
5 changes: 4 additions & 1 deletion client/src/modules/journal/templates/log.record.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<div ng-if="row.entity.hrRecord" class="ui-grid-cell-contents">
<div ng-if="row.entity.hrRecord && row.entity.action != 'deleted'" class="ui-grid-cell-contents">
<bh-reference-link reference="row.entity.hrRecord" />
</div>
<div ng-if="row.entity.hrRecord && row.entity.action == 'deleted'" class="ui-grid-cell-contents">
<span class="text-danger">{{ row.entity.hrRecord }}</span>
</div>
<div ng-if="!row.entity.hrRecord && row.entity.action == 'deleted'" class="ui-grid-cell-contents">
<em class="text-danger" translate>POSTING_JOURNAL.DELETED_TRANSACTION</em>
</div>
8 changes: 7 additions & 1 deletion client/src/modules/journal/templates/log.transaction.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@
ui-sref="journal({filters : [{ key : 'trans_id', displayValue : row.entity.transId, value: row.entity.transId, cacheable: 0 },
{ key : 'includeNonPosted', value : 1 }, { key : 'period', value : 'allTime' }]})"
ui-sref-opts="{ reload : false }"
ng-if="row.entity.transId"
ng-if="row.entity.transId && row.entity.action != 'deleted'"
class="text-uppercase">
{{ row.entity.transId }}
</a>

<span
ng-if="row.entity.transId && row.entity.action == 'deleted'"
class="text-danger text-uppercase">
{{ row.entity.transId }}
</span>
</div>
4 changes: 3 additions & 1 deletion server/controllers/finance/journal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@ async function log(req, res, next) {
th.timestamp AS timestamp,
th.value AS value,
th.action,
u.display_name
u.display_name,
dm.text as hrRecord
FROM transaction_history th
JOIN user u ON u.id = th.user_id
LEFT JOIN document_map dm ON dm.uuid = th.record_uuid
`;

filters.fullText('description', 'value');
Expand Down
8 changes: 7 additions & 1 deletion server/controllers/finance/transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,13 @@ async function deleteTransaction(uuid, actions, userId) {
throw new Unauthorized(`User is not authorized to remove ${documentMap.text}.`);
}

const transactionRecord = await db.exec('SELECT * FROM posting_journal WHERE record_uuid = ?', [db.bid(uuid)]);
const transactionRecord = await db.exec(`
SELECT pj.*, dm.text as hrRecord
FROM posting_journal pj
JOIN document_map dm ON dm.uuid = pj.record_uuid
WHERE pj.record_uuid = ?
`, [db.bid(uuid)]);

const INSERT_TRANSACTION_HISTORY = 'INSERT INTO transaction_history SET ?;';
const transactionHistory = {
uuid : db.uuid(),
Expand Down

0 comments on commit 75c3d9c

Please sign in to comment.