Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested answer

Issue on posting customized payment document that has FCY transactions

(6) ShareShare
ReportReport
Posted on by 117
Dear All,
 

I have voucher in the system that is self customized and I am experiencing the issue when posting fcy transactions in my posting codeunit, when I click post on the post button of my fcy voucher after selecting fcy invoice to pay the vendor,
I am getting this error Realized Gains Acc. must have a value in Currency: Code=USD. It cannot be zero or empty and actually there is not gain and loss in currency since am using the same currency for invoice and payment with the same rate.
secondly, I obliged and set Realized Gains Acc. and Realized loss Acc. the error changed and requested Debit rounding account to be on vendor posting group, i obliged again and set the account including the credit one. The voucher posted successfully and when I checked the entries, I found 4 entries 4 entries where two were expected 
bank and payable but the accounts for Realized Gains\Realized loss and Rounding also recorded amounts (balanced double entry) that were different from (bank and payable) by 30 in lcy. 
My question is why are these accounts (Realized Gains\Realized loss and Rounding) recording values if am paying and invoice with a voucher both captured in foreign currency with the same exchange rate?
why are Realized Gains\Realized loss and Rounding required? why can't the voucher transaction post to bank and payable only with amount and amount lcy equivalent?
 
how should I change my codeunit?
 here is my extract 
 
GenJnline."Currency Code" := voucher."Currency Code";
 
                //lcy and fcy
                if voucher."Currency Code" = '' then begin
                    GenJnline."Currency Factor" := 1;
                    GenJnline.Amount :=voucherLine."Net Amount";
                    GenJnline."Amount (LCY)" := voucherLine."Net Amount";
                end else begin
                    GenJnline."Currency Factor" := voucher."Exchange Rate";
                    GenJnline.Amount := voucherLine."Net Amount";
                    GenJnline."Amount (LCY)" := voucherLine."Net Amount" * GenJnline."Currency Factor";
                end;
 
Kindly assist
  • Vahid Ghafarpour Profile Picture
    9,688 Super User 2025 Season 1 on at
    Issue on posting customized payment document that has FCY transactions
    If any of the responses helped resolve your issue, please take a moment to mark the best answer. This helps others in the community quickly find solutions to similar problems.

    To do this, simply click the "Does this answer your question?" button on the most helpful response and like the helpful posts. If your issue is still unresolved, feel free to provide more details so the community can assist further!

    Thanks for being an active part of the Dynamics 365 Community! 😊
  • Suggested answer
    Jainam M. Kothari Profile Picture
    5,891 on at
  • Suggested answer
    Saif Ali Sabri Profile Picture
    1,823 Super User 2025 Season 1 on at
    Issue on posting customized payment document that has FCY transactions
    Your issue appears to be related to how currency exchange rates, realized gains/losses, and rounding differences are handled in your custom posting codeunit in Microsoft Dynamics 365 Business Central. Even though the invoice and payment use the same foreign currency (FCY) and the same exchange rate, Business Central's posting logic requires the accounts for Realized Gains, Realized Losses, and Rounding due to system validation rules.
    Possible Causes & Why These Accounts Are Used:
    1. Currency Factor Calculation & Precision Differences
      • Even when using the same FCY and exchange rate, decimal precision differences may cause rounding adjustments in the Amount (LCY) field.
      • If rounding differences occur, BC automatically posts the difference to Rounding Account.
    2. System Validations on Currency Transactions
      • BC requires Realized Gains/Losses accounts to be set for any FCY transactions, even if there is no exchange rate difference.
      • When posting FCY transactions, the system expects these accounts as part of standard validation.
    3. Exchange Rate Handling & Rounding Impact
      • If the Exchange Rate Precision differs between setup and calculation, a minor difference in LCY may cause additional journal entries.
      • The Rounding Account captures any remaining decimal differences.

    Solution & Code Fixes
    You need to adjust how you calculate Amount (LCY) to ensure consistency and avoid unnecessary rounding differences.
    1. Ensure Correct Exchange Rate Application
    Modify your code to correctly calculate LCY amounts with precision:
    al
    CopyEdit
     
    GenJnline."Currency Code" := voucher."Currency Code";
    // If LCY transaction
    if voucher."Currency Code" = '' then begin
        GenJnline."Currency Factor" := 1;
        GenJnline.Amount := voucherLine."Net Amount";
        GenJnline."Amount (LCY)" := Round(voucherLine."Net Amount", 0.01);
    end 
    // If FCY transaction
    else begin
        GenJnline."Currency Factor" := voucher."Exchange Rate";
        GenJnline.Amount := voucherLine."Net Amount";
        GenJnline."Amount (LCY)" := Round(voucherLine."Net Amount" * GenJnline."Currency Factor", 0.01);
    end;
     
    Key Fixes:
    • Use Round() to minimize decimal precision mismatches that could trigger rounding account postings.
    • Ensure Exchange Rate Precision is consistent with your setup in General Ledger Setup.

    2. Check General Ledger Setup & Posting Groups
    1. Verify Rounding Precision
      • Go to General Ledger Setup → Ensure Amount Rounding Precision is correctly set (e.g., 0.01 for 2 decimal places).
    2. Review FCY Setup in Currencies
      • Navigate to Currencies (Page 330) → Confirm that Decimal Places and Exchange Rate Precision are correctly configured.
    3. Check Vendor Posting Group Accounts
      • Ensure that the Realized Gains, Losses, and Rounding Accounts are correctly assigned in the Vendor Posting Group.

    Expected Outcome After Fixes
    • The system should no longer post unnecessary rounding and gain/loss entries.
    • Only Bank and Payables should be recorded as expected.
    • If rounding still occurs, check Currency Exchange Rates Setup for inconsistencies.
    If the issue persists, please check whether other customizations might be interfering with the posting process.
  • Suggested answer
    YUN ZHU Profile Picture
    81,360 Super User 2025 Season 1 on at
    Issue on posting customized payment document that has FCY transactions
    Hi, it seems to be a problem caused by customization. Try changing the assignment statement to Record.Validate().
    More details:
    Dynamics 365 Business Central: The difference between Record.Validate() Method and assignment statement
     
    PS: Dynamics 365 Business Central: How to disable Application of Ledger Entries in Different Currencies (Appln. between Currencies)
     
    Hope this helps.
    Thanks.
    ZHU
  • Suggested answer
    Suresh Kulla Profile Picture
    46,798 on at
    Issue on posting customized payment document that has FCY transactions
    If there is a variance in the transaction, it will post that entry to the Rounding. You can find more information about rounding here
     
     
     
  • Suggested answer
    Ramesh Kumar Profile Picture
    3,280 on at
    Issue on posting customized payment document that has FCY transactions
    Hi,

    Could you please check your General Ledger setup to ensure the currency is either set as the local currency or left empty? If it's not empty, it may cause confusion and result in unrealized gain/loss entries.
     
     
    Thanks
    Ramesh
     
    If this was helpful, please check the "Does this answer your question?" box and mark it as verified.
  • KAYKAY Profile Picture
    117 on at
    Issue on posting customized payment document that has FCY transactions
    any update please

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,095 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,866 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans