I have two tables invoice and payments

invoice has following columns :

period,customerid,producttype,cashapplyseq,invoiced_amount

data

Jan , 10001, X,3,10.00
Jan, 10001,Y,5,20.00
Jan,10001,A,1,5.00
Feb,10001,A,1,5.00
Mar,10001,A,1,5.00
Apr,10001,A,1,10.00
Apr,10001,B,2,5.00

Payment table :

period,customerid,collectedcash,collectedserialno
Jan ,10001,35.00,1
Mar ,10001,5.00,2
Apr ,10001,7.00,3
Need help to show the below data using a query :
invoiceperiod,cid,type,cashappliedseq,invoicedcash,postedcash,paidperiod
Jan , 10001 ,X, 3, 10.00 , 10.00 ,Jan
Jan , 10001, Y, 5, 20.00, 20.00,Jan
Jan , 10001, A,1, 5.00, 5.00,Jan
Feb ,10001, A, 1, 5.00, 5.00,Mar
Mar,10001,A,1,5.00,5.00,Mar
Apr,10001,A,1,10.00,7.00,Apr
Apr,10001,B,2,5.00,0,Apr

This is similar to cr/db posting in banking ...

Any thoughts ?