zoukankan      html  css  js  c++  java
  • AX 2012 Create and post Vendor Invoice Journals (Ver2)

    static void createVendorInvoiceJournal(Args args)
    {
        LedgerJournalCheckPost                  jourCheckPost;
        LedgerJournalTable                          jourTable;
        InventTable                                       inventTable;
        DimensionAttributeValueSet            dimAttrValueSet;
        DimensionAttributeValueSetItem     dimAttrValueSetItem;
        DimensionAttributeValue                 dimAttrValue;
        DimensionAttribute                          dimAttr;
        Common                                           dimensionValueEntity;
        AxLedgerJournalTable header = new AxLedgerJournalTable();
        AxLedgerJournalTrans trans = new AxLedgerJournalTrans();
        AxLedgerJournalTrans trans1 = new AxLedgerJournalTrans();
        container            offsetDim;
        str 30      accNo,departmentDim,businessUnitDim,costCenterDim,itemGroupDim;
        str 30      businessUnitDimValue,costCenterDimValue,itemGroupDimValue,departmentDimValue;
        int           indexcount;
         
        LedgerJournalNameId ledgerJournalNameId = "APInvoice";
        DimensionAttributeValueCombination davc;

        header.parmJournalName(ledgerJournalNameId);
        header.parmJournalType(LedgerJournalType::VendInvoiceRegister);
        header.save();

        trans.parmAccountType(LedgerJournalACType::Vend);
        trans.parmJournalNum(header.ledgerJournalTable().JournalNum);

        select firstonly RecId from davc where davc.DisplayValue == "CN-001";    
        trans.parmLedgerDimension(davc.RecId);
        trans.parmAmountCurCredit(99.15);
        trans.parmTaxItemGroup("UB");
        trans.save();

        trans1.parmOffsetAccountType(LedgerJournalACType::Ledger);
        //dimAttrValueSet = DimensionAttributeValueSet::find(inventTable.DefaultDimension);
        dimAttrValueSet = DimensionAttributeValueSet::find(22565462243);

        while select dimAttrValueSetItem where dimAttrValueSetItem.DimensionAttributeValueSet ==  
         dimAttrValueSet.RecId
        {
            dimAttrValue = DimensionAttributeValue::find 
                                                                (dimAttrValueSetItem.DimensionAttributeValue);
            dimAttr = DimensionAttribute::find(dimAttrValue.DimensionAttribute);
            dimensionValueEntity = DimensionDefaultingControllerBase::findBackingEntityInstance
             (curext(),
            dimAttr, dimAttrValue.EntityInstance);

            if(dimAttr.Name == "Department")
            {
                departmentDim = dimAttr.Name;
                departmentDimValue = dimAttrValue.getValue();
            }
            if(dimAttr.Name == "BusinessUnit")
            {
                businessUnitDim = dimAttr.Name;
                businessUnitDimValue = dimAttrValue.getValue();
            }
            if(dimAttr.Name == "CostCenter")
            {
                costCenterDim = dimAttr.Name;
                costCenterDimValue = dimAttrValue.getValue();
            }
            if(dimAttr.Name == "ItemGroup")
            {
                itemGroupDim = dimAttr.Name;
                itemGroupDimValue = dimAttrValue.getValue();
            }
      }
        accNo = DimensionAttributeValueCombination::getDisplayValue(WNXParameters::find().VendorLedgerDimension);
        indexcount = 2; trans1.parmJournalNum(header.ledgerJournalTable().JournalNum);
        //First is  Display value, followed by Main Account and then dimensions.
        offsetDim =
      [accNo,accNo,indexcount,businessUnitDim,businessUnitDimValue,departmentDim,departmentDimValue];
        //offsetDim = ["110180", "110180", 2, "BusinessUnit", "001", "Department", "022"];
        //Manual input
        //offsetDim = ["112000", "112000", 0]; //Manual input
        trans1.parmLedgerDimension(AxdDimensionUtil::getLedgerAccountId(offsetDim));
        trans1.parmAmountCurDebit(99.15);
        trans1.parmTaxItemGroup("UB");
        trans1.save(); jourTable = header.ledgerJournalTable();
        if (jourTable.RecId > 0)
        {
            jourCheckPost = ledgerJournalCheckPost::newLedgerJournalTable(jourTable, NoYes::Yes, NoYes::Yes);
            // Post only if there is succesful validation.
            if (jourCheckPost.validate())
            {
                jourCheckPost.run();
            }
        }
    }

  • 相关阅读:
    python 回调函数,最简单的例子
    python 构造一个可以返回多个值的函数
    python 使用函数参数注解
    Python 两个星号(**)的 参数
    python 什么是位置参数?
    sqlalchemy 的 ORM 与 Core 混合方式使用示例
    sqlalchemy 的 Core 方式使用示例
    sqlalchemy 的 ORM 方式使用示例
    sys.stdin的三种方式
    可以多分类的神经网络
  • 原文地址:https://www.cnblogs.com/fogfog/p/6122420.html
Copyright © 2011-2022 走看看