有些场景下,供应商开发票时会有折扣,开票金额会小于收货金额,过账发票时,系统根据收货金额过账,自动产生折扣金额对应的日记账,与过账发票产生的供应商交易记录自动核销。
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 放在这里做个备份