
//// Receive 


SELECT * FROM tbl_recvoucher AS v LEFT JOIN tbl_trarecord AS d ON v.invno= d.invno


SELECT invno,apdate,cid,cty,d.amount,did,dty,cheno,chedt,ref FROM tbl_recvoucher AS v LEFT JOIN tbl_recvoucherde AS d ON v.id = d.seid




INSERT INTO `tbl_trarecord` (`invno`, `dty`, `did`, `amo`, `cid`, `cty`, `chkno`, `chkdt`, `ref`, `apdate`) SELECT DISTINCT v.invno, d.dty, d.did, d.amount, d.cid, d.cty, d.cheno, d.chedt, d.ref, v.apdate FROM tbl_recvoucher AS v LEFT JOIN tbl_recvoucherde AS d ON v.id = d.seid LEFT JOIN tbl_trarecord AS tr ON v.invno = tr.invno WHERE tr.invno IS NULL






INSERT INTO `tbl_traledger1` (`invno`, `dty`, `did`, `amo`, `cid`, `cty`, `chkno`, `chkdt`, `ref`, `apdate`) SELECT DISTINCT v.invno, d.dty, d.did, d.amount, d.cid, d.cty, d.cheno, d.chedt, d.ref, v.apdate FROM tbl_recvoucher AS v LEFT JOIN tbl_recvoucherde AS d ON v.id = d.seid LEFT JOIN tbl_traledger1 AS tr ON v.invno = tr.invno WHERE tr.invno IS NULL


//// Payments

SELECT * FROM tbl_payvoucher AS v LEFT JOIN tbl_trarecord AS d ON v.invno= d.invno


SELECT invno,apdate,cid,cty,d.amount,did,dty,cheno,chedt,ref FROM tbl_payvoucher AS v LEFT JOIN tbl_payvoucherde AS d ON v.id = d.seid




INSERT INTO `tbl_trarecord` (`invno`, `dty`, `did`, `amo`, `cid`, `cty`, `chkno`, `chkdt`, `ref`, `apdate`) SELECT DISTINCT v.invno, d.dty, d.did, d.amount, d.cid, d.cty, d.cheno, d.chedt, d.ref, v.apdate FROM tbl_payvoucher AS v LEFT JOIN tbl_payvoucherde AS d ON v.id = d.seid LEFT JOIN tbl_trarecord AS tr ON v.invno = tr.invno WHERE tr.invno IS NULL






INSERT INTO `tbl_traledger1` (`invno`, `dty`, `did`, `amo`, `cid`, `cty`, `chkno`, `chkdt`, `ref`, `apdate`) SELECT DISTINCT v.invno, d.dty, d.did, d.amount, d.cid, d.cty, d.cheno, d.chedt, d.ref, v.apdate FROM tbl_payvoucher AS v LEFT JOIN tbl_payvoucherde AS d ON v.id = d.seid LEFT JOIN tbl_traledger1 AS tr ON v.invno = tr.invno WHERE tr.invno IS NULL






