home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a070 / 3.ddi / FOXPRO / SAMPLE / INVOICEP.PRG < prev    next >
Encoding:
Text File  |  1989-11-06  |  6.1 KB  |  222 lines

  1. * ┌─────────────────────────────────────────────────────────────────────┐ *
  2. * │  INVOICEP.PRG: INVOICE PRINT                                        │ *
  3. * │  Copyright (c) 1989 Tech III, Inc. All rights reserved.             │ *
  4. * │  Tech III of San Pedro, California      (213) 547-2191.             │ *
  5. * │  "The bridge connecting people and technology."(tm)                 │ *
  6. * └─────────────────────────────────────────────────────────────────────┘ *
  7. @ 00,00 SAY WINTITLE(PROMPT())
  8.  
  9. SELECT lines
  10. SET ORDER TO lns_inv
  11. SELECT invoice
  12. IF EOF() .OR. BOF()
  13.   GO TOP
  14. ENDIF
  15. STORE RECNO() TO curr_rec
  16. STORE SET('MEMOWIDTH') TO memocols
  17. SET ORDER TO inv_inv
  18. SET RELATION TO invoice INTO lines
  19. IF EOF() .OR. BOF()
  20.   GO TOP
  21. ELSE
  22.   SKIP 0
  23. ENDIF
  24.  
  25. * INITIALIZE VARIABLES
  26. PUBLIC taxamt
  27. STORE 0 TO taxamt
  28. STORE .t. TO _box, printing
  29. STORE invoice TO startno, endno
  30.  
  31. * DEFINITIONS
  32. ON ESCAPE STORE .f. TO printing
  33. ON PAGE AT LINE 56 DO prn_foot
  34.  
  35. * USER INPUT: SELECT INVOICE RANGE TO PRINT
  36.  
  37. @ 02,02 SAY 'Begin printing with invoice number:  ' GET startno PICTURE '99999'
  38. @ 04,02 SAY 'Stop printing after invoice number:  ' GET endno PICTURE '99999' ;
  39. RANGE startno,
  40. READ
  41.  
  42. IF .NOT. YESNO("System is ready to print.")
  43.   STORE .f. TO printing
  44. ELSE
  45.   IF .NOT. READY2PR()
  46.     STORE .f. TO printing
  47.   ENDIF
  48. ENDIF
  49.  
  50. IF .NOT. printing
  51.   DO standby WITH 'You have canceled the report.'
  52. ELSE
  53.   SEEK startno
  54.   
  55.   * START PRINTING
  56.   ACTIVATE WINDOW pticker
  57.   SET CONSOLE OFF
  58.   SET PRINT ON
  59.   PRINTJOB
  60.     SCAN REST WHILE printing .AND. invoice <= endno
  61.       STORE invoice TO this_one
  62.       STORE 1 TO pagenum
  63.       STORE INVSUB() TO invtot
  64.       STORE invoice->taxrate TO mtaxrate
  65.       STORE 0 TO taxamt
  66.       DO prn_head
  67.       SELECT lines
  68.       SCAN REST WHILE invoice = this_one
  69.         DO prn_items
  70.       ENDSCAN
  71.       STORE PROW() TO start_line
  72.       DO WHILE PROW() >= start_line
  73.         ?
  74.       ENDDO
  75.       SELECT invoice
  76.     ENDSCAN
  77.     SET PRINTER OFF
  78.     SET CONSOLE ON
  79.     DEACTIVATE WINDOW pticker
  80.     DO standby WITH 'Your print request has been completed.'
  81.   ENDPRINTJOB
  82. ENDIF
  83.  
  84. * Housekeeping
  85. SET RELATION TO
  86. ON ESCAPE
  87. ON PAGE
  88. SELECT invoice
  89. GOTO curr_rec
  90. RETURN
  91.  
  92. * HEADINGS
  93. PROCEDURE prn_head
  94.   STORE 0 TO _plineno, _pcolno
  95.   DEFINE BOX FROM 00 TO 79 HEIGHT 52 AT LINE 5 SINGLE
  96.   ?
  97.   ?
  98.   STORE " INVOICE # " + LTRIM(STR(invoice->invoice,10)) TO invno_str
  99.   ? invno_str AT (79 - LEN(invno_str)) STYLE 'B'
  100.   ?
  101.   ?
  102.   ?
  103.   ?  PTICKER() + "B ┌                                  ┐  S ┌                                  ┐" AT 01
  104.   ?  PTICKER() + "I                                       H" AT 01
  105.   ?? LEFT(invoice->contact,32) AT 04
  106.   ??  LEFT(invoice->s_contact,32) AT 44
  107.   ?  PTICKER() + "L                                       I" AT 01
  108.   ?? LEFT(invoice->company,32) AT 04
  109.   ?? LEFT(invoice->s_company,32)    AT 44
  110.   ?  PTICKER() + "L                                       P" AT 01
  111.   ?? LEFT(invoice->address1,32) AT 04
  112.   ?? LEFT(invoice->s_address1,32) AT 44
  113.   ?  LEFT(invoice->city,20) AT 04
  114.   ?? invoice->state AT 25
  115.   ?? invoice->zip AT 28
  116.   ?? LEFT(invoice->s_city,22) AT 44
  117.   ?? invoice->s_state AT 66
  118.   ?? invoice->s_zip AT 69
  119.   ?  PTICKER() + "T                                       T         " AT 01
  120.   ?  PTICKER() + "O └                                  ┘  O └                                  ┘" AT 01
  121.   ?  PTICKER() + '├' AT 00
  122.   ?? "──────────┬──────────────────┬───────┬────────────┬───────────────────────────" AT 01
  123.   ?? '┤' AT 79
  124.   ?  PTICKER() + "Date    │       P.O #      │ Slsmn │  Ship via  │" AT 03
  125.   ?  PTICKER() + '├' AT 00
  126.   ?? "──────────┼──────────────────┼───────┼────────────┼───────────────────────────" AT 01
  127.   ?? '┤' AT 79
  128.   ?  PTICKER() + "│                  │       │            │" AT 11
  129.   ?? invoice->inv_date AT 02
  130.   ?? invoice->po AT 13
  131.   ?? invoice->soldby AT 33
  132.   ?? invoice->shipvia AT 40
  133.   ?  PTICKER() + '└' AT 00
  134.   ?? "──────────┴──────────────────┴───────┴────────────┴───────────────────────────" AT 01
  135.   ?? '┘' AT 79
  136.   ?  PTICKER() + '┌' AT 00
  137.   ?? "────────┬─────────────────────────────────────────┬─────┬─────────┬───────────" AT 01
  138.   ?? '┐' AT 79
  139.   ?  PTICKER() + "Item # │ Description                             │ Qty │ Price   │ Extension" AT 02
  140.   ?  PTICKER() + '├' AT 00
  141.   ?? "────────┴─────────────────────────────────────────┴─────┴─────────┴───────────" AT 01
  142.   ?? '┤' AT 79
  143.   RETURN
  144.   
  145.   * LINE ITEMS
  146. PROCEDURE prn_items
  147.   ? PTICKER() + lines->item AT 2
  148.   ?? IIF(taxable,'*',' ') AT 9
  149.   ?? LEFT(lines->descript,37) AT 11
  150.   ?? lines->quantity PICTURE '9999999' AT 50
  151.   ?? lines->price PICTURE '999,999.99' AT 57
  152.   ?? lines->quantity*lines->price PICTURE '9999,999.99' AT 68
  153.   IF taxable
  154.     STORE taxamt+((mtaxrate*(quantity*price))*.01) TO taxamt
  155.   ENDIF
  156.   RETURN
  157.   
  158.   * FOOTERS
  159. PROCEDURE prn_foot
  160.   * PRINT PAGE NUMBER IF MORE PAGES TO GO, OR IF THIS IS LAST PAGE OF MULTI-
  161.   * PAGE INVOICE
  162.   ? PTICKER()
  163.   ? PTICKER()
  164.   IF invoice = this_one .OR. pagenum > 1
  165.     ?? 'PAGE ' + STR(pagenum,3) AT 35
  166.   ENDIF
  167.   * PRINT A HEADER (AND CONTINUE) IF MORE PAGES TO GO
  168.   IF invoice = this_one
  169.     EJECT
  170.     STORE pagenum + 1 TO pagenum
  171.     DO prn_head
  172.   ELSE
  173.     * PRINT TOTAL IF THIS IS THE LAST PAGE
  174.     ? 'INVOICE TOTAL: $ ' + TRANSFORM(invtot,       '99,999,999.99') AT 40
  175.     ? 'TAX AMOUNT(*): $ ' + TRANSFORM(taxamt,       '99,999,999.99') AT 40
  176.     ? 'GROSS TOTAL  : $ ' + TRANSFORM(invtot+taxamt,'99,999,999.99') AT 40
  177.     EJECT
  178.     STORE 1 TO pagenum
  179.   ENDIF
  180.   
  181.   RETURN
  182.   
  183. FUNCTION getfirst
  184.   SET NEAR ON
  185.   SEEK startno
  186.   IF FOUND()
  187.     STORE .t. TO returnval
  188.   ELSE
  189.     DO standby WITH "That invoice isn't on file."
  190.     IF .NOT. BOF()
  191.       SKIP -1
  192.     ENDIF
  193.     IF EOF()
  194.       GO TOP
  195.     ENDIF
  196.     STORE invoice TO startno
  197.     STORE .f. TO returnval
  198.   ENDIF
  199.   SET NEAR OFF
  200.   RETURN returnval
  201.   
  202. FUNCTION getlast
  203.   SET NEAR ON
  204.   SEEK endno
  205.   IF FOUND()
  206.     STORE .t. TO returnval
  207.   ELSE
  208.     DO standby WITH "That invoice isn't on file."
  209.     IF .NOT. BOF()
  210.       SKIP -1
  211.     ENDIF
  212.     IF EOF()
  213.       GO TOP
  214.     ENDIF
  215.     STORE invoice TO endno
  216.     STORE .f. TO returnval
  217.   ENDIF
  218.   SET NEAR OFF
  219.   RETURN returnval
  220.   
  221.   * EOF
  222.