Add blank column, rename column.
[capital-apms-progress.git] / process / report / taxinvce.p
blobf9585ef2f59e6e5d240d84af670da49bdb29b2ab
1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
2 &ANALYZE-RESUME
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*--------------------------------------------------------------------------
5 ------------------------------------------------------------------------*/
6 DEF INPUT PARAMETER report-options AS CHAR NO-UNDO.
7 &SCOPED-DEFINE trn-per-page 41
9 DEF VAR from-invoice LIKE Invoice.InvoiceNo NO-UNDO INITIAL 0.
10 DEF VAR to-invoice LIKE Invoice.InvoiceNo NO-UNDO INITIAL 0.
11 DEF VAR invoice-list AS CHAR NO-UNDO INITIAL "".
12 DEF VAR copy-only AS LOGICAL NO-UNDO INITIAL No.
13 DEF VAR output-to-pdf AS LOGICAL NO-UNDO INITIAL No.
14 RUN parse-parameters.
16 /* Report counters */
17 DEF VAR ln AS DEC INIT 0.00 NO-UNDO.
19 /* Line definitions */
21 DEF VAR date-in-words AS CHAR NO-UNDO.
22 DEF VAR tenant-address AS CHAR NO-UNDO EXTENT 10.
23 DEF VAR client-code AS CHAR NO-UNDO.
24 DEF VAR entity-type AS CHAR NO-UNDO.
25 DEF VAR entity-code AS INT NO-UNDO.
26 DEF VAR office-address AS CHAR NO-UNDO EXTENT 5.
27 DEF VAR trn-line AS CHAR NO-UNDO.
28 DEF VAR trn-no AS INT NO-UNDO.
29 DEF VAR regarding AS CHAR NO-UNDO.
30 DEF VAR client-name AS CHAR NO-UNDO FORMAT "X(80)".
32 DEF VAR reset-page AS CHAR NO-UNDO.
33 DEF VAR half-line AS CHAR NO-UNDO. half-line = CHR(27) + "=".
34 DEF VAR time-font AS CHAR NO-UNDO.
35 DEF VAR title-font AS CHAR NO-UNDO.
36 DEF VAR num-font AS CHAR NO-UNDO.
37 DEF VAR prompt-font AS CHAR NO-UNDO.
38 DEF VAR tenant-address-font AS CHAR NO-UNDO.
39 DEF VAR re-font AS CHAR NO-UNDO.
40 DEF VAR to-font AS CHAR NO-UNDO.
41 DEF VAR line-printer AS CHAR NO-UNDO.
42 DEF VAR credit-font AS CHAR NO-UNDO.
43 DEF VAR remittance-title-font AS CHAR NO-UNDO.
44 DEF VAR remittance-font AS CHAR NO-UNDO.
45 DEF VAR remittance-font-bold AS CHAR NO-UNDO.
46 DEF VAR remittance-prompt AS CHAR NO-UNDO.
47 DEF VAR stamp-font AS CHAR NO-UNDO.
48 DEF VAR remit-out-codes AS CHAR NO-UNDO.
50 DEF VAR page-no AS INT NO-UNDO.
52 DEF VAR logo-codes AS CHAR NO-UNDO.
53 DEF VAR copy-no AS INT NO-UNDO.
54 DEF VAR display-percent AS LOGI NO-UNDO.
56 DEF VAR gst-applies AS LOGI NO-UNDO.
58 DEF VAR time-stamp AS CHAR NO-UNDO.
59 DEF VAR user-name AS CHAR NO-UNDO.
60 {inc/username.i "user-name"}
62 time-stamp =
63 STRING( TODAY, "99/99/9999" ) + " - " + STRING( TIME, "HH:MM:SS" ) +
64 " for " + user-name.
66 {inc/ofc-this.i}
67 gst-applies = Office.GST <> ?.
69 {inc/ofc-set.i "Invoice-terms-routine" "invoice-terms-routine"}
70 IF NOT AVAILABLE(OfficeSetting) THEN
71 invoice-terms-routine = "".
73 {inc/ofc-set.i "Remittance-account" "remittance-account"}
74 IF NOT AVAILABLE(OfficeSetting) THEN
75 remittance-account = "".
77 {inc/ofc-set.i "GST-Number" "gst-number"}
78 IF NOT AVAILABLE(OfficeSetting) THEN
79 gst-number = REPLACE( STRING( Office.GSTNo, ">99,999,999"),",","-") .
80 {inc/ofc-set.i "GST-Number-Name" "gst-number-name"}
81 IF NOT AVAILABLE(OfficeSetting) THEN
82 gst-number-name = "GST NO.".
84 /* Check Office settings for the use of Due-Date on Invoice 'late charge message' */
85 {inc/ofc-set.i "LateChargeBasis" "late-charge-basis"}
87 {inc/ofc-set-l.i "GST-Multi-Company" "gst-multi-company"}
89 /* _UIB-CODE-BLOCK-END */
90 &ANALYZE-RESUME
93 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
95 /* ******************** Preprocessor Definitions ******************** */
97 &Scoped-define PROCEDURE-TYPE Procedure
98 &Scoped-define DB-AWARE no
102 /* _UIB-PREPROCESSOR-BLOCK-END */
103 &ANALYZE-RESUME
106 /* ************************ Function Prototypes ********************** */
108 &IF DEFINED(EXCLUDE-pdf-file-name) = 0 &THEN
110 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD pdf-file-name Procedure
111 FUNCTION pdf-file-name RETURNS CHARACTER
113 from-num AS CHAR,
114 to-num AS CHAR,
115 num-list AS CHAR
116 ) FORWARD.
118 /* _UIB-CODE-BLOCK-END */
119 &ANALYZE-RESUME
121 &ENDIF
124 /* *********************** Procedure Settings ************************ */
126 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
127 /* Settings for THIS-PROCEDURE
128 Type: Procedure
129 Allow:
130 Frames: 0
131 Add Fields to: Neither
132 Other Settings: CODE-ONLY
134 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
136 /* ************************* Create Window ************************** */
138 &ANALYZE-SUSPEND _CREATE-WINDOW
139 /* DESIGN Window definition (used by the UIB)
140 CREATE WINDOW Procedure ASSIGN
141 HEIGHT = 23.4
142 WIDTH = 77.57.
143 /* END WINDOW DEFINITION */
145 &ANALYZE-RESUME
147 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Procedure
148 /* ************************* Included-Libraries *********************** */
150 {inc/method/m-txtrep.i}
151 {inc/method/m-hpgl.i}
152 {inc/entity.i}
153 {inc/convert.i}
155 /* _UIB-CODE-BLOCK-END */
156 &ANALYZE-RESUME
162 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
165 /* *************************** Main Block *************************** */
168 DEF VAR preview AS LOGI INIT No NO-UNDO.
170 IF output-to-pdf THEN DO:
171 /* Procedure pdf-to modifies txtrep-print-file */
172 RUN txtrep-pdf-filename( pdf-file-name( STRING( from-invoice ), STRING( to-invoice ), invoice-list) ).
173 RUN txtrep-output-mode("pdf").
174 RUN hpgl-output-mode("pdf").
175 END.
177 IF NOT output-to-pdf THEN
178 OUTPUT TO VALUE(txtrep-print-file) KEEP-MESSAGES PAGE-SIZE 0.
180 RUN tax-invoices.
182 IF NOT output-to-pdf THEN DO:
183 OUTPUT CLOSE.
184 RUN view-output-file ( preview ).
185 END.
187 /* _UIB-CODE-BLOCK-END */
188 &ANALYZE-RESUME
191 /* ********************** Internal Procedures *********************** */
193 &IF DEFINED(EXCLUDE-carriage-return) = 0 &THEN
195 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE carriage-return Procedure
196 PROCEDURE carriage-return :
197 /*------------------------------------------------------------------------------
198 Purpose:
199 Parameters: <none>
200 Notes:
201 ------------------------------------------------------------------------------*/
203 PUT CONTROL CHR(13).
205 END PROCEDURE.
207 /* _UIB-CODE-BLOCK-END */
208 &ANALYZE-RESUME
210 &ENDIF
212 &IF DEFINED(EXCLUDE-each-invoice) = 0 &THEN
214 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-invoice Procedure
215 PROCEDURE each-invoice :
216 /*------------------------------------------------------------------------------
217 Purpose:
218 Parameters: <none>
219 Notes:
220 ------------------------------------------------------------------------------*/
222 DEF VAR count-from AS INTEGER NO-UNDO INIT 1.
223 DEF VAR count-to AS INTEGER NO-UNDO INIT 2.
225 IF copy-only THEN
226 count-from = 2.
228 /* If PDF then do not print the COPY watermarked page */
229 IF output-to-pdf THEN
230 ASSIGN
231 count-from = 1
232 count-to = 1.
234 DO copy-no = count-from TO count-to:
236 page-no = 1.
237 RUN get-tenant-details.
239 display-percent = No.
240 FOR EACH InvoiceLine OF Invoice NO-LOCK:
241 display-percent = display-percent OR InvoiceLine.Percent <> 100.00.
242 END.
244 RUN page-header.
246 FOR EACH InvoiceLine OF Invoice NO-LOCK:
247 RUN each-line.
248 END.
250 RUN total-line.
251 RUN page-footer.
252 RUN page-feed.
254 END.
256 END PROCEDURE.
258 /* _UIB-CODE-BLOCK-END */
259 &ANALYZE-RESUME
261 &ENDIF
263 &IF DEFINED(EXCLUDE-each-line) = 0 &THEN
265 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-line Procedure
266 PROCEDURE each-line :
267 /*------------------------------------------------------------------------------
268 Purpose:
269 Parameters: <none>
270 Notes:
271 ------------------------------------------------------------------------------*/
273 RUN next-line.
275 PUT UNFORMATTED
276 SPACE(9)
277 STRING( InvoiceLine.AccountText, "X(50)" ) SPACE(2)
278 STRING( InvoiceLine.Amount, ">,>>>,>>9.99CR" ) SPACE(7)
279 STRING( IF display-percent THEN STRING( InvoiceLine.Percent, ">>9.99" )
280 ELSE "", "X(6)" ) SPACE(4)
281 STRING( InvoiceLine.YourShare, ">,>>>,>>9.99CR" ).
282 RUN skip-line(1).
284 END PROCEDURE.
286 /* _UIB-CODE-BLOCK-END */
287 &ANALYZE-RESUME
289 &ENDIF
291 &IF DEFINED(EXCLUDE-get-client-address) = 0 &THEN
293 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-client-address Procedure
294 PROCEDURE get-client-address :
295 /*------------------------------------------------------------------------------
296 Purpose:
297 ------------------------------------------------------------------------------*/
298 DEF INPUT PARAMETER client-code AS CHAR NO-UNDO.
300 DEF VAR i AS INT NO-UNDO.
301 DEF VAR client-address AS CHAR NO-UNDO INITIAL "".
303 FIND Client WHERE Client.ClientCode = client-code NO-LOCK NO-ERROR.
304 IF NOT AVAILABLE(Client) THEN RETURN.
306 IF Client.Name <> Client.LegalName AND Client.LegalName <> ? AND Client.LegalName <> "" THEN
307 client-name = Client.LegalName.
308 ELSE
309 client-name = Client.Name.
311 client-address = TRIM( REPLACE(Client.RemittanceAddress, CHR(13), "") ).
312 IF client-address = ? OR client-address = "" THEN RETURN.
314 DO i = 1 TO 5:
315 IF i <= NUM-ENTRIES( client-address, "~n" ) THEN
316 ASSIGN office-address[i] = ENTRY( i, client-address, "~n" ) NO-ERROR.
317 ELSE
318 office-address[i] = "".
320 IF office-address[i] = ? THEN office-address[i] = "".
321 END.
323 END PROCEDURE.
325 /* _UIB-CODE-BLOCK-END */
326 &ANALYZE-RESUME
328 &ENDIF
330 &IF DEFINED(EXCLUDE-get-control-strings) = 0 &THEN
332 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-control-strings Procedure
333 PROCEDURE get-control-strings :
334 /*------------------------------------------------------------------------------
335 Purpose: Get all control strings for this report
336 ------------------------------------------------------------------------------*/
338 DEF VAR rows AS DEC NO-UNDO.
339 DEF VAR cols AS DEC NO-UNDO.
341 RUN make-control-string( "PCL", "reset,simplex,portrait,a4,tm,0,lm,6",
342 OUTPUT reset-page, OUTPUT rows, OUTPUT cols ).
344 RUN make-control-string( "PCL", "Helvetica,Point,20,Bold,Proportional",
345 OUTPUT title-font, OUTPUT rows, OUTPUT cols ).
347 RUN make-control-string( "PCL", "Times,Point,6,Normal,Proportional",
348 OUTPUT time-font, OUTPUT rows, OUTPUT cols ).
350 RUN make-control-string( "PCL", "Helvetica,Point,10,Proportional,Normal",
351 OUTPUT prompt-font, OUTPUT rows, OUTPUT cols ).
353 RUN make-control-string( "PCL", "Courier,Fixed,cpi,12,Bold",
354 OUTPUT num-font, OUTPUT rows, OUTPUT cols ).
356 RUN make-control-string( "PCL", "Helvetica,Point,10,Proportional,Normal",
357 OUTPUT tenant-address-font, OUTPUT rows, OUTPUT cols ).
359 RUN make-control-string( "PCL", "Helvetica,Point,11,Proportional,Bold",
360 OUTPUT re-font, OUTPUT rows, OUTPUT cols ).
362 RUN make-control-string( "PCL", "Helvetica,Point,8,Proportional,Normal",
363 OUTPUT to-font, OUTPUT rows, OUTPUT cols ).
365 RUN make-control-string( "PCL", "LinePrinter,lpi,9.54",
366 OUTPUT line-printer, OUTPUT rows, OUTPUT cols ).
368 RUN make-control-string( "PCL", "Helvetica,Point,14,Proportional,Bold",
369 OUTPUT credit-font, OUTPUT rows, OUTPUT cols ).
371 RUN make-control-string ( "PCL", "Proportional,Times,Bold,Point,16",
372 OUTPUT remittance-title-font, OUTPUT rows, OUTPUT cols ).
374 RUN make-control-string ( "PCL", "Times,Proportional,point,9,normal,lpi,7",
375 OUTPUT remittance-font, OUTPUT rows, OUTPUT cols ).
377 RUN make-control-string ( "PCL", "Times,Proportional,point,8,normal,lpi,7",
378 OUTPUT remittance-prompt, OUTPUT rows, OUTPUT cols ).
380 RUN make-control-string ( "PCL", "Times,Proportional,point,10,bold",
381 OUTPUT remittance-font-bold, OUTPUT rows, OUTPUT cols ).
383 RUN make-control-string ( "PCL", "Times,Proportional,Point,4,Normal",
384 OUTPUT stamp-font, OUTPUT rows, OUTPUT cols ).
386 END PROCEDURE.
388 /* _UIB-CODE-BLOCK-END */
389 &ANALYZE-RESUME
391 &ENDIF
393 &IF DEFINED(EXCLUDE-get-office-details) = 0 &THEN
395 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-office-details Procedure
396 PROCEDURE get-office-details :
397 /*------------------------------------------------------------------------------
398 Purpose:
399 Parameters: <none>
400 Notes:
401 ------------------------------------------------------------------------------*/
403 FIND Office WHERE Office.ThisOffice NO-LOCK.
405 DEF VAR i AS INT NO-UNDO.
407 DO i = 1 TO 5:
408 ASSIGN office-address[i] = "".
409 ASSIGN
410 office-address[i] = ENTRY( i, Office.StreetAddress, CHR(10) ) NO-ERROR.
411 IF office-address[i] = ? THEN office-address[i] = "".
412 END.
414 END PROCEDURE.
416 /* _UIB-CODE-BLOCK-END */
417 &ANALYZE-RESUME
419 &ENDIF
421 &IF DEFINED(EXCLUDE-get-tenant-details) = 0 &THEN
423 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-tenant-details Procedure
424 PROCEDURE get-tenant-details :
425 /*------------------------------------------------------------------------------
426 Purpose:
427 ------------------------------------------------------------------------------*/
429 DEF VAR i AS INT NO-UNDO.
430 DEF VAR addr AS CHAR NO-UNDO.
431 DEF VAR company-code AS INT NO-UNDO.
433 FIND Tenant WHERE Tenant.TenantCode = Invoice.EntityCode NO-LOCK.
435 regarding = "".
436 IF Tenant.EntityType = 'P' THEN
438 /* Note: find fails if lease is not unique - this is deliberate! */
439 FIND TenancyLease WHERE TenancyLease.TenantCode = Tenant.TenantCode NO-LOCK NO-ERROR.
440 IF AVAILABLE(TenancyLease) THEN DO:
441 regarding = TenancyLease.AreaDescription.
442 IF regarding = ? THEN regarding = "".
443 END.
445 FIND FIRST Property WHERE Property.PropertyCode = Tenant.EntityCode
446 NO-LOCK NO-ERROR.
447 IF AVAILABLE Property THEN DO:
448 regarding = (IF regarding <> "" THEN TRIM(regarding) + ", " ELSE "")
449 + Property.Name
450 + (IF Property.Name <> Property.StreetAddress THEN ", " + Property.StreetAddress ELSE "" ).
451 END.
452 END.
453 ELSE IF Tenant.EntityType = 'L' THEN
455 FIND FIRST Company WHERE Company.CompanyCode = Tenant.EntityCode
456 NO-LOCK NO-ERROR.
457 IF AVAILABLE Company THEN regarding = Company.LegalName.
458 END.
460 entity-type = Tenant.EntityType.
461 entity-code = Tenant.EntityCode.
462 client-code = get-entity-client( entity-type, entity-code ).
463 RUN get-client-address( client-code ).
465 IF gst-multi-company THEN DO:
466 company-code = get-entity-ledger( Tenant.EntityType, Tenant.EntityCode ).
467 FIND FIRST Company WHERE Company.CompanyCode = company-code NO-LOCK NO-ERROR.
468 IF AVAILABLE(Company) THEN DO:
469 IF Company.OperationalCountry = 'AUS' THEN
470 gst-number = Company.BusinessNo.
471 ELSE
472 gst-number = Company.TaxNo.
473 END.
474 END.
476 /* If the user has entered Attn text, send it to be constructed into the address */
477 IF AVAILABLE Invoice AND Invoice.AttnTo <> "" AND Invoice.AttnTo <> ? THEN
478 RUN process/getaddr.p( "T," + Invoice.AttnTo, Tenant.TenantCode, "BILL", OUTPUT addr ).
479 ELSE
480 RUN process/getaddr.p( "T", Tenant.TenantCode, "BILL", OUTPUT addr ).
482 DO i = 1 TO 10: tenant-address[i] = "". END.
483 DO i = 1 TO NUM-ENTRIES( addr, "~n" ):
484 tenant-address[i] = ENTRY( i, addr, "~n" ).
485 END.
487 END PROCEDURE.
489 /* _UIB-CODE-BLOCK-END */
490 &ANALYZE-RESUME
492 &ENDIF
494 &IF DEFINED(EXCLUDE-next-line) = 0 &THEN
496 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE next-line Procedure
497 PROCEDURE next-line :
498 /*------------------------------------------------------------------------------
499 Purpose:
500 Parameters: <none>
501 Notes:
502 ------------------------------------------------------------------------------*/
504 trn-no = trn-no + 1.
506 IF trn-no >= {&trn-per-page} THEN
508 RUN page-footer.
509 RUN page-feed.
510 RUN page-header.
511 END.
513 END PROCEDURE.
515 /* _UIB-CODE-BLOCK-END */
516 &ANALYZE-RESUME
518 &ENDIF
520 &IF DEFINED(EXCLUDE-page-feed) = 0 &THEN
522 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE page-feed Procedure
523 PROCEDURE page-feed :
524 /*------------------------------------------------------------------------------
525 Purpose:
526 Parameters: <none>
527 Notes:
528 ------------------------------------------------------------------------------*/
530 PUT CONTROL CHR(12).
531 page-no = page-no + 1.
533 END PROCEDURE.
535 /* _UIB-CODE-BLOCK-END */
536 &ANALYZE-RESUME
538 &ENDIF
540 &IF DEFINED(EXCLUDE-page-footer) = 0 &THEN
542 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE page-footer Procedure
543 PROCEDURE page-footer :
544 /*------------------------------------------------------------------------------
545 Purpose:
546 ------------------------------------------------------------------------------*/
547 DEF VAR amount-due AS CHAR NO-UNDO.
549 IF Invoice.Total < 0 THEN
551 PUT CONTROL line-printer.
552 RUN pcl-moveto( 90, 11 ). RUN carriage-return.
553 PUT CONTROL credit-font.
554 PUT UNFORMATTED "This is a credit note. Please do not pay.".
555 END.
556 ELSE
558 DEF VAR n-days AS INT NO-UNDO.
560 If the settings table has an invoice-terms-routine defined then execute
561 that to print the terms.
563 IF invoice-terms-routine <> "" THEN DO:
564 /* Generate HPGL for the E. & O. E. */
565 RUN hpgl-initialize.
566 IF output-to-pdf THEN
567 RUN VALUE(invoice-terms-routine) ( Invoice.TermsCode, remittance-account, "pdf" ).
568 ELSE
569 RUN VALUE(invoice-terms-routine) ( Invoice.TermsCode, remittance-account, "hpgl" ).
570 RUN hpgl-append( RETURN-VALUE ).
571 RUN hpgl-get-codes( YES, YES, OUTPUT remit-out-codes ).
572 PUT CONTROL remit-out-codes.
574 PUT CONTROL line-printer.
575 RUN pcl-moveto( 90, 11 ). RUN carriage-return.
576 RUN skip-line(2).
577 END.
578 ELSE DO:
579 PUT CONTROL line-printer.
580 RUN pcl-moveto( 90, 11 ). RUN carriage-return.
582 PUT CONTROL prompt-font.
583 PUT UNFORMATTED "E. & O.E. This account is now due.".
584 RUN skip-line(2).
585 ASSIGN n-days = INT( Invoice.TermsCode ) NO-ERROR.
586 IF n-days > 0 THEN
587 PUT UNFORMATTED "Interest may be charged on payments received after " +
588 IF late-charge-basis = 'DueDate' AND Invoice.DueDate <> ?
589 THEN STRING(Invoice.DueDate, "99/99/9999") + "."
590 ELSE STRING( Invoice.InvoiceDate
591 + (IF Invoice.TermsCode = "M" THEN 29 ELSE n-days), "99/99/9999" )
592 + ".".
593 END.
594 END.
596 PUT CONTROL line-printer.
597 RUN skip-line( 1 ).
599 IF copy-no = 2 THEN DO:
600 PUT CONTROL stamp-font.
601 PUT UNFORMATTED time-stamp.
602 END.
604 PUT CONTROL line-printer.
605 RUN skip-line( 0.5 ).
607 PUT UNFORMATTED FILL( "_ ", 60 ).
608 RUN skip-line(2.5).
609 PUT CONTROL remittance-title-font.
610 PUT UNFORMATTED "Remittance Advice".
611 PUT CONTROL remittance-font.
613 RUN skip-line(1.5).
614 PUT UNFORMATTED "Please return this portion with your cheque, payable to:".
615 RUN skip-line(1.5).
617 PUT CONTROL remittance-font-bold client-name remittance-font.
618 RUN skip-line(1).
620 DEF VAR i AS INT NO-UNDO.
621 DO i = 1 TO 5:
622 PUT UNFORMATTED office-address[i]. RUN skip-line(1).
623 END.
625 DEF VAR remittance-codes AS CHAR NO-UNDO.
626 amount-due = TRIM( STRING( Invoice.Total + Invoice.TaxAmount, ">,>>>,>>>,>>9.99CR" ) ).
628 RUN hpgl-initialize.
629 RUN hpgl-moveto( 110, 50 ).
630 RUN hpgl-text( remittance-prompt, "Our Ref:" ).
631 RUN hpgl-move-relative( 20, 0 ).
632 RUN hpgl-text( remittance-font, "T" + STRING( Tenant.TenantCode, "99999" ) + "/" + STRING( Invoice.InvoiceNo ) ).
633 RUN hpgl-move-relative( 25, 0 ).
634 RUN hpgl-text( remittance-prompt, "Date:" ).
635 RUN hpgl-move-relative( 10, 0 ).
636 RUN hpgl-text( remittance-font, STRING( Invoice.InvoiceDate, "99/99/9999" ) ).
637 RUN hpgl-move-relative( -55, -18 ).
638 RUN hpgl-text( remittance-prompt, "From:" ).
639 RUN hpgl-move-relative( 20, 0 ).
640 RUN hpgl-text( remittance-font, Tenant.Name ).
641 RUN hpgl-move-relative( -20, -4 ).
642 RUN hpgl-text( remittance-prompt, "Re:" ).
643 RUN hpgl-move-relative( 20, 0 ).
644 RUN hpgl-text( remittance-font, regarding ).
645 RUN hpgl-move-relative( -20, -4 ).
646 RUN hpgl-text( remittance-prompt, "Amount Due:" ).
647 RUN hpgl-move-relative( 20, 0 ).
648 RUN hpgl-text( remittance-font, amount-due ).
649 RUN hpgl-move-relative( -20, -6 ).
650 RUN hpgl-text( remittance-prompt, "Amount Paid:" ).
652 RUN hpgl-get-codes( yes, no, OUTPUT remittance-codes ).
653 PUT CONTROL remittance-codes.
655 IF copy-no = 2 THEN RUN print-copy-sign.
657 END PROCEDURE.
659 /* _UIB-CODE-BLOCK-END */
660 &ANALYZE-RESUME
662 &ENDIF
664 &IF DEFINED(EXCLUDE-page-header) = 0 &THEN
666 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE page-header Procedure
667 PROCEDURE page-header :
668 /*------------------------------------------------------------------------------
669 Purpose:
670 Parameters: <none>
671 Notes:
672 ------------------------------------------------------------------------------*/
674 RUN reset-page.
675 RUN print-title.
676 RUN print-address.
677 RUN print-header.
679 PUT CONTROL re-font.
681 IF gst-multi-company THEN DO:
682 PUT UNFORMATTED "SUPPLIER:".
683 RUN carriage-return.
684 PUT CONTROL line-printer.
685 PUT UNFORMATTED SPACE(14).
686 PUT CONTROL re-font.
687 PUT UNFORMATTED STRING( client-name, "X(80)" ).
688 RUN carriage-return.
689 RUN skip-line(2).
690 PUT UNFORMATTED "ABN:".
691 RUN carriage-return.
692 PUT UNFORMATTED SPACE(17).
693 PUT UNFORMATTED STRING( gst-number, "X(80)" ).
694 RUN carriage-return.
695 RUN skip-line(2).
696 PUT UNFORMATTED "RE:".
697 RUN carriage-return.
698 PUT UNFORMATTED SPACE(17).
699 PUT UNFORMATTED STRING( regarding, "X(80)" ).
700 END.
701 ELSE DO:
702 PUT UNFORMATTED "RE:".
703 RUN carriage-return.
704 PUT CONTROL line-printer.
705 PUT UNFORMATTED SPACE(11).
706 PUT CONTROL re-font.
707 PUT UNFORMATTED STRING( regarding, "X(80)" ).
708 END.
710 RUN skip-line(3).
713 PUT CONTROL to-font.
714 PUT UNFORMATTED "TO:".
715 RUN carriage-return.
716 PUT CONTROL line-printer.
717 PUT UNFORMATTED SPACE(9).
718 PUT CONTROL to-font.
719 PUT UNFORMATTED STRING( Invoice.ToDetail, "X(100)" ).
720 RUN skip-line(2).
723 RUN print-invoice-header.
725 END PROCEDURE.
727 /* _UIB-CODE-BLOCK-END */
728 &ANALYZE-RESUME
730 &ENDIF
732 &IF DEFINED(EXCLUDE-parse-parameters) = 0 &THEN
734 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE parse-parameters Procedure
735 PROCEDURE parse-parameters :
736 /*------------------------------------------------------------------------------
737 Purpose:
738 ------------------------------------------------------------------------------*/
739 DEF VAR i AS INT NO-UNDO.
740 DEF VAR token AS CHAR NO-UNDO.
742 {inc/showopts.i "report-options"}
744 DO i = 1 TO NUM-ENTRIES( report-options, "~n" ):
745 token = ENTRY( i, report-options, "~n" ).
746 CASE( ENTRY( 1, token ) ):
747 WHEN "OutputPDF" THEN output-to-pdf = YES.
748 WHEN "InvoiceRange" THEN ASSIGN
749 from-invoice = INT( ENTRY( 2, token ) )
750 to-invoice = INT( ENTRY( 3, token ) ).
751 WHEN "InvoiceList" THEN ASSIGN
752 invoice-list = SUBSTRING( token, INDEX( token, ",") + 1).
753 WHEN "CopyOnly" THEN copy-only = Yes.
754 END CASE.
755 END.
757 END PROCEDURE.
759 /* _UIB-CODE-BLOCK-END */
760 &ANALYZE-RESUME
762 &ENDIF
764 &IF DEFINED(EXCLUDE-print-address) = 0 &THEN
766 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-address Procedure
767 PROCEDURE print-address :
768 /*------------------------------------------------------------------------------
769 Purpose:
770 Parameters: <none>
771 Notes:
772 ------------------------------------------------------------------------------*/
774 DEF VAR i AS INT NO-UNDO.
775 DEF VAR invoice-date AS CHAR NO-UNDO.
777 RUN skip-line(6).
778 PUT CONTROL tenant-address-font.
780 PUT UNFORMATTED STRING( tenant-address[1], "X(50)" ).
781 RUN carriage-return.
782 PUT UNFORMATTED SPACE( 100 ) (IF gst-applies THEN "Tax " ELSE "") + "Invoice No:".
783 RUN carriage-return.
784 PUT CONTROL num-font.
785 PUT UNFORMATTED SPACE( 78 ) STRING( Invoice.InvoiceNo, ">>>>9" ).
786 PUT CONTROL tenant-address-font.
787 RUN skip-line(2).
789 PUT UNFORMATTED STRING( tenant-address[2], "X(50)" ). RUN carriage-return.
790 IF gst-applies THEN
791 PUT UNFORMATTED SPACE( 100 ) gst-number-name.
792 RUN carriage-return.
794 PUT CONTROL num-font.
795 IF gst-applies THEN
796 PUT UNFORMATTED SPACE( 83 - LENGTH(gst-number)) gst-number.
798 PUT CONTROL tenant-address-font.
799 RUN skip-line(2).
801 PUT UNFORMATTED STRING( tenant-address[3], "X(50)" ).
802 RUN skip-line(2).
804 PUT UNFORMATTED STRING( tenant-address[4], "X(50)" ). RUN carriage-return.
806 RUN date-to-word( Invoice.InvoiceDate, OUTPUT invoice-date ).
807 PUT UNFORMATTED SPACE(118) STRING( invoice-date, "X(20)" ). RUN carriage-return.
808 RUN skip-line(2).
810 PUT UNFORMATTED STRING( tenant-address[5], "X(50)" ). RUN skip-line(2).
811 PUT UNFORMATTED STRING( tenant-address[6], "X(50)" ). RUN skip-line(2).
812 PUT UNFORMATTED STRING( tenant-address[7], "X(50)" ). RUN skip-line(1).
814 END PROCEDURE.
816 /* _UIB-CODE-BLOCK-END */
817 &ANALYZE-RESUME
819 &ENDIF
821 &IF DEFINED(EXCLUDE-print-copy-sign) = 0 &THEN
823 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-copy-sign Procedure
824 PROCEDURE print-copy-sign :
825 /*------------------------------------------------------------------------------
826 Purpose:
827 Parameters: <none>
828 Notes:
829 ------------------------------------------------------------------------------*/
831 DEF VAR copy-codes AS CHAR NO-UNDO.
833 RUN hpgl-initialize.
834 RUN hpgl-copywatermark.
835 RUN hpgl-get-codes( yes, no, OUTPUT copy-codes ).
836 PUT CONTROL copy-codes.
838 END PROCEDURE.
840 /* _UIB-CODE-BLOCK-END */
841 &ANALYZE-RESUME
843 &ENDIF
845 &IF DEFINED(EXCLUDE-print-header) = 0 &THEN
847 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-header Procedure
848 PROCEDURE print-header :
849 /*------------------------------------------------------------------------------
850 Purpose:
851 ------------------------------------------------------------------------------*/
853 RUN skip-line( 2 ).
854 RUN pcl-move-relative( 0, 50 ).
855 PUT CONTROL title-font.
856 PUT UNFORMATTED STRING( IF Invoice.Total < 0 THEN
857 "CREDIT NOTE" ELSE IF gst-applies THEN "TAX INVOICE" ELSE " INVOICE", "X(25)" ).
858 RUN carriage-return.
859 PUT CONTROL tenant-address-font.
860 PUT UNFORMATTED SPACE(138) STRING( "Page " + STRING( page-no ) ).
861 PUT CONTROL line-printer.
862 RUN skip-line(1).
863 PUT CONTROL title-font.
864 PUT UNFORMATTED FILL( "__", 60 ).
865 RUN skip-line(5).
866 PUT CONTROL line-printer.
868 END PROCEDURE.
870 /* _UIB-CODE-BLOCK-END */
871 &ANALYZE-RESUME
873 &ENDIF
875 &IF DEFINED(EXCLUDE-print-invoice-header) = 0 &THEN
877 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-invoice-header Procedure
878 PROCEDURE print-invoice-header :
879 /*------------------------------------------------------------------------------
880 Purpose:
881 ------------------------------------------------------------------------------*/
882 DEF VAR blrb AS CHAR NO-UNDO.
884 PUT CONTROL line-printer.
886 blrb = WRAP((IF Invoice.Blurb = ? OR TRIM(Invoice.Blurb) = ""
887 THEN Invoice.ToDetail ELSE Invoice.Blurb), 104).
889 IF page-no = 1 THEN DO.
890 DEF VAR i AS INT NO-UNDO.
891 DO i = 1 TO NUM-ENTRIES( blrb, "~n" ):
892 RUN next-line.
893 PUT UNFORMATTED (IF i > 1 THEN FILL(" ",9) ELSE "TO: ")
894 ENTRY( i, blrb, "~n" ).
895 RUN skip-line(1).
896 END.
897 END.
899 trn-no = trn-no + 3.
900 RUN next-line.
901 RUN skip-line(2).
902 PUT UNFORMATTED SPACE(9)
903 STRING( "Description", "X(50)" ) SPACE(2)
904 STRING( " Amount ", "X(14)" ) SPACE(6)
905 STRING( IF display-percent THEN "Percent" ELSE "", "X(7)" ) SPACE(4)
906 STRING( " Share ", "X(14)" ).
907 RUN skip-line(2).
909 END PROCEDURE.
911 /* _UIB-CODE-BLOCK-END */
912 &ANALYZE-RESUME
914 &ENDIF
916 &IF DEFINED(EXCLUDE-print-title) = 0 &THEN
918 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-title Procedure
919 PROCEDURE print-title :
920 /*------------------------------------------------------------------------------
921 Purpose:
922 ------------------------------------------------------------------------------*/
924 RUN hpgl-initialize.
925 RUN client-logo( entity-type, entity-code, client-code ).
926 RUN client-address( entity-type, entity-code, client-code ).
927 RUN hpgl-get-codes( yes, YES, OUTPUT logo-codes ).
928 PUT CONTROL logo-codes.
930 PUT CONTROL line-printer.
931 /* RUN skip-line(0.5). */
933 END PROCEDURE.
935 /* _UIB-CODE-BLOCK-END */
936 &ANALYZE-RESUME
938 &ENDIF
940 &IF DEFINED(EXCLUDE-reset-page) = 0 &THEN
942 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE reset-page Procedure
943 PROCEDURE reset-page :
944 /*------------------------------------------------------------------------------
945 Purpose:
946 Parameters: <none>
947 Notes:
948 ------------------------------------------------------------------------------*/
950 PUT CONTROL reset-page.
951 trn-no = 0.
952 ln = 0.
954 END PROCEDURE.
956 /* _UIB-CODE-BLOCK-END */
957 &ANALYZE-RESUME
959 &ENDIF
961 &IF DEFINED(EXCLUDE-skip-line) = 0 &THEN
963 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE skip-line Procedure
964 PROCEDURE skip-line :
965 /*------------------------------------------------------------------------------
966 Purpose:
967 Parameters: <none>
968 Notes:
969 ------------------------------------------------------------------------------*/
971 DEF INPUT PARAMETER n AS DEC NO-UNDO.
973 DEF VAR int-part AS INT NO-UNDO.
974 DEF VAR dec-part AS DEC NO-UNDO.
976 int-part = TRUNCATE( n, 0 ).
977 IF int-part < 0 THEN RETURN.
978 dec-part = n - int-part.
979 IF int-part = 0 AND dec-part = 0 THEN RETURN.
981 /* Need to have this like the following - do not touch */
982 IF int-part <> 0 THEN PUT CONTROL FILL( CHR(10), int-part ).
983 IF dec-part <> 0 THEN PUT CONTROL half-line.
985 ln = ln + n.
987 RUN carriage-return.
989 END PROCEDURE.
991 /* _UIB-CODE-BLOCK-END */
992 &ANALYZE-RESUME
994 &ENDIF
996 &IF DEFINED(EXCLUDE-skip-to-line) = 0 &THEN
998 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE skip-to-line Procedure
999 PROCEDURE skip-to-line :
1000 /*------------------------------------------------------------------------------
1001 Purpose:
1002 Parameters: <none>
1003 Notes:
1004 ------------------------------------------------------------------------------*/
1006 DEF INPUT PARAMETER line-no AS DEC NO-UNDO.
1008 DEF VAR int-part AS INT NO-UNDO.
1009 DEF VAR dec-part AS DEC NO-UNDO.
1011 int-part = TRUNCATE( line-no - ln, 0 ).
1012 IF int-part < 0 THEN RETURN.
1013 dec-part = ( line-no - ln ) - int-part.
1014 IF int-part = 0 AND dec-part = 0 THEN RETURN.
1016 IF int-part <> 0 THEN PUT CONTROL FILL( CHR(10), int-part ).
1017 IF dec-part <> 0 THEN PUT CONTROL half-line.
1019 ln = line-no.
1021 RUN carriage-return.
1023 END PROCEDURE.
1025 /* _UIB-CODE-BLOCK-END */
1026 &ANALYZE-RESUME
1028 &ENDIF
1030 &IF DEFINED(EXCLUDE-tax-invoices) = 0 &THEN
1032 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE tax-invoices Procedure
1033 PROCEDURE tax-invoices :
1034 /*------------------------------------------------------------------------------
1035 Purpose:
1036 Parameters: <none>
1037 Notes:
1038 ------------------------------------------------------------------------------*/
1040 DEF VAR i AS INT NO-UNDO.
1042 RUN get-office-details.
1043 RUN get-control-strings.
1044 RUN date-to-word( TODAY, OUTPUT date-in-words ).
1046 IF invoice-list <> ? THEN
1047 DO i = 1 TO NUM-ENTRIES( invoice-list ):
1048 FIND Invoice WHERE
1049 Invoice.InvoiceStatus = "A" AND
1050 Invoice.InvoiceNo = INT( ENTRY( i, invoice-list ) )
1051 NO-LOCK NO-ERROR.
1052 IF AVAILABLE Invoice THEN DO:
1054 /* If outputting to PDF the do individual files for each invoice */
1055 IF output-to-pdf THEN DO:
1056 RUN txtrep-pdf-filename( 'Invoice-' + ENTRY( i, invoice-list ) ).
1057 OUTPUT TO VALUE(txtrep-print-file) KEEP-MESSAGES PAGE-SIZE 0.
1058 END.
1060 RUN each-invoice.
1062 /* If PDF mode then output will be opened again for the next file */
1063 IF output-to-pdf THEN
1064 OUTPUT CLOSE.
1065 END.
1066 END.
1068 IF from-invoice <> ? AND to-invoice <> ? THEN
1069 FOR EACH Invoice NO-LOCK WHERE
1070 Invoice.InvoiceStatus = "A" AND
1071 Invoice.InvoiceNo >= from-invoice AND
1072 Invoice.InvoiceNo <= to-invoice:
1074 IF output-to-pdf THEN DO:
1075 RUN txtrep-pdf-filename( 'Invoice-' + STRING( Invoice.InvoiceNo ) ).
1076 OUTPUT TO VALUE(txtrep-print-file) KEEP-MESSAGES PAGE-SIZE 0.
1077 END.
1079 RUN each-invoice.
1081 IF output-to-pdf THEN
1082 OUTPUT CLOSE.
1083 END.
1085 END PROCEDURE.
1087 /* _UIB-CODE-BLOCK-END */
1088 &ANALYZE-RESUME
1090 &ENDIF
1092 &IF DEFINED(EXCLUDE-total-line) = 0 &THEN
1094 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE total-line Procedure
1095 PROCEDURE total-line :
1096 /*------------------------------------------------------------------------------
1097 Purpose:
1098 Parameters: <none>
1099 Notes:
1100 ------------------------------------------------------------------------------*/
1102 trn-no = trn-no + IF gst-applies THEN 4 ELSE 1.
1103 RUN next-line.
1105 RUN skip-line(1).
1107 IF gst-applies THEN
1109 PUT UNFORMATTED SPACE(92) FILL( '-', 12 ). RUN skip-line(1).
1110 PUT UNFORMATTED SPACE(9)
1111 STRING( "Your total share", "X(50)" ) SPACE(33)
1112 STRING( Invoice.Total, ">,>>>,>>9.99CR" ). RUN skip-line(1).
1113 PUT UNFORMATTED SPACE(9)
1114 STRING( "Plus GST", "X(50)" ) SPACE(33)
1115 STRING( Invoice.TaxAmount, ">,>>>,>>9.99CR" ). RUN skip-line(1).
1116 END.
1118 PUT UNFORMATTED SPACE(92) FILL( '-', 12 ). RUN skip-line(1).
1119 PUT UNFORMATTED SPACE(9)
1120 STRING( "Amount now due", "X(50)" ) SPACE(33)
1121 STRING( Invoice.Total + Invoice.TaxAmount, ">,>>>,>>9.99CR" ). RUN skip-line(1).
1122 PUT UNFORMATTED SPACE(92) FILL( '=', 12 ). RUN skip-line(1).
1124 END PROCEDURE.
1126 /* _UIB-CODE-BLOCK-END */
1127 &ANALYZE-RESUME
1129 &ENDIF
1131 /* ************************ Function Implementations ***************** */
1133 &IF DEFINED(EXCLUDE-pdf-file-name) = 0 &THEN
1135 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION pdf-file-name Procedure
1136 FUNCTION pdf-file-name RETURNS CHARACTER
1138 from-num AS CHAR,
1139 to-num AS CHAR,
1140 num-list AS CHAR
1142 /*------------------------------------------------------------------------------
1143 Purpose: Construct the pdf filename based on what invoices are specified
1144 Notes:
1145 ------------------------------------------------------------------------------*/
1146 DEF VAR pdf-file-name AS CHAR NO-UNDO.
1147 DEF VAR i AS INT NO-UNDO.
1149 IF invoice-list <> ? THEN
1150 DO i = 1 TO NUM-ENTRIES( num-list ):
1152 IF pdf-file-name <> "" THEN
1153 pdf-file-name = pdf-file-name + '-'.
1154 ELSE
1155 pdf-file-name = 'Invoice'.
1157 pdf-file-name = pdf-file-name + ENTRY( i, num-list ).
1158 END.
1160 IF from-num <> ? AND to-num <> ? THEN DO:
1161 IF from-num = to-num THEN
1162 pdf-file-name = 'Invoice-' + from-num.
1163 ELSE
1164 pdf-file-name = 'Invoice-' + from-num + '-to-' + to-num.
1165 END.
1167 RETURN pdf-file-name.
1169 END FUNCTION.
1171 /* _UIB-CODE-BLOCK-END */
1172 &ANALYZE-RESUME
1174 &ENDIF