Listing: 1 IMPLEMENTATION MODULE LateLetters; 2 (* 3 * ModBase 4 * Release 3.0 5 * (c) Copyright 1986 - 1991 PMI 6 * P.O. Box 8402 7 * Green Bay Wi 53308 8 * All Rights Reserved 9 * by Ed Ross 10 *) 11 12 FROM ModBase3 IMPORT ReadDBRec,NumberRecords,Deleted; 13 FROM DBFInvoice IMPORT OpenInvoiceDBF,OpenInvoiceDBF,CloseInvoiceDBF, ***** ^ duplicate identifier 14 InvoiceDBF,MoveInvoiceFromDBF,InvoiceRec; 15 FROM DateFunctions IMPORT DateDiff,ValidDate; 16 FROM DspFiles IMPORT ReadDisplayFrame; 17 FROM PMIGlobals IMPORT Today,TodayStr,Config,PMIScreens; 18 FROM ScrnUtl2 IMPORT CloseDisplayFrame; 19 FROM ScrnUtl1 IMPORT FieldNum; 20 FROM NumTypes IMPORT Real8; 21 FROM ScreenInput IMPORT ListToEdField,ListFromEdField; 22 FROM DBFCustomer IMPORT OpenCustomerDBF,MoveCustomerFromDBF,FindCustomerByCin; 23 FROM Customer IMPORT GetCustAddr,GetCustName,AddressRec,AddressTypes; 24 FROM M2Strings IMPORT CompareStr,Length,Assign; 25 FROM StringIO IMPORT WriteStr,WriteEol,outp; 26 FROM StrEdit IMPORT CrunchBlanks; 27 FROM PosUtils IMPORT Equal; 28 FROM ScrnTypes IMPORT DisplayFrame, 29 InitDisplayFrame; 30 FROM GenLists IMPORT GenList,GetElmt,NewList,DisposeList,ListInsert,SortList, 31 ListLength,GetElmtAdr; 32 FROM ListUtils IMPORT TextFileToList,TextListToFile; 33 FROM FramePainter IMPORT ShowDisplayFrame; 34 FROM ControlUtils IMPORT Control; 35 IMPORT VWindows; 36 FROM SYSTEM IMPORT ADDRESS,ADR; 37 FROM HandleIO IMPORT FileExists,CloseHandle,CreateFile,OpenFile; 38 FROM PrinterUtils IMPORT DisplayLine,SetupDisplayLine,RemoveDisplayLine, 39 AddPrintElemt,PrintDisplayLine,ClearDisplayLine; 40 41 42 CONST 43 FileNamePre = 'Late30.Pre'; ***** ^ not supported yet 44 FileNameSuf = 'Late30.Suf'; ***** ^ not supported yet 45 46 47 PROCEDURE CreateLateLetters(); 48 49 50 VAR DF : DisplayFrame; 51 Pre,Suf : GenList; 52 Err : CARDINAL; 53 B : BOOLEAN; 54 FN : ARRAY[0..20] OF CHAR; ***** ^ not supported yet ***** ^ not supported yet 55 BEGIN 56 InitDisplayFrame(DF,VWindows.CurrentWindow); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 57 ReadDisplayFrame(PMIScreens,DF,'LateLetter'); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 58 NewList(Pre); ***** ^ not supported yet ***** ^ not supported yet 59 NewList(Suf); ***** ^ not supported yet ***** ^ not supported yet 60 FN := FileNamePre; ***** ^ not supported yet ***** ^ not supported yet 61 Err := TextFileToList(FN,Pre); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 62 FN := FileNameSuf; ***** ^ not supported yet ***** ^ not supported yet 63 Err := TextFileToList(FN,Suf); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 64 B := ListToEdField(Pre,DF,FieldNum(DF,'Prefix')); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 65 B := ListToEdField(Suf,DF,FieldNum(DF,'Suffix')); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 66 ShowDisplayFrame(DF,0,0,0,0); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 67 Control(DF); ***** ^ not supported yet ***** ^ not supported yet 68 B := ListFromEdField(DF,FieldNum(DF,'Prefix'),Pre); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 69 B := ListFromEdField(DF,FieldNum(DF,'Suffix'),Suf); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 70 Err := TextListToFile(Pre,FileNamePre); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 71 Err := TextListToFile(Suf,FileNameSuf); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 72 CloseDisplayFrame(DF); ***** ^ not supported yet ***** ^ not supported yet 73 74 END CreateLateLetters; ***** ^ not supported yet 75 76 PROCEDURE SortInvList(A1 : ADDRESS; Len1 : CARDINAL; 77 A2 : ADDRESS; Len2 : CARDINAL) : INTEGER; 78 VAR 79 I1 : POINTER TO InvoiceRec; ***** ^ not supported yet 80 I2 : POINTER TO InvoiceRec; ***** ^ not supported yet 81 BEGIN 82 I1 := A1; ***** ^ not supported yet ***** ^ not supported yet 83 I2 := A2; ***** ^ not supported yet ***** ^ not supported yet 84 85 IF NOT Equal(I1^.CUSTID,I2^.CUSTID) ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 86 THEN RETURN CompareStr(I1^.CUSTID,I2^.CUSTID); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 87 ELSE IF NOT Equal(I1^.INVOICE,I2^.INVOICE) ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 88 THEN RETURN CompareStr(I1^.INVOICE,I2^.INVOICE) ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 89 ELSE RETURN 0; 90 END; 91 END; 92 93 END SortInvList; ***** ^ not supported yet 94 95 PROCEDURE ProduceLateLetters(); 96 CONST 97 FF = CHR(12); ***** ^ undeclared identifier ***** ^ not supported yet 98 VAR 99 B : BOOLEAN; 100 L : LONGINT; 101 J : LONGINT; 102 M : CARDINAL; 103 Code : CARDINAL; 104 Inv : InvoiceRec; 105 OutStd : GenList; 106 Pre,Suf : GenList; 107 ER,prt : CARDINAL; 108 CurrentCIN : ARRAY[0..20] OF CHAR; ***** ^ not supported yet ***** ^ not supported yet 109 CustName : ARRAY[0..60] OF CHAR; ***** ^ not supported yet ***** ^ not supported yet 110 TotalOut : Real8; 111 Line : DisplayLine; 112 L1,L2,L3,L4,L5 : DisplayLine; 113 Hand : CARDINAL; 114 Err : CARDINAL; 115 116 FN : ARRAY[0..40] OF CHAR; ***** ^ not supported yet ***** ^ not supported yet 117 118 119 120 PROCEDURE PrintHeader(); 121 CONST 122 Blanks = ' '; ***** ^ not supported yet 123 VAR 124 J : CARDINAL; 125 P : POINTER TO ARRAY[0..500] OF CHAR; ***** ^ not supported yet ***** ^ not supported yet 126 Code,Size : CARDINAL; 127 CompName : ARRAY[0..60] OF CHAR; ***** ^ not supported yet ***** ^ not supported yet 128 CompAddr : AddressRec; 129 BEGIN 130 PrintDisplayLine(L1,Hand); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 131 PrintDisplayLine(L2,Hand); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 132 PrintDisplayLine(L3,Hand); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 133 PrintDisplayLine(L4,Hand); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 134 (* print comany name and address here *) 135 GetCustName(CurrentCIN,CustName); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 136 GetCustAddr(CompAddr,Billing); ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier 137 (* WriteEol(Hand,CustName); *) 138 FOR J := 1 TO 6 DO 139 WriteEol(Hand,''); ***** ^ not supported yet ***** ^ not supported yet 140 END; 141 WriteStr(Hand,Blanks); ***** ^ not supported yet ***** ^ not supported yet 142 WriteEol(Hand,CompAddr.Line[0]); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 143 WriteStr(Hand,Blanks); ***** ^ not supported yet ***** ^ not supported yet 144 WriteEol(Hand,CompAddr.Line[1]); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 145 WriteStr(Hand,Blanks); ***** ^ not supported yet ***** ^ not supported yet 146 WriteEol(Hand,CompAddr.Line[2]); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 147 WriteStr(Hand,Blanks); ***** ^ not supported yet ***** ^ not supported yet 148 WriteEol(Hand,CompAddr.Line[3]); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 149 FOR J := 1 TO 2 DO 150 WriteEol(Hand,''); ***** ^ not supported yet ***** ^ not supported yet 151 END; 152 FOR J := 1 TO ListLength(Pre) DO ***** ^ not supported yet ***** ^ not supported yet 153 GetElmtAdr(Pre,J,P,Size,Code); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 154 WriteEol(Hand,P^); ***** ^ not supported yet ***** ^ not supported yet 155 END; 156 WriteEol(Hand,' '); ***** ^ not supported yet ***** ^ not supported yet 157 158 159 WriteEol(Hand,' '); ***** ^ not supported yet ***** ^ not supported yet 160 PrintDisplayLine(L5,Hand); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 161 END PrintHeader; ***** ^ not supported yet 162 163 PROCEDURE PrintFooter(); 164 165 VAR J, Size,Code : CARDINAL; 166 P : ARRAY[0..100] OF CHAR; ***** ^ not supported yet ***** ^ not supported yet 167 BEGIN 168 ClearDisplayLine(Line); ***** ^ not supported yet ***** ^ not supported yet 169 AddPrintElemt(Line,TotalOut,'R',45,14,'L'); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 170 AddPrintElemt(Line,'Total outstanding ','S',15,15,'L'); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 171 PrintDisplayLine(Line,Hand); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 172 WriteEol(Hand,' '); ***** ^ not supported yet ***** ^ not supported yet 173 FOR J := 1 TO ListLength(Suf) DO ***** ^ not supported yet ***** ^ not supported yet 174 GetElmt(Suf,J,P,Code); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 175 WriteEol(Hand,P); ***** ^ not supported yet ***** ^ not supported yet 176 END; 177 WriteStr(Hand,12C); ***** ^ not supported yet ***** ^ not supported yet 178 END PrintFooter; ***** ^ not supported yet 179 180 PROCEDURE PrintLine(); 181 (* print line should look like this 182 1 2 3 4 5 6 7 183 01234567890123456789012345678901234567890123456789012345678901234567890 184 Invoice Date Invoice Amount Amount Due 185 xx-xxxxxx xx-xx-xx $xxxxxxxxx.xx $xxxxxxxxxx.xx 186 *) 187 VAR B : BOOLEAN; 188 BEGIN 189 WITH Inv DO ***** ^ not supported yet 190 ClearDisplayLine(Line); ***** ^ not supported yet ***** ^ not supported yet 191 AddPrintElemt(Line,INVOICE,'S',2,10,'L'); ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet 192 AddPrintElemt(Line,INVDATE,'D',14,20,'L'); ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet 193 AddPrintElemt(Line,TOTALAMT,'R',28,10,'R'); ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet 194 AddPrintElemt(Line,AMTOUT,'R',45,10,'R'); ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet 195 PrintDisplayLine(Line,Hand); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 196 ClearDisplayLine(Line); ***** ^ not supported yet ***** ^ not supported yet 197 END; ***** ^ not supported yet 198 END PrintLine; ***** ^ not supported yet 199 200 201 BEGIN 202 (* Set up the titles and the prefix * suffix *) 203 SetupDisplayLine(Line,76); ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet 204 SetupDisplayLine(L1,76); ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet 205 SetupDisplayLine(L2,76); ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet 206 SetupDisplayLine(L3,76); ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet 207 SetupDisplayLine(L4,76); ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet 208 SetupDisplayLine(L5,76); ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet 209 CrunchBlanks(Config.CompanyName); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 210 CrunchBlanks(Config.CompanyAddr1); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 211 CrunchBlanks(Config.CompanyAddr2); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 212 CrunchBlanks(Config.Phone); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 213 AddPrintElemt(L1,Config.CompanyName,'S', ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 214 40-(Length(Config.CompanyName) DIV 2),30,'L'); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 215 AddPrintElemt(L1,Today,'D',65,Length(TodayStr),'L'); ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 216 217 AddPrintElemt(L2,Config.CompanyAddr1,'S', ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 218 40- (Length(Config.CompanyAddr1) DIV 2),79,'L'); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 219 220 AddPrintElemt(L3,Config.CompanyAddr2,'S', ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 221 40- (Length(Config.CompanyAddr2) DIV 2),79,'L'); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 222 AddPrintElemt(L4,Config.Phone,'S', ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 223 40 - (Length(Config.Phone) DIV 2),20,'L'); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 224 AddPrintElemt(L5, ***** ^ not supported yet ***** ^ undeclared identifier 225 ' Invoice Date Invoice Amount Amount Due', 'S',0,75,'L'); ***** ^ not supported yet ***** ^ not supported yet 226 NewList(Pre); ***** ^ not supported yet ***** ^ undeclared identifier 227 NewList(Suf); ***** ^ not supported yet ***** ^ undeclared identifier 228 FN := FileNamePre; ***** ^ undeclared identifier ***** ^ not supported yet 229 Err := TextFileToList(FN,Pre); ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ undeclared identifier 230 FN := FileNameSuf; ***** ^ undeclared identifier ***** ^ not supported yet 231 Err := TextFileToList(FN,Suf); ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ undeclared identifier 232 OpenInvoiceDBF(FALSE); ***** ^ not supported yet ***** ^ not supported yet 233 NewList(OutStd); ***** ^ not supported yet ***** ^ undeclared identifier 234 L := NumberRecords(InvoiceDBF); ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 235 FOR J := 1 TO L DO ***** ^ undeclared identifier ***** ^ undeclared identifier 236 ReadDBRec(InvoiceDBF,J); ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier 237 IF NOT Deleted(InvoiceDBF) ***** ^ not supported yet ***** ^ not supported yet 238 THEN 239 MoveInvoiceFromDBF(Inv); ***** ^ not supported yet ***** ^ undeclared identifier 240 IF (Inv.INVPRNT = 'P') AND ValidDate(Inv.INVDATE) (* Been printed but not closed *) ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet 241 THEN 242 IF DateDiff(Today,Inv.INVDATE) > 30 ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet 243 THEN ListInsert(Inv,1,OutStd,1); ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ undeclared identifier ***** ^ not supported yet 244 END; (*out longer than 30 days *) 245 END; (* been printed *) 246 END; (* not deleted *) 247 END; (* loop reading out *) 248 CloseInvoiceDBF(); ***** ^ not supported yet ***** ^ not supported yet 249 SortList(OutStd,SortInvList); (* sort by cust by invoice number *) ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet 250 CurrentCIN := 'XxXxX??'; (* make sure the first doesn't match *) ***** ^ undeclared identifier ***** ^ not supported yet 251 ER := OpenFile(Hand,Config.ReportPrt); (* open report printer *) ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 252 253 FOR M :=1 TO ListLength(OutStd) DO ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ undeclared identifier 254 GetElmt(OutStd,M,Inv,Code); ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ undeclared identifier ***** ^ undeclared identifier ***** ^ undeclared identifier 255 CrunchBlanks(Inv.CUSTID); ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet 256 IF NOT Equal(CurrentCIN,Inv.CUSTID) ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ undeclared identifier ***** ^ not supported yet 257 THEN (* new customer in list *) 258 IF NOT (Equal(CurrentCIN,'XxXxX??')) (* if not the first cust*) ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet 259 THEN 260 PrintFooter(); ***** ^ undeclared identifier ***** ^ not supported yet 261 END; 262 Assign( Inv.CUSTID,CurrentCIN ); ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ undeclared identifier 263 B := FindCustomerByCin(CurrentCIN); ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ undeclared identifier 264 PrintHeader(); ***** ^ undeclared identifier ***** ^ not supported yet 265 TotalOut := 0.0; ***** ^ undeclared identifier 266 END; (* end new customer *) 267 TotalOut := TotalOut + Inv.AMTOUT; ***** ^ undeclared identifier ***** ^ undeclared identifier ***** ^ undeclared identifier ***** ^ not supported yet 268 PrintLine(); ***** ^ undeclared identifier ***** ^ not supported yet 269 END; 270 Err := CloseHandle(Hand); ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ undeclared identifier 271 DisposeList(Pre); ***** ^ not supported yet ***** ^ undeclared identifier 272 DisposeList(Suf); ***** ^ not supported yet ***** ^ undeclared identifier 273 RemoveDisplayLine(Line); ***** ^ not supported yet ***** ^ undeclared identifier 274 RemoveDisplayLine(L1); ***** ^ not supported yet ***** ^ undeclared identifier 275 RemoveDisplayLine(L2); ***** ^ not supported yet ***** ^ undeclared identifier 276 RemoveDisplayLine(L3); ***** ^ not supported yet ***** ^ undeclared identifier 277 RemoveDisplayLine(L4); ***** ^ not supported yet ***** ^ undeclared identifier 278 RemoveDisplayLine(L5); ***** ^ not supported yet ***** ^ undeclared identifier 279 END ProduceLateLetters; ***** ^ not supported yet 280 END LateLetters. ***** ^ not supported yet 407 errors