REPORTFORM;BR5_E.frf
TITLE;RECEIPT DAILY CASH,CHEQUE REPORT
SQL;select bktr.DOCNO,
SQL;armst.XCOMP, bktr.AMT_IN,
SQL;if(left(bktr.PAYTYPE,2)="01",bktr.AMT_IN,0) as XCASH,
SQL;if(left(bktr.PAYTYPE,2)="02",bktr.AMT_IN,0) as XCHK
SQL;from bktr 
SQL;left join armst on bktr.ARACCID = armst.ACCID
SQL;where left(bktr.TRTYPE,2) = "AR" and 
SQL;(left(bktr.PAYTYPE,2) = "01" or left(bktr.PAYTYPE,2) = "02")
SQL;order by bktr.DOCNO
CONDITION;FROM DATE~BKTR.DATEDOC~Date~2~~
EXCELSQL;select arcard.REFNO as "เลขที่เอกสารตั้งหนี้", arcard.DATEINV as "วันที่ตั้งหนี้",  arcard.DOCNO as "เลขที่เอกสาร" , arcard.DATEDOC as "วันที่",
EXCELSQL;arcard.ACCID as "รหัสลูกค้า", armst.XCOMP as "บริษัท", arcard.AMOUNT_D as "ยอดหนี้ตั้งหนี้", 
EXCELSQL;arcard.RECAMT as "ยอดรับชำระหนี้", arcard.AMOUNT_D - arcard.RECAMT as "ยอดหนี้คงเหลือ", arpayhd.XDATECHK as "วันที่เช็ค", arpayhd.XCHKNO as "เลขที่เช็ค"
EXCELSQL;from arcard
EXCELSQL;left join armst on arcard.ACCID = armst.ACCID
EXCELSQL;left join arpayhd on arcard.docno = arpayhd.docno
EXCELSQL;where left(arcard.trtype,2) = "BR" 
EXCELSQL;order by arcard.DATEDOC, arcard.DOCNO, arcard.ACCID
