Skip to content

Conversation

@shahrukh-compuco
Copy link
Contributor

Overview

This PR adds credit note details to the sage 50 report, mainly it adds following three files as currently these fields are empty for credit note transactions

  • Reference field will show credit note number
  • Details will show credit note line item description
  • Project Refn will show credit note line item's financial type name

Before

before.csv

After

after.csv

This comment was marked as outdated.

@erawat erawat requested a review from Copilot July 2, 2025 11:41
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances the Sage50 CSV export by including credit note details—number, line item description, and financial type—whenever credit notes are present.

  • Extend the SELECT query to pull credit note fields and join the relevant tables conditionally.
  • Map the new credit note values into the Details, Reference, and Project Refn columns.
  • Only apply the additional joins and columns when $supportCreditNote is enabled.
Comments suppressed due to low confidence (2)

CRM/Financial/BAO/ExportFormat/DataProvider/Sage50CSVProvider.php:255

  • New behavior for credit note details should be covered by automated tests. Add or update a test case to verify that credit note descriptions override standard item descriptions in the CSV export.
    $item[self::DETAILS_LABEL] = !empty($exportResultDao->credit_note_description) ? $exportResultDao->credit_note_description

CRM/Financial/BAO/ExportFormat/DataProvider/Sage50CSVProvider.php:87

  • The SELECT list is missing a comma after credit_note_financial_type, which will cause a SQL syntax error. Add a trailing comma before the FROM clause.
      . ($supportCreditNote ? "ftycn.name" : "''") . " AS credit_note_financial_type

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')
" . ($supportCreditNote ? "LEFT JOIN financeextras_credit_note_line fcli ON (fcli.id = fi.entity_id AND fi.entity_table = 'financeextras_credit_note_line')" : "") . "
" . ($supportCreditNote ? "LEFT JOIN financeextras_credit_note_line fcli ON (fcli.id = fi.entity_id AND fi.entity_table = 'financeextras_credit_note_line') LEFT JOIN financeextras_credit_note fcn ON (fcli.credit_note_id = fcn.id) LEFT JOIN civicrm_financial_type ftycn ON fcli.financial_type_id = ftycn.id" : "") . "
Copy link

Copilot AI Jul 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Combining multiple JOIN clauses into one long concatenated string reduces readability. Consider splitting each JOIN into its own concatenated segment or formatting them on separate lines.

Copilot uses AI. Check for mistakes.
@erawat
Copy link
Member

erawat commented Jul 2, 2025

CRM/Financial/BAO/ExportFormat/DataProvider/Sage50CSVProvider.php:87

  • The SELECT list is missing a comma after credit_note_financial_type, which will cause a SQL syntax error. Add a trailing comma before the FROM clause.
      . ($supportCreditNote ? "ftycn.name" : "''") . " AS credit_note_financial_type

@shahrukh-compuco can u check the copilot comment especially.

CRM/Financial/BAO/ExportFormat/DataProvider/Sage50CSVProvider.php:87

The SELECT list is missing a comma after credit_note_financial_type, which will cause a SQL syntax error. Add a trailing comma before the FROM clause.
      . ($supportCreditNote ? "ftycn.name" : "''") . " AS credit_note_financial_type

@shahrukh-compuco
Copy link
Contributor Author

shahrukh-compuco commented Jul 2, 2025

credit_note_financial_type

@erawat I think the suggestion is wrong as adding a comma before from will cause the syntax error

@shahrukh-compuco shahrukh-compuco merged commit 0ea1799 into sage50-workstream Jul 2, 2025
2 checks passed
@erawat erawat deleted the civimm-349-fix-credit-note-records branch July 2, 2025 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants