过账采购发票
大多数场景下,开票前一般都会跟供应商进行收货单的对账,准确无误后,根据协商的金额将所对账的采购订单开一个发票。
在PurchFormLetter中增加一个方法用于根据对账单明细生成对应的Parm表记录(AX2009)。
public void ERM_CreateParmByStatement(ERM_VendStatementTable _statementTable) { ERM_PurchTableInvoice purchTableInvoice; ERM_PurchInvoice purchInvoice; PurchLine purchLineLocal; ; ttsbegin; select firstonly purchTableInvoice where purchTableInvoice.StatementId == _statementTable.StatementId; select firstonly purchInvoice where purchInvoice.StatementId == _statementTable.StatementId; this.createParmUpdate(); purchParmUpdate.SpecQty = PurchUpdate::ReceiveNow; purchParmUpdate.SumBy = AccountOrder::Order; purchParmUpdate.SumNum = _statementTable.StatementId; purchParmUpdate.SumPurchId = purchTableInvoice.PurchId; purchParmUpdate.update(); while select purchTableInvoice where purchTableInvoice.StatementId == _statementTable.StatementId { //info(purchTableInvoice.PurchId); purchParmTable.clear(); purchParmTable.ParmId = purchParmUpdate.ParmId; purchParmTable.PurchId = purchTableInvoice.PurchId; purchParmTable.initFromPurchTable(PurchTable::find(purchParmTable.PurchId)); purchParmTable.Approved = NoYes::Yes; purchParmTable.Num = _statementTable.StatementId; purchParmTable.TransDate = purchInvoice.InvoiceDate; purchParmTable.insert(); while select purchLineLocal where purchLineLocal.PurchId == purchTableInvoice.PurchId { if(purchLineLocal.receivedInTotalServer()) { purchParmLine.clear(); purchParmLine.ParmId = purchParmTable.ParmId; purchParmLine.TableRefId = purchParmTable.TableRefId; purchParmLine.initFromPurchLine(purchLineLocal); purchParmLine.ReceiveNow = purchLineLocal.receivedInTotalServer(); purchParmLine.InventNow = purchLineLocal.receivedInventInTotal(); purchParmLine.RemainAfter = 0; purchParmLine.RemainAfterInvent = 0; purchParmLine.RemainBefore = purchParmLine.ReceiveNow; purchParmLine.RemainBeforeInvent = purchParmLine.InventNow; purchParmLine.LineAmount = purchParmLine.calcLineAmountForced(); purchParmLine.insert(); } } } this.initParameters(); this.editLinesChanged(false); this.reArrangeNow(true); this.validateAll(false); this.reArrange(true); this.validateAll(true); ttscommit; }
放在这里做备份。