Thanks rahual
BillAmount: is calculated from BillItem
Sum(Rate *Quantity) Where Bill Id=1
AdvancePaid: is calculated from table AdvancePayment sum(AdvAmount) where BillId=1
Payable: as BillAmount- AdvancePaid
PaidAmount: is calcaluted from table RecievedAmount:
Sum(RecievedAmount) where BillId=1
DueAmount: is Calculated as Payable-PaidAmount
Problem is that if there is no advance paid against billId or payment recieved it return no rows.
if there are two advance payments made in advancePayment table then it return n *2 rows. and similarly of RecievedPayments
Best Regards
Qasim Ali