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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Inventory Account for posting

(1) ShareShare
ReportReport
Posted on by

AX Version: AX-2012 R3 CU8

I am having a Purchase order for which vendor has overcharge.

I need to post a general journal by code to accrue the difference. I am having a fix credit ledger account and I need to have Inventory account as debit account.

I am not able to get the Inventory account that needs to be debited. Can some one please help me to identify the inventory account?

Thanks In advance.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Brandon Wiese Profile Picture
    17,788 on at

    The table where the Inventory posting data is stored is called InventPosting.  To fetch the inventory balance main account that is typically used on a purchase order for an item, use something like the following.

    LedgerDimension  ledgerDimension;
    
    ledgerDimension = InventPosting::accountItemLedgerDimension(
                        InventAccountType::PurchReceipt,
                        purchLine.ItemId,
                        purchLine.inventTable().itemGroupId(),
                        purchLine.ProcurementCategory,
                        purchLine.VendAccount,
                        purchLine.VendGroup,
                        purchLine.TaxGroup);

    Examples of this code can be found in class InventMov_Purch method accountItem(..).

    Unfortunately, the ledgerDimension that is returned is what is called a "default account" and cannot be directly stored on a LedgerJournalTrans record in the LedgerDimension field.  Typically in AX it would then be combined with additional financial dimensions, i.e. a DefaultDimension field, to construct a final LedgerDimension.

    While this is not the only way, you can convert that default account to a useful LedgerDimension with the following code.

    ledgerDimension = DimensionDefaultingService::serviceCreateLedgerDimension(
                        ledgerDimension);

    The ::serviceCreateLedgerDimension(..) static function has additional optional parameters for providing more than one DefaultDimension values, representing financial dimension, which it will merge with the main account for you, or you can use it as shown to convert just the main account by itself.

    Notice that the DimensionDefaultingService class has many other interesting methods, such as ::serviceMergeLedgerDimensions(..) and :: serviceMergeDefaultDimensions(..).

    This code is provided for education purposes only.  Use at your own risk and test fully before deploying any code changes to a production environment.

  • Suggested answer
    Ludwig Reinhard Profile Picture
    Microsoft Employee on at

    Hi,

    Why you want to post something by code?

    If I understand your request correctly, then the standard AX adjustment functionality available in the PO invoice form can create the adjustment you are looking for.

    You only need to define a charge code that debits your item and credits and offset ledger account.

    CH2.png

    CH2.png

    All the best,

    Ludwig

  • Brandon Wiese Profile Picture
    17,788 on at

    I agree with Ludwig.  Even though I've provided some example code for how to do what you asked, in general you should never post to your inventory balance accounts directly as it will pretty much always create tie-out issues later with Inventory value reports.  If you must adjust the value of the Inventory receipt, use a misc. charge of type Item, which you can also create in code.  Or, as Ludwig suggests, use the Adjustment feature.

  • Suggested answer
    Muhammad Yousaf Profile Picture
    1,339 on at

    Dear Deep,

    while invoicing the PO, you can include charges... and these types of charges can be setup first, where you can debit the item/inventory (whatever) and credit the offset account... we are doing this practice on daily basis

    and sometimes you have some additional expenses of packaging etc. etc., you can have these charges setup and then use them during the course of invoicing the PO

    I hope it helps

    Regards

    Yousaf

  • Suggested answer
    Community Member Profile Picture
    on at

    Thanks Brandon for your reply.

  • Community Member Profile Picture
    on at

    Thanks all for your reply. As per my requirement, the solution suggested by Brandon help me.

  • rajeev tiwari Profile Picture
    434 on at

    Hello Deep , 

    I have similar requirement ,where i added a customised field  of enum type noyes i.e checkbox to select discount ledger in inventory posting parameter and also in Sales Line .

    When I enter item id in sales line and if checkbox is ticked as yes then while posting i need to post discount in specified ledger where check box is yes in inventory posting.

    Can you please tell me where you have written code and if possible send me code so that i can use it.

    as I tried writing in inventmov_sales but it didn't worked for me to select different ledger.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans