Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Suggested answer

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?

  • haroonattari Profile Picture
    haroonattari 2,296 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

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 288,768 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,985 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans