SALES.LST 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  1. Listing:
  2. 1 IMPLEMENTATION MODULE Sales;
  3. 2 (*
  4. 3 Copyright (C) 1988,1989 Jensen & Partners International
  5. 4 *)
  6. 5
  7. 6 IMPORT FIO, Str, IO, Misc, Globals, Window, Client, Items, Btree, Lib;
  8. 7 FROM Globals IMPORT WriteAt, PromptFore, DisplayBorder,
  9. ***** ^ duplicate identifier
  10. 8 DisplayFore, DisplayBack, GetMenu, TaxRate,
  11. 9 DataFore, DataBack, ItemIndex, ItemData,
  12. 10 ClientData, ClientIndex;
  13. 11 FROM Window IMPORT GotoXY, WinType, TextColor, TextBackground,
  14. ***** ^ duplicate identifier
  15. 12 ClrEol, Use, Used, PutOnTop, Open, WinDef,
  16. 13 Black, White, SingleFrame, DoubleFrame, SetFrame,
  17. 14 SetTitle, CenterLowerTitle, CursorOn, CursorOff,
  18. 15 Hide;
  19. 16 CONST
  20. 17 MAX_ROWS = 15;
  21. 18 FIRST_ROW = 6;
  22. 19
  23. 20 TYPE
  24. 21 SalesRec = RECORD
  25. 22 Item : Items.ItemRec;
  26. ***** ^ not supported yet
  27. 23 Qty : CARDINAL;
  28. 24 END;
  29. ***** ^ not supported yet
  30. 25
  31. 26 VAR
  32. 27 SaleItems : ARRAY[FIRST_ROW..MAX_ROWS] OF SalesRec;
  33. ***** ^ not supported yet
  34. ***** ^ not supported yet
  35. 28 SummaryFile : FIO.File;
  36. ***** ^ not supported yet
  37. 29 year, month, day : CARDINAL;
  38. 30 weekday : Lib.DayType;
  39. ***** ^ not supported yet
  40. 31 misc : ARRAY[0..3] OF CHAR;
  41. ***** ^ not supported yet
  42. ***** ^ not supported yet
  43. 32 ok : BOOLEAN;
  44. 33 SalesWin, lastWin : WinType;
  45. 34 SummaryWin, psumWin : WinType;
  46. 35 OnScreen : BOOLEAN;
  47. 36 keyPressed : CHAR;
  48. 37 blankItem : Items.ItemRec;
  49. ***** ^ not supported yet
  50. 38 CurrentTotals : TotalRec;
  51. ***** ^ undeclared identifier
  52. 39 SubTotal, GrandTotal, SalesTax : LONGREAL;
  53. 40
  54. 41 PROCEDURE PressAKey( txt : ARRAY OF CHAR);
  55. ***** ^ not supported yet
  56. 42 VAR
  57. 43 ch : CHAR;
  58. 44 BEGIN
  59. 45 TextColor(PromptFore);
  60. ***** ^ not supported yet
  61. ***** ^ not supported yet
  62. 46 TextBackground(DisplayBack);
  63. ***** ^ not supported yet
  64. ***** ^ not supported yet
  65. 47 WriteAt(MAX_ROWS+1,1,txt);
  66. ***** ^ not supported yet
  67. ***** ^ not supported yet
  68. 48 GotoXY(30,MAX_ROWS+1);
  69. ***** ^ not supported yet
  70. ***** ^ not supported yet
  71. 49 ch := IO.RdKey();
  72. ***** ^ not supported yet
  73. ***** ^ not supported yet
  74. ***** ^ not supported yet
  75. 50 GotoXY(1,MAX_ROWS+1);
  76. ***** ^ not supported yet
  77. ***** ^ not supported yet
  78. 51 ClrEol();
  79. ***** ^ not supported yet
  80. ***** ^ not supported yet
  81. 52 keyPressed := CAP(ch);
  82. ***** ^ undeclared identifier
  83. ***** ^ not supported yet
  84. 53 END PressAKey;
  85. ***** ^ not supported yet
  86. 54
  87. 55
  88. 56 PROCEDURE Template();
  89. 57 (*
  90. 58 This procedure un-hides the item display window and displays
  91. 59 the field names.
  92. 60 *)
  93. 61 VAR
  94. 62 x : CARDINAL;
  95. 63 BEGIN
  96. 64 lastWin := Used();
  97. ***** ^ not supported yet
  98. ***** ^ not supported yet
  99. ***** ^ not supported yet
  100. 65 Use(SalesWin);
  101. ***** ^ not supported yet
  102. ***** ^ not supported yet
  103. 66 PutOnTop(SalesWin);
  104. ***** ^ not supported yet
  105. ***** ^ not supported yet
  106. 67 Clear();
  107. ***** ^ undeclared identifier
  108. ***** ^ not supported yet
  109. 68 OnScreen := TRUE;
  110. 69 IF FIO.Exists(TotalFile) THEN
  111. ***** ^ not supported yet
  112. ***** ^ not supported yet
  113. ***** ^ undeclared identifier
  114. 70 SummaryFile := FIO.Open(TotalFile);
  115. ***** ^ not supported yet
  116. ***** ^ not supported yet
  117. ***** ^ not supported yet
  118. ***** ^ undeclared identifier
  119. 71 FIO.Seek(SummaryFile,0);
  120. ***** ^ not supported yet
  121. ***** ^ not supported yet
  122. ***** ^ not supported yet
  123. ***** ^ not supported yet
  124. 72 x := FIO.RdBin(SummaryFile,CurrentTotals,SIZE(TotalRec));
  125. ***** ^ not supported yet
  126. ***** ^ not supported yet
  127. ***** ^ not supported yet
  128. ***** ^ not supported yet
  129. ***** ^ undeclared identifier
  130. ***** ^ undeclared identifier
  131. 73 FIO.Close(SummaryFile);
  132. ***** ^ not supported yet
  133. ***** ^ not supported yet
  134. ***** ^ not supported yet
  135. 74 ELSE
  136. 75 WITH CurrentTotals DO
  137. ***** ^ not supported yet
  138. 76 TotalDollars := 0.0;
  139. ***** ^ undeclared identifier
  140. 77 TotalCash := 0.0;
  141. ***** ^ undeclared identifier
  142. 78 TotalCharge := 0.0;
  143. ***** ^ undeclared identifier
  144. 79 NumTrans := 0;
  145. ***** ^ undeclared identifier
  146. 80 END;
  147. ***** ^ not supported yet
  148. 81 END;
  149. 82 END Template;
  150. ***** ^ not supported yet
  151. 83
  152. 84 PROCEDURE Clear();
  153. 85 (**
  154. 86 Clear information off the Sales screen
  155. 87 **)
  156. 88 VAR
  157. 89 i : CARDINAL;
  158. 90 BEGIN
  159. 91 TextColor(DataFore);
  160. ***** ^ not supported yet
  161. ***** ^ not supported yet
  162. 92 TextBackground(DataBack);
  163. ***** ^ not supported yet
  164. ***** ^ not supported yet
  165. 93 WriteAt(1,11," ");
  166. ***** ^ not supported yet
  167. ***** ^ not supported yet
  168. 94 WriteAt(1,37," ");
  169. ***** ^ not supported yet
  170. ***** ^ not supported yet
  171. 95 WriteAt(1,63," ");
  172. ***** ^ not supported yet
  173. ***** ^ not supported yet
  174. 96 WriteAt(2,11," ");
  175. ***** ^ not supported yet
  176. ***** ^ not supported yet
  177. 97 WriteAt(2,40," ");
  178. ***** ^ not supported yet
  179. ***** ^ not supported yet
  180. 98 FOR i := FIRST_ROW TO MAX_ROWS DO
  181. 99 WriteAt(i,3," ");
  182. ***** ^ not supported yet
  183. ***** ^ not supported yet
  184. 100 WriteAt(i,16," ");
  185. ***** ^ not supported yet
  186. ***** ^ not supported yet
  187. 101 WriteAt(i,45," ");
  188. ***** ^ not supported yet
  189. ***** ^ not supported yet
  190. 102 WriteAt(i,53," ");
  191. ***** ^ not supported yet
  192. ***** ^ not supported yet
  193. 103 WriteAt(i,66," ");
  194. ***** ^ not supported yet
  195. ***** ^ not supported yet
  196. 104 END;
  197. 105 WriteAt(MAX_ROWS+2,45," ");
  198. ***** ^ not supported yet
  199. ***** ^ not supported yet
  200. 106 WriteAt(MAX_ROWS+2,66," ");
  201. ***** ^ not supported yet
  202. ***** ^ not supported yet
  203. 107 END Clear;
  204. ***** ^ not supported yet
  205. 108
  206. 109 PROCEDURE DisplayClient( aClient : Client.ClientRec);
  207. ***** ^ not supported yet
  208. 110 VAR
  209. 111 S : ARRAY[0..9] OF CHAR;
  210. ***** ^ not supported yet
  211. ***** ^ not supported yet
  212. 112 ok : BOOLEAN;
  213. 113 BEGIN
  214. 114 TextColor(DataFore);
  215. ***** ^ not supported yet
  216. ***** ^ not supported yet
  217. 115 TextBackground(DataBack);
  218. ***** ^ not supported yet
  219. ***** ^ not supported yet
  220. 116 WriteAt(1,11," ");
  221. ***** ^ not supported yet
  222. ***** ^ not supported yet
  223. 117 WriteAt(1,37," ");
  224. ***** ^ not supported yet
  225. ***** ^ not supported yet
  226. 118 WriteAt(1,63," ");
  227. ***** ^ not supported yet
  228. ***** ^ not supported yet
  229. 119 WriteAt(2,11," ");
  230. ***** ^ not supported yet
  231. ***** ^ not supported yet
  232. 120 WriteAt(2,40," ");
  233. ***** ^ not supported yet
  234. ***** ^ not supported yet
  235. 121 WITH aClient DO
  236. ***** ^ not supported yet
  237. 122 WriteAt(1,11,CNum);
  238. ***** ^ not supported yet
  239. ***** ^ undeclared identifier
  240. 123 WriteAt(1,37,LName);
  241. ***** ^ not supported yet
  242. ***** ^ undeclared identifier
  243. 124 WriteAt(1,63,FName);
  244. ***** ^ not supported yet
  245. ***** ^ undeclared identifier
  246. 125 WriteAt(2,11,Phone);
  247. ***** ^ not supported yet
  248. ***** ^ undeclared identifier
  249. 126 WriteAt(2,40," ");
  250. ***** ^ not supported yet
  251. ***** ^ not supported yet
  252. 127 Str.FixRealToStr(Balance,2,S,ok);
  253. ***** ^ not supported yet
  254. ***** ^ not supported yet
  255. ***** ^ undeclared identifier
  256. ***** ^ not supported yet
  257. ***** ^ not supported yet
  258. 128 IF ok = FALSE THEN
  259. 129 WriteAt(2,40,"???");
  260. ***** ^ not supported yet
  261. ***** ^ not supported yet
  262. 130 ELSE
  263. 131 WriteAt(2,40,S);
  264. ***** ^ not supported yet
  265. ***** ^ not supported yet
  266. 132 END;
  267. 133 END;
  268. ***** ^ not supported yet
  269. 134 END DisplayClient;
  270. ***** ^ not supported yet
  271. 135
  272. 136 PROCEDURE GetClient( VAR aClient : Client.ClientRec ) : BOOLEAN;
  273. ***** ^ not supported yet
  274. 137 VAR
  275. 138 CNum : Globals.FileKey;
  276. ***** ^ not supported yet
  277. 139 ReEnter,
  278. 140 GotClient : BOOLEAN;
  279. 141 ch : CHAR;
  280. 142 BEGIN
  281. 143 GotClient := FALSE;
  282. 144 CNum := "";
  283. ***** ^ not supported yet
  284. 145 REPEAT (* until GotClient *)
  285. 146 ReEnter := FALSE;
  286. 147 Clear();
  287. ***** ^ not supported yet
  288. ***** ^ not supported yet
  289. 148 GotoXY(11,1); Misc.InputStr(CNum, 10);
  290. ***** ^ not supported yet
  291. ***** ^ not supported yet
  292. ***** ^ not supported yet
  293. ***** ^ not supported yet
  294. ***** ^ not supported yet
  295. ***** ^ not supported yet
  296. 149 IF CNum[0] <= ' ' THEN (* cancel the transaction *)
  297. ***** ^ not supported yet
  298. ***** ^ not supported yet
  299. 150 RETURN FALSE;
  300. 151 ELSE (* a CNum was entered *)
  301. 152 IF Btree.Find(ClientIndex,CNum,aClient) THEN
  302. ***** ^ not supported yet
  303. ***** ^ not supported yet
  304. ***** ^ not supported yet
  305. ***** ^ not supported yet
  306. ***** ^ not supported yet
  307. 153 DisplayClient(aClient);
  308. ***** ^ not supported yet
  309. ***** ^ not supported yet
  310. 154 GotClient := TRUE;
  311. 155 ELSIF Btree.Search(ClientIndex,CNum,aClient) THEN
  312. ***** ^ not supported yet
  313. ***** ^ not supported yet
  314. ***** ^ not supported yet
  315. ***** ^ not supported yet
  316. ***** ^ not supported yet
  317. 156 REPEAT
  318. 157 DisplayClient(aClient);
  319. ***** ^ not supported yet
  320. ***** ^ not supported yet
  321. 158 GetMenu("T)his One, N)ext, P)revious, or R)e-enter? ",
  322. ***** ^ not supported yet
  323. ***** ^ not supported yet
  324. 159 Globals.CharSet{'T','N','P'},ch);
  325. ***** ^ not supported yet
  326. ***** ^ not supported yet
  327. ***** ^ not supported yet
  328. ***** ^ not supported yet
  329. ***** ^ not supported yet
  330. 160 CASE ch OF
  331. 161 'T' : GotClient := TRUE;
  332. 162 | 'N' : IF Btree.Next(ClientIndex,aClient) THEN
  333. 163 DisplayClient(aClient);
  334. 164 ELSE
  335. 165 Globals.Beep();
  336. 166 END;
  337. 167 | 'P' : IF Btree.Prev(ClientIndex,aClient) THEN
  338. 168 DisplayClient(aClient);
  339. 169 ELSE
  340. 170 Globals.Beep();
  341. 171 END;
  342. 172 | 'R' : ReEnter := TRUE;
  343. 173 ELSE
  344. 174 Globals.Beep();
  345. 175 END; (* case *)
  346. 176 UNTIL GotClient OR ReEnter;
  347. 177 ELSE
  348. 178 Globals.Beep(); Globals.Beep(); Globals.Beep();
  349. 179 PressAKey("That client is not in our records!");
  350. 180 TextColor(DataFore);
  351. 181 TextBackground(DataBack);
  352. 182 END;
  353. 183 END;
  354. 184 UNTIL GotClient;
  355. 185 RETURN TRUE;
  356. 186 END GetClient;
  357. 187
  358. 188
  359. 189 PROCEDURE DisplayItem( row : CARDINAL; anItem : Items.ItemRec );
  360. 190 VAR
  361. 191 ok : BOOLEAN;
  362. 192 S : ARRAY[0..9] OF CHAR;
  363. 193 BEGIN
  364. 194 TextColor(DataFore);
  365. 195 TextBackground(DataBack);
  366. 196 WriteAt(row,16,anItem.Description);
  367. 197 WriteAt(row,53," ");
  368. 198 Str.FixRealToStr(anItem.Retail,2,S,ok);
  369. 199 IF ok = FALSE THEN
  370. 200 WriteAt(row,53,"???");
  371. 201 ELSE
  372. 202 WriteAt(row,53,S);
  373. 203 END;
  374. 204 END DisplayItem;
  375. 205
  376. 206
  377. 207 PROCEDURE GetOneItem( row: CARDINAL;
  378. 208 VAR anItem : Items.ItemRec ): BOOLEAN;
  379. 209 VAR
  380. 210 item : Globals.FileKey;
  381. 211 ReEnter,
  382. 212 GotItem : BOOLEAN;
  383. 213 ch : CHAR;
  384. 214 BEGIN
  385. 215 GotItem := FALSE;
  386. 216 Str.Copy(item,"");
  387. 217 REPEAT
  388. 218 ReEnter := FALSE;
  389. 219 GotoXY(3,row); Misc.InputStr(item,10);
  390. 220 IF item[0] <= ' ' THEN (* cancel the transaction *)
  391. 221 RETURN FALSE;
  392. 222 ELSE (* an item number was entered *)
  393. 223 IF Btree.Find(ItemIndex,item,anItem) THEN
  394. 224 DisplayItem(row,anItem);
  395. 225 GotItem := TRUE;
  396. 226 ELSIF Btree.Search(ItemIndex,item,anItem) THEN
  397. 227 REPEAT
  398. 228 DisplayItem(row,anItem);
  399. 229 GetMenu("T)his One, N)ext, P)revious, or R)e-enter? ",
  400. 230 Globals.CharSet{'T','N','P'},ch);
  401. 231 CASE ch OF
  402. 232 'T' : GotItem := TRUE;
  403. 233 | 'N' : IF Btree.Next(ItemIndex,anItem) THEN
  404. 234 DisplayItem(row,anItem);
  405. 235 ELSE
  406. 236 Globals.Beep();
  407. 237 END;
  408. 238 | 'P' : IF Btree.Prev(ItemIndex,anItem) THEN
  409. 239 DisplayItem(row,anItem);
  410. 240 ELSE
  411. 241 Globals.Beep();
  412. 242 END;
  413. 243 | 'R' : ReEnter := TRUE;
  414. 244 ELSE
  415. 245 Globals.Beep();
  416. 246 END; (* case *)
  417. 247 UNTIL GotItem OR ReEnter;
  418. 248 ELSE
  419. 249 Globals.Beep(); Globals.Beep(); Globals.Beep();
  420. 250 PressAKey("That item is not in our records!");
  421. 251 TextColor(DataFore);
  422. 252 TextBackground(DataBack);
  423. 253 END;
  424. 254 END;
  425. 255 UNTIL GotItem;
  426. 256 RETURN TRUE;
  427. 257 END GetOneItem;
  428. 258
  429. 259 PROCEDURE GetSaleItem( VAR which : CARDINAL;
  430. 260 VAR action : CARDINAL ) : BOOLEAN;
  431. 261 VAR
  432. 262 item : Items.ItemRec;
  433. 263 qty : CARDINAL;
  434. 264 qtyStr : ARRAY[0..4] OF CHAR;
  435. 265 ok : BOOLEAN;
  436. 266 ch : CHAR;
  437. 267 thisTotal : LONGREAL;
  438. 268 S : ARRAY[0..10] OF CHAR;
  439. 269 BEGIN
  440. 270 action := 0;
  441. 271 ok := FALSE;
  442. 272 qtyStr := "1";
  443. 273 IF GetOneItem(which,item) THEN
  444. 274 REPEAT
  445. 275 WriteAt(which,45," ");
  446. 276 GotoXY(45,which); Misc.InputStr(qtyStr,5);
  447. 277 qty := CARDINAL(Str.StrToCard(qtyStr,10,ok));
  448. 278 UNTIL ok;
  449. 279 SaleItems[which].Qty := qty;
  450. 280 SaleItems[which].Item := item;
  451. 281 thisTotal := LONGREAL(qty) * item.Retail;
  452. 282 WriteAt(which,66," ");
  453. 283 Str.FixRealToStr(thisTotal,2,S,ok);
  454. 284 IF ok = FALSE THEN
  455. 285 WriteAt(which,66,"???");
  456. 286 ELSE
  457. 287 WriteAt(which,66,S);
  458. 288 END;
  459. 289 SubTotal := SubTotal + thisTotal;
  460. 290 SalesTax := (SubTotal * TaxRate)/100.0;
  461. 291 GrandTotal := SubTotal + SalesTax;
  462. 292
  463. 293 WriteAt(MAX_ROWS+2,45," ");
  464. 294 WriteAt(MAX_ROWS+2,66," ");
  465. 295 Str.FixRealToStr(SalesTax,2,S,ok);
  466. 296 IF ok = FALSE THEN
  467. 297 WriteAt(MAX_ROWS+2,45,"???");
  468. 298 ELSE
  469. 299 WriteAt(MAX_ROWS+2,45,S);
  470. 300 END;
  471. 301 Str.FixRealToStr(GrandTotal,2,S,ok);
  472. 302 IF ok = FALSE THEN
  473. 303 WriteAt(MAX_ROWS+2,66,"???");
  474. 304 ELSE
  475. 305 WriteAt(MAX_ROWS+2,66,S);
  476. 306 END;
  477. 307
  478. 308 END;
  479. 309 GetMenu("C)ancel item, N)o Sale, A)nother item, D)one with sale: ",
  480. 310 Globals.CharSet{'C','N','A','D'},ch);
  481. 311 CASE ch OF
  482. 312 'D' : RETURN TRUE;
  483. 313 | 'A' : RETURN FALSE;
  484. 314 | 'C' : DEC(which);
  485. 315 DisplayItem(which+1,blankItem);
  486. 316 WriteAt(which+1,45," ");
  487. 317 WriteAt(which+1,66," ");
  488. 318 | 'N' : action := 99;
  489. 319 RETURN TRUE;
  490. 320 ELSE
  491. 321 Globals.Beep();
  492. 322 END;
  493. 323 RETURN FALSE;
  494. 324 END GetSaleItem;
  495. 325
  496. 326
  497. 327 PROCEDURE Work();
  498. 328 (**
  499. 329 Perform the entry of sales, information requests, etc.
  500. 330 Template should be called first to open the window.
  501. 331 **)
  502. 332 VAR
  503. 333 theClient : Client.ClientRec;
  504. 334 ch : CHAR;
  505. 335 transDone : BOOLEAN;
  506. 336 choice, i,
  507. 337 row : CARDINAL;
  508. 338 BEGIN
  509. 339 SubTotal := 0.0;
  510. 340 GrandTotal := 0.0;
  511. 341 SalesTax := 0.0;
  512. 342 IF GetClient(theClient) THEN
  513. 343 transDone := FALSE;
  514. 344 FOR row := FIRST_ROW TO MAX_ROWS DO
  515. 345 SaleItems[row].Qty := 0;
  516. 346 END;
  517. 347 row := FIRST_ROW;
  518. 348 REPEAT
  519. 349 transDone := GetSaleItem( row, choice );
  520. 350 INC(row);
  521. 351 UNTIL (transDone) OR (row>MAX_ROWS);
  522. 352 IF choice = 0 THEN
  523. 353 (* take the cash or charge *)
  524. 354 GetMenu("Will that be C)ash or cH)arge? ",
  525. 355 Globals.CharSet{'C','H'},ch);
  526. 356 CASE ch OF
  527. 357 'C' : CurrentTotals.TotalCash :=
  528. 358 CurrentTotals.TotalCash + GrandTotal;
  529. 359 | 'H' : CurrentTotals.TotalCharge :=
  530. 360 CurrentTotals.TotalCharge + GrandTotal;
  531. 361 theClient.Balance := theClient.Balance +
  532. 362 GrandTotal;
  533. 363 Btree.Delete(ClientData);
  534. 364 Btree.Add(ClientData,theClient,SIZE(Client.ClientRec));
  535. 365 ELSE
  536. 366 Globals.Beep();
  537. 367 END;
  538. 368 CurrentTotals.TotalDollars :=
  539. 369 CurrentTotals.TotalDollars + GrandTotal;
  540. 370 INC(CurrentTotals.NumTrans);
  541. 371 ELSE
  542. 372 (* cancel transaction *)
  543. 373 Clear();
  544. 374 END;
  545. 375 END; (* if *)
  546. 376 END Work;
  547. 377
  548. 378 PROCEDURE Summary();
  549. 379 (**
  550. 380 Summarize current sales figures in a window
  551. 381 **)
  552. 382 VAR
  553. 383 SummaryWin, psumWin : WinType;
  554. 384 ch : CHAR;
  555. 385 S : ARRAY[0..10] OF CHAR;
  556. 386 ok : BOOLEAN;
  557. 387 BEGIN
  558. 388 psumWin := Used();
  559. 389 SummaryWin := Open( WinDef( 28, 10, 52, 17,
  560. 390 White,Black,TRUE,FALSE,TRUE,TRUE,
  561. 391 SingleFrame,White,Black) );
  562. 392 SetFrame(SummaryWin,DoubleFrame,DataFore,
  563. 393 DataBack);
  564. 394 SetTitle(SummaryWin,"Daily Totals",CenterLowerTitle);
  565. 395 Use(SummaryWin);
  566. 396 CursorOff();
  567. 397 TextColor(DataFore);
  568. 398 TextBackground(DataBack);
  569. 399 Window.Clear();
  570. 400 WriteAt(2,3,"Total Sales: $");
  571. 401 WriteAt(3,3,"Cash Sales: ");
  572. 402 WriteAt(4,3,"Charge Sales: ");
  573. 403 WriteAt(5,3,"# Trans: ");
  574. 404 PutOnTop(SummaryWin);
  575. 405 (* write out the current totals *)
  576. 406 WITH CurrentTotals DO
  577. 407 Str.FixRealToStr(TotalDollars,2,S,ok);
  578. 408 WriteAt(2,18,S);
  579. 409 Str.FixRealToStr(TotalCash,2,S,ok);
  580. 410 WriteAt(3,18,S);
  581. 411 Str.FixRealToStr(TotalCharge,2,S,ok);
  582. 412 WriteAt(4,18,S);
  583. 413 GotoXY(18,5);
  584. 414 IO.WrCard(NumTrans,4);
  585. 415 END;
  586. 416 ch := IO.RdKey();
  587. 417 Window.Close(SummaryWin);
  588. 418 PutOnTop(psumWin);
  589. 419 Use(psumWin);
  590. 420 CursorOn();
  591. 421 END Summary;
  592. 422
  593. 423 PROCEDURE Close();
  594. 424 (**
  595. 425 Remove the Sales screen from the screen
  596. 426 **)
  597. 427 BEGIN
  598. 428 Hide(SalesWin);
  599. 429 Use(lastWin);
  600. 430 PutOnTop(lastWin);
  601. 431 OnScreen := FALSE;
  602. 432 (* write out summary file *)
  603. 433 SummaryFile := FIO.Create(TotalFile);
  604. 434 FIO.Seek(SummaryFile,0);
  605. 435 FIO.WrBin(SummaryFile,CurrentTotals,SIZE(TotalRec));
  606. 436 FIO.Close(SummaryFile);
  607. 437 END Close;
  608. 438
  609. 439 BEGIN (* init code *)
  610. 440
  611. 441 (* set up the summary file name *)
  612. 442 TotalFile := "000000.TOT"; (* default name *)
  613. 443
  614. 444 Lib.GetDate(year,month,day,weekday);
  615. 445 IF year > 1900 THEN year := year - 1900; END;
  616. 446
  617. 447 Str.CardToStr(LONGCARD(year),misc,10,ok);
  618. 448 IF misc[1] = 0C THEN
  619. 449 TotalFile[4] := '0';
  620. 450 TotalFile[5] := misc[0];
  621. 451 ELSE
  622. 452 TotalFile[4] := misc[0];
  623. 453 TotalFile[5] := misc[1];
  624. 454 END;
  625. 455
  626. 456 Str.CardToStr(LONGCARD(month),misc,10,ok);
  627. 457 IF misc[1] = 0C THEN
  628. 458 TotalFile[0] := '0';
  629. 459 TotalFile[1] := misc[0];
  630. 460 ELSE
  631. 461 TotalFile[0] := misc[0];
  632. 462 TotalFile[1] := misc[1];
  633. 463 END;
  634. 464
  635. 465 Str.CardToStr(LONGCARD(day),misc,10,ok);
  636. 466 IF misc[1] = 0C THEN
  637. 467 TotalFile[2] := '0';
  638. 468 TotalFile[3] := misc[0];
  639. 469 ELSE
  640. 470 TotalFile[2] := misc[0];
  641. 471 TotalFile[3] := misc[1];
  642. 472 END;
  643. 473
  644. 474 (* create the sales window *)
  645. 475
  646. 476 SalesWin := Open( WinDef( 0, 4, 79, 22,
  647. 477 White,Black,TRUE,FALSE,TRUE,TRUE,
  648. 478 SingleFrame,White,Black) );
  649. 479 SetFrame(SalesWin,SingleFrame,DisplayBorder,
  650. 480 DisplayBack);
  651. 481 Use(SalesWin);
  652. 482 TextColor(DisplayFore);
  653. 483 TextBackground(DisplayBack);
  654. 484 Window.Clear();
  655. 485 WriteAt(1,3,"Client:");
  656. 486 WriteAt(2,3,"Phone:");
  657. 487 WriteAt(1,30,"Last:");
  658. 488 WriteAt(1,55,"First:");
  659. 489 WriteAt(2,30,"Balance:");
  660. 490 WriteAt(4,3,"ITEM");
  661. 491 WriteAt(4,16,"DESCRIPTION");
  662. 492 WriteAt(4,45,"QTY");
  663. 493 WriteAt(4,53,"EACH");
  664. 494 WriteAt(4,66,"TOTAL");
  665. 495 WriteAt(17,40,"TAX:");
  666. 496 WriteAt(17,57,"TOTAL:");
  667. 497
  668. 498 blankItem.Retail := 0.0;
  669. 499 blankItem.Description := " ";
  670. 500
  671. 501 END Sales.
  672. 169 errors