Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Calling the LedgerPurchaseInvoice Service in AX 2012

(0) ShareShare
ReportReport
Posted on by 415

Hi All,

I am trying to call LedgerPurchaseInvoice Service.It was creates invoice journal Under "Invoice Register" . But My requirements is I want to create invoice  under "Invoice Journal" at Account Payables 

Can anybody guide me on this. 

Regards,

Srinivas

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Calling the LedgerPurchaseInvoice Service in AX 2012

    Thanks Vassu for your help,

    I have changed that line (you mentioned above in your comment).

    but i found one more Line in same code "saveAxLedgerJournalTable" :

     journalName = AxdDocumentParameters::find().InvoiceRegisterJournalName

    does i need to change this line also ? because this is for InvoiceRegister Journal .

    please suggest ?

    Thanks.

  • vaasu Profile Picture
    vaasu 415 on at
    RE: Calling the LedgerPurchaseInvoice Service in AX 2012

    not required

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Calling the LedgerPurchaseInvoice Service in AX 2012

    thank you so much Vaasu,

    Okay i will change like that .

    Could you please tell me any other place that i need to change ?

    Thanks.

  • Verified answer
    vaasu Profile Picture
    vaasu 415 on at
    RE: Calling the LedgerPurchaseInvoice Service in AX 2012

    Yes,

    The document services are pointing to Invoice Register,

    Its hard coded values.

    Can you please check the below class and line

    AxdPurchaseInvoice - classe

    saveAxLedgerJournalTable - method

    //Default one

    //axLedgerJournalTable_CustVend.parmJournalType(LedgerJournalType::PurchaseLedger);

    change to

       axLedgerJournalTable_CustVend.parmJournalType(LedgerJournalType::VendInvoiceRegister);

    Then you can create invoice journal.

    Regards,

    Srinivas

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Calling the LedgerPurchaseInvoice Service in AX 2012

    Hello Vasu and Levgen,

          i am trying same Class (LedgerPurchaseInvoice) in Dynamics Excel Add-In to import AP Vendor Invoices in Vendor Invoice Journal in Account PAyable Module .

     have you resolve this issue ?

    please tell me .

    Thanks.

  • Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: Calling the LedgerPurchaseInvoice Service in AX 2012

    and what is the journal type of Vend_Inv ?

  • vaasu Profile Picture
    vaasu 415 on at
    RE: Calling the LedgerPurchaseInvoice Service in AX 2012

    Hi Ievgen,

    I have tried both Invoice Register and VendInvoiceRegister but the invoice create under Invoice Register at Account Payable Journals.

  • Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: Calling the LedgerPurchaseInvoice Service in AX 2012

    Hey vaasu,

    Why do you specify VendInvoiceRegister journal type if you don't want to have invoice register ?

    journalHeader.JournalType = AxdEnum_LedgerJournalType.VendInvoiceRegister;

  • vaasu Profile Picture
    vaasu 415 on at
    RE: Calling the LedgerPurchaseInvoice Service in AX 2012

    Hi ievgen,

    This is the code.

    CallContext callcontext = new CallContext();

                   callcontext.Company = "MFI";

                   PurchaseInvoiceServiceClient client = new PurchaseInvoiceServiceClient();

                   AxdPurchaseInvoice purchaseInvoice = new AxdPurchaseInvoice();

                   AxdEntity_LedgerJournalTable journalHeader = new AxdEntity_LedgerJournalTable();

                  journalHeader.JournalType = AxdEnum_LedgerJournalType.VendInvoiceRegister;

                   journalHeader.JournalTypeSpecified = true;

                   journalHeader.JournalName = "Vend_Inv";

                   IList<AxdEntity_LedgerJournalTrans> journalLines = new List<AxdEntity_LedgerJournalTrans>();

                   for (int i = 0; i < vendorGlDistributions.Count; i++)

                   {

                       AxdEntity_LedgerJournalTrans journalLine = new AxdEntity_LedgerJournalTrans();

                       if (i == 0)

                       {

                           journalLine.AccountType = AxdEnum_LedgerJournalACType.Vend;

                       }

                       else

                       {

                           journalLine.AccountType = AxdEnum_LedgerJournalACType.Ledger;

                       }

                       if (journalLine.AccountType == AxdEnum_LedgerJournalACType.Vend)

                       {

                           journalLine.AccountTypeSpecified = true;

                           journalLine.Company = "MFI";

                           AxdType_MultiTypeAccount account = new AxdType_MultiTypeAccount();

                           account.Account = vendorInforation.VendorAccount;

                           account.DisplayValue = vendorInforation.VendorAccount;

                           journalLine.Invoice = vendorInforation.InvoiceId;

                           journalLine.AmountCurDebit = vendorGlDistributions[0].Debit;

                           journalLine.AmountCurDebitSpecified = true;

                       }

                       else if (journalLine.AccountType == AxdEnum_LedgerJournalACType.Ledger)

                       {

                           journalLine.AccountTypeSpecified = true;

                           journalLine.Company = "MFI";

                           AxdType_MultiTypeAccount account = new AxdType_MultiTypeAccount();

                           account.DisplayValue = "010220-009-009004";

                           account.Account = vendorInforation.VendorAccount;

                           account.DisplayValue = vendorInforation.VendorAccount;

                           journalLine.LedgerDimension = account;

                       }

                       journalLines.Add(journalLine);

                   }

                   journalHeader.LedgerJournalTrans = new AxdEntity_LedgerJournalTrans[1] { journalLine };

                   journalHeader.LedgerJournalTrans = journalLines.ToArray();

                   purchaseInvoice.LedgerJournalTable = new AxdEntity_LedgerJournalTable[1] { journalHeader };

                   try

                   {

                       EntityKey[] entitykey = client.create(callcontext, purchaseInvoice);

                       journalBatchNumer = entitykey[0].KeyData[0].Value;

                   }

                   catch (Exception exception)

                   {

                   }

                   return journalBatchNumer;

    Please check this code and guide.

  • Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: Calling the LedgerPurchaseInvoice Service in AX 2012

    Hi vaasu,

    There is no significant changes between 2009 and 2012, this link propose to create new document.

    I'm not sure if it is possible with LedgerPurchaseInvoiceService.

    Can you share your code ?

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!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans