Dynamics AX 清空供应商余额

来源:互联网 发布:山东淘宝商城 编辑:程序博客网 时间:2024/04/30 09:48


static void createVendBalanceLedger(Args _args)
{
    TmpCustVendTrans                vendTransBalanceCurrency;
    VendTable                               vendTable;
    AxLedgerJournalTable            axLedgerJournalTable;
    AxLedgerJournalTrans            axLedgerJournalTrans;
    LedgerJournalNameId             ledgerJournalNameId;
    ;

    axLedgerJournalTable    =   AxLedgerJournalTable::construct();
    ledgerJournalNameId =   "LedgerJournalName";
    axLedgerJournalTable.parmName("Adjustment vend balance");
    axLedgerJournalTable.parmJournalName(ledgerJournalNameId);
    axLedgerJournalTable.save();
    while select vendTable
    {
        vendTransBalanceCurrency.setTmpData(TmpCustVendTrans::vendTransBalanceCurrency(vendTable.AccountNum, true, vendTable.Currency));
        while select vendTransBalanceCurrency
            where vendTransBalancecurrency.CurrencyCode != ""
                &&vendTransBalanceCurrency.AmountCur != 0
        {
            axLedgerJournalTrans    =   AxLedgerJournalTrans::construct();
            axLedgerJournalTrans.parmJournalNum(axLedgerJournalTable.parmJournalNum());
            axLedgerJournalTrans.parmTransDate(systemdateget());
            axLedgerJournalTrans.parmCurrencyCode(vendTransBalancecurrency.CurrencyCode);
            axLedgerJournalTrans.parmAccountType(LedgerJournalACType::Vend);
            axLedgerJournalTrans.parmAccountNum(vendTable.AccountNum);
            if (vendTransBalancecurrency.CurrencyCode == "LocalCurrency")
            {
                axLedgerJournalTrans.parmPostingProfile("#########"); //LocalAccount
            }
            else
            {
                axLedgerJournalTrans.parmPostingProfile("##########");
            }
            axLedgerJournalTrans.parmAmountCurCredit(vendTransBalanceCurrency.AmountCur);
            axLedgerJournalTrans.save();
        }
    }
}


After above job execute, in Generanl Ledger > Journals > General Journal will have a journal record, open it and click Lines you will find  Credit, there have values and then create a new record and fill the correct data in Debit field and then post.   Now, all the Vend balance have been zero.



0 0