生成折扣日记账

Posted Farseer

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了生成折扣日记账相关的知识,希望对你有一定的参考价值。

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

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 放在这里做个备份

以上是关于生成折扣日记账的主要内容,如果未能解决你的问题,请参考以下文章

iOS - 我们如何通过促销代码为应用内购买提供折扣?

(导航组件)返回首页fragment时如何在activity上显示返回箭头?

postman 自动生成 curl 代码片段

postman 自动生成 curl 代码片段

java学习日记

总账和日记账生成流程