Solved

Warning when AP Bill total is zero

  • 7 November 2023
  • 3 replies
  • 51 views

Userlevel 7
Badge +12

Hi i cannot work out what i am missing. I want a warning not a stop message when an AP Bill is created/updated if the Total value is 0. It works but i cannot save the Bill with a zero as the error keeps presenting on save. I have tried Row Inserted but that triggers to early.

 

  public class APInvoiceEntry_Extension : PXGraphExtension<PX.Objects.AP.APInvoiceEntry>
  {
    #region Event Handlers

    protected void APInvoice_RowPersisted(PXCache cache, PXRowPersistedEventArgs e, PXRowPersisted InvokeBaseHandler)
    {
      if(InvokeBaseHandler != null)
        InvokeBaseHandler(cache, e);
      var row = (APInvoice)e.Row;
                       if (row !=null && row.CuryLineTotal == 0)
            {
                throw new PXSetPropertyException("The document total is zero", PXErrorLevel.Warning);
            }
    }

icon

Best answer by Vignesh Ponnusamy 7 November 2023, 16:19

View original

3 replies

Userlevel 5
Badge

@dcomerford  - Please try the following:  

 

protected void APInvoice_RowPersisting(PXCache cache, PXRowPersistingEventArgs e, PXRowPersisting InvokeBaseHandler)
{
  if (InvokeBaseHandler != null)
    InvokeBaseHandler(cache, e);
  var row = (APInvoice)e.Row;
  if (row != null && row.CuryLineTotal == 0 && (e.Operation == PXDBOperation.Insert || e.Operation == PXDBOperation.Update))
  {
    cache.RaiseExceptionHandling<APInvoice.curyLineTotal>(e.Row, row.CuryLineTotal, new PXSetPropertyException("The document total is zero", PXErrorLevel.Warning));
  }
}

Userlevel 7
Badge +12

@StevenRatner Thank you it does work correctly but the Error is not very visible i was hoping to still have the popup. The user will see the small warning icon but if they dont see ti or click on it then it will be missed

Userlevel 7
Badge +4

Hi @dcomerford,

You can override Persist() invoke base(which will commit the record to DB), add condition to verify the total then display the pop-up warning. Following is an example you can try,

        public delegate void PersistDelegate();
[PXOverride]
public void Persist(PersistDelegate baseMethod)
{
baseMethod();
if (Base.Document.Current.CuryLineTotal == 0)
{
// Acuminator disable once PX1050 HardcodedStringInLocalizationMethod [Justification]
throw new PXException("The document total is zero");
}
}

Good Luck,

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved