web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

How to detect Credit Note / Debit Note for posted Sales invoice (D365FO)?

(4) ShareShare
ReportReport
Posted on by 317

Context


  • Printing is triggered after posting from SalesInvoiceJournalPrint.printJournal(Set _journalList) (extension).

  • I can print my custom report successfully after posting.

  • I also added a manual print button on CustInvoiceJournal (multi-select) and it works.

Problem


  • In Thai localization, I found CustInvoiceTableExtensionTH.NoteFormat (enum TaxUnrealizedSalesNoteFormat) which can indicate CN/DN.

  • However, for many posted invoices created from Sales order “Credit invoicing”, CustInvoiceTableExtensionTH.NoteFormat is empty/None, but the standard output still prints with “Credit Note” title.

  • Therefore, NoteFormat is not populated in all flows, and Number sequence is not reliable.

Questions


  1. In standard D365FO, what is the correct source of truth to decide “Invoice vs Credit Note vs Debit Note” for sales invoices?

  2. Which table/field does standard logic use (e.g., CustInvoiceJour.InvoiceAmount sign, CustInvoiceTrans quantities, correction/reversal flags, references to original invoice, etc.)?

  3. For Thai DN/CN documents: is there a standard field (or doc type) that is always set for DN (not just “amount > 0”)?

  4. Is there a recommended API / method to reuse (e.g., a standard method that returns the document title/type, similar to SalesInvoiceContract.parmDocumentTitle() or something in SalesFormLetter_Invoice / SalesInvoiceJournalPrint)?

  5. If NoteFormat is only used by some TH scenarios, when is it supposed to be populated, and by which class/table update?

  6. Best practice for custom report header: should we implement a fallback like “if NoteFormat empty -> use amount sign for CN, otherwise use NoteFormat for DN/CN”, or is there a better approach?
     

Any pointers to the exact class/method names or a pattern you have used would be greatly appreciated.

Categories:
I have the same question (2)
  • Suggested answer
    Martin Dráb Profile Picture
    238,740 Most Valuable Professional on at
    You can answer many of your questions by yourself, because you have access to all the standard code.
     
    1.+2. Open Report design of SalesInvoice report, right-click the feld with @DocumentTitle text and open Expression. You'll see that the value comes from DocumentTitle parameter. Find SalesInvoiceContract class and its parmDocumentTitle() method. Right-click the name and choose Find references. This tells you that you need to look into SalesInvoiceController.outputReport(), where you'll learn that the value comes from SalesInvoiceController.documentTitle(). The method does quite a few things, but what you're interested in is on the top. There is some special behaviour for certain countries, but the default logic is this:
    isCreditNote = custInvoiceJour.InvoiceAmount < 0 || (custInvoiceJour.InvoiceAmount == 0 && custInvoiceJour.Qty < 0);
    3. I'm not familiar with Thai localization.
    4. If you want to always get the same title as in the standard report, use the standard logic discussed above.
    5. Use references to see where the field is used. It seems to me that value is supposed to be set by users, not by code.
    6. How your custom report should behave depends on your business requirements.
  • Suggested answer
    Giorgio Bonacorsi Profile Picture
    1,427 on at
    You cannot delete a posted transaction, doing so is illegal (and you will face serious issues with authorities if performed in a prod). :-)

    The only correct way is to reverse the original transaction and then post the corrected one.
    About the document means:
    - Credit note: You are giving the customer credit because you previously overcharged them or invoiced for something that was not delivered;
    - Debit note: You are requesting additional payment from the customer (e.g., for interest due to late payment);
     
    Here the different way to do a credit note:
    - Free-text invoice with a negative amount
    - Negative sales order
    - Sales return order (from the Sales and marketing module)
     
    Alway consult a financial consultant before to proceed.
     
    Thank you,
    Giorgio

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 577 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 309

#3
Diego Mancassola Profile Picture

Diego Mancassola 259

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans