Hello,
When you post a prepayment invoice from a Sales Order, Business Central creates a Posted Sales Invoice that includes fields referencing the originating Sales Order.
Key fields on the Posted Sales Invoice Header that maintain this link include:
Order No. (the original Sales Order number)
Prepayment Invoice (Boolean)
Prepayment Order No. (if applicable)
Similarly, when you post the final Sales Invoice, the Order No. field also retains the original Sales Order reference, ensuring both invoices trace back to the same order.
Custom Fields for Negative Lines
For your second question (custom fields like Line Type or Reference Invoice Number):
You can extend table 112 “Sales Invoice Line”.
Use the event OnAfterInsertPrepaymentLine in codeunit 442 (Sales-Post Prepayments) to populate these fields only when Quantity < 0.
This allows Business Central to automatically assign your custom data when generating the negative prepayment reversal line during posting.
Regards,
Oussama Sabbouh