SalesLine自定义计算行金额未在发票中显示的技术求助
解决销售订单过账发票后自定义净额计算失效的问题
由于calcLineAmount()是final方法无法包装,你可以通过以下几个关键节点的自定义逻辑来确保发票中的净额按规则计算:
同步自定义字段到SalesInvoiceLine表
首先需要在SalesInvoiceLine表中添加相同的No of months字段,确保销售订单行的自定义值能传递到发票行,这是后续计算的基础。重写SalesLine的updateAmounts方法
这个方法会在订单确认、过账等流程中被调用更新行金额,在这里加入自定义计算逻辑,覆盖默认值:public void updateAmounts() { super(); if (this.'No of months' > 0) { this.LineAmount = this.Price * this.Qty * this.'No of months'; this.update(); } }重写SalesInvoiceLine的initFromSalesLine方法
在生成发票行时,同步自定义字段并直接计算正确的净额:public void initFromSalesLine(SalesLine _salesLine) { super(_salesLine); this.'No of months' = _salesLine.'No of months'; if (this.'No of months' > 0) { this.LineAmount = this.Price * this.Qty * this.'No of months'; } }拦截发票过账时的金额重计算
在SalesFormLetter_Invoice类的updateLines方法中,添加逻辑确保发票行金额不会被默认逻辑覆盖:protected void updateLines(SalesFormLetterContract _contract) { super(_contract); SalesInvoiceLine salesInvoiceLine; while select forupdate salesInvoiceLine where salesInvoiceLine.SalesId == this.parmSalesId() { if (salesInvoiceLine.'No of months' > 0) { salesInvoiceLine.LineAmount = salesInvoiceLine.Price * salesInvoiceLine.Qty * salesInvoiceLine.'No of months'; salesInvoiceLine.update(); } } }
以上步骤覆盖了订单行更新、发票行初始化、过账后修正三个关键环节,确保自定义计算的净额在整个流程中保持一致,不会被系统默认逻辑覆盖。
内容的提问来源于stack exchange,提问作者Saba Iqbal
相关产品推荐
相关产品推荐

