If you choose the AIF LedgerGeneralJournalService be aware of the following Problem:
Certain fields in the table LedgerJournalTrans do not get populated when using the Account Type "Vendor"
EG:
- the vendors posting profile is missing
- no Terms of Payments
- the due date does not get calculated
This happens because code on the form is triggered when you select the vendor account manually. The above described fields usually get populated by the LedgerJournalEngine Class.
Fix:
To fix this problem you have to modify the service axd Class. But caution! If you simply call the Standard LedgerJournalEngine Class, the AIF produces an Error. Here is my first approach:
AxdLedgerGeneralJournal
public void updateNow() { (.. std code ..) // --> LedgerJournalTrans ledgerJournalTrans; LedgerJournalEngine_DailyAif ledgerJournalEngine = new LedgerJournalEngine_DailyAif(); // <-- data-blogger-escaped---="" data-blogger-escaped-..="" data-blogger-escaped-code="" data-blogger-escaped-std=""> ledgerJournalTrans = axLedgerJournalTrans.ledgerJournalTrans(); switch (ledgerJournalTrans.AccountType) { case LedgerJournalACType::Vend: ledgerJournalEngine.accountModified(ledgerJournalTrans); ledgerJournalEngine.initFromVendTable(ledgerJournalTrans); break; } ledgerJournalTrans.update(); (.. std code ..) }
any inbound message will now result into the following Error: The request failed with the following error:
Exception of type 'Microsoft.Dynamics.Ax.Xpp.InvalidRemoteCallException' was thrown
Debugging with VS surfaced that the use of the FormRun parameter in the constructor resulted into an error. You need to create a couple of new classes based on LedgerJournalEngine and LedgerJournalEngine_Daily. Simply get rid of the parameter in method new().
I finally got everything to work with the following code:
AxdLedgerGeneralJournal
public void updateNow() { #macrolib.LedgerAIF SysGlobalCache cache = classfactory.globalCache(); LedgerJournalTable ledgerJournalTable; LedgerJournalInclTax ledgerJournalInclTax; // --> LedgerJournalTrans ledgerJournalTrans; // LedgerJournalEngine_DailyAif is a new class based on LedgerJournalEngine LedgerJournalEngine_DailyAif ledgerJournalEngine = new LedgerJournalEngine_DailyAif(); // <-- super(); ledgerJournalTable = axLedgerJournalTable.ledgerJournalTable(); ledgerJournalInclTax = LedgerJournalTable::find(ledgerJournalTable.JournalNum).LedgerJournalInclTax; [ledgerJournalTable.JournalTotalDebit, ledgerJournalTable.JournalTotalCredit, ledgerJournalTable.JournalTotalOffsetBalance] = LedgerJournalTable::journalBalanceMST(ledgerJournalTable.JournalNum, false, ledgerJournalInclTax, false); ledgerJournalTable.JournalBalance = ledgerJournalTable.JournalTotalDebit - ledgerJournalTable.JournalTotalCredit; ledgerJournalTable.update(); // --> ledgerJournalTrans = axLedgerJournalTrans.ledgerJournalTrans(); switch (ledgerJournalTrans.AccountType) { case LedgerJournalACType::Vend: ledgerJournalEngine.accountModified(ledgerJournalTrans); ledgerJournalEngine.initFromVendTable(ledgerJournalTrans); break; } ledgerJournalTrans.update(); // <-- (.. std code ..) }
If you want to reproduce this scenario:
- get the latest AX2012 vm (refresh 4 with CU7)
- create a new inbound port for the AIF service (simply use the file system adapter...)
- use the following xml
ussi http://schemas.microsoft.com/dynamics/2008/01/services/GeneralJournalService/create ussi Detail GenJrn General Journal Vend 1007.00 ussi USD US_SI_000007 US_SI_000007 1.0000000000 Ledger ussi 500110-003-022-00000001-Application Development 500110 BusinessUnit 003 Department 022 Project 00000001 ServiceLine Application Development 2013-12-26 No Po Invoice
Further thoughts:
- Alternatively you could use the service LedgerPurchaseInvoiceService, this will create an Invoice Register (but in my experience they are less frequently used than the Ledger Journals / Invoice Journals)
- In order to submit a invoice number with the GeneralJournalService you need to add the field invoice!
hope this helps
-k