Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

Create Invoice Journal via AIF

Posted on by 1,272

Hi All,

I am trying to create an invoice journal using AIF services in AX 2012. I have tried to use LedgerGeneralJournalService and LedgerPurchaseInvioceService but none of them allows me to make an invoice journal. The first one only creates journal type : Daily and the second one only creates Invoice register. Is there any service for creating an Invoice Journal?

*This post is locked for comments

  • haroonattari Profile Picture
    haroonattari 2,309 on at
    RE: Create Invoice Journal via AIF

    Hi Dick
    I am enabling creation of Vendor Invoice Journal and have followed the steps you have mentioned in your post but still getting following error message:

    Journal name APINV does not support journal type Daily.

    To resolve this problem, I made following changes to construct method of LedgerJournalTableType

        journalNameId = _axLedgerJournalTable.ledgerJournalTable().JournalName;

        journalType = LedgerJournalName::find(journalNameId).JournalType;

              //switch(_axLedgerJournalTable.ledgerJournalTable().JournalType)

            switch(journalType)

    but now the following error is popping when I am trying to create APINV journal

    Field 'Journal batch number' must be filled in.

    Any clue, how this can be resolved.

  • vaasu Profile Picture
    vaasu 415 on at
    RE: Create Invoice Journal via AIF

    Is there any way to fix the problem. 

    Pls guide me on this. i am also facing the same problem. 

    regards,

    srinivas

  • Dick Wenning Profile Picture
    Dick Wenning 8,705 on at
    RE: Create Invoice Journal via AIF

    ALLOW CUSTOMER AND VENDOR ACCOUNT TYPES:

    Microsoft has code some hardcoded limitation in the class LedgerJournalTransType method validateAccountType and validateOffsetAccountType. Simply remove the AifFault::checkFailedLogFault line and it will work again.

    GET IN CONTROL WITH VOUCHERS:

    In case the voucher Num sequence is set on manual, you have to add the voucher in the XML message. But there are some quite annoying implementation choices made by the AX 2009 developers’ team. Look in class LedgerJournalTransType method defaultVoucher. The field gets unattached and cleared. Next it calls the method determineDefaultVoucher and this will trigger the numbersequence. In case it was a manual numbersequence your value was lost by processing the defaultVoucher method.

    CREATE NON DAILY JOURNALS

    You need to create new derived classes from the class LedgerJournalTableType overload the methods:

    • defaultJournalType

    • isJournalNameValidJournalType

    • new

    • construct

    Also remove the limitation of the method initQuery in the AxdLedgerGeneralJournal class Also add this new class in the construct of the LedgerJournalTableType class.

    INVOICE REGISTRATION

    Create a new derived class for LedgerJournalTableType

    protected void new(AxLedgerJournalTable _axLedgerJournalTable, LedgerJournalOperation _operation, boolean _isInteractiveContext)

    {

       ;

       Debug::assert(_operation == LedgerJournalOperation::Create);

       axLedgerJournalTable = _axLedgerJournalTable;

       ledgerJournalTable = axLedgerJournalTable.ledgerJournalTable();

       operation = _operation;

       isInteractiveContext = _isInteractiveContext;

    }

    protected boolean isJournalNameValidJournalType()

    {

       boolean journalTypeIsValid;

       ;

       if (ledgerJournalName.RecId != 0)

       {

           journalTypeIsValid = (ledgerJournalName.JournalType == LedgerJournalType::PurchaseLedger);

       }

       else

       {

           journalTypeIsValid =  false;

       }

       return journalTypeIsValid;

    }

    protected void defaultJournalType()

    {

       if (operation == LedgerJournalOperation::Create)

       {

           ledgerJournalTable.JournalType = LedgerJournalType::PurchaseLedger;

           axLedgerJournalTable.setFieldAsTouched(fieldnum(LedgerJournalTable,JournalType));

       }

    }

    public static LedgerJournalTableType_PurchaseLedger construct(AxLedgerJournalTable _axLedgerJournalTable, LedgerJournalOperation _operation, boolean _isInteractiveContext)

    {

       LedgerJournalTableType_PurchaseLedger ledgerJournalTableType_PurchaseLedger;

       ;

       ledgerJournalTableType_PurchaseLedger = new LedgerJournalTableType_PurchaseLedger(_axLedgerJournalTable, _operation, _isInteractiveContext);

       return ledgerJournalTableType_PurchaseLedger;

    }

    Also the default ledger account of the vendor posting profile needs to be added to the prepeare for save method of the AxdLedgerGeneral class

    if(axLedgerJournalTable.parmJournalType() == LedgerJournalType::PurchaseLedger &&                                                                  

                  axLedgerJournalTrans.parmAccountType() == LedgerJournalACType::Vend)                                                                            

    {                                                                                                                                                  

         axLedgerJournalTrans.parmOffsetAccountType(LedgerJournalACType::Ledger);                                                                        

         axLedgerJournalTrans.parmOffsetAccount(

                              VendLedgerAccounts::purchLedgerOffsetAccount(axLedgerJournalTrans.parmAccountNum()));                    

               }

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Create Invoice Journal via AIF

    Hi dev,

    The error is thrown because journal type is defaulted to daily and the journal setup has a different setting eg 'Vendor invoice recording' in your case. I faced the same error while creating my journals through code. I added the following line of code to pick the journal type from the journal setup:

    journalTable.parmJournalType(LedgerJournalName::find(JournalName).JournalType);

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Create Invoice Journal via AIF

    Have you got this issue resolved? Please let me know.

  • dynamics developer Profile Picture
    dynamics developer 1,272 on at
    RE: Create Invoice Journal via AIF

    Hi Nitesh,

    Thanks for your response.

    This exception is thrown by AX when I try to use LedgerGeneralJournalService

    Exception: "Journal name APInv does not support journal type Daily."

    The journal type is "Vendor invoice recording". Also there is no property for inserting Invoice  Number and Doc Date in this service.

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Create Invoice Journal via AIF

    As per my understanding you can utilize LedgerGeneralJournalService to create Invoice Journal

    You need to specify valid Journal name, Account type and Offset Type

    please verify and let us know if you need details

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans