Hello everyone,
I need advice on the best approach for a customization in Microsoft Dynamics 365 Business Central.
My client has a requirement to add freight charges after a Sales Order or Purchase Order has already been posted. The requirement is for both:
-
Posted Sales Invoice
-
Posted Purchase Invoice
The client does not want to add freight during Sales Order or Purchase Order creation. They also do not want to create a separate sales/purchase invoice or use a manual credit memo process.
Business Requirement
Example:
-
Original Posted Invoice Amount = ₹20
-
Freight Amount added later = ₹5
-
Final amount to be paid/received = ₹25
The client wants the user to open the already posted invoice, click an Add Freight button, enter the freight G/L account and freight amount, and then the invoice should effectively become payable/receivable for ₹25.
Later, when the user clicks a custom Make Payment button from the Posted Invoice page, the payment should be created for the total amount, including both:
-
Original invoice amount
-
Freight amount
So in this example, payment should be made for ₹25 in one go.
Required Process
The desired process is:
-
User posts a Sales Order or Purchase Order.
-
A Posted Sales Invoice or Posted Purchase Invoice is created.
-
User opens the Posted Invoice.
-
User clicks Add Freight.
-
System validates whether payment has already been made.
-
If payment is already completed, freight should not be allowed.
-
If unpaid, a dialog should open with:
-
Freight G/L Account
-
Freight Amount
-
Freight should be linked to the same posted invoice.
-
If freight already exists, the same freight record should be updated instead of creating a duplicate.
-
User should later click Make Payment and pay the original invoice amount plus freight amount together.
Important Business Rules
-
Freight can only be added after invoice posting.
-
Freight cannot be added after payment is completed.
-
Only one freight record should exist per invoice.
-
Existing freight should be editable before payment.
-
The final payment should include both the original invoice amount and freight amount.
-
This should work for both customer and vendor invoices.
Technical Concern
Initially, I explored directly inserting/updating records in posted tables such as:
-
Posted Sales Invoice Line
-
Posted Purchase Invoice Line
-
G/L Entry
-
Customer Ledger Entry
-
Vendor Ledger Entry
-
Detailed Customer/Vendor Ledger Entry
-
VAT Entry
However, I understand this may not be the correct or safe approach because posted invoices and ledger entries are part of the accounting/audit trail.
So I am considering another approach:
-
Add a custom Freight Adjustment Entry table.
-
When freight is added, post a linked freight adjustment using standard journal posting logic.
-
Do not directly modify original G/L Entry, Customer Ledger Entry, or Vendor Ledger Entry.
-
Link the freight ledger entry to the original posted invoice.
-
On the Posted Invoice page, show:
-
Original Invoice Amount
-
Freight Amount
-
Total Including Freight
-
During payment, use one payment journal line and apply it to both:
For example:
| Component |
Amount |
| Original Invoice |
₹20 |
| Freight Adjustment |
₹5 |
| Total Payment |
₹25 |
The payment would be applied to both ledger entries using the same Applies-to ID.
Any suggestions, best practices, or warnings would be very helpful.
Thanks in advance.