1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
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.
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"}
63 STRING( TODAY, "99/99/9999" ) + " - " + STRING( TIME, "HH:MM:SS" ) +
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
*/
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
*/
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
118 /* _UIB-CODE-BLOCK-END
*/
124 /* *********************** Procedure Settings
************************ */
126 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
127 /* Settings for
THIS-PROCEDURE
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
143 /* END WINDOW DEFINITION
*/
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
}
155 /* _UIB-CODE-BLOCK-END
*/
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").
177 IF NOT output-to-pdf
THEN
178 OUTPUT TO VALUE(txtrep-print-file
) KEEP-MESSAGES PAGE-SIZE 0.
182 IF NOT output-to-pdf
THEN DO:
184 RUN view-output-file
( preview
).
187 /* _UIB-CODE-BLOCK-END
*/
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 /*------------------------------------------------------------------------------
201 ------------------------------------------------------------------------------*/
207 /* _UIB-CODE-BLOCK-END
*/
212 &IF DEFINED(EXCLUDE-each-invoice) = 0 &THEN
214 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-invoice Procedure
215 PROCEDURE each-invoice
:
216 /*------------------------------------------------------------------------------
220 ------------------------------------------------------------------------------*/
222 DEF VAR count-from
AS INTEGER NO-UNDO INIT 1.
223 DEF VAR count-to
AS INTEGER NO-UNDO INIT 2.
228 /* If PDF then do not print the COPY watermarked page
*/
229 IF output-to-pdf
THEN
234 DO copy-no
= count-from
TO count-to
:
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.
246 FOR EACH InvoiceLine
OF Invoice
NO-LOCK:
258 /* _UIB-CODE-BLOCK-END
*/
263 &IF DEFINED(EXCLUDE-each-line) = 0 &THEN
265 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-line Procedure
266 PROCEDURE each-line
:
267 /*------------------------------------------------------------------------------
271 ------------------------------------------------------------------------------*/
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" ).
286 /* _UIB-CODE-BLOCK-END
*/
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 /*------------------------------------------------------------------------------
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.
309 client-name
= Client.Name.
311 client-address
= TRIM( REPLACE(Client.RemittanceAddress
, CHR(13), "") ).
312 IF client-address
= ?
OR client-address
= "" THEN RETURN.
315 IF i
<= NUM-ENTRIES( client-address
, "~n" ) THEN
316 ASSIGN office-address
[i
] = ENTRY( i
, client-address
, "~n" ) NO-ERROR.
318 office-address
[i
] = "".
320 IF office-address
[i
] = ?
THEN office-address
[i
] = "".
325 /* _UIB-CODE-BLOCK-END
*/
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
).
388 /* _UIB-CODE-BLOCK-END
*/
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 /*------------------------------------------------------------------------------
401 ------------------------------------------------------------------------------*/
403 FIND Office
WHERE Office.ThisOffice
NO-LOCK.
405 DEF VAR i
AS INT NO-UNDO.
408 ASSIGN office-address
[i
] = "".
410 office-address
[i
] = ENTRY( i
, Office.StreetAddress
, CHR(10) ) NO-ERROR.
411 IF office-address
[i
] = ?
THEN office-address
[i
] = "".
416 /* _UIB-CODE-BLOCK-END
*/
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 /*------------------------------------------------------------------------------
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.
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
= "".
445 FIND FIRST Property
WHERE Property.PropertyCode
= Tenant.EntityCode
447 IF AVAILABLE Property
THEN DO:
448 regarding
= (IF regarding
<> "" THEN TRIM(regarding
) + ", " ELSE "")
450 + (IF Property.Name
<> Property.StreetAddress
THEN ", " + Property.StreetAddress
ELSE "" ).
453 ELSE IF Tenant.EntityType
= 'L'
THEN
455 FIND FIRST Company
WHERE Company.CompanyCode
= Tenant.EntityCode
457 IF AVAILABLE Company
THEN regarding
= Company.LegalName.
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.
472 gst-number
= Company.TaxNo.
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
).
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" ).
489 /* _UIB-CODE-BLOCK-END
*/
494 &IF DEFINED(EXCLUDE-next-line) = 0 &THEN
496 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE next-line Procedure
497 PROCEDURE next-line
:
498 /*------------------------------------------------------------------------------
502 ------------------------------------------------------------------------------*/
506 IF trn-no
>= {&trn-per-page} THEN
515 /* _UIB-CODE-BLOCK-END
*/
520 &IF DEFINED(EXCLUDE-page-feed) = 0 &THEN
522 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE page-feed Procedure
523 PROCEDURE page-feed
:
524 /*------------------------------------------------------------------------------
528 ------------------------------------------------------------------------------*/
531 page-no
= page-no
+ 1.
535 /* _UIB-CODE-BLOCK-END
*/
540 &IF DEFINED(EXCLUDE-page-footer) = 0 &THEN
542 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE page-footer Procedure
543 PROCEDURE page-footer
:
544 /*------------------------------------------------------------------------------
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.".
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. */
566 IF output-to-pdf
THEN
567 RUN VALUE(invoice-terms-routine
) ( Invoice.TermsCode
, remittance-account
, "pdf" ).
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.
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.".
585 ASSIGN n-days
= INT( Invoice.TermsCode
) NO-ERROR.
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" )
596 PUT CONTROL line-printer.
599 IF copy-no
= 2 THEN DO:
600 PUT CONTROL stamp-font.
601 PUT UNFORMATTED time-stamp.
604 PUT CONTROL line-printer.
605 RUN skip-line
( 0.5 ).
607 PUT UNFORMATTED FILL( "_ ", 60 ).
609 PUT CONTROL remittance-title-font.
610 PUT UNFORMATTED "Remittance Advice".
611 PUT CONTROL remittance-font.
614 PUT UNFORMATTED "Please return this portion with your cheque, payable to:".
617 PUT CONTROL remittance-font-bold client-name remittance-font.
620 DEF VAR i
AS INT NO-UNDO.
622 PUT UNFORMATTED office-address
[i
].
RUN skip-line
(1).
625 DEF VAR remittance-codes
AS CHAR NO-UNDO.
626 amount-due
= TRIM( STRING( Invoice.Total
+ Invoice.TaxAmount
, ">,>>>,>>>,>>9.99CR" ) ).
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.
659 /* _UIB-CODE-BLOCK-END
*/
664 &IF DEFINED(EXCLUDE-page-header) = 0 &THEN
666 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE page-header Procedure
667 PROCEDURE page-header
:
668 /*------------------------------------------------------------------------------
672 ------------------------------------------------------------------------------*/
681 IF gst-multi-company
THEN DO:
682 PUT UNFORMATTED "SUPPLIER:".
684 PUT CONTROL line-printer.
685 PUT UNFORMATTED SPACE(14).
687 PUT UNFORMATTED STRING( client-name
, "X(80)" ).
690 PUT UNFORMATTED "ABN:".
692 PUT UNFORMATTED SPACE(17).
693 PUT UNFORMATTED STRING( gst-number
, "X(80)" ).
696 PUT UNFORMATTED "RE:".
698 PUT UNFORMATTED SPACE(17).
699 PUT UNFORMATTED STRING( regarding
, "X(80)" ).
702 PUT UNFORMATTED "RE:".
704 PUT CONTROL line-printer.
705 PUT UNFORMATTED SPACE(11).
707 PUT UNFORMATTED STRING( regarding
, "X(80)" ).
714 PUT UNFORMATTED "TO:".
716 PUT CONTROL line-printer.
717 PUT UNFORMATTED SPACE(9).
719 PUT UNFORMATTED STRING( Invoice.ToDetail
, "X(100)" ).
723 RUN print-invoice-header.
727 /* _UIB-CODE-BLOCK-END
*/
732 &IF DEFINED(EXCLUDE-parse-parameters) = 0 &THEN
734 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE parse-parameters Procedure
735 PROCEDURE parse-parameters
:
736 /*------------------------------------------------------------------------------
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.
759 /* _UIB-CODE-BLOCK-END
*/
764 &IF DEFINED(EXCLUDE-print-address) = 0 &THEN
766 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-address Procedure
767 PROCEDURE print-address
:
768 /*------------------------------------------------------------------------------
772 ------------------------------------------------------------------------------*/
774 DEF VAR i
AS INT NO-UNDO.
775 DEF VAR invoice-date
AS CHAR NO-UNDO.
778 PUT CONTROL tenant-address-font.
780 PUT UNFORMATTED STRING( tenant-address
[1], "X(50)" ).
782 PUT UNFORMATTED SPACE( 100 ) (IF gst-applies
THEN "Tax " ELSE "") + "Invoice No:".
784 PUT CONTROL num-font.
785 PUT UNFORMATTED SPACE( 78 ) STRING( Invoice.InvoiceNo
, ">>>>9" ).
786 PUT CONTROL tenant-address-font.
789 PUT UNFORMATTED STRING( tenant-address
[2], "X(50)" ).
RUN carriage-return.
791 PUT UNFORMATTED SPACE( 100 ) gst-number-name.
794 PUT CONTROL num-font.
796 PUT UNFORMATTED SPACE( 83 - LENGTH(gst-number
)) gst-number.
798 PUT CONTROL tenant-address-font.
801 PUT UNFORMATTED STRING( tenant-address
[3], "X(50)" ).
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.
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).
816 /* _UIB-CODE-BLOCK-END
*/
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 /*------------------------------------------------------------------------------
829 ------------------------------------------------------------------------------*/
831 DEF VAR copy-codes
AS CHAR NO-UNDO.
834 RUN hpgl-copywatermark.
835 RUN hpgl-get-codes
( yes
, no
, OUTPUT copy-codes
).
836 PUT CONTROL copy-codes.
840 /* _UIB-CODE-BLOCK-END
*/
845 &IF DEFINED(EXCLUDE-print-header) = 0 &THEN
847 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-header Procedure
848 PROCEDURE print-header
:
849 /*------------------------------------------------------------------------------
851 ------------------------------------------------------------------------------*/
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)" ).
859 PUT CONTROL tenant-address-font.
860 PUT UNFORMATTED SPACE(138) STRING( "Page " + STRING( page-no
) ).
861 PUT CONTROL line-printer.
863 PUT CONTROL title-font.
864 PUT UNFORMATTED FILL( "__", 60 ).
866 PUT CONTROL line-printer.
870 /* _UIB-CODE-BLOCK-END
*/
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 /*------------------------------------------------------------------------------
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" ):
893 PUT UNFORMATTED (IF i
> 1 THEN FILL(" ",9) ELSE "TO: ")
894 ENTRY( i
, blrb
, "~n" ).
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)" ).
911 /* _UIB-CODE-BLOCK-END
*/
916 &IF DEFINED(EXCLUDE-print-title) = 0 &THEN
918 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-title Procedure
919 PROCEDURE print-title
:
920 /*------------------------------------------------------------------------------
922 ------------------------------------------------------------------------------*/
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).
*/
935 /* _UIB-CODE-BLOCK-END
*/
940 &IF DEFINED(EXCLUDE-reset-page) = 0 &THEN
942 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE reset-page Procedure
943 PROCEDURE reset-page
:
944 /*------------------------------------------------------------------------------
948 ------------------------------------------------------------------------------*/
950 PUT CONTROL reset-page.
956 /* _UIB-CODE-BLOCK-END
*/
961 &IF DEFINED(EXCLUDE-skip-line) = 0 &THEN
963 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE skip-line Procedure
964 PROCEDURE skip-line
:
965 /*------------------------------------------------------------------------------
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.
991 /* _UIB-CODE-BLOCK-END
*/
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 /*------------------------------------------------------------------------------
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.
1021 RUN carriage-return.
1025 /* _UIB-CODE-BLOCK-END
*/
1030 &IF DEFINED(EXCLUDE-tax-invoices) = 0 &THEN
1032 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE tax-invoices Procedure
1033 PROCEDURE tax-invoices
:
1034 /*------------------------------------------------------------------------------
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
):
1049 Invoice.InvoiceStatus
= "A" AND
1050 Invoice.InvoiceNo
= INT( ENTRY( i
, invoice-list
) )
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.
1062 /* If PDF mode then output will be opened again for the next file
*/
1063 IF output-to-pdf
THEN
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.
1081 IF output-to-pdf
THEN
1087 /* _UIB-CODE-BLOCK-END
*/
1092 &IF DEFINED(EXCLUDE-total-line) = 0 &THEN
1094 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE total-line Procedure
1095 PROCEDURE total-line
:
1096 /*------------------------------------------------------------------------------
1100 ------------------------------------------------------------------------------*/
1102 trn-no
= trn-no
+ IF gst-applies
THEN 4 ELSE 1.
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).
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).
1126 /* _UIB-CODE-BLOCK-END
*/
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
1142 /*------------------------------------------------------------------------------
1143 Purpose
: Construct the pdf filename based on what invoices are specified
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
+ '
-'.
1155 pdf-file-name
= 'Invoice'.
1157 pdf-file-name
= pdf-file-name
+ ENTRY( i
, num-list
).
1160 IF from-num
<> ?
AND to-num
<> ?
THEN DO:
1161 IF from-num
= to-num
THEN
1162 pdf-file-name
= 'Invoice-'
+ from-num.
1164 pdf-file-name
= 'Invoice-'
+ from-num
+ '
-to-'
+ to-num.
1167 RETURN pdf-file-name.
1171 /* _UIB-CODE-BLOCK-END
*/