• 生成折扣日记账


    有些场景下,供应商开发票时会有折扣,开票金额会小于收货金额,过账发票时,系统根据收货金额过账,自动产生折扣金额对应的日记账,与过账发票产生的供应商交易记录自动核销。

    public void createDiscountJournal(ERM_VendStatementTable _statementTable)
    {
        LedgerJournalTable          journalTable;
        LedgerJournalTrans          journalTrans;
        Voucher                     voucher;
        CustVendOpenTransManager    manager;
        VendTransOpen               vendTransOpen;
        VendTrans                   vendTrans;
        LedgerJournalCheckPost      journalCheckPost;
        LedgerJournalName           journalName;
        ERM_PurchInvoice            purchInvoice;
        ;
    
        if(!_statementTable.discountAmount())
            return;
    
        ttsbegin;
    
        select purchInvoice
        where purchInvoice.StatementId == _statementTable.StatementId;
    
    
        journalName = LedgerJournalName::find(VendParameters::find().ERM_DiscountJournalNameId);
    
        voucher = NumberSeq::newGetVoucher(LedgerParameters::numRefLedgerTempVoucher()).voucher();
        journalTable.initFromLedgerJournalName(journalName.JournalName);
        journalTable.insert();
    
        journalTrans.JournalNum         = journalTable.JournalNum;
        journalTrans.Voucher            = voucher;
        journalTrans.TransDate          = purchInvoice.InvoiceDate? purchInvoice.InvoiceDate:systemDateGet();
        journalTrans.AccountType        = LedgerJournalACType::Vend;
        journalTrans.AccountNum         = _statementTable.VendAccount;
        journalTrans.AmountCurDebit     = _statementTable.discountAmount();
        journalTrans.Approved           = NoYes::Yes;
        journalTrans.OffsetAccountType  = journalName.OffsetAccountType;
        journalTrans.OffsetAccount      = journalName.OffsetAccount;
        journalTrans.CurrencyCode       = VendTable::find(_statementTable.VendAccount).Currency;
        journalTrans.ExchRate           = Currency::exchRate(journalTrans.CurrencyCode);
        journalTrans.SettleVoucher      = SettlementType::SelectedTransact;
    
        journalTrans.insert();
    
        manager = CustVendOpenTransManager::construct(journalTrans);
    
    
        select vendTransOpen
        exists join vendTrans
        where vendTransOpen.RefRecId == vendTrans.RecId &&
                vendTrans.Invoice == _statementTable.StatementId &&
                    vendTrans.AccountNum == _statementTable.VendAccount;
    
        manager.updateTransMarked(vendTransOpen,NoYes::Yes);
    
        journalCheckPost = LedgerJournalCheckPost::newLedgerJournalTable(journalTable,NoYes::Yes);
        journalCheckPost.run();
    
        _statementTable.Status = ERM_VendStatementStatus::Invoiced;
        _statementTable.update();
        _statementTable.dataSource().reread();
        _statementTable.dataSource().refresh();
        _statementTable.dataSource().active();
    
        ttscommit;
    
    }

    AX2009 放在这里做个备份

  • 相关阅读:
    误操作 rpm -e --nodeps zlib
    Raid阵列之简单介绍
    GpG使用指南
    hadoop系统的端口
    网站日志流量复杂分析
    Flume在企业大数据仓库架构中位置及功能
    Hue的安装与部署
    Hive中的数据倾斜
    Hive的三种Join方式
    如何每日增量加载数据到Hive分区表
  • 原文地址:https://www.cnblogs.com/Farseer1215/p/6995165.html
Copyright © 2020-2023  润新知