Preview:
void Test1.testpayment(int id)
{
	fetpay = Payment_form[ID == id];
	fetinv = Internal_Invoice[ID == fetpay.CP_Internal_Invoice_ID];
	cp_invoice_id = fetpay.CP_Internal_Invoice_ID;
	all_payments = Payment_form[CP_Internal_Invoice_ID == cp_invoice_id];
	pay = 0;
	for each  rec in all_payments
	{
		pay = pay + rec.Payment_Amount.toDecimal();
	}
	fetinv.Paid_Amount=pay;
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter