Simple Ledger creation & Posting Program

Submitted by Karthikeyan on

clear
clea all
set talk off
use jour1
store space(15) to acname
store 0 to r,p, ds, cs, br, bl, mamt
@10,10 say "Account Name" get acname
read
clear
set devi to scre
set print on
set print to ledger.out
@2,2 say replicate("-",75)
@3,3 say "Date"
@3,13 say "Particulars"
@3,28 say "Amount"
@3,41 say "Date"
@3,52 say "Particulars"
@3,67 say "Amount"
@4,2 say replicate("-",75)
@5,28 say [Ledger for ] + alltrim(acname)
@6,28 say "-------------------"
r = 7
p = 7
do while .not. eof()
scan for upper(part1) = upper(alltrim(acname))
@r,2 say date
@r,11 say "To " + part2
@r,26 say credit
ds = ds + credit
r = r+1
endscan
scan for upper(part2) = upper(alltrim(acname))
@p,40 say date
@p,50 say "By " + part1
@p,65 say debit
cs =  cs + debit
p = p+1
endscan
enddo 

if p>r
br = p
else
br = r
endif

if cs > ds
bl = cs - ds
mamt = cs
@r+1,11 say "To bal b/d"
@r+1,26 say bl
@br+5,50 say "By Bal c/d"
@br+5,65 say bl
else
bl = ds - cs
mamt = ds
@p+1, 50 say "By bal c/d"
@p+1, 66 say bl
@br+5,11 say "To Bal b/d"
@br+5,26 say bl
endif

@br+2,26 say "------------"
@br+2,66 say "------------"
@br+3,26 say mamt
@br+3,66 say mamt
@br+4,26 say "------------"
@br+4,66 say "------------"
@br+6,2 say replicate("-",75)
set devi to scre
set print to
set print off
return

Screenshots

FoxPro Ledger A/c selection

FoxPro Ledger A/c selection

Recommended :
FoxPro e-Book
  1. FoxPro Programming Quick Reference e-Book (New! Revised Edition)