From e8436a79c4c68afcb90da5da326ad7970bbfa814 Mon Sep 17 00:00:00 2001 From: lomamech Date: Tue, 15 Mar 2022 12:00:18 +0100 Subject: [PATCH] improvement(Employee voucher) - Add creditor name in Voucher for Employee closes #6377 --- server/controllers/finance/reports/vouchers/index.js | 1 - .../controllers/finance/reports/vouchers/receipt.handlebars | 2 +- server/controllers/finance/vouchers.js | 6 +++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/server/controllers/finance/reports/vouchers/index.js b/server/controllers/finance/reports/vouchers/index.js index fb9cd54057..6da36da043 100644 --- a/server/controllers/finance/reports/vouchers/index.js +++ b/server/controllers/finance/reports/vouchers/index.js @@ -82,7 +82,6 @@ async function receipt(req, res, next) { } } - /** * GET reports/finance/vouchers * diff --git a/server/controllers/finance/reports/vouchers/receipt.handlebars b/server/controllers/finance/reports/vouchers/receipt.handlebars index 734564f9e8..0824656cb1 100644 --- a/server/controllers/finance/reports/vouchers/receipt.handlebars +++ b/server/controllers/finance/reports/vouchers/receipt.handlebars @@ -69,7 +69,7 @@ {{currency debit ../details.currency_id}} {{currency credit ../details.currency_id}} - {{ entity_reference }} + {{ entity_reference }} {{ creditorName }} {{ document_reference }} {{/each}} diff --git a/server/controllers/finance/vouchers.js b/server/controllers/finance/vouchers.js index bf3be4e2d2..245c00afd6 100644 --- a/server/controllers/finance/vouchers.js +++ b/server/controllers/finance/vouchers.js @@ -86,14 +86,18 @@ async function lookupVoucher(vUuid) { WHERE v.uuid = ?; `; + // For get Creditor name const itemSql = ` SELECT BUID(vi.uuid) AS uuid, vi.debit, vi.credit, vi.account_id, a.number, a.label, BUID(vi.document_uuid) as document_uuid, document_map.text AS document_reference, - BUID(entity_uuid) AS entity_uuid, entity_map.text AS entity_reference, vi.description + BUID(entity_uuid) AS entity_uuid, entity_map.text AS entity_reference, vi.description, + CONCAT('/ ', c.text) AS creditorName FROM voucher_item vi JOIN account a ON a.id = vi.account_id LEFT JOIN entity_map ON entity_map.uuid = vi.entity_uuid LEFT JOIN document_map ON document_map.uuid = vi.document_uuid + LEFT JOIN employee emp ON emp.creditor_uuid = vi.entity_uuid + LEFT JOIN creditor c ON c.uuid = emp.creditor_uuid WHERE vi.voucher_uuid = ? ORDER BY vi.account_id DESC, vi.debit DESC, vi.credit ASC, entity_reference; `;