Skip to main content
Question

Hard code limit to 100% PO receipt

  • April 8, 2026
  • 1 reply
  • 28 views

Forum|alt.badge.img

Hello all,

I have a basic requirement that an AP Bill should only be created if the PO receipt is 100%, else it should allow the user to even create it. How to achieve this?

1 reply

Naveen Boga
Captain II
Forum|alt.badge.img+20
  • Captain II
  • April 24, 2026

Hi ​@Harry  You can write a logic to validate in the AP Bill screen graph extension like below.

Graph Extension — RowInserting / RowPersisting Override  
Extend the APInvoiceEntry graph and add a validation that checks receipt completion before allowing the bill to be saved.

Hope this helps!
 

public class APInvoiceEntry_Extension : PXGraphExtension<APInvoiceEntry>
{
public override void Initialize()
{
base.Initialize();
}

protected void _(Events.RowPersisting<APInvoice> e)
{
if (e.Operation == PXDBOperation.Insert ||
e.Operation == PXDBOperation.Update)
{
APInvoice bill = e.Row as APInvoice;
if (bill == null) return;

if (!IsReceiptFullyReceived(bill))
{
e.Cache.RaiseExceptionHandling<APInvoice.refNbr>(
bill,
bill.RefNbr,
new PXSetPropertyException(
"AP Bill cannot be created. The linked PO Receipt is not 100% complete.",
PXErrorLevel.Error));

e.Cancel = true;
}
}
}

private bool IsReceiptFullyReceived(APInvoice bill)
{
// Query POReceiptLine to check if all lines are fully billed
var receiptLines = PXSelectJoin<POReceiptLine,
InnerJoin<APTran,
On<APTran.receiptNbr, Equal<POReceiptLine.receiptNbr>,
And<APTran.receiptLineNbr, Equal<POReceiptLine.lineNbr>>>>,
Where<APTran.tranType, Equal<Required<APTran.tranType>>,
And<APTran.refNbr, Equal<Required<APTran.refNbr>>>>>
.Select(Base, bill.DocType, bill.RefNbr);

foreach (PXResult<POReceiptLine, APTran> row in receiptLines)
{
POReceiptLine receiptLine = row;

// Compare received qty vs billed qty
if (receiptLine.ReceiptQty > receiptLine.BilledQty)
{
return false;
}
}

return true;
}
}