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

    static void  createVendorInvoiceJournal(Args _args)
    {
        LedgerJournalCheckPost  jourCheckPost;
        LedgerJournalTable      jourTable;
    
        AxLedgerJournalTable    header  = new AxLedgerJournalTable();
        AxLedgerJournalTrans    trans   = new AxLedgerJournalTrans();
    
        container               offsetDim;
    
        // The AP invoice journal name, could vary.
        LedgerJournalNameId     ledgerJournalNameId = "AP";
    
        // This is the entry against the Vendor account.
        // It will have to pre-exist for this script to work.
        // It is probably created the first time such an entry is
        // made on a journal line.
        DimensionAttributeValueCombination  davc;
    
        LedgerJournalACType         accType, offsetAccType;
    
        BankAccountTable            bankAccountTable;
    
        accType         = LedgerJournalACType::Vend;
        offsetAccType   = LedgerJournalACType::Ledger;
    
        header.parmJournalName(ledgerJournalNameId);
        header.parmJournalType(LedgerJournalType::VendInvoiceRegister);
        header.save();
    
        trans.parmAccountType(accType);
        trans.parmJournalNum(header.ledgerJournalTable().JournalNum);
    
        offsetDim   = ["52121-Disp", "52121", 2, "Site", "OK", "Department", "204"];    //First is Display value, followed by Main Account and then dimensions.
    
        trans.parmAccountType(LedgerJournalACType::Vend);
      
        // Note: This only works if the DimensionValueAttributeCombindation record
        // exists from before.
        select firstonly RecId from davc
            where davc.DisplayValue == "Vendor123"; //Vendor123 is the vendor account number.
    
        trans.parmLedgerDimension(davc.RecId);
    
        //There's a parm method for credit as well.
        trans.parmAmountCurDebit(99.15);
        trans.parmOffsetAccountType(offsetAccType);
    trans.clearField(fieldNum(ledgerJournalTrans, offsetLedgerDimension), false); trans.parmOffsetLedgerDimension(AxdDimensionUtil::getLedgerAccountId(offsetDim)); trans.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(); } } }
  • 相关阅读:
    自动刷新页面
    超链接<A>链接到某个文档
    JS脚本的对话框
    表最后更新的标识列
    c#对象私有属性在重载Equals中的使用
    一个关于在Fedora下安装jdk的问题
    表格的行转列
    UNION和UNION ALL的区别
    关于使用存储过程的一些好处以及注意事项[转]
    SQL 外链接操作小结
  • 原文地址:https://www.cnblogs.com/fogfog/p/6121369.html
Copyright © 2011-2022 走看看