我希望覆盖业务逻辑中SOInvoiceEntry图的InvoiceOrder逻辑,因此如果未选择“Bill Separately'选项,我可以更改聚合发票的逻辑。
我在下面编写了一个扩展方法来替换内置的InvoiceOrder方法。
Base.DoSomething();
我不确定如何访问原始对象的受保护方法。通常我只是调用int *p_darr = new int[num]
,但我认为我无法访问受保护的方法,因为扩展对象不是直接从SOInvoiceEntry派生的。
我是否需要覆盖我想要使用的受保护方法,或者是否有办法从扩展程序中访问它们?
任何帮助都会很棒。
感谢。
答案 0 :(得分:1)
您使用传递给方法的委托作为基本调用。对于InvoiceCreated,您应该能够覆盖它并调用它,如下所示:
public class SOInvoiceEntryExtension : PXGraphExtension<SOInvoiceEntry>
{
public delegate void InvoiceOrderDelegate(DateTime invoiceDate,
PXResult<SOOrderShipment, SOOrder, CurrencyInfo, SOAddress, SOContact, SOOrderType> order,
PXResultset<SOShipLine, SOLine> details,
Customer customer,
DocumentList<ARInvoice, SOInvoice> list);
[PXOverride]
public virtual void InvoiceOrder(DateTime invoiceDate,
PXResult<SOOrderShipment, SOOrder, CurrencyInfo, SOAddress, SOContact, SOOrderType> order,
PXResultset<SOShipLine, SOLine> details,
Customer customer,
DocumentList<ARInvoice, SOInvoice> list,
InvoiceOrderDelegate baseMethod)
{
//Code before
baseMethod?.Invoke(invoiceDate, order, details, customer, list);
//Code after
// This also works, but the delegate should be used.
//Base.InvoiceOrder(invoiceDate, order, details, customer, list);
//InvoiceCreated(someInvoice, someSource);
}
[PXOverride]
public virtual void InvoiceCreated(ARInvoice invoice, SOOrder source, SOInvoiceEntry.InvoiceCreatedDelegate baseMethod)
{
baseMethod?.Invoke(invoice, source);
}
}