1     rem This is the Depreciation Calculator

%INCLUDE ALL.BAS
500     dim n(2,20),k$(3,20)
     z5$="cg"
     RESTORE
     DATA 0,28,31,30,31,30,31,31,30,31,30,31
     DATA 24,24,24,17,2,5,14,20,20
     DATA 4,10,10,24,24,1,8,2,12,12,12,4,4,12,12,12,12
     FOR Z=1 TO 12:READ N(1,1):NEXT Z:N(1,1)=0: REM DUMMY READ TO SET POINTER
1008 DIM H(9),S(9),T(4,9)
1009 PRINT clear$:PRINT
1090 U$="##,###,###"
1095 FOR Z=1 TO 104:A$=A$+"-":NEXT Z
1100 REM GET DATES ROUTINE
1145 Z9=0
1200 REM READ TAB VALUES ROUTINE
3000 REM READ NAME FILE SUBROUTINE
3005 a5=T%(12)
     FOR Z=3 TO 11:READ N(1,Z):NEXT Z
3085 Z9=1:FOR Z=3 TO 11:K$(0,Z)=MID$(N$,Z9,N(1,Z)):Z9=Z9+N(1,Z):NEXT Z
3090 N$="":FOR Z=1 TO 20:N(1,Z)=0:NEXT Z
3125 REM ROUTINE TO ELIMINATE TRAILING BLANKS
     l8=1
3130 FOR I=3 TO 6
     l9=len(k$(0,i))
3140 FOR Z=l9 TO l8 STEP -1
3150 IF MID$(K$(0,I),Z,1)<>" " THEN 3170
3160 NEXT Z
3170 Z$=""
3180 FOR Z0=1 TO Z
3190 Z$=Z$+MID$(K$(0,I),Z0,1)
3200 NEXT Z0
3210 K$(0,I)="":K$(0,I)=Z$
3220 NEXT I
6000 REM CALCULATE DEPRECIATION ON ASSETS
6005 PRINT clear$:PRINT
6010 PRINT "CALCULATING DEPRECIATION FOR THE YEAR"
6015 FOR Z=0 TO 9
6020 H(Z)=0:S(Z)=0:T(0,Z)=0:T(1,Z)=0:T(2,Z)=0:T(3,Z)=0:A(Z)=0
6025 NEXT Z
6030 T1=0:T2=0:T3=0:T4=0:P0=1
6035 X=1
6200 open z5$ recl 256 as 1
6205 z3=(size(z5$)*block.size)/256
6210 FOR Z2=1 TO Z3
6215 read #1,z2;N(2,1),N(2,2),N(2,3),N$
6220 IF N(2,2)=0 THEN 6230
6225 NEXT Z2
6230 close 1
6235 Z2=Z2-1
6240 PRINT:PRINT "RECORDS TO BE CALCULATED ";Z2
6245 PRINT:INPUT "TO DO CALCULATION, TYPE RETURN.";line temp$
     FOR Z=1 TO 17:READ N(1,Z):NEXT Z
     RESTORE : REM RESTORE POINTER TO READ DAYS PER MONTH
6300 open z5$ recl 256 as 1
6310 FOR Z1=1 TO Z2
6320 read #1,z1;N(2,1),N(2,2),N(2,3),N$,D1,D2,D3,D4,D5,D6,D7,D8,D9
6325 D6=0:D7=0:D8=0
6330 Z9=1:FOR Z=4 TO 8:K$(3,Z)=MID$(N$,Z9,N(1,Z)):Z9=Z9+N(1,Z):NEXT Z
6400 IF RIGHT$(K$(3,7),2)=RIGHT$(D$(6),2) THEN GOSUB 10000
6420 IF K$(3,8)="SL" THEN GOSUB 20000
6430 IF K$(3,8)="D1" THEN GOSUB 20200
6440 IF K$(3,8)="D2" THEN GOSUB 20400
6450 IF K$(3,8)="D3" THEN GOSUB 20600
6460 IF K$(3,8)="SD" THEN GOSUB 20800
6500 print #1,z1;N(2,1),N(2,2),N(2,3),n$,D1,D2,D3,D4,D5,D6,D7,D8,D9
6600 NEXT Z1
6700 GOTO 30000
10000 REM THIS ROUTINE RETURNS A DECIMAL PART OF THE YEAR BASED
10005 REM ON THE YEAR END DATE AND ASSET ACQUISITION DATE
10010 REM FOR BOTH ORDINARY AND CLADR DEPRECIATION SYSTEMS
10015 REM FOR FIRST YEAR DEPRECIATION PURPOSES
10050 PRINT clear$:PRINT
10060 PRINT "DO YOU WISH TO TAKE THE ADDITIONAL 20% FIRST YEAR"
10070 PRINT "DEPRECIATION ALLOWED FOR THIS ASSET?"
10080 PRINT:INPUT line temp$
10085 IF left$(temp$,1)="n" OR left$(temp$,1)="N" THEN 10100
10090 IF left$(temp$,1)<>"y" AND left$(temp$,1)<>"Y" THEN 10050
10095 GOSUB 10600
10100 IF LEFT$(K$(3,7),1)="H" THEN Y1=.5:GOTO 10595
10105 IF LEFT$(K$(3,7),3)="M01" THEN Y1=1:GOTO 10595
10110 IF LEFT$(K$(3,7),3)="M02" THEN Y1=0:GOTO 10595
10310 FOR Z=0 TO 11
10315 IF Z=VAL(LEFT$(K$(3,7),2)) THEN 10450
10320 READ X
10330 Y1=Y1+X
10340 NEXT Z
10450 Y1=Y1+VAL(MID$(K$(3,7),4,2))
10460 RESTORE
10465 Y1=365-Y1
10470 Z9=80
10475 FOR Z=1 TO 25
10480 IF VAL(RIGHT$(K$(3,7),2))=Z9 THEN Y1=Y1+1:Y1=Y1/366:GOTO 10595
10485 Z9=Z9+4
10490 NEXT Z
10580 Y1=Y1/365
10595 RETURN
10600 IF K$(3,6)<>"N" THEN 10695
10610 D2=D2-D1*.2:D3=D3+D1*.2
10695 RETURN
20000 REM THIS ROUTINE CALCULATES STRAIGHT LINE DEPRECIATION
20005 Z9=D2-D9:REM Z9 = DEPRECIABLE BASIS LESS SALVAGE
20010 Z9=Z9/D5:REM Z9 = ADJUSTED BASIS/REMAINING YEARS
20015 D5=D5-1:REM REDUCE REMAINING LIFE FIGURE
20020 IF Y1<>0 THEN Z9=Z9*Y1
20025 IF D2-Z9<D9 THEN Z9=D2-D9
20030 D8=D8+Z9:D7=D8/4:D6=D8/12
20040 D2=D2-Z9:REM REDUCE DEPRECIABLE BASIS BY YEARS DEPRECIATION
20050 D3=D3+Z9:REM INCREASE PRIOR YEARS DEPRECIATION BY AMOUNT TAKEN
20060 Z9=0:Y1=0
20195 RETURN
20200 REM THIS ROUTINE CALCULATES DECLINING BALANCE - 125% DEPRECIATION
20205 Z9=D2-D9:REM Z9 = DEPRECIABLE BASIS LESS SALVAGE
20210 Z9=Z9/D5:REM Z9 = ADJUSTED BASIS/REMAINING YEARS
20211 Z9=Z9*1.25
20215 D5=D5-1:REM REDUCE REMAINING LIFE FIGURE
20220 IF Y1<>0 THEN Z9=Z9*Y1
20225 IF D2-Z9<D9 THEN Z9=D2-D9
20230 D8=D8+Z9:D7=D8/4:D6=D8/12
20240 D2=D2-Z9:REM REDUCE DEPRECIABLE BASIS BY YEARS DEPRECIATION
20250 D3=D3+Z9:REM INCREASE PRIOR YEARS DEPRECIATION BY AMOUNT TAKEN
20260 Z9=0:Y1=0
20395 RETURN
20400 REM THIS ROUTINE CALCULATES DECLINING BALANCE - 150% DEPRECIATION
20405 Z9=D2-D9:REM Z9 = DEPRECIABLE BASIS LESS SALVAGE
20410 Z9=Z9/D5:REM Z9 = ADJUSTED BASIS/REMAINING YEARS
20411 Z9=Z9*1.5
20415 D5=D5-1:REM REDUCE REMAINING LIFE FIGURE
20420 IF Y1<>0 THEN Z9=Z9*Y1
20425 IF D2-Z9<D9 THEN Z9=D2-D9
20430 D8=D8+Z9:D7=D8/4:D6=D8/12
20440 D2=D2-Z9:REM REDUCE DEPRECIABLE BASIS BY YEARS DEPRECIATION
20450 D3=D3+Z9:REM INCREASE PRIOR YEARS DEPRECIATION BY AMOUNT TAKEN
20460 Z9=0:Y1=0
20595 RETURN
20600 REM THIS ROUTINE CALCULATES DECLINING BALANCE - 200% DEPRECIATION
20605 Z9=D2-D9:REM Z9 = DEPRECIABLE BASIS LESS SALVAGE
20610 Z9=Z9/D5:REM Z9 = ADJUSTED BASIS/REMAINING YEARS
20611 Z9=Z9*2
20615 D5=D5-1:REM REDUCE REMAINING LIFE FIGURE
20620 IF Y1<>0 THEN Z9=Z9*Y1
20625 IF D2-Z9<D9 THEN Z9=D2-D9
20630 D8=D8+Z9:D7=D8/4:D6=D8/12
20640 D2=D2-Z9:REM REDUCE DEPRECIABLE BASIS BY YEARS DEPRECIATION
20650 D3=D3+Z9:REM INCREASE PRIOR YEARS DEPRECIATION BY AMOUNT TAKEN
20660 Z9=0:Y1=0
20795 RETURN
20800 REM THIS ROUTINE CALCULATES SUM-OF-YEARS-DIGITS DEPRECIATION
20805 Z9=D2-D9:REM Z9 = DEPRECIABLE BASIS LESS SALVAGE
20810 FOR Z=1 TO D5:B=B+Z:NEXT Z:Z=0:Z=D5/B:B=0
20811 Z9=Z9*Z:REM ADJUSTED BASIS * SUM-OF-YEARS DECIMAL
20815 D5=D5-1:REM REDUCE REMAINING LIFE FIGURE
20820 IF Y1<>0 THEN Z9=Z9*Y1
20825 IF D2-Z9<D9 THEN Z9=D2-D9
20830 D8=D8+Z9:D7=D8/4:D6=D8/12
20840 D2=D2-Z9:REM REDUCE DEPRECIABLE BASIS BY YEARS DEPRECIATION
20850 D3=D3+Z9:REM INCREASE PRIOR YEARS DEPRECIATION BY AMOUNT TAKEN
20860 Z9=0:Y1=0
20995 RETURN
30000 REM ROUTINE TO CLOSE FILES AND RETURN TO BIZMASTERII
30005 close 1
30050 CHAIN "master16"
