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

Notifications

Announcements

Community site session details

Community site session details

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

Customer Payment Journal Created but Not Posted (Voucher Does Not Balance Error in X++)

(1) ShareShare
ReportReport
Posted on by 447
Hi Everyone,
 
 
I tried to create and post a Customer Payment Journal programmatically in Dynamics 365 Finance & Operations (X++) I followed several articles and examples.
The journal is created successfully but when the posting runs, the journal is cancelled and I get the following error

 
Voucher CRJ-003625: The transactions on voucher CRJ-003625 do not balance as per 1/7/2026.
(Accounting currency: -1,500,000.00, Reporting currency: -1,500,000.00)

Voucher transactions:
Voucher: CRJ-003625
Date: 1/7/2026
Account: 161100..
Transaction currency amount: -1,500,000.00
Accounting currency amount: -1,500,000.00
Reporting currency amount: -1,500,000.00
Currency: IQD
Text: Create and post test customer payment journal.
 
The journal header and the transaction line are created but the journal does not post.
What is my mistake in the code? I want to create a normal Customer Payment Journal and create its transaction line correctly
Post the journal automatically without getting a balance error
Any guidance on what is missing or incorrectly set (offset account, debit/credit logic, dimensions, etc.) would be appreciated.
 

here is the code I used:
 public static void main(Args _args)
{
    Ledgerjournalname       ledgerjournalname;
    LedgerjournalTable      LedgerjournalTable;
    LedgerjournalTrans      LedgerjournalTrans;
    LedgerjournalCheckPost  LedgerjournalCheckPost;
    NumberSeq               numberSeq;
    

    
    AccountNum customerAccount = 'C-000012';

    
    select ledgerjournalname
        where ledgerjournalname.JournalName == "CRJ";

    ttsBegin;
    LedgerjournalTable.JournalName = ledgerjournalname.JournalName;
    LedgerjournalTable.initFromLedgerJournalName();
    LedgerjournalTable.JournalNum =
        JournalTableData::newTable(LedgerjournalTable).nextJournalId();
    LedgerjournalTable.insert();
    ttsCommit;

    ttsBegin;
    numberSeq =
        NumberSeq::newGetVoucherFromId(ledgerjournalname.NumberSequenceTable);

    LedgerjournalTrans.Voucher     = numberSeq.voucher();
    LedgerjournalTrans.JournalNum = LedgerjournalTable.JournalNum;
    LedgerjournalTrans.CurrencyCode =
        Ledger::accountingCurrency(CompanyInfo::current());

    LedgerjournalTrans.AccountType = LedgerJournalACType::Cust;
    LedgerjournalTrans.parmAccount(
        customerAccount,
        LedgerjournalTrans.AccountType
    );

    LedgerjournalTrans.Txt = 'Create and post test customer payment journal';

    LedgerjournalTrans.ExchRate =
        ExchangeRateHelper::exchRate(LedgerjournalTrans.CurrencyCode);

    LedgerjournalTrans.AmountCurCredit = 1500000; 

    LedgerjournalTrans.TransDate  = systemDateGet();

    LedgerjournalTrans.OffsetAccountType =
        LedgerJournalACType::Ledger;

    LedgerjournalTrans.parmOffsetAccount(
        ledgerJournalTable.parmOffsetAccount(),
        ledgerJournalTable.OffsetAccountType
    );

    LedgerjournalTrans.OffsetLedgerDimension =
        LedgerjournalTable.OffsetLedgerDimension;

    LedgerjournalTrans.DefaultDimension =
        CustTable::find(customerAccount).DefaultDimension;

    LedgerjournalTrans.OffsetDefaultDimension =
        CustTable::find(customerAccount).DefaultDimension;

    LedgerjournalTrans.insert();
    ttsCommit;

    LedgerjournalCheckPost =
        LedgerjournalCheckPost::newLedgerJournalTable(
            LedgerjournalTable,
            NoYes::Yes
        );

    LedgerjournalCheckPost.run();

    info("Customer journal has been created");
}


 
I have the same question (0)
  • Suggested answer
    Komi Siabi Profile Picture
    13,130 Most Valuable Professional on at
    I see you are getting the OffsetLedgerDimension from the JournalTable. You want to doublecheck that is actually a valid ledger account. 
     
    You can add logging statements(info) to be sure of the value. Alternatively, you may comment LedgerjournalCheckPost.run(); get the journal created and do manual validation and revert your Post function.
  • D365FO Junior-Dev Profile Picture
    447 on at
    @Komi Siabi thanks for the reply could you please show me the correct way to set OffsetLedgerDimension properly? if this cause the issue!
    When I select the offset account in the D365 FO UI the journal is valid and can be posted successfully.

  • Suggested answer
    Sagar121 Profile Picture
    887 on at
    Hi ,
     
    This error is coming from LedgerJournalCheckpost.run() you are already using it so all the validations will be already respected.
     
    Can you check if you are getting value in debit as well? There might be issue with Data so try to change the values.( Customer, amount)
     
    Checkout this URL:
  • Suggested answer
    Komi Siabi Profile Picture
    13,130 Most Valuable Professional on at
    Ahan, 
     
    You see that your offset account is empty. You are getting the OffsetLedgerDimension from the Header which was also empty. You should set the OffsetLedgerDimension right on the line just like you did for the mainAccount.

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

News and Announcements

Season of Giving Solutions is Here!

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
Abhilash Warrier Profile Picture

Abhilash Warrier 679 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

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

#3
Martin Dráb Profile Picture

Martin Dráb 264 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans