home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Du Jour
/
SoftwareDuJour.iso
/
BUSINESS
/
DBASE
/
DB3.ARC
/
PAYBILLS.PRG
< prev
next >
Wrap
Text File
|
1984-10-25
|
10KB
|
257 lines
*********** Paybills COMMAND FILE ***********
* Before this procedure can be accessed, the check number and balance must
* not too complicated. Repetitive procedures in the main loop (controlled
* by the variable 'T_Finish') could have been put in separate command files
* to make this file easier to understand and maintain, but this way it
* minimizes disk accesses and increases speed.
* This file finds bills to be paid in the Costbase, generates the next
* check number, writes a check in the Checkfil and maintains the checkbook
* balance.
* The next check number and checkbook balance are recalled from a file
* called Konstant.mem. The final values for both of these are stored in the
* same file after all the bills have been paid.
* Entries must include at least the name of the party being paid.
* Balances are automatically computed and shown to the operator.
* Check numbers are automatically assigned by the computer.
* If several entries are made against a single check number (the
* operator has this option), these are added and shown as a single
* item in the printout.
********************************************************************
*
RESTORE FROM Konstant
*
T_Begin = 1
DO WHILE T_Begin < LEN(NextCheck) .AND. SUBSTR(NextCheck,T_Begin,1)=' '
T_Begin = T_Begin + 1
ENDDO
Nextcheck = SUBSTR(NextCheck,T_Begin)
*
*
* Initialize. 'T_New' is used to determine whether the program should generate
* a new check number or use the old one (where several bills to a single
* supplier are being paid). 'T_Finish' is the control variable that determines
* whether we should run through the procedure again, or are done paying bills.
STORE 'N' TO T_New, T_Finish
DO WHILE LEN(T_Finish) <> 0
T_Enter = 'C'
DO WHILE LEN(T_Enter) <> 0
CLEAR
@ 2, 0 SAY 'WRITING CHECK: '+NextCheck+' BALANCE: '+STR(MBalance,9,2)
@ 5, 0
ACCEPT ' MAKE CHECK TO: ' TO T_Name
ACCEPT ' INVOICE NUMBER: ' TO T_Bill_No
INPUT ' ENTER AMOUNT: ' TO T_Amount
T_Name = UPPER(T_Name)
T_Bill_No = UPPER(T_Bill_No)
@ 6,20 SAY T_Name
@ 7,20 SAY T_Bill_No
IF TYPE('T_Amount') = 'U' .OR. TYPE('T_Amount') = 'L'
@ 8,20 SAY 'No Amount'
T_Amount = 0.00
ELSE
T_Amount = T_Amount * 1.00
@ 8,20 SAY T_Amount PICTURE '999,999.99'
ENDIF
@ 11, 0 SAY 'Any key to CHANGE,'
WAIT '<ENTER> if O.K. ' TO T_Enter
ENDDO T_Enter
*
IF LEN(T_Name) > 10
T_Key = SUBSTR(T_Name,1,10)
ELSE
T_Key = TRIM(T_Name)
ENDIF
*
IF T_Key <> ' '
T_Look = .T.
T_Start = 0
@ 12, 0
@ 11, 0 SAY "Searching for bill"
* Selecting file Costbase.Dbf
SELECT 3
FIND &T_Key
IF RECNO() = 0
@ 11, 0
? " I CAN'T FIND THE NAME. Please check the spelling."
? " Or maybe it hasn't been posted to the Costbase yet."
WAIT 'Press <ENTER> to continue.'
ELSE
DO Payfind WITH T_Bill_No,T_Amount,T_Key,T_Look,T_Start
ENDIF there is an unpaid bill for the supplier
*
* 'T_Start' is brought in from Payfind.prg. If we started at the first
* entry for a name (had only the name), T_Start=0. If we had more than
* the name, T_Start contains the record numerber we started on. Since this
* could be in the middle of the listing, we use 'T_Count' so that we can
* come back to the top of the listing for the name once.
IF T_Start > 0
T_Count = 0
ELSE
T_Count = 1
ENDIF
*
Confirm = ' '
DO WHILE UPPER(Confirm) <> 'P' .AND. .NOT. T_Look
@ 9,0 CLEAR
? 'RECORD NAME AMOUNT BILL #';
+' DATE JOB'
?
DISPLAY ' '+Name, Amount, Bill_Nmbr, Bill_Date,Client+'-';
+ STR(Job_Nmbr,4)
?
?
? ' P to PAY this bill,'
? ' Q to QUIT without paying,'
WAIT ' <ENTER> to continue. ' TO CONFIRM
*
IF UPPER(Confirm) = 'Q'
IF UPPER(T_New) = 'S'
NextCheck = STR(VAL(NextCheck)+1,5)
T_Begin = 1
DO WHILE T_Begin<LEN(NextCheck).AND.SUBSTR(NextCheck,T_Begin,1)=' '
T_Begin = T_Begin + 1
ENDDO
NextCheck = SUBSTR(NextCheck,T_Begin)
ENDIF
T_New = ' '
T_Look = .T.
ELSE
IF UPPER(Confirm) = 'P'
T_Found = STR(RECNO(),5)
REPLACE Check_Date WITH Date(), Check_Nmbr WITH NextCheck
MBalance = (MBalance-Amount)
*
SELECT 6
APPEND BLANK
REPLACE Check_Date WITH C->Check_Date, Name WITH C->Name,;
Check_Nmbr WITH C->Check_Nmbr, Balance WITH MBalance,;
Amount WITH C->Amount, Bill_Nmbr WITH C->Bill_Nmbr;
Client WITH C->Client, Job_Nmbr WITH C->Job_Nmbr
SELECT 3
CLEAR
@ 3, 0 SAY 'CHECK WRITTEN: '+NextCheck+;
' NEW BALANCE: '+STR(MBalance,9,2)
?
DISPLAY 'PAYMENT MADE:',Check_Date, Name, Amount, Bill_Nmbr,;
Bill_Date, Client, Job_Nmbr OFF
?
? ' S for SAME SUPPLIER (Repeats check #)'
?
WAIT ' <ENTER> to continue.' TO T_New
IF UPPER(T_New) <> 'S'
NextCheck = STR(VAL(NextCheck)+1,5)
T_Begin = 1
DO WHILE T_Begin < LEN(NextCheck) .AND. ;
SUBSTR(NextCheck,T_Begin,1)=' '
T_Begin = T_Begin + 1
ENDDO
NextCheck = SUBSTR(NextCheck,T_Begin)
ELSE
Confirm = ' '
ENDIF
ENDIF
*
IF UPPER(T_New) = 'S' .OR. UPPER(Confirm) <> 'P'
* If Confirm <> 'P', we rejected the first unpaid bill that was
* shown. Rather than going back to the beginning, the loop
* below SKIPs to the next INDEXed name until we find an unpaid
* bill, or go beyond the records for the name we are paying.
* The same applies if we want to pay another bill to the
* same supplier (T_New='S'). Since we are in the file on the name
* we want we SKIP to the next record until we find an unpaid
* bill or run out of records for that name.
* If we had only the name and started with the first unpaid
* bill we stop now since we have looked at all the unpaid bills
* for that supplier.
* If we could have entered the list of records for this
* supplier in the middle (more than the name provided), we look
* at the unpaid bills between where we are and the end of the
* list, then go up to the first entry for that name and check
* all of the unpaid bills that we had previously skipped past.
* This is controlled by T_Count.
* After the second FIND in the command file (below), we
* stop looking when the record number we are on is greater than
* or equal to the number of the record we start on (T_Start).
*
SKIP
DO WHILE Check_Nmbr <> ' ' .AND. Name=T_Key .AND. .NOT. EOF()
SKIP
ENDDO
*
* We enter this loop when we reach the end of the records with
* names that match the one we are looking for. If we started
* with the first unpaid bill, the record number is greater than
* T_Start (because T_Start=0) and T_Count=1 (because we set it to
* that value). The second IF below is True and we terminate the
* search.
* If T_Start>0, T_Count=0 the first time we run out of
* records with a matching name, so the program does the ELSE
* commands below.
* T_Start is still >0 and Count is now 1, so the last term in
* the first IF applies. On this second pass when we get to a
* record number >=T_Start, we drop into the loop and do the IF to
* terminate the search because we have now looked at all the
* unpaid bills for the name we entered.
IF EOF() .OR. Name <> T_Key .OR. (RECNO() >= T_Start .AND.;
T_Start <> 0 .AND. T_Count >0)
IF (RECNO() >= T_Start .AND. T_Count > 0)
T_Look = .T.
@ 4, 0 CLEAR
? ' We have now looked at all the entries for '+ T_Name
? ' <ENTER> to continue.'
?
IF UPPER(T_New)='S'
NextCheck = STR(VAL(NextCheck)+1,5)
T_Start = 1
DO WHILE T_Start < LEN(NextCheck) .AND.;
SUBSTR(NextCheck,T_Start,1) =' '
T_Start = T_Start + 1
ENDDO
NextCheck = SUBSTR(NextCheck,T_Start)
T_New = 'N'
ENDIF
WAIT
ELSE
T_Count = T_Count + 1
@ 13, 0 CLEAR
@ 16, 0 SAY "I'M WORKING AS FAST AS I CAN -- HANG ON! "
FIND &T_Key
DO WHILE Check_Nmbr <> ' '
SKIP
ENDDO
ENDIF
ENDIF
ENDIF is it the right record
ENDIF
ENDDO Confirm the record
ENDIF
*
IF UPPER(T_New) <> 'S'
@ 4, 0 CLEAR
? 'Type any key to continue. '
WAIT 'Press <ENTER> to exit ' TO T_Finish
ENDIF
ENDDO T_Finish
*
RELEASE T_Name,T_Bill_No,T_Key,T_Amount,T_Start,T_Found,T_Look,T_New,;
T_Enter,T_Count,Abort,Continue,T_Finish,Confirm,T_Begin
SAVE TO Konstant
*
SELECT 6
PACK
COUNT TO Any
@ 3,0 CLEAR
IF Any=0
? ' No new checks in the checkfile.'
WAIT ' <ENTER> to continue.'
ELSE
? 'There are '+STR(Any,5)+' new checks in the CheckFile.'
WAIT 'Do you want to print the checkstubs now (Y or N)? ' TO Hardcopy
IF UPPER(Hardcopy) = 'Y'
DO Nametest WITH '6'
DO Checkstu
ENDIF
ENDIF
*
RETURN