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

Notifications

Announcements

No record found.

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)?

(3) ShareShare
ReportReport
Posted on by 67

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
    237,758 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
    852 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 704 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 570 Super User 2025 Season 2

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 408 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans