1 REM INVOICE
5 CLS
10 PRINT TAB(10); "PROGRAM INVOICE":PRINT
20 CLEAR 6000
30 DEFINT C,J,I
40 DEFDBL S,P,A,V,Q
54 DIM F$(20)
55 DIM R$(15)
57 GOSUB 9000
65 DIM NN$(20),D2$(20),QU(20),P1(20),PE(20),QO(20)
66 DIM D3$(20),D4$(20),D5$(20),D6$(20),D7$(20)
70 DIM H0(50),H1$(50),H2$(50),H3$(50),H4$(50),H5(50),H6(50)
75 DIM H7(50),H8(50),H9(50)
80 FOR I=1 TO 200:NEXT I
1000 REM INVOICING
1005 CLS:PRINT TAB(15); "INVOICING PROCEDURE":PRINT
1010 PRINT"EACH INVOICE CAN HAVE AT MOST 10 LINES. INVOICE IS
1015 PRINT"PRINTED ON SCREEN AND/OR PRINTER WHEN COMPLETE."
1017 PRINT"AT MOST 50 INVOICES MAY BE PROCESSED IN ONE RUN."
1020 GOSUB 10100
1040 INPUT"IS PRINTER BEING USED(Y/N)";Z2$
1045 IF Z2$<>"Y" AND Z2$<>"N" THEN GOSUB 10000:GOTO 1040
1100 IF Z2$="Y" THEN PRINT"PREPARE INVOICE IN PRINTER.":GOSUB 10100
1110 CLS
1120 INPUT"ENTER NUMBER OF CUSTOMER TO BE INVOICED(-1 TO END)";C
1125 IF C=-1 THEN GOTO 1800
1130 INPUT"CUSTOMER NAME ";N$(1)
1135 INPUT"2ND LINE NAME ";N$(2)
1140 INPUT"STREET ADDRESS";N$(3)
1145 INPUT"CITY,STATE,ZIP";N$(4),N$(5),N$(6)
1280 INPUT"PRESS 1 TO INVOICE,2 TO ABORT";Z9
1285 IF Z9<>1 AND Z9<>2 THEN GOSUB 10000:GOTO 1280
1290 IF Z9=2 GOTO 1110
1295 CG=0 ' CG=# PRINTED LINES SO FAR
1300 CLS:J=CR+1
1305 J1=1 ' NUMBER OF LINES IN INVOICE SO FAR
1307 INPUT"INVOICE NUMBER ";N1$(J)
1310 INPUT"DATE OF INVOICE IN FORM MM/DD/YY";D$(J)
1320 IF LEN(D$(J))<>8 THEN GOSUB 10000:GOTO 1310
1321 PO$=""
1322 INPUT"CUSTOMER ORDER NUMBER";PO$
1325 INPUT"SHIPPED VIA          ";SV$
1326 TM$="NET 10 DAYS"
1327 INPUT"TERMS               ";TM$
1330 PRINT TAB(50);"**********":PRINT"LINE";J1;:INPUT"ITEM NO.";NN$(J1)
1340 LINE INPUT "   ITEM DESCRIPTION ";XXX$:D2$(J1)=XXX$:CG=CG+1:IF NN$(J1)="EK" THEN NN$(J1)="0":J1=J1+1:GOTO 1330
1341 GOTO 1350
1346 CG=CG+1
1350 REM
1354 INPUT"QUANTITY ORDERED,UNIT PRICE ";QU(J1),P1(J1)
1355 CLS
1360 PRINT"NUMBER OF LINES PRINTED SO FAR = ";CG
1370 PE(J1)=QU(J1)*P1(J1)
1377 J2=J1
1380 PRINT F$(3):GOSUB 4000
1390 GOSUB 10300
1400 IF Z9$="N" THEN PRINT "DO AGAIN":GOSUB 10100:CG=CG-1:GOTO 1330
1410 INPUT"MORE ITEMS ON INVOICE(Y/N)";Z9$
1415 IF Z9$<>"Y" AND Z9$<>"N" THEN GOSUB 10000:GOTO 1410
1420 IF Z9$="N" THEN GOTO 1450
1430 IF CG>=10 THEN PRINT"INVOICE FULL. MACHINE TO TOTAL":GOSUB 10100:GOTO 1450
1440 J1=J1+1: GOTO 1330
1450 REM INVOICE COMPLETE
1451 CLS:INPUT"TAXABLE(Y/N)";XX$:IF XX$<>"Y" AND XX$<>"N" THEN GOTO 1451
1452 IF XX$="Y" THEN INPUT"TAX RATE (%) ";TX:TX=TX/100
1454 PRINT:PRINT:INPUT "SHIPPING ";AF
1455 CLS:PRINT"INVOICE NUMBER ";N1$(J);TAB(40); "DATE :";D$(J)
1460 PRINT F$(3)
1470 TE=0:QU=0:QO=0
1480 FOR J2=1 TO J1:GOSUB 4000:TE=TE+PE(J2):QU=QU+QU(J2):QO=QO+QO(J2):NEXT J2
1485 FOR J5=1 TO 62:PRINT"-";:NEXT:PRINT
1490 PRINT USING F$(5);QU,TE
1491 AT=0
1492 IF XX$="Y" THEN AT=TE*TX 
1494 PRINT USING F$(9);AT
1496 PRINT USING F$(8);AF
1497 AQ=TE+AT+AF:SA(1)=AQ
1498 PRINT USING F$(10);AQ
1500 PRINT:GOSUB 10300
1510 IF Z9$="N" THEN PRINT "OLD INVOICE ELIMINATED":GOTO 1700
1520 REM COMPLETED INVOICE GOOD
1530 IF Z2$<>"Y" GOTO 1600
1550 LPRINT TAB(5); CN
1555 LPRINT TAB(5); N$(1)
1560 IF N$(2)<>"" THEN LPRINT TAB(5); N$(2)
1565 LPRINT TAB(5); N$(3)
1570 LPRINT TAB(5); N$(4);",";N$(5);"   ";N$(6)
1575 LPRINT:IF N$(2)="" THEN LPRINT" "
1580 LPRINT" ":LPRINT" "
1582 LPRINT USING F$(11);PO$,N1$(J),SV$,STR$(CF),TM$,D$(J):LPRINT" ":LPRINT" "
1583 FOR J2=1 TO J1:GOSUB 4100:NEXT J2
1584 FOR J2=CG+1 TO 18:LPRINT" ":NEXT
1587 LPRINT TAB(60);" ";:FOR J5=1 TO 12:LPRINT"-";:NEXT:LPRINT" "
1590 LPRINT TAB(38);" ";:LPRINT USING "TOTAL                  $$#####.##";TE
1594 LPRINT TAB(38);" ";:LPRINT USING "SALES TAX              $$#####.##";AT
1596 LPRINT TAB(38);" ";:LPRINT USING "CARFARE                $$#####.##";AF
1598 LPRINT TAB(38);" ";:LPRINT USING "PAY THIS AMT.          $$#####.##";AQ
1599 FOR J7=1 TO 18:LPRINT" ":NEXT
1660 C7=C7+1:H0(C7)=C:H1$(C7)=D$(1):H2$(C7)=N1$(1):H3$(C7)=T$(1)
1670 H4$(C7)=N2$(1):H5(C7)=SA(1):H6(C7)=SD(1)
1680 H7(C7)=AF:H8(C7)=AT:H9(C7)=TE
1700 REM ZERO ALL INVOICE VARIABLES
1710 FOR J=1 TO 19:NN$(J)="":D2$(J)="":QU(J)=0:P1(J)=0:PE(J)=0:QO(J)=0:D3$(J)="":D4$(J)="":D5$(J)="":D6$(J)="":NEXT J
1720 CLS
1730 INPUT"DO YOU WANT MORE INVOICES(Y/N)";Z9$
1740 IF Z9$<>"Y" AND Z9$<>"N" THEN GOSUB 10000:GOTO 1730
1745 IF C7=50 THEN PRINT"TRANSACTION MATRIX FULL":GOSUB 10100:GOTO 1800
1750 IF Z9$="Y" THEN GOTO 1100
1800 CLS
1806 CLS:INPUT"PRESS 1 FOR TRANSACTIONS REPORT...ELSE 2";Z9$
1807 IF Z9$<>"1"AND Z9$<>"2" THEN GOSUB 10000:GOTO 1806
1808 IF Z9$="2" GOTO 1900
1810 IF Z2$="Y" THEN PRINT"PREPARE PRINTER FOR TRANSACTIONS FILE."
1820 GOSUB 10100
1830 CLS
1835 PRINT"        TRANSACTIONS REPORT":PRINT
1836 IF Z2$="Y" THEN LPRINT TAB(20); "TRANSACTIONS REPORT"
1840 PRINT F$(6):IF Z2$="Y" THEN LPRINT F$(6)
1850 FOR J=1 TO C7:PRINT USING F$(7);H0(J),H1$(J),H2$(J),H3$(J),H5(J),H6(J):NEXT J
1860 IF Z2$="Y" THEN  FOR J=1 TO C7:LPRINT USING F$(7);H0(J),H1$(J),H2$(J),H3$(J),H5(J),H6(J):NEXT J
1870 T=0:T3=0:T4=0:T5=0
1872 FOR J=1 TO C7
1874 T=T+H5(J):T3=T3+H7(J):T4=T4+H8(J):T5=T5+H9(J)
1875 NEXT J
1880 PRINT
1881 PRINT USING "EXTENDED PRICE TOTALS:     $$####.##";T5
1882 PRINT USING "TOTAL SHIPPING:            $$####.##";T3
1883 PRINT USING "TOTAL SALES TAX:           $$####.##";T4
1884 PRINT USING "TOTAL OF INVOICE AMOUNTS:  $$####.##";T
1885 IF Z2$="Y" THEN LPRINT" "
1889 IF Z2$<>"Y" GOTO 1900
1890 LPRINT" "
1891 LPRINT USING "EXTENTED PRICE TOTALS:    $$####.##";T5
1892 LPRINT USING "TOTAL CARFARE:            $$####.##";T3
1893 LPRINT USING "TOTAL SALES TAX:          $$####.##";T4
1894 LPRINT USING "TOTAL OF INVOICE AMOUNTS: $$####.##";T
1896 PRINT:END
4000 REM PRINTING LINE OF INVOICE ON CRT
4010 PRINT USING F$(4);NN$(J2),D2$(J2),QU(J2),P1(J2),PE(J2)
4020 RETURN
4100 REM PRINTING LINE OF INVOICE ON PRINTER
4101 REM LINE BELOW EXECUTED IF QUANTITY NOT AN INTEGER
4102 IF ABS(QU(J2)-INT(QU(J2)))>.01 THEN LPRINT USING F$(14);NN$(J2),QU(J2),D2$(J2),P1(J2),PE(J2)
4104 IF NN$(J2)="0" THEN LPRINT USING F$(15);D2$(J2):GOTO 4120
4105 IF Z2$="Y" THEN LPRINT USING F$(12);NN$(J2),QU(J2),D2$(J2),P1(J2),PE(J2)
4110 IF D3$(J2)<>"" THEN LPRINT USING F$(13);D3$(J2)
4112 IF D4$(J2)<>"" THEN LPRINT USING F$(13);D4$(J2)
4114 IF D5$(J2)<>"" THEN LPRINT USING F$(13);D5$(J2)
4116 IF D6$(J2)<>"" THEN LPRINT USING F$(13);D6$(J2)
4118 IF D7$(J2)<>"" THEN LPRINT USING F$(13);D7$(J2)
4120 RETURN
6000 REM SBR DISPLAYING DATA FOR 1 CUSTOMER RECORD(NO AR)
6010 CLS
6020 PRINT "CUST NUMBER =";CN;TAB(30);"NAME = ";N$(1)
6030 PRINT"DEPARTMENT: ";N$(2)
6040 PRINT N$(3);" , ";N$(4);",";N$(5);"    ";N$(6)
6050 PRINT
6055 L$(1)="YTD SALES:#######.##  YTD PAYMENTS:#######.##  YTD NO SALES ###"
6060 PRINT USING L$(1);SY,PY,CS
6065 L$(1)="DATE LAST PAYMENT: %       %    AMT.LAST PAYMENT:#######.##"
6070 PRINT USING L$(1);D1$(2),SL
6075 PRINT"SALESMAN CODE    :";CF,:IF TX$="Y" THEN PRINT "TAXABLE" ELSE PRINT "NONTAXABLE"
6077 PRINT"PRICING CODE(1-5):";JK
6080 PRINT"# RECORDS IN FILE :";CR;TAB(32);"# PHYSICAL RECORDS:";CZ
6099 RETURN
6100 REM SBR DISPLAYS DATA FOR CUSTOMER A/R
6110 PRINT F$(1)
6120 FOR J=1 TO CR
6125 PRINT J;":";
6130 PRINT USING F$(2);N1$(J),D$(J),T$(J),N2$(J),SA(J),SD(J)
6140 IF J/13 = INT(J/13) THEN GOSUB 10100:PRINT F$(1)
6150 NEXT J
6160 RETURN
9000 REM FORMATTING VARIABLES
9010 F$(1)="RF   ITEM #      DATE   TYPE      APPLY TO   AMOUNT    DISCOUNTS "
9020 F$(2)="  %       % %       %   ########  %      %   ######.##  ######.##"
9030 F$(3)="ITEM NO.   DESCRIPTION   QUANT.   UNIT PR.       EXTENDED PR."
9040 F$(4)="%       % %            %  ####    ####.##          #####.## "
9050 F$(5)="            TOTAL        #####                   $$#####.##"
9060 F$(6)="CUST. NO.   DATE    INVOICE #   TYPE    AMOUNT    OTHER CH."
9070 F$(7)=" #####   %       %  %       %   ####### ######.##   ######.##"
9080 F$(8)="          CARFARE                                $$#####.##"
9090 F$(9)="        SALES TAX                                $$#####.##"
9092 F$(10)="  PAY THIS AMOUNT                                $$#####.##"
9093 F$(11)="%        %  %     %   %           %  %   % %              %  %         %"
9094 F$(12)="%     %### %                                        %######.## ######.##"
9095 F$(13)="              %                                     %"
9096 F$(14)="% % ###.## %                                      %  ######.## ######.##"
9098 F$(15)="           %                                        %"
9099 RETURN
10000 REM INPUT ERROR SBR
10010 PRINT"INPUT ERROR! TRY AGAIN!":FOR Z9=1 TO 300:NEXT Z9
10020 RETURN
10100 INPUT"PRESS ENTER TO CONTINUE";Z9:RETURN
10200 REM Y,N,A SBR
10205 Z9$=" "
10210 INPUT"ENTER Y IF OK,N IF ERROR,A TO ABORT";Z9$
10220 IF Z9$<>"Y" AND Z9$<>"N" AND Z9$<>"A" THEN GOSUB 10000:GOTO 10205
10230 RETURN
10300 REM Y,N SBR
10305 Z9$=" "
10310 INPUT"ENTER Y IF OK, N IF ERROR";Z9$
10320 IF Z9$<>"Y" AND Z9$<>"N" THEN GOSUB 10000:GOTO 10305
10330 RETURN
10400 REM MORE ENTRY? SBR
10405 Z9$=" "
10410 INPUT"DO YOU DESIRE MORE ENTRIES(Y/N)";Z9$
10420 IF Z9$<>"Y" AND Z9$<>"N" THEN GOSUB 10000:GOTO 10405
10430 RETURN
10500 REM ONLY Y/N SBR
10510 IF Z9$<>"Y" AND Z9$<>"N" THEN GOSUB 10000
10520 RETURN
11000 REM ELIMINATES TRAILING BLANKS OF VARIABLE Z8$
11010 IF RIGHT$(Z8$,1)=" " THEN Z8$=LEFT$(Z8$,LEN(Z8$)-1):GOTO 11010
11020 RETURN
