***********************************************************
*
* FILE: B:CANCEL.CMD
*
* ENTER CANCELLED CHARGES AND DEPOSITS
*
* DATE: 30-AUG-81

STORE 'V3.5' TO V:CANCEL

*
***********************************************************

ERASE
STORE CHR(M:CANCELNO) TO M:CANCELCH
@ 2,0 SAY 'CANCELLATION CHARACTER IS ' GET M:CANCELCH
READ

STORE -1 TO C:NUMBER
STORE 0.00 TO A:CHK
STORE 0.00 TO A:DEP
STORE 0 TO N:CHK
STORE 0 TO N:DEP
STORE F TO C:UNNUM
STORE F TO FINISHED

*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

DO WHILE T

ERASE
STORE T TO M:LOOKING
@ 2,0 SAY 'ENTER CANCELLED ITEMS ' + V:CANCEL

IF .NOT. C:UNNUM 
	@ 4,0 SAY 'ENTER CHECK # OF 0 TO GO TO CREDITS'
	STORE C:NUMBER+1 TO C:NUMBER
	@ 7,0 SAY 'ENTER CHECK NUMBER ' GET C:NUMBER PICTURE '9999'
	READ
	IF C:NUMBER = 0
		STORE T TO C:UNNUM
		STORE F TO M:LOOKING
	ELSE
		STORE 0.00 TO C:AMOUNT
		@ 8,0 SAY '            AMOUNT ' GET C:AMOUNT PICTURE '9999999.99'
		READ

	ENDIF
ELSE
	@ 4,0 SAY 'ENTER AMOUNT OF 0 TO QUIT'
	STORE 0.00 TO C:AMOUNT
	@ 7,0 SAY 'AMOUNT ' GET C:AMOUNT PICTURE '9999999.99'
	READ
	IF C:AMOUNT = 0 
		RELEASE FINISHED, M:LOOKING, C:UNNUM
		STORE M:CANCELNO + 1 TO M:CANCELNO
		ERASE
		?
		? N:CHK,' Checks, total= ', A:CHK
		?
		? N:DEP,' Deposits, total= ', A:DEP
		WAIT
		RELEASE RIGHT
		RETURN
	ENDIF
*	STORE 0 TO C:MM
*	STORE 0 TO C:DD
*	STORE 0 TO C:YY
*	@ 8,0 SAY '  DATE ' GET C:MM PICTURE '99'
*	@ 8,12 GET C:DD PICTURE '99'
*	@ 8,16 GET C:YY PICTURE '99'
*	READ
ENDIF

* FIND CANCELLED ITEM *************************************

IF M:LOOKING
	IF .NOT. C:UNNUM
		STORE STR(C:NUMBER,4) TO CNUM
		FIND &CNUM
		RELEASE CNUM
		IF #<> 0 .AND. C:AMOUNT = AMOUNT
		  STORE T TO RIGHT
		ELSE
		  STORE F TO RIGHT
		ENDIF

	ELSE
		STORE F TO RIGHT
		LOCATE FOR AMOUNT=C:AMOUNT .AND. NUMBER=0;
		.AND. CANCEL = ' '
	ENDIF
IF EOF .OR. (# = 0 )
	? 'ERROR: RECORD NOT FOUND' + CHR(7)
	STORE 0 TO M:COUNT
	DO WHILE M:COUNT < 20
	STORE M:COUNT + 1 TO M:COUNT
	ENDDO
	RELEASE M:COUNT
ENDIF

ENDIF

* DISPLAY AND FIND NEXT IF THIS WASN'T IT *****************

IF (.NOT. EOF ) .AND. ( # <> 0)
DO WHILE M:LOOKING

@ 10,0  SAY '          NAME '
@ 10,15 SAY NAME
@ 11,0  SAY '        NUMBER '
@ 11,15 SAY NUMBER
@ 12,0  SAY ' DATE MM/DD/YY '
@ 12,15 SAY MM
@ 12,19 SAY DD
@ 12,23 SAY YY
@ 13,0  SAY '        AMOUNT '
@ 13,15 SAY AMOUNT
@ 14,0  SAY '      TYPECODE '
@ 14,15 SAY TYPECODE
@ 15,0  SAY '        CANCEL '
@ 15,15 SAY CANCEL

IF RIGHT
	@ 19,0 SAY CHR(7)
ENDIF
STORE ' ' TO A
@ 20,0 SAY 'ENTER <CR> TO CANCEL, 0 TO ABANDON SEARCH, . TO FIND NEXT'
@ 21,0 GET A
READ

IF A=' '
	IF CANCEL = ' '
		IF TYPECODE < 100
		  STORE N:DEP+1 TO N:DEP
		  STORE A:DEP+AMOUNT TO A:DEP
		ELSE
		  IF NUMBER <> 0
		    STORE N:CHK+1 TO N:CHK
		    STORE A:CHK+AMOUNT TO A:CHK
		  ENDIF
		ENDIF
		IF TYPECODE >=100
  		  REPLACE CANCEL WITH M:CANCELCH
		  REPLACE CANCEL WITH !(CANCEL)
		ELSE
		  REPLACE CANCEL WITH M:CANCELCH
		ENDIF
	ELSE
		? 'ERROR: ALREADY CANCELLED' + CHR(7)
	ENDIF
	STORE F TO M:LOOKING
ENDIF

IF A = '.'
	IF C:UNNUM
		SKIP
	ELSE
		CONTINUE
	ENDIF
ENDIF

IF A = '0'
	STORE F TO M:LOOKING
ENDIF

IF EOF .OR. #=0
	? CHR(7) + 'END OF FILE REACHED'
	STORE F TO M:LOOKING
ENDIF

ENDDO

ENDIF

ENDDO

*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

