DBFPAYME.LST 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. Listing:
  2. 1 (*
  3. 2 * ModBase
  4. 3 * Release 3.0
  5. 4 * (c) Copyright 1986 - 1991 PMI
  6. 5 * P.O. Box 8402
  7. 6 * Green Bay Wi 53308
  8. 7 * All Rights Reserved
  9. 8 * by Ed Ross
  10. 9 *)
  11. 10
  12. 11 IMPLEMENTATION MODULE DBFPayments;
  13. 12 FROM ModBase3 IMPORT InitDBF,OpenDBF,CloseDBF,ReadDBRec,GetField,
  14. 13 DeleteRecord,DBFile,DefaultFixUp,NilDBF,Record;
  15. 14 FROM DBCopier IMPORT DBPack;
  16. 15 FROM DBIndxes IMPORT InitIndex,OpenIndex,AddToUpdateList,CloseIndex,
  17. 16 CurrentRec,FindPositionCh,BuildIndex,GoTop,GoBottom,
  18. 17 NextRecord,PrevRecord,CurrentKeyCh,FindPositionN,
  19. 18 CurrentKeyN,InitCompIndex,BuildCompIndex,DBIndex;
  20. 19 FROM StrEdit IMPORT CrunchBlanks;
  21. 20 FROM PMIGlobals IMPORT Today,Config;
  22. 21 FROM Drectory IMPORT DeleteFile;
  23. 22 FROM StrConv IMPORT StrToReal;
  24. 23 FROM NumTypes IMPORT Real8;
  25. 24 FROM DBStuff IMPORT MakeKey;
  26. 25 FROM DateFunctions IMPORT DaysSince1900;
  27. 26 FROM ScanUtils IMPORT Present,CaseSens;
  28. 27 FROM DBFields IMPORT GetDateField,GetLogicalField,GetNumField,Replace,
  29. 28 ReplaceD,ReplaceN;
  30. 29
  31. 30
  32. 31
  33. 32 CONST
  34. 33 Buffer = 0;
  35. 34 Safty = TRUE;
  36. 35 Exclusive = FALSE;
  37. 36 AutoLock = TRUE;
  38. 37
  39. 38 VAR IndexOpen,DBInit : BOOLEAN;
  40. 39
  41. 40 PROCEDURE MovePaymentsToDBF(Rec : PaymentsRec );
  42. ***** ^ undeclared identifier
  43. 41 (* This code will move the data from the record to *)
  44. 42 (* the data base *)
  45. 43 BEGIN
  46. 44 WITH Rec DO
  47. ***** ^ not supported yet
  48. 45 Replace( PaymentsDBF, 1,INVOICE); (* Invoice number *)
  49. ***** ^ not supported yet
  50. ***** ^ undeclared identifier
  51. ***** ^ undeclared identifier
  52. 46 ReplaceD( PaymentsDBF, 2,PMTDATE ); (* Payment Date *)
  53. ***** ^ not supported yet
  54. ***** ^ undeclared identifier
  55. ***** ^ undeclared identifier
  56. 47 ReplaceN( PaymentsDBF, 3,PMTAMT ); (* Payment amount *)
  57. ***** ^ not supported yet
  58. ***** ^ undeclared identifier
  59. ***** ^ undeclared identifier
  60. 48 Replace( PaymentsDBF, 4,CHECKNB ); (* Check number *)
  61. ***** ^ not supported yet
  62. ***** ^ undeclared identifier
  63. ***** ^ undeclared identifier
  64. 49 Replace( PaymentsDBF, 5,CUSTID); (* Customer who payed *)
  65. ***** ^ not supported yet
  66. ***** ^ undeclared identifier
  67. ***** ^ undeclared identifier
  68. 50 END; (* end of with REC *)
  69. ***** ^ not supported yet
  70. 51 END MovePaymentsToDBF;
  71. ***** ^ not supported yet
  72. 52
  73. 53
  74. 54
  75. 55 PROCEDURE MovePaymentsFromDBF(VAR Rec : PaymentsRec );
  76. ***** ^ undeclared identifier
  77. 56 (* This code will move the data from the Database to *)
  78. 57 (* the record *)
  79. 58 VAR B : BOOLEAN;
  80. 59 R : Real8;
  81. 60 BEGIN
  82. 61 WITH Rec DO
  83. ***** ^ not supported yet
  84. 62 GetField( PaymentsDBF, 1,INVOICE ); (* Invoice number *)
  85. ***** ^ not supported yet
  86. ***** ^ undeclared identifier
  87. ***** ^ undeclared identifier
  88. 63 GetDateField( PaymentsDBF, 2,PMTDATE ); (* Payment Date *)
  89. ***** ^ not supported yet
  90. ***** ^ undeclared identifier
  91. ***** ^ undeclared identifier
  92. 64 GetNumField( PaymentsDBF, 3,PMTAMT ); (* Payment amount *)
  93. ***** ^ not supported yet
  94. ***** ^ undeclared identifier
  95. ***** ^ undeclared identifier
  96. 65 GetField( PaymentsDBF, 4,CHECKNB ); (* Check number *)
  97. ***** ^ not supported yet
  98. ***** ^ undeclared identifier
  99. ***** ^ undeclared identifier
  100. 66 GetField( PaymentsDBF, 5,CUSTID ); (* Customer who payed *)
  101. ***** ^ not supported yet
  102. ***** ^ undeclared identifier
  103. ***** ^ undeclared identifier
  104. 67 END; (* end of with REC^ *)
  105. ***** ^ not supported yet
  106. 68 END MovePaymentsFromDBF;
  107. ***** ^ not supported yet
  108. 69
  109. 70
  110. 71
  111. 72
  112. 73
  113. 74 PROCEDURE MakeCustidKey( DBF : DBFile; Idx : DBIndex;
  114. 75 VAR Key : ARRAY OF CHAR);
  115. ***** ^ not supported yet
  116. 76 VAR
  117. 77 B : BOOLEAN;
  118. 78 BEGIN
  119. 79 GetField( PaymentsDBF, 5,Key ); (* Customer who payed *)
  120. ***** ^ not supported yet
  121. ***** ^ undeclared identifier
  122. ***** ^ not supported yet
  123. 80 MakeKey(Key);
  124. ***** ^ not supported yet
  125. ***** ^ not supported yet
  126. 81 END MakeCustidKey;
  127. ***** ^ not supported yet
  128. 82
  129. 83
  130. 84
  131. 85
  132. 86 PROCEDURE OpenPaymentsDBF(WithIdx : BOOLEAN);
  133. 87 VAR ER : CARDINAL;
  134. 88 BEGIN
  135. 89 IndexOpen := WithIdx;
  136. 90
  137. 91 (* Open the DBF file *)
  138. 92
  139. 93 IF NOT DBInit THEN
  140. 94 DBInit:=TRUE;
  141. 95 InitDBF("Payments.DBF", PaymentsDBF,Buffer,Safty,Exclusive,AutoLock,
  142. ***** ^ not supported yet
  143. ***** ^ not supported yet
  144. ***** ^ undeclared identifier
  145. ***** ^ not supported yet
  146. ***** ^ not supported yet
  147. ***** ^ not supported yet
  148. 96 DefaultFixUp );
  149. ***** ^ not supported yet
  150. 97 InitCompIndex( "Pymts.Idx",CustidIdx,PaymentsDBF,MakeCustidKey,Buffer,
  151. ***** ^ not supported yet
  152. ***** ^ not supported yet
  153. ***** ^ undeclared identifier
  154. ***** ^ undeclared identifier
  155. ***** ^ not supported yet
  156. 98 Safty,FALSE,Exclusive);
  157. ***** ^ not supported yet
  158. ***** ^ not supported yet
  159. 99 AddToUpdateList( PaymentsDBF, CustidIdx );
  160. ***** ^ not supported yet
  161. ***** ^ undeclared identifier
  162. ***** ^ undeclared identifier
  163. 100
  164. 101 END;
  165. 102 IF NOT OpenDBF( PaymentsDBF)
  166. ***** ^ not supported yet
  167. ***** ^ undeclared identifier
  168. 103 THEN
  169. 104 HALT;
  170. ***** ^ undeclared identifier
  171. 105 END;
  172. 106
  173. 107 IF WithIdx THEN
  174. 108
  175. 109 (* open all indexes and append to dbfile *)
  176. 110 IF NOT OpenIndex( CustidIdx )
  177. ***** ^ not supported yet
  178. ***** ^ undeclared identifier
  179. 111 THEN
  180. 112 ER := BuildCompIndex(CustidIdx,'C','Custid',12); (* check key lenght *)
  181. ***** ^ not supported yet
  182. ***** ^ undeclared identifier
  183. ***** ^ not supported yet
  184. ***** ^ not supported yet
  185. 113 END;
  186. 114 END; (* end with idx *)
  187. 115
  188. 116 END OpenPaymentsDBF;
  189. ***** ^ not supported yet
  190. 117
  191. 118
  192. 119
  193. 120 PROCEDURE ClosePaymentsDBF (); (* close Data and index files *)
  194. 121
  195. 122 BEGIN
  196. 123 CloseDBF(PaymentsDBF); (* close dbf file *)
  197. ***** ^ not supported yet
  198. ***** ^ undeclared identifier
  199. 124 IF IndexOpen
  200. 125 THEN
  201. 126 CloseIndex(CustidIdx ); (* close index file *)
  202. ***** ^ not supported yet
  203. ***** ^ undeclared identifier
  204. 127 END;
  205. 128 END ClosePaymentsDBF;
  206. ***** ^ not supported yet
  207. 129
  208. 130
  209. 131
  210. 132
  211. 133
  212. 134
  213. 135 PROCEDURE FindPaymentsByCustid( Key : ARRAY OF CHAR) : BOOLEAN;
  214. ***** ^ not supported yet
  215. 136 VAR Found : BOOLEAN;
  216. 137 CKey : ARRAY[0..80] OF CHAR;
  217. ***** ^ not supported yet
  218. ***** ^ not supported yet
  219. 138 BEGIN
  220. 139 FindPositionCh( CustidIdx, Key, Found);
  221. ***** ^ not supported yet
  222. ***** ^ undeclared identifier
  223. ***** ^ not supported yet
  224. ***** ^ not supported yet
  225. 140 CurrentKeyCh(CustidIdx,CKey);
  226. ***** ^ not supported yet
  227. ***** ^ undeclared identifier
  228. ***** ^ not supported yet
  229. 141 Found := Present(Key,CKey,CaseSens);
  230. ***** ^ not supported yet
  231. ***** ^ not supported yet
  232. ***** ^ not supported yet
  233. ***** ^ not supported yet
  234. 142 IF Found
  235. 143 THEN ReadDBRec( PaymentsDBF, CurrentRec( CustidIdx));
  236. ***** ^ not supported yet
  237. ***** ^ undeclared identifier
  238. ***** ^ not supported yet
  239. ***** ^ undeclared identifier
  240. 144 END;
  241. 145 RETURN Found;
  242. 146 END FindPaymentsByCustid;
  243. ***** ^ not supported yet
  244. 147
  245. 148
  246. 149 PROCEDURE DeletePayments();
  247. 150 (* go through the payments file and delete all payments greater than
  248. 151 the number of weeks to keep payments *)
  249. 152 VAR
  250. 153 LI : LONGINT;
  251. 154 DeleteDate, PaymentDate : CARDINAL;
  252. 155 Payment : PaymentsRec;
  253. ***** ^ undeclared identifier
  254. 156 BEGIN
  255. 157 DeleteDate := DaysSince1900(Today) + (Config.KeepPaymentHist * 7);
  256. ***** ^ not supported yet
  257. ***** ^ not supported yet
  258. ***** ^ not supported yet
  259. ***** ^ not supported yet
  260. 158 (* payment hist is in weeks *)
  261. 159 FOR LI := 1 TO Record(PaymentsDBF) DO
  262. ***** ^ not supported yet
  263. ***** ^ undeclared identifier
  264. 160 ReadDBRec(PaymentsDBF,LI);
  265. ***** ^ not supported yet
  266. ***** ^ undeclared identifier
  267. ***** ^ not supported yet
  268. 161 MovePaymentsFromDBF(Payment);
  269. ***** ^ not supported yet
  270. ***** ^ not supported yet
  271. 162 IF ( DaysSince1900(Payment.PMTDATE) > DeleteDate)
  272. ***** ^ not supported yet
  273. ***** ^ not supported yet
  274. ***** ^ not supported yet
  275. 163 THEN DeleteRecord(PaymentsDBF);
  276. ***** ^ not supported yet
  277. ***** ^ undeclared identifier
  278. 164 END;
  279. 165 END;
  280. 166 END DeletePayments;
  281. ***** ^ not supported yet
  282. 167
  283. 168 PROCEDURE PackPayments();
  284. 169 VAR
  285. 170 EM : CARDINAL;
  286. 171 BEGIN
  287. 172 ClosePaymentsDBF();
  288. ***** ^ not supported yet
  289. ***** ^ not supported yet
  290. 173 OpenPaymentsDBF(FALSE);
  291. ***** ^ not supported yet
  292. ***** ^ not supported yet
  293. 174 DeletePayments();
  294. ***** ^ not supported yet
  295. ***** ^ not supported yet
  296. 175 DBPack(PaymentsDBF);
  297. ***** ^ not supported yet
  298. ***** ^ undeclared identifier
  299. 176
  300. 177 CloseDBF(PaymentsDBF);
  301. ***** ^ not supported yet
  302. ***** ^ undeclared identifier
  303. 178 EM := DeleteFile("Pymts.Idx");
  304. ***** ^ not supported yet
  305. ***** ^ not supported yet
  306. 179 OpenPaymentsDBF(TRUE); (* open & rebuild the index *)
  307. ***** ^ not supported yet
  308. ***** ^ not supported yet
  309. 180 ClosePaymentsDBF();
  310. ***** ^ not supported yet
  311. ***** ^ not supported yet
  312. 181
  313. 182 END PackPayments;
  314. ***** ^ not supported yet
  315. 183
  316. 184 BEGIN
  317. 185 NilDBF(PaymentsDBF);
  318. ***** ^ not supported yet
  319. ***** ^ undeclared identifier
  320. 186 IndexOpen := FALSE;
  321. 187 DBInit:=FALSE;
  322. 188 END DBFPayments.
  323. ***** ^ not supported yet
  324. 134 errors