EDIT:
After I discovered the solution, I greatly simplified this question because I put a lot of things in the original version that -- as it turns out -- had nothing to do with the issue. I think this is more valuable for posterity with this stripped-down version:
/END EDIT
I have a modified APInvoice Graph. Here is my extension class declaration:
public class APInvoiceExtended : PXCacheExtension<APInvoice>, IBqlTable
{
public static bool IsActive() { return true; }
public static Type GetUsrAmountExcludedType()
{
return typeof(APInvoiceExtended.usrAmountExcludedFromDiscount);
}
// Auto-Generated from ERP Customization Editor
#region UsrAmountExcludedFromDiscount
[PXDBDecimal]
[PXUIField(DisplayName = "Amt Excl. Discount", Enabled = true,
IsReadOnly = false)]
public virtual decimal? UsrAmountExcludedFromDiscount { get; set; }
public abstract class usrAmountExcludedFromDiscount : PX.Data.BQL.BqlDecimal.Field<usrAmountExcludedFromDiscount> { }
#endregion
I am changing the default behavior of the Discount calculations by allowing my user to specify a portion of the Invoice that is not subject to any discount.
From Use Case Description:
If the terms call for a 5% discount on an Invoice that is $125, but $25 of the cost was for shipping -- my user wants to exclude that from the discountable amount. So, in this case instead of offering a discount of $6.25, they want to exclude the shipping, and have a discount of $5 offered.
I have a custom field called "usrAmountExcludedFromDiscount ".
I have a subclass of the TermsID Attribute as Hugues Beauséjour described in this SO Post Override curyOrigDiscAmt
Everything works fine.
But, my user wants to go back and change the adjusted discount amount.
The problem is that the system does not respond to any event at the field level.
My field Override Code: (I tried many different events, all reacted the same)
protected virtual void _(Events.FieldVerifying<APInvoiceExtension.usrAmountExcludedFromDiscount> e)
{
if (e.Row == null) return;
APInvoice apInvoice = e.Row as APInvoice;
var oldValue = e.OldValue as Decimal?;
var newValue = e.NewValue as Decimal?;
if (oldValue == newValue) return;
var Cache = e.Cache;
var Graph = e.Cache.Graph;
...
Etc... There is more code there, but the issue is it isn't fired and doesn't run.
How can I trigger a recalc when my custom field, usrAmountExcludedFromDiscount is changed by the user?


