Search This Blog

Thursday, April 26, 2012

AX2012 Import PriceDiscount journals using PricePriceDiscJournalService


The following sample code used to create the agreement journals using PricePriceDiscJournalService.

static void Krishh_ImportPriceTradeAgreementJournals(Args _args)
{
    // variable declaration
    PricePriceDiscJournalService            PriceDiscSvc;
    PricePriceDiscJournal                   PriceDiscJour;
    PricePriceDiscJournal_PriceDiscAdmTrans PriceDiscJourAdmTrans;
    PricePriceDiscJournal_InventDim         PriceDiscJourDim;

    AifEntityKeyList                        keys;
 
    // Instantilization
    PriceDiscSvc = PricePriceDiscJournalService::construct();
    PriceDiscJour = new PricePriceDiscJournal();
    PriceDiscJourAdmTrans = PriceDiscJour.createPriceDiscAdmTrans().addNew();
    PriceDiscJourDim = PriceDiscJourAdmTrans.createInventDim().addNew();

    // Set PriceDiscJourDim by getting the invent Item from EcoResProduct
    PriceDiscJourDim.parminventDimId(InventDimCombination::
        findByDistinctProductVariant(
            EcoResProduct::findByDisplayProductNumber(
               "PT SKRUE WN 5451 K30").RecId)
                    .InventDimId);

    //PriceDiscJourAdmTrans
    //you can pass the field parameters based on the fields that available with you.'
    PriceDiscJourAdmTrans.parmInventDim().add(PriceDiscJourDim);
    PriceDiscJourAdmTrans.parmItemRelation("1-02-51400");
    PriceDiscJourAdmTrans.parmItemCode(TableGroupAll::Table);
    PriceDiscJourAdmTrans.parmAmount(98.00);
    PriceDiscJourAdmTrans.parmFromDate(today());
    PriceDiscJourAdmTrans.parmAccountCode(TableGroupAll::All);
    //define the purch prices or sales prices by defining the enum below
    PriceDiscJourAdmTrans.parmrelation(PriceType::PriceSales);
    // you can pass your own currency or you can get company standard currency
    PriceDiscJourAdmTrans.parmCurrency(CompanyInfo::standardCurrency());

    // creates the journal
    // open the Procurement and sourcing and inquires you can click on price discount agreement journals.
    // you can review the journal and post the journal.
    keys = PriceDiscSvc.create(PriceDiscJour);
}

3 comments:

  1. Hi Mate,

    Is there a way to post the journal automatically as well?

    Thanks!!!!

    ReplyDelete
  2. Hi Krishna,
    is there a way to update a price agreement journal?
    Thanks,
    Waseem.

    ReplyDelete
  3. Hi Krishna,

    How we can create price discount journal from EP Ax 2012?

    ReplyDelete

Thanks for visiting my blog,
I will reply for your comment within 48 hours.

Thanks,
krishna.