home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
database
/
dbbooks.zip
/
BOOKS.DOC
< prev
next >
Wrap
Text File
|
1987-02-14
|
20KB
|
760 lines
Bookkeeping System Command Files
Here are the command files for the bookkeeping system. The
first is BINSTALL, which allows you to set up the initial general
information and Chart of Accounts.
******************************* BINSTALL.CMD
**************** Start the Chart of Accounts.
SET TALK OFF
SET DEFA TO B
********************** Get General Information.
ERASE
USE GENINFO
DELE ALL
PACK
APPEND BLANK
?
? " Start the Bookkeeping System"
? "This program allows you to set up general"
? "information and a Chart of Accounts for the"
? "bookkeeping system. You need to use this"
? "program only once. The edit option under the"
? "BOOKS main menu allows you to make changes."
@ 9,0 SAY "Enter the name of the Company or User"
@ 9,40 GET COMPANY
READ
****************** Next, set up chart of accounts.
ERASE
? "Next, you need to set up the Chart of Accounts"
? "Account numbers use the format XXX.XX (e.g. 100.00)"
? "Account numbers in the range of 100.00 to 299.99"
? "Are for INCOME only. Account numbers in the range"
? "300.00 to 999.99 are for EXPENSES only."
?
? "Press any key to continue..."
WAIT
ERASE
? "Accounts that have a non-zero decimal portion"
? "are sub-accounts, and are not included in totals."
? "Hence, you may want to break transactions that "
? "involve a single check into sub-accounts. For "
? "example, you only write one check for utilities."
? "You may, however, wish to record the amount of"
? "this single check that went toward Gas, and the"
? "amount that went toward Electricity. To do so,"
? "Set up three accounts as follows:"
?
? " Account"
? " Number Title"
?
? " 400.00 Utilities"
? " 400.10 Gas"
? " 400.20 Electricity"
?
? "In this example, only one check will be written,"
? "for account 400. Accounts 400.10 and 400.20 will"
? "be recorded, but checks will not be written."
?
? "Press RETURN to continue, ESC to QUIT...."
WAIT
ERASE
USE COA INDEX COA
DELE ALL
PACK
STORE T TO ADDING
DO WHILE ADDING
APPEND BLANK
ERASE
@ 1, 0 SAY "Type in Account Number, Title, and Current Balance"
@ 1,50 SAY "."
@ 2, 0 SAY "Enter Ctrl-W to Quit"
@ 4, 0 SAY "Account Number"
@ 4,16 GET ACCT
@ 5, 0 SAY "Title"
@ 5,16 GET TITLE
@ 6, 0 SAY "Month-to-Date"
@ 6,16 GET AMOUNT
@ 7, 0 SAY "Quarter-to-Date"
@ 7,16 GET QTD
@ 8, 0 SAY "Year-to-Date"
@ 8,16 GET YTD
READ
************* Check for 0 as acct.
IF ACCT = 0
STORE F TO ADDING
ENDIF
ENDDO (while adding)
************** Done adding.
ERASE
? "Returning to dot prompt. To use the bookkeeping"
? "System, type DO BOOKS when dot appears."
?
?
DELE ALL FOR ACCT = 0
PACK
USE
BOOKS is the main menu program for the bookkeeping system...
*********************************** BOOKS.CMD
*************** Bookkeeping System Main Menu.
SET TALK OFF
SET DEFA TO B
SET BELL OFF
STORE 0 TO CHOICE
*************** First, get today's date.
ERAS
STORE DATE() TO T:DATE
@ 5,1 SAY "Enter today's date";
GET T:DATE PICT "99/99/99"
READ
***************** Display Main Menu.
DO WHILE CHOICE <> 5
ERASE
@ 2,10 SAY "Bookkeeping System Main Menu"
@ 4,11 SAY "1. Add New Transactions"
@ 5,11 SAY "2. Update Chart of Accounts"
@ 6,11 SAY "3. Print Reports"
@ 7,11 SAY "4. Edit Data"
@ 8,11 SAY "5. Exit"
@ 10,10 SAY "Enter your choice (1-4) from above"
@ 10,45 GET CHOICE PICT "9"
READ
************** Branch Accordingly.
DO CASE
CASE CHOICE = 1
DO ADDTRANS
CASE CHOICE = 2
DO UPDATER
CASE CHOICE = 3
DO BREPORTS
CASE CHOICE = 4
DO BEDIT
ENDCASE
ENDDO (while choice <> 4)
The ADDTRANS file allows you to enter individual income and
expense transactions. It rejects transactions that do not have a
valid account number.
*********************************** ADDTRANS.CMD
************************** Add new transactions.
************************** Set up data files.
************* First, get last check number
USE GENINFO
STORE LAST:CHECK TO CNO
SET BELL OFF
SELE PRIM
USE TRANS INDEX ACCT,DATES
SELE SECO
USE COA INDEX COA
SELE PRIM
******************* Get data for transactions.
STORE T TO ADDING
DO WHILE ADDING
APPEND BLANK
REPLACE DATE WITH T:DATE
ERASE
@ 1, 0 SAY "--- Enter new transactions (0 when done) --"
************** Accept only valid account numbers.
STORE N TO OK
DO WHILE .NOT. OK
@ 3, 0 SAY "Account Number"
@ 3,15 GET ACCT
READ
IF ACCT > 0
STORE STR(ACCT,6,2) TO LOOKUP
SELE SECO
************** Make sure account exists on COA.
FIND &LOOKUP
IF # > 0
STORE T TO OK
@ 3,26 SAY TITLE
STORE TITLE TO MTITLE
ELSE
@ 3,26 SAY "No such account!"
? CHR(7)
ENDIF (account number exists)
ELSE
STORE F TO ADDING
STORE T TO OK
LOOP
ENDIF (acct > 0)
SELE PRIM
ENDDO (while .NOT. ok)
*********** Get rest of info if user not exiting.
IF ADDING
************** Get reason
@ 5, 0 SAY "Description"
@ 5,12 GET REASON
READ
*************** If no reason type in, use account title.
IF REASON = " "
REPLACE REASON WITH TITLE
@ 5,12 SAY REASON
ENDIF
@ 7, 0 SAY "Amount"
@ 7, 7 GET AMOUNT
@ 9, 0 SAY "Date"
@ 9, 5 GET DATE
READ
*********** Ask about type if expense account
*********** and not a sub-account.
IF ACCT > 299.99 .AND. INT(ACCT)=ACCT
@ 11, 0 SAY "Type (1=Check, 2=Other)"
@ 11,24 GET TYPE
READ
************ If check, ask about check info.
IF TYPE = 1
REPL CHECK:NO WITH CNO
@ 13, 0 SAY "Check Number"
@ 13,13 GET CHECK:NO
@ 15, 0 SAY "To Whom Paid"
@ 15,13 GET TO:WHOM
READ
********* Incerement check number.
STORE CHECK:NO TO CNO
STORE CNO +1 TO CNO
ENDIF (type = 1
ENDIF (acct > 299.99)
ENDIF(if adding)
ENDDO (while adding)
************** Done adding. Close files and update
************** General information file.
SELE PRIM
DELE ALL FOR ACCT=0
USE
SELE SECO
USE
USE GENINFO
REPLACE LAST:CHECK WITH CNO
USE
RETURN
The UPDATER command file updates Month-to-date, Quarter-to-
Date, and Year-to-Date balances on the Chart of Accounts file
(COA) from the transaction (TRANS) file.
*********************************** UPDATER.CMD
************** Monthly update program for
************** Updating Chart of Accounts Balances.
ERAS
? "This program should be performed once a month"
? "to bring the Chart of Accounts totals up-to-date"
?
STORE " " TO YN
@ 5,2 SAY "Is this the program you want? " GET YN
READ
IF !(YN) <> "Y"
RETURN
ENDIF (yn <> y)
******************** Ask about start of new quarter.
ERASE
STORE " " TO QTR
@ 10,2 SAY "Is this the start of a new quarter? "
@ 10,38 GET QTR
READ
************* Perform the update.
ERASE
? "Performing the update...."
USE TRANS INDEX ACCT
COPY TO TEMP FOR .NOT. POSTED
REPL ALL POSTED WITH T
USE COA INDEX COA
************** Set Month-to-Date field (AMOUNT) to zero.
REPLACE ALL AMOUNT WITH 0
************** If start of new quarter, replace all
************** Quarterly balances with zeroes too.
IF !(QTR)="Y"
REPLACE ALL QTD WITH 0
ENDIF (qtr=y)
************** Update from TEMO file, then
************** increment QTD and YTD.
UPDATE ON ACCT FROM TEMP ADD AMOUNT
REPL ALL QTD WITH QTD+AMOUNT
REPL ALL YTD WITH YTD+AMOUNT
************** Now, set POSTED flag in TRANS to T.
USE TRANS
REPLACE ALL POSTED WITH T
************** Update Geninfo File
USE GENINFO
REPLACE LAST:UPDAT WITH T:DATE
USE
RETURN
BREPORTS asks the user which report they want, and branches
to the appropriate command file...
********************************* BREPORTS.CMD
********************** Ask user which report
********************** to use, and branch accordingly.
STORE 0 TO REPCHOICE
DO WHILE REPCHOICE <> 5
ERASE
TEXT
Bookkeeping Report Options
1. Current Transactions
2. Chart of Accounts
3. Write checks
4. Check Register
5. Return to Main Menu
ENDTEXT
@ 12,10 SAY "Enter choice (1-5) from above ";
GET REPCHOICE PICTURE "9"
READ
DO CASE
CASE REPCHOICE=1
DO CURREPT
CASE REPCHOICE=2
DO COAREPT
CASE REPCHOICE=3
DO CHECKS
CASE REPCHOICE=4
DO REGISTER
ENDCASE
ENDDO (while repchoice <> 5)
RETURN
The CURREPT command file prints data from the TRANS file,
either for the current month, or a range of dates (e.g. 01/01/84-
03/31/84). It uses pre-defined reports (ACCT.FRM or DATES.FRM)
to print the basic reports. However, these report formats do NOT
contain page headings or totals. The program itself provides
page headings and totals, and uses the REPORT FORM command in the
PLAIN mode.
********************************** CURREPT.CMD
********** Print report of Current Transactions.
********** First get company name from geninfo file
USE GENINFO
STORE COMPANY TO COMPANY
********** First, get info on dates, and store
********** to first search macro (COND1)
ERASE
STORE " " TO YN
@ 5,2 SAY "Transactions for this month only? ";
GET YN
READ
************* Set up condition according to user's request.
IF !(YN)="Y"
STORE "DATE = '"+$(T:DATE,1,2)+"'" TO COND1
STORE F TO RANGE
ELSE
STORE " " TO START,FINISH
@ 7,2 SAY "Enter starting date " GET START PICT "99/99/99"
@ 9,2 SAY "Enter ending date " GET FINISH PICT "99/99/99"
READ
STORE "DATE >=START .AND. DATE <=FINISH" TO COND1
STORE T TO RANGE
ENDIF (yn=y)
********************** Next, get sort order.
ERAS
STORE 0 TO RCHOICE
@ 3,10 SAY "Sort Orders"
@ 5,8 SAY "1. By Account Number"
@ 6,8 SAY "2. By Date"
@ 8,8 SAY "Enter choice (1-2) " GET RCHOICE PICT "9"
READ
********************** Set up sort order and report type.
IF RCHOICE = 2
USE TRANS INDEX DATES
STORE "DATES" TO ROPTION
ELSE
USE TRANS INDEX ACCT
STORE "ACCTS" TO ROPTION
ENDIF
********************** Ask about printer....
ERAS
STORE " " TO YN
@ 5,2 SAY "Send Report to printer? " GET YN
READ
********************** and set up second macro
********************** accordingly (COND2).
IF !(YN)="Y"
STORE "TO PRINT" TO COND2
ELSE
STORE " " TO COND2
ENDIF (yn=y)
********************** Mark sub-accounts for report.
REPL ALL MARKER WITH "*" FOR ACCT <> INT(ACCT)
********************** Print the report using
********************** pre-defined report formats.
SET EJECT OFF
ERASE
? " Current Transactions for &COMPANY"
?
********************* Print appropriate sub-heading.
IF RANGE
? "For transactions from &START to &FINISH"
ELSE
? "For &T:DATE"
ENDIF (range)
*********** Caculate totals, leaving out sub-accounts.
SUM AMOUNT FOR ACCT<300 .AND. &COND1 .AND. INT(ACCT)=ACCT TO INCOME
SUM AMOUNT FOR ACCT>=300 .AND. &COND1 .AND. INT(ACCT)=ACCT TO EXPENSE
******************** Print income transactions.
?
? "INCOME:"
REPO FORM &ROPTION FOR ACCT<300 .AND. &COND1 &COND2 PLAIN
? "Total Income ",INCOME
?
******************** Print expense transactions.
? "EXPENSES:"
REPO FORM &ROPTION FOR ACCT>=300 .AND. &COND1 &COND2 PLAIN
? "Total Expenses ",EXPENSE
******************** Display balance at bottom of sheet.
?
? "Total Income ",INCOME
? "Total Expenses ",EXPENSE
? " ---------"
? "Balance ",INCOME-EXPENSE
?
? " NOTE: Sub accounts (with decimal numbers above 0) "
? " are not included in totals."
EJECT
*************** If report not going to printer,
*************** pause on screen.
IF COND2 = " "
?
? "Press any key to continue"
WAIT
ENDIF (cond2=" ")
RETURN
The COAREPT program prints the Chart of Accounts with MTD
AMOUNT), QTD, and YTD balances, using COA.FRM as the REPORT
FORMat.
**************************** COAREPT.CMD
************ Print Chart of Accounts and Balances.
************ Get date of last update.
USE GENINFO
STORE LAST:UPDAT TO LAST:DATE
USE COA INDEX COA
************ Ask about hardcopy.
ERAS
STORE " " TO YN
@ 5,2 SAY "Send report to printer? " GET YN
READ
IF !(YN)="Y"
STORE "TO PRINT" TO COND
ELSE
STORE " " TO COND
ENDIF (yn=y)
*********** Calculate totals, leaving out sub-accounts.
ERASE
? "Calculating totals...."
SUM AMOUNT FOR ACCT<300 .AND. INT(ACCT)=ACCT TO TOT:MTD1
SUM AMOUNT FOR ACCT>=300 .AND. INT(ACCT)=ACCT TO TOT:MTD2
SUM QTD FOR ACCT<300 .AND. INT(ACCT)=ACCT TO TOT:QTD1
SUM QTD FOR ACCT>=300 .AND. INT(ACCT)=ACCT TO TOT:QTD2
SUM YTD FOR ACCT<300 .AND. INT(ACCT)=ACCT TO TOT:YTD1
SUM YTD FOR ACCT>=300 .AND. INT(ACCT)=ACCT TO TOT:YTD2
********************** Print the report using
********************** pre-defined report formats.
SET EJECT OFF
ERASE
? " Chart of Accounts for &COMPANY"
?
********************* Print appropriate sub-heading.
? "Last Update: &LAST:DATE"
******************** Print income accounts.
?
? "INCOME:"
REPO FORM COA FOR ACCT<300 &COND PLAIN
? "Total Income ",TOT:MTD1," ",TOT:QTD1," ",TOT:YTD1
?
******************** Print expense transactions.
? "EXPENSES:"
REPO FORM COA FOR ACCT>=300 &COND PLAIN
? "Total Expenses ",TOT:MTD2," ",TOT:QTD2," ",TOT:YTD2
******************** Display balance at bottom of sheet.
?
? "Total Income ",TOT:MTD1," ",TOT:QTD1," ",TOT:YTD1
? "Total Expenses ",TOT:MTD2," ",TOT:QTD2," ",TOT:YTD2
?
? "Balance ",;
TOT:MTD1-TOT:MTD2," ",TOT:QTD1-TOT:QTD2," ",;
TOT:YTD1-TOT:YTD2
EJECT
*************** If report not going to printer,
*************** pause on screen.
IF COND = " "
?
?
? "Press any key to continue"
WAIT
ENDIF (cond=" ")
RETURN
The CHECKS command file prints checks. It uses a memory
file called ENGLISH.MEM to help transalate numbers to English.
The ENGLISH.MEM command file is created by the MAKEMEMS command
file presented after CHECKS. However, MAKEMEMS must be created
and run before CHECKS.CMD will work.
************************************ CHECKS.CMD
************************************ Write checks.
ERASE
SET TALK OFF
? "Preparing checks file"
?
? "Load checks into printer"
***************** Save existing memory variables to THOUGHT,
***************** and bring in English-equivalent variables.
SAVE TO THOUGHT
RESTORE FROM ENGLISH
*************** Create little file of checks to be written.
USE TRANS INDEX ACCT
COPY TO TEMP FOR CHECK:NO>0 .AND. .NOT. WRITTEN
USE TEMP
INDEX ON CHECK:NO TO CHECKNOS
GO TOP
?
? "First check to be printed will be ",CHECK:NO
?
?
? "Press any key to begin writing checks"
WAIT
ERASE
SET PRINT ON
DO WHILE .NOT. EOF
************ Translate AMOUNT to English.
STORE 1 TO COUNTER,START
STORE STR(AMOUNT,9,2) TO STRING
****************************** Loop through thousands and hundreds.
DO WHILE COUNTER < 3
************************** Split out hundreds, tens, and ones.
STORE $(STRING,START,3) TO CHUNK
STORE $(CHUNK,1,1) TO HUN
STORE $(CHUNK,2,2) TO TEN
STORE $(CHUNK,3,1) TO ONE
********************* Handle hundreds.
IF VAL(CHUNK) > 99
STORE ENGLISH + U&HUN + ' HUNDRED ' TO ENGLISH
ENDIF (chunk > 99)
********************* Handle second 2 digits.
STORE VAL(TEN) TO T
IF T > 0
DO CASE
********** Case 1: Handle teens or even tens.
CASE (INT(T/10.0)=T/10.0) .OR. (T>9 .AND. T<20)
STORE ENGLISH + U&TEN TO ENGLISH
********** Case 2: Handle greater than 10 but not evenly divisible.
CASE T > 9 .AND. (INT(T/10.0)#T/10.0)
STORE $(TEN,1,1) +'0' TO TEN
STORE ENGLISH + U&TEN+' '+U&ONE TO ENGLISH
********** Case 3: Handle less than 10.
CASE T < 10
STORE ENGLISH + U&ONE TO ENGLISH
ENDCASE
ENDIF (T > 0)
**************** Add "Thousand" if necessary.
IF AMOUNT > 999.99 .AND. COUNTER = 1
STORE ENGLISH+' THOUSAND ' TO ENGLISH
ENDIF (need to add "thousand")
**************** Prepare for pass through hundreds.
STORE 4 TO START
STORE COUNTER+1 TO COUNTER
ENDDO (while counter < 3.)
***************** Tack on cents.
IF INT(AMOUNT) > 0
STORE ENGLISH + " AND " TO ENGLISH
ENDIF
STORE ENGLISH + $(STRING,8,2)+"/100" TO ENGLISH
***************** Print a check.
? " ",DATE
?
? " ",TO:WHOM," ",AMOUNT
?
? " ",ENGLISH
?
?
?
?
?
SKIP
STORE " " TO ENGLISH
ENDDO
SET PRINT OFF
************************ Flag checks as written in TRANS
USE TRANS
REPLACE ALL WRITTEN WITH Y FOR CHECK:NO>0
USE
***************** Get rid of "English" memory
***************** variables, and bring back originals.
RELEASE ALL
RESTORE FROM THOUGHT
USE
RETURN
The MAKEMEMS command file creates the ENGLISH.MEM memory
file that CHECKS.CMD depends on to translate numbers to English.
*************** MAKEMEMS.CMD
*************** Sets up memory file for
*************** storing English equivalents.
SET DEFA TO B
SET TALK OFF
RELE ALL
STORE ' ' TO U,ENGLISH
STORE 'ONE' TO U1
STORE 'TWO' TO U2
STORE 'THREE' TO U3
STORE 'FOUR' TO U4
STORE 'FIVE' TO U5
STORE 'SIX' TO U6
STORE 'SEVEN' TO U7
STORE 'EIGHT' TO U8
STORE 'NINE' TO U9
STORE 'TEN' TO U10
STORE 'ELEVEN' TO U11
STORE 'TWELVE' TO U12
STORE 'THIRTEEN' TO U13
STORE 'FOURTEEN' TO U14
STORE 'FIFTEEN' TO U15
STORE 'SIXTEEN' TO U16
STORE 'SEVENTEEN' TO U17
STORE 'EIGHTEEN' TO U18
STORE 'NINETEEN' TO U19
STORE 'TWENTY' TO U20
STORE 'THIRTY' TO U30
STORE 'FORTY' TO U40
STORE 'FIFTY' TO U50
STORE 'SIXTY' TO U60
STORE 'SEVENTY' TO U70
STORE 'EIGHTY' TO U80
STORE 'NINETY' TO U90
SAVE TO ENGLISH
DISP MEMO
RETURN
I did not include the code for handling the check register
here, because I'm hoping to discuss this in class. It presents a
few design problems; such as how to handle deposits to the
checking acount, how to handle multiple accounts, and others. In
this class, I'm more concerned about design considerations than
tricky programming techniques. In DBMS programming, you can
always "borrow" a routine (such as the check-writing routine
above) to solve a particular problem. Setting up the database
(which includes all data and index files), requires a more subtle
design skill.