From 5fe5d28c89e89874cb6ae2698bf2d2771f1fb274 Mon Sep 17 00:00:00 2001 From: olayiwola-compucorp <85277674+olayiwola-compucorp@users.noreply.github.com> Date: Mon, 28 Oct 2024 08:23:34 +0100 Subject: [PATCH] FOSFASPRT-19: Sage export for credit note line items should respect configured logic --- .../BAO/ExportFormat/DataProvider/Sage50CSVProvider.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CRM/Financial/BAO/ExportFormat/DataProvider/Sage50CSVProvider.php b/CRM/Financial/BAO/ExportFormat/DataProvider/Sage50CSVProvider.php index 791cd98..2f4fd78 100644 --- a/CRM/Financial/BAO/ExportFormat/DataProvider/Sage50CSVProvider.php +++ b/CRM/Financial/BAO/ExportFormat/DataProvider/Sage50CSVProvider.php @@ -73,7 +73,11 @@ public static function runExportQuery($batchId) { fii.amount as tax_amount, eftc.id as civicrm_entity_financial_trxn_id, li.label as item_description, - li.financial_type_id as financial_type_id, + CASE + WHEN li.financial_type_id IS NOT NULL + THEN li.financial_type_id + ELSE fcli.financial_type_id + END as financial_type_id, fty.name as financial_type, ftyc.name as contribution_financial_type, ov.label as department_code @@ -100,6 +104,7 @@ public static function runExportQuery($batchId) { AND fi.entity_id = fiii.entity_id) AND (fii.financial_account_id IN ($taxAccounts))) LEFT JOIN civicrm_line_item li ON (li.id = fi.entity_id AND fi.entity_table = 'civicrm_line_item') + LEFT JOIN financeextras_credit_note_line fcli ON (fcli.id = fi.entity_id AND fi.entity_table = 'financeextras_credit_note_line') LEFT JOIN civicrm_financial_account fac ON fac.id = fi.financial_account_id LEFT JOIN civicrm_financial_type fty ON li.financial_type_id = fty.id LEFT JOIN civicrm_financial_type ftyc ON c.financial_type_id = ftyc.id