I'm trying to Restrict the updating Receipt after payment on posted Purchase Order

 
if the Invoice is already paid or Partially paid For the Purchase order,again same PO should not allow to post to receive.for this requirement I wrote below code

IF PurchaseHeader.Receive THEN BEGIN
PurInvHdrRec.SETRANGE("Order No.", PurchaseHeader."No.");
IF PurInvHdrRec.FINDSET THEN BEGIN
LineAmt := 0;
RemAmt := 0;
REPEAT
;
LineAmt += PurInvHdrRec.Amount;
RemAmt += PurInvHdrRec."Remaining Amount";

UNTIL (PurInvHdrRec.NEXT = 0);

PurInvHdrRec."Buy-from Vendor Name", PurInvHdrRec."Posting Description");
IF LineAmt <> RemAmt THEN
ERROR('You cannot receive more Items in this Purchase Order');
END;
END;

now my issue is the amount and remaining amount showing 0 for brief clarification pls find the attachment .and kindly help me out
 
Related
Recommended