LOGIC:
sales: If the amount entered in the 1st Installment, 2nd Installment or 3rd Installment is equal to Total Invoiced Amount field, or anyone of these fields is equal to Total Invoiced Amount field, then Payment status to be CLOSE. Default Value of Payment Status is OPEN.
purchases: If the Amount Paid is equal to Total Invoice Amount, Payment Status to be updated as CLOSE. Default Value of Payment Status is OPEN.