<% 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 theaccode=orequest.form('ac') if isnull(theaccode) theaccode=orequest.querystring('ac') endif theaccode=transform(theaccode) if val(theaccode)=0 return '

# You must select an account

' endif set date ymd pdate1=ctod(fromdate) pdate2=ctod(todate) set date british usesafe('acctran') usesafe('accounts') select [accounts] locate for accountid=theaccode Acname=allt(accountid)+[ ]+allt(name) if not empty(address1) acname=acname+[
]+allt(address1) endif if not empty(address2) acname=acname+[
]+allt(address2) endif if not empty(phone) acname=acname+[
Contact: ]+allt(phone) endif openingbalancealias=sys(2015) closingbalancealias=sys(2015) SELECT [acctran] SET ORDER TO acdate =seek(theaccode) FILEstring=[

## ACCOUNT LEDGER

]+CHR(13) FILESTRING=FILESTRING+ACNAME do case case empty(pdate1) and empty(PDATE2) FILEstring=FILESTRING+[

### FROM START TO END

] case not empty(pdate1) and empty(pdate2) FILEstring=FILESTRING+[

### FROM ]+transform(pdate1)+[ TO END

] otherwise FILEstring=FILESTRING+[

### FROM ]+transform(pdate1)+[ TO ]+transform(pdate2)+[

] ENDCASE STORE 0 TO gldebits, glcredits filestring=FILESTRING+CHR(13)+[

] filestring=FILESTRING+[DATE | VTP | TR# | DETAILS | DEBIT | CREDIT | BALANCE
--- | --- | --- | --- | --- | --- | ---
] store 0 to openingbalance, thedebits, thecredits, closingbalance do while not eof() and accountid=theaccode and date0 thedebits=openingbalance ELSE thecredits=abs(openingbalance) ENDIF glhead=glhead+[
]+transform(pdate1)+[] glhead=glhead+[ | ]+allt(transform([OPEN]))+[] glhead=glhead+[ | ] glhead=glhead+[ | OPENING BALANCE] glhead=glhead+[ | ]+iif(openingbalance>0,TRANSFORM(openingbalance,'999,999,999,999.99'),[ ])+[] glhead=glhead+[ | ]+iif(openingbalance<0,TRANSFORM(abs(openingbalance),'999,999,999,999.99'),[ ])+[] glhead=glhead+[ | ]+TRANSFORM(closingbalance,'999,999,999,999.99')+[
] filestring=filestring+glhead+CHR(13) glhead="" endif DO WHILE NOT EOF() and accountid=theaccode if not empty(pdate2) and date>pdate2 exit endif glhead=[] if debit-credit>0 thedebits=thedebits+debit-credit endif if credit-DEBIT>0 thecredits=thecredits+credit-debit endif if not empty(debit-credit) closingbalance=closingbalance+debit-credit glhead=glhead+[
]+transform(date)+[] glhead=glhead+[ | ]+allt(transform(vtype))+[] glhead=glhead+[ | ]+allt(transform(transid))+[] glhead=glhead+[ | ]+allt(transform(desc))+[] glhead=glhead+[ | ]+iif(debit-credit>0,TRANSFORM(debit-credit,'999,999,999,999.99'),[ ])+[] glhead=glhead+[ | ]+iif(credit-debit>0,TRANSFORM(credit-debit,'999,999,999,999.99'),[ ])+[] glhead=glhead+[ | ]+TRANSFORM(closingbalance,'999,999,999,999.99')+[
] endif if not empty(glhead) filestring=filestring+glhead+CHR(13) endif skip ENDDO OVERALL=THEDEBITS-thecredits if not empty(THEDEBITS) OR NOT EMPTY(THECREDITS) glhead="" glhead=glhead+[
BALANCE:] glhead=glhead+[ | ]+iif(THEDEBITS>0,TRANSFORM(THEDEBITS,'999,999,999,999.99'),[ ])+[] glhead=glhead+[ | ]+iif(thecredits>0,TRANSFORM(thecredits,'999,999,999,999.99'),[ ])+[] glhead=glhead+[ | ]+TRANSFORM(OVERALL,'999,999,999,999.99')+[
] filestring=filestring+glhead+chr(13) endif filestring=filestring+CHR(13)+[

] %>

# <%=xcompany.name%>

<%=FILESTRING%>