<% temporaryfolder=addbs(oprop.appstartpath)+[temp\] *temporaryfolder=[temp\] fromdate=orequest.form('datefrom') todate=orequest.form('dateto') if isnull(fromdate) fromdate=NVL(orequest.querystring('datefrom'),'{}') endif if isnull(todate) todate=NVL(orequest.querystring('dateto'),'{}') endif pcust=orequest.form('ac') if isnull(pcust) pcust=NVL(orequest.querystring('ac'),'') endif pdate1=ctod(fromdate) pdate2=ctod(todate) usesafe('acctran') usesafe('glcodes') usesafe('accounts') usesafe('itemmast') openingbalancealias=sys(2015) closingbalancealias=sys(2015) SELECT [acctran] SET ORDER TO acdate *** =SYS(3101,65001) paccountid=pcust IF EMPTY(PaCCOUNTID) return 'Must select an account!' STORE 0 TO _tally RETURN ENDIF Public cdmline, tsql, x, Y, z, wheretext, wheretext2, ordertext, rept_More Store 0 To acounter Store Space(0) To wheretext, ordertext, wheretext2 *wheretext=" AND (X.debit<>0 or x.credit<>0 " Do Case Case Empty(pdate1) And Empty(pdate2) user_reptsecline="" Case Empty(pdate1) And Not Empty(pdate2) user_reptsecline="As on "+Dtoc(pdate2) wheretext=Alltrim(wheretext)+" And x.Date <= PDate2 " Case Not Empty(pdate1) And Empty(pdate2) user_reptsecline="From "+Dtoc(pdate1) wheretext=Alltrim(wheretext)+" And x.Date >= PDate1 " IF VAL(LEFT(paccountid,2))<9 wheretext2=Alltrim(wheretext2)+" and y.date < pdate1 " endif Case Not Empty(pdate1) And Not Empty(pdate2) user_reptsecline="From "+Dtoc(pdate1)+" to "+Dtoc(pdate2) wheretext=Alltrim(wheretext)+" And BETWEEN(x.Date,pdate1,pdate2) " IF VAL(LEFT(paccountid,2))<9 wheretext2=Alltrim(wheretext2)+" and y.date < pdate1 " endif Endcase If Not Empty(pAccountid) rept_More=.F. wheretext=Alltrim(wheretext)+" and x.Accountid=pAccountid " If Not Empty(wheretext2) wheretext2=Alltrim(wheretext2)+" and y.Accountid=pAccountid " Endif Else rept_More=.T. Endif If Not(Empty(wheretext)) wheretext=" where "+Substr(wheretext,5) Endif If Not Empty(wheretext2) wheretext2=" where "+Substr(wheretext2,5) Endif *** SELECT [accounts] =SEEK(paccountid,[accounts],[accountid]) acname=ALLTRIM(name) urduname=ALLTRIM(extra) TEXT TO dividright noshow TEXTMERGE DETAILS OF ACCOUNT
<')>> <> <'+Alltrim(urduNAME))>> <Phone: '+Alltrim(phone))>> endtext *** IF NOT empty(wheretext2) tsql=[select y.accountid, '' as transid, '' as vtype, {//} as date, '' as checkno, SUM(y.debit-y.credit) as opbal, ] tsql =tsql+[ 0.00 as debit, 0.00 as credit, {//} as ddate, 'OPENING BALANCE' as desc ] tsql =tsql+[ from acctran y group by y.accountid ]+wheretext2 tsql=tsql+[having opbal<>0 union all ] tsql=tsql+[(Select x.Accountid, X.TRANSID, x.vtype, x.date,x.checkno, 0.00 as opbal, x.debit, x.credit, x.ddate,] tsql =tsql+[ x.desc from acctran x ]+wheretext+[) order by date, vtype, transid into cursor salecust readwrite ] ELSE tsql =[ Select x.Accountid, X.TRANSID, x.vtype, x.date,x.checkno, 0.00 as opbal, x.debit, x.credit, x.ddate,] tsql =tsql+[ x.desc from acctran x ]+wheretext+[ order by x.date, x.vtype, x.transid into cursor salecust readwrite ] endif &tsql select distinct vtype from dbf() into cursor vtypes SCAN do case case vtype=[CashSale] =usesafe('cashsale') =usesafe('cashdata') case vtype=[Invoice] =usesafe('Invoice') =usesafe('invdata') Case vtype=[CREFUND] =usesafe('rcInvoice') =usesafe('rcinvdata') case vtype=[CreditMemo] =usesafe('rInvoice') =usesafe('rinvdata') case vtype=[CreditBill] =usesafe('rbill') =usesafe('rbilldata') case vtype=[Bill] =usesafe('Bill') =usesafe('billdata') case vtype=[CashBill] =usesafe('cashbill') =usesafe('cbilldata') endcase endscan select [salecust] tstr=[

DATE | VTYPE | TR# | DETAIL | DEBIT | CREDIT | BALNCE
--- | --- | --- | --- | --- | --- | ---
] TBAL=0 *SET DEBUG ON *SET STEP ON SCAN THETR=TRANSID LETGO=.T. TBAL=TBAL+opbal+DEBIT-CREDIT tstr=tstr+[
] tstr=tstr+[]+TRANSFORM(DATE)+[ | ]+TRANSFORM(VTYPE)+[ | ]+TRANSFORM(TRANSID)+[] TSTR=TSTR+[ | ]+TRANSFORM(desc)+[ | ]+IIF(debit<>0,TRANSFORM(DEBIT,'99999999999.99'),' ')+[] TSTR=TSTR+[ | ]+IIF(credit<>0,TRANSFORM(credit,'99999999999.99'),' ')+[] TSTR=TSTR+[ | ]+IIF(tbal<>0,TRANSFORM(tbal,'99999999999.99'),'0.00')+[
] DO CASE CASE vtype=[CashSale] SELECT [cashdata] SET ORDER TO transid =SEEK(THETR) TRHEAD=[] IF NOT EOF() TSTR=TSTR+[
| DETAILS] tstr=tstr+[ | QTY | PRICE] tstr=tstr+[ | TOTAL | DISC] tstr=tstr+[ | NET |
] ENDIF DO WHILE NOT EOF() AND TRANSID=THETR =SEEK(itemid,[itemmast],[itemid]) IF NOT EMPTY(itemmast.extra) AND NOT ALLTRIM(itemmast.extra)==[ ] itemnameurdu=[
]+ALLTRIM(itemmast.extra) ELSE itemnameurdu=[] endif TSTR=TSTR+[
| ]+ALLTRIM(DESC)+itemnameurdu+[] TSTR=TSTR+[ | ]+ALLTRIM(TRANSFORM(QTY))+[] TSTR=TSTR+[ | ]+ALLTRIM(TRANSFORM(RATE))+[] TSTR=TSTR+[ | ]+ALLTRIM(TRANSFORM(QTY*RATE))+[] TSTR=TSTR+[ | ]+IIF(discount<>0,TRANSFORM(discount,'99999999999.99'),' ')+[] TSTR=TSTR+[ | ]+IIF(QTY*RATE-DISCOUNT<>0,TRANSFORM(QTY*RATE-DISCOUNT,'99999999999.99'),' ')+[] TSTR=TSTR+[ |
] SKIP ENDDO SELECT [cashsale] =SEEK(THETR,[cashsale],[transid]) IF NOT EMPTY(expamt) =SEEK(expac,[accounts],[accountid]) IF EOF([accounts]) expdesc=[OTHER EXPENSES] ELSE EXPDESC=ALLTRIM(ACCOUNTS.NAME) ENDIF tstr=tstr+[
]+expdesc+[ | Amount | ]+TRANSFORM(EXPAMT,'99999999999.99')+[
] endif IF NOT EMPTY(srvchgs) =SEEK(xcompany.srvac,[accounts],[accountid]) IF EOF([accounts]) expdesc=[OTHER CHARGES] ELSE EXPDESC=ALLTRIM(ACCOUNTS.NAME) ENDIF tstr=tstr+[
]+expdesc+[ | Amount | ]+TRANSFORM(MEMDISC,'99999999999.99')+[ |
] ENDIF IF NOT EMPTY(memdisc) =SEEK(xcompany.srvac,[accounts],[accountid]) IF EOF([accounts]) expdesc=[MEMBER DISCOUNT] ELSE EXPDESC=ALLTRIM(ACCOUNTS.NAME) ENDIF tstr=tstr+[
]+expdesc+[ | Amount | ]+TRANSFORM(MEMDISC)+[ |
] endif CASE vtype=[Invoice] SELECT [invdata] SET ORDER TO transid =SEEK(THETR) TRHEAD=[] IF NOT EOF() TSTR=TSTR+[
| DETAILS] tstr=tstr+[ | QTY | PRICE] tstr=tstr+[ | TOTAL | DISC] tstr=tstr+[ | NET |
] ENDIF DO WHILE NOT EOF() AND TRANSID=THETR =SEEK(itemid,[itemmast],[itemid]) IF NOT EMPTY(itemmast.extra) AND NOT ALLTRIM(itemmast.extra)==[ ] itemnameurdu=[
]+ALLTRIM(itemmast.extra) ELSE itemnameurdu=[] endif TSTR=TSTR+[
| ]+ALLTRIM(DESC)+itemnameurdu+[] TSTR=TSTR+[ | ]+ALLTRIM(TRANSFORM(QTY))+[] TSTR=TSTR+[ | ]+ALLTRIM(TRANSFORM(RATE))+[] TSTR=TSTR+[ | ]+ALLTRIM(TRANSFORM(QTY*RATE))+[] TSTR=TSTR+[ | ]+IIF(discount<>0,TRANSFORM(discount,'99999999999.99'),' ')+[] TSTR=TSTR+[ | ]+IIF(QTY*RATE-DISCOUNT<>0,TRANSFORM(QTY*RATE-DISCOUNT,'99999999999.99'),' ')+[] TSTR=TSTR+[ |
] SKIP ENDDO SELECT [invoice] =SEEK(THETR,[invoice],[transid]) IF NOT EMPTY(expamt) =SEEK(expac,[accounts],[accountid]) IF EOF([accounts]) expdesc=[OTHER EXPENSES] ELSE EXPDESC=ALLTRIM(ACCOUNTS.NAME) ENDIF tstr=tstr+[
]+expdesc+[ | Amount | ]+TRANSFORM(EXPAMT,'99999999999.99')+[ |
] endif IF NOT EMPTY(cashpmt) tstr=tstr+[
Cash Payment | Amount | ]+TRANSFORM(CASHPMT,'99999999999.99')+[ |
] endif case vtype=[CreditMemo] SELECT [Rinvdata] SET ORDER TO transid =SEEK(THETR) TRHEAD=[] IF NOT EOF() TSTR=TSTR+[
| DETAILS] tstr=tstr+[ | QTY | PRICE] tstr=tstr+[ | TOTAL | DISC] tstr=tstr+[ | NET |
] ENDIF DO WHILE NOT EOF() AND TRANSID=THETR =SEEK(itemid,[itemmast],[itemid]) IF NOT EMPTY(itemmast.extra) AND NOT ALLTRIM(itemmast.extra)==[ ] itemnameurdu=[
]+ALLTRIM(itemmast.extra) ELSE itemnameurdu=[] endif TSTR=TSTR+[
| ]+ALLTRIM(DESC)+itemnameurdu+[] TSTR=TSTR+[ | ]+ALLTRIM(TRANSFORM(QTY))+[] TSTR=TSTR+[ | ]+ALLTRIM(TRANSFORM(RATE))+[] TSTR=TSTR+[ | ]+ALLTRIM(TRANSFORM(QTY*RATE))+[] TSTR=TSTR+[ | ]+IIF(discount<>0,TRANSFORM(discount,'99999999999.99'),' ')+[] TSTR=TSTR+[ | ]+IIF(QTY*RATE-DISCOUNT<>0,TRANSFORM(QTY*RATE-DISCOUNT,'99999999999.99'),' ')+[] TSTR=TSTR+[ |
] SKIP ENDDO SELECT [RINVOICE] CASE vtype=[CREFUND] SELECT [Rcinvdata] SET ORDER TO transid =SEEK(THETR) TRHEAD=[] IF NOT EOF() TSTR=TSTR+[
| DETAILS] tstr=tstr+[ | QTY | PRICE] tstr=tstr+[ | TOTAL | DISC] tstr=tstr+[ | NET |
] ENDIF DO WHILE NOT EOF() AND TRANSID=THETR =SEEK(itemid,[itemmast],[itemid]) IF NOT EMPTY(itemmast.extra) AND NOT ALLTRIM(itemmast.extra)==[ ] itemnameurdu=[
]+ALLTRIM(itemmast.extra) ELSE itemnameurdu=[] endif TSTR=TSTR+[
| ]+ALLTRIM(DESC)+itemnameurdu+[] TSTR=TSTR+[ | ]+ALLTRIM(TRANSFORM(QTY))+[] TSTR=TSTR+[ | ]+ALLTRIM(TRANSFORM(RATE))+[] TSTR=TSTR+[ | ]+ALLTRIM(TRANSFORM(QTY*RATE))+[] TSTR=TSTR+[ | ]+IIF(discount<>0,TRANSFORM(discount,'99999999999.99'),' ')+[] TSTR=TSTR+[ | ]+IIF(QTY*RATE-DISCOUNT<>0,TRANSFORM(QTY*RATE-DISCOUNT,'99999999999.99'),' ')+[] TSTR=TSTR+[ |
] SKIP ENDDO SELECT [RCINVOICE] CASE vtype=[Bill] SELECT [BILLDATA] SET ORDER TO transid =SEEK(THETR) TRHEAD=[] IF NOT EOF() TSTR=TSTR+[
| DETAILS] tstr=tstr+[ | QTY | PRICE] tstr=tstr+[ | TOTAL | DISC] tstr=tstr+[ | NET |
] ENDIF DO WHILE NOT EOF() AND TRANSID=THETR =SEEK(itemid,[itemmast],[itemid]) IF NOT EMPTY(itemmast.extra) AND NOT ALLTRIM(itemmast.extra)==[ ] itemnameurdu=[
]+ALLTRIM(itemmast.extra) ELSE itemnameurdu=[] endif TSTR=TSTR+[
| ]+ALLTRIM(DESC)+itemnameurdu+[] TSTR=TSTR+[ | ]+ALLTRIM(TRANSFORM(QTY))+[] TSTR=TSTR+[ | ]+ALLTRIM(TRANSFORM(RATE))+[] TSTR=TSTR+[ | ]+ALLTRIM(TRANSFORM(QTY*RATE))+[] TSTR=TSTR+[ | ]+IIF(discount<>0,TRANSFORM(discount,'99999999999.99'),' ')+[] TSTR=TSTR+[ | ]+IIF(QTY*RATE-DISCOUNT<>0,TRANSFORM(QTY*RATE-DISCOUNT,'99999999999.99'),' ')+[] TSTR=TSTR+[ |
] SKIP ENDDO SELECT [BILL] =SEEK(THETR,[BILL],[transid]) IF NOT EMPTY(expamt) =SEEK(expac,[accounts],[accountid]) IF EOF([accounts]) expdesc=[OTHER EXPENSES] ELSE EXPDESC=ALLTRIM(ACCOUNTS.NAME)+[ TRANSPORT CHARGES] ENDIF tstr=tstr+[
]+expdesc+[ | Amount | ]+TRANSFORM(EXPAMT,'99999999999.99')+[ |
] endif IF NOT EMPTY(cashpmt) tstr=tstr+[
Cash Payment | Amount | ]+TRANSFORM(CASHPMT,'99999999999.99')+[ |
] endif CASE vtype=[CashBill] SELECT [CBILLDATA] SET ORDER TO transid =SEEK(THETR) TRHEAD=[] IF NOT EOF() TSTR=TSTR+[
| DETAILS] tstr=tstr+[ | QTY | PRICE] tstr=tstr+[ | TOTAL | DISC] tstr=tstr+[ | NET |
] ENDIF DO WHILE NOT EOF() AND TRANSID=THETR =SEEK(itemid,[itemmast],[itemid]) IF NOT EMPTY(itemmast.extra) AND NOT ALLTRIM(itemmast.extra)==[ ] itemnameurdu=[
]+ALLTRIM(itemmast.extra) ELSE itemnameurdu=[] endif TSTR=TSTR+[
| ]+ALLTRIM(DESC)+itemnameurdu+[] TSTR=TSTR+[ | ]+ALLTRIM(TRANSFORM(QTY))+[] TSTR=TSTR+[ | ]+ALLTRIM(TRANSFORM(RATE))+[] TSTR=TSTR+[ | ]+ALLTRIM(TRANSFORM(QTY*RATE))+[] TSTR=TSTR+[ | ]+IIF(discount<>0,TRANSFORM(discount,'99999999999.99'),' ')+[] TSTR=TSTR+[ | ]+IIF(QTY*RATE-DISCOUNT<>0,TRANSFORM(QTY*RATE-DISCOUNT,'99999999999.99'),' ')+[] TSTR=TSTR+[ |
] SKIP ENDDO SELECT [CASHBILL] =SEEK(THETR,[CASHBILL],[transid]) IF NOT EMPTY(expamt) =SEEK(expac,[accounts],[accountid]) IF EOF([accounts]) expdesc=[OTHER EXPENSES] ELSE EXPDESC=ALLTRIM(ACCOUNTS.NAME) ENDIF tstr=tstr+[
]+expdesc+[ | Amount | ]+TRANSFORM(EXPAMT,'99999999999.99')+[ |
] endif IF NOT EMPTY(cashpmt) tstr=tstr+[
Cash Payment | Amount | ]+TRANSFORM(CASHPMT,'99999999999.99')+[ |
] endif CASE vtype=[CreditBill] SELECT [RBILLDATA] SET ORDER TO transid =SEEK(THETR) TRHEAD=[] IF NOT EOF() TSTR=TSTR+[
| DETAILS] tstr=tstr+[ | QTY | PRICE] tstr=tstr+[ | TOTAL | DISC] tstr=tstr+[ | NET |
] ENDIF DO WHILE NOT EOF() AND TRANSID=THETR =SEEK(itemid,[itemmast],[itemid]) IF NOT EMPTY(itemmast.extra) AND NOT ALLTRIM(itemmast.extra)==[ ] itemnameurdu=[
]+ALLTRIM(itemmast.extra) ELSE itemnameurdu=[] endif TSTR=TSTR+[
| ]+ALLTRIM(DESC)+itemnameurdu+[] TSTR=TSTR+[ | ]+ALLTRIM(TRANSFORM(QTY))+[] TSTR=TSTR+[ | ]+ALLTRIM(TRANSFORM(RATE))+[] TSTR=TSTR+[ | ]+ALLTRIM(TRANSFORM(QTY*RATE))+[] TSTR=TSTR+[ | ]+IIF(discount<>0,TRANSFORM(discount,'99999999999.99'),' ')+[] TSTR=TSTR+[ | ]+IIF(QTY*RATE-DISCOUNT<>0,TRANSFORM(QTY*RATE-DISCOUNT,'99999999999.99'),' ')+[] TSTR=TSTR+[ |
] SKIP ENDDO SELECT [RBILL] =SEEK(THETR,[RBILL],[transid]) CASE vtype=[Journal] CASE vtype=[Payment] CASE vtype=[Recepit] endcase tstr=tstr+[] SELECT [SALECUST] endscan tstr=tstr+[

] USE IN SELECT([cashsale]) USE IN SELECT([CashData]) USE IN SELECT([invoice]) USE IN SELECT([InvData]) USE IN SELECT([Rinvoice]) USE IN SELECT([RInvData]) USE IN SELECT([BILL]) USE IN SELECT([BILLData]) USE IN SELECT([CASHBILL]) USE IN SELECT([CBILLData]) USE IN SELECT([RBILL]) USE IN SELECT([RBILLData]) USE IN SELECT([accounts]) USE IN SELECT([itemmast]) close tables *** %>

# <%=xcompany.name%>

<%=tstr%>