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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
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

  • Suggested answer
    Mea_ Profile Picture
    60,286 on at

    Hi vaasu,

    Due to this article www.ellipsesolutions.com you cannot do this, however there are steps how to create your own service.

  • vaasu Profile Picture
    415 on at

    Hi Ievgen,

    The above link related to AX 2009 not in ax2012.

    I am able to create new Invoice journal, but it creates in Invoice Register bot in Invoice Journals , How can I achieve it.

    can you please guide me.

  • Mea_ Profile Picture
    60,286 on at

    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 ?

  • vaasu Profile Picture
    415 on at

    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
    60,286 on at

    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
    415 on at

    Hi Ievgen,

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

  • Mea_ Profile Picture
    60,286 on at

    and what is the journal type of Vend_Inv ?

  • Community Member Profile Picture
    on at

    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.

  • Verified answer
    vaasu Profile Picture
    415 on at

    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
    on at

    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.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans