1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*--------------------------------------------------------------------------
5 Approved Vouchers Report
6 ------------------------------------------------------------------------*/
7 DEF INPUT PARAMETER report-options
AS CHAR NO-UNDO.
9 DEF VAR preview
AS LOGI
NO-UNDO INIT No.
10 DEF VAR payment-style
AS CHAR NO-UNDO INIT "".
11 DEF VAR bank-account
AS CHAR NO-UNDO INIT "".
12 DEF VAR due-before
AS DATE NO-UNDO.
13 DEF VAR exporting
AS LOGI
NO-UNDO INIT No.
14 DEF VAR file-name
AS CHAR NO-UNDO INIT "".
15 DEF VAR cheque-date
AS DATE NO-UNDO.
16 DEF VAR cheque-message
AS CHAR NO-UNDO INIT "".
17 DEF VAR print-approval-page
AS LOGI
NO-UNDO INIT No.
18 DEF VAR first-cheque-no
AS INT NO-UNDO INIT ?.
19 DEF VAR enforce-cheque-limit
AS LOGI
NO-UNDO INIT No.
20 DEF VAR test-client-code
AS CHAR NO-UNDO INIT ?.
21 DEF VAR creditor-list
AS CHAR NO-UNDO INIT "".
22 DEF VAR creditor-1
AS INT NO-UNDO INIT 0.
23 DEF VAR creditor-n
AS INT NO-UNDO INIT 999999.
24 DEF VAR project-1
AS INT NO-UNDO INIT 0.
25 DEF VAR project-n
AS INT NO-UNDO INIT 999999.
26 DEF VAR account-1
AS DEC NO-UNDO INIT 0.
27 DEF VAR account-n
AS DEC NO-UNDO INIT 10000.
30 DEF VAR user-name
AS CHAR NO-UNDO.
31 {inc
/username.i
"user-name"}
32 DEF VAR timeStamp
AS CHAR FORMAT "X(44)" NO-UNDO.
33 timeStamp
= STRING( TODAY, "99/99/9999") + ", " + STRING( TIME, "HH:MM:SS") + " for " + user-name.
35 &SCOPED-DEFINE CARD-PYMT "Credit Card Payment"
37 DEF VAR pr-line
AS CHAR INIT "" NO-UNDO.
/* used everywhere to hold print line
*/
38 DEF VAR on-approval-page
AS LOGI
NO-UNDO.
40 DEF VAR title-font
AS CHAR NO-UNDO INITIAL "proportional,helv,point,12,bold".
41 DEF VAR time-font
AS CHAR NO-UNDO INITIAL "proportional,helv,point,6,normal".
42 DEF VAR break1-font
AS CHAR NO-UNDO INITIAL "proportional,helv,point,12,bold".
43 DEF VAR break2-font
AS CHAR NO-UNDO INITIAL "proportional,helv,point,8,bold".
44 DEF VAR line1-font
AS CHAR NO-UNDO INITIAL "fixed,courier,cpi,18,lpi,9,bold".
45 DEF VAR line2-font
AS CHAR NO-UNDO INITIAL "fixed,courier,cpi,18,lpi,9,normal".
46 DEF VAR amt-fmt
AS CHAR INIT "(>>,>>>,>>9.99)" NO-UNDO.
47 DEF VAR i
AS INT NO-UNDO.
49 /* ensure bank account is scoped to entire program
*/
50 FIND FIRST BankAccount
WHERE BankAccount.BankAccountCode
= bank-account
NO-LOCK NO-ERROR.
53 {inc
/ofc-acct.i
"CREDITORS" "sundry-creditors"}
54 {inc
/ofc-set.i
"Card-Payment-Creditor" "card-payment-creditor"}
56 DEF VAR pay-by-card
AS CHAR NO-UNDO INITIAL "".
58 DEF TEMP-TABLE Payment
NO-UNDO
59 FIELD CreditorCode
AS INT
60 FIELD OtherCreditorCode
AS INT
62 FIELD BankAccountCode
AS CHAR
65 FIELD PaymentStyle
AS CHAR
66 INDEX XPKPayments
IS UNIQUE PRIMARY CreditorCode PaymentStyle
67 INDEX XAK1Payments BankAccountCode ChequeNo PaymentStyle
69 INDEX XAK3Payments PaymentStyle .
71 DEF TEMP-TABLE BeingPaid
NO-UNDO
72 FIELD BankAccountCode
AS CHAR
74 FIELD PaymentStyle
AS CHAR
75 FIELD VoucherSeq
AS INT
76 FIELD CreditorCode
AS INT
77 INDEX XPKBeingPaid
IS UNIQUE PRIMARY VoucherSeq PaymentStyle
78 INDEX XAK1BeingPaid PaymentStyle .
80 DEF TEMP-TABLE PseudoCheque
NO-UNDO
81 FIELD ChequeNo
LIKE Cheque.ChequeNo
82 FIELD CreditorCode
LIKE Cheque.CreditorCode
83 FIELD PayeeName
LIKE Cheque.PayeeName
84 FIELD Amount
LIKE Cheque.Amount
85 INDEX XPKPseudo
IS UNIQUE PRIMARY ChequeNo
86 INDEX XAK1Pseudo PayeeName CreditorCode.
88 /* _UIB-CODE-BLOCK-END
*/
92 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
94 /* ******************** Preprocessor Definitions
******************** */
96 &Scoped-define PROCEDURE-TYPE Procedure
100 /* _UIB-PREPROCESSOR-BLOCK-END
*/
104 /* ************************ Function Prototypes
********************** */
106 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD check-client Procedure
107 FUNCTION check-client
RETURNS LOGICAL
108 ( INPUT et
AS CHAR, INPUT ec
AS INT ) FORWARD.
110 /* _UIB-CODE-BLOCK-END
*/
113 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD get-parent-entity Procedure
114 FUNCTION get-parent-entity
RETURNS CHARACTER
115 ( INPUT et
AS CHAR, INPUT ec
AS INT ) FORWARD.
117 /* _UIB-CODE-BLOCK-END
*/
120 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD pay-creditor Procedure
121 FUNCTION pay-creditor
RETURNS LOGICAL
122 ( INPUT creditor-code
AS INT ) FORWARD.
124 /* _UIB-CODE-BLOCK-END
*/
127 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD pay-voucher Procedure
128 FUNCTION pay-voucher
RETURNS LOGICAL
129 ( /* parameter-definitions
*/ ) FORWARD.
131 /* _UIB-CODE-BLOCK-END
*/
134 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD print-payment Procedure
135 FUNCTION print-payment
RETURNS DECIMAL
136 ( /* parameter-definitions
*/ ) FORWARD.
138 /* _UIB-CODE-BLOCK-END
*/
142 /* *********************** Procedure Settings
************************ */
144 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
145 /* Settings for
THIS-PROCEDURE
149 Add Fields to
: Neither
150 Other Settings
: CODE-ONLY
COMPILE
152 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
154 /* ************************* Create Window
************************** */
156 &ANALYZE-SUSPEND _CREATE-WINDOW
157 /* DESIGN Window definition
(used by the UIB
)
158 CREATE WINDOW Procedure
ASSIGN
161 /* END WINDOW DEFINITION
*/
167 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Procedure
168 /* ************************* Included-Libraries
*********************** */
170 {inc
/method
/m-txtrep.i
}
172 /* _UIB-CODE-BLOCK-END
*/
177 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
180 /* *************************** Main Block
*************************** */
182 OUTPUT TO VALUE( IF exporting
THEN file-name
ELSE txtrep-print-file
) KEEP-MESSAGES PAGE-SIZE 0.
183 RUN pclrep-start
( preview
OR exporting
,
184 "reset,portrait,tm,2,a4,lm,6," + line1-font
).
186 IF print-approval-page
THEN RUN approval-page.
187 RUN build-payment-info.
188 RUN imitate-cheque-run.
189 RUN print-payment-summary.
194 MESSAGE "Export Complete" VIEW-AS ALERT-BOX INFORMATION TITLE "Finished".
198 /* _UIB-CODE-BLOCK-END
*/
202 /* ********************** Internal Procedures
*********************** */
204 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE approval-page Procedure
205 PROCEDURE approval-page
:
206 /*------------------------------------------------------------------------------
208 ------------------------------------------------------------------------------*/
209 on-approval-page
= Yes.
210 RUN pclrep-down-by
(4).
211 RUN pclrep-line
( title-font
+ ",point,18", "Cheque Authorisation" ).
212 RUN pclrep-line
( line1-font
+ ",cpi,8,lpi,4", " ").
213 RUN pclrep-down-by
(8).
214 RUN pclrep-line
( title-font
+ ",point,15,lpi,4", "Documentation correct:" ).
215 RUN pclrep-down-by
(4).
216 RUN pclrep-line
( line1-font
+ ",cpi,8,lpi,4", "_________________________________ ___ /___ /____").
217 RUN pclrep-down-by
(8).
218 RUN pclrep-line
( title-font
+ ",point,15,lpi,4", "Cheques approved for signature:" ).
219 RUN pclrep-down-by
(4).
220 RUN pclrep-line
( line1-font
+ ",cpi,8,lpi,4", "_________________________________ ___ /___ /____").
221 RUN pclrep-page-break.
223 on-approval-page
= No.
226 /* _UIB-CODE-BLOCK-END
*/
230 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE build-card-payment Procedure
231 PROCEDURE build-card-payment
:
232 /*------------------------------------------------------------------------------
234 ------------------------------------------------------------------------------*/
235 DEF BUFFER CardPayment
FOR Payment.
236 DEF BUFFER CardVchrPaid
FOR BeingPaid.
238 DEF VAR card-creditor
AS INT NO-UNDO.
240 IF NOT CAN-FIND( FIRST Payment
WHERE Payment.PaymentStyle
= "CARD") THEN RETURN.
241 ASSIGN card-creditor
= INT(card-payment-creditor
) NO-ERROR.
242 IF ERROR-STATUS:ERROR THEN DO:
243 MESSAGE "The Office Setting 'Card-Payment-Creditor' needs" SKIP
244 "to be set to a Creditor Code before the 'CARD'" SKIP
245 "payment style can be used."
246 VIEW-AS ALERT-BOX ERROR
247 TITLE "Card-Payment-Creditor not set".
251 FOR EACH Payment
WHERE Payment.PaymentStyle
= "CARD":
252 FIND CardPayment
WHERE CardPayment.CreditorCode
= card-creditor
253 AND CardPayment.PaymentStyle
= {&CARD-PYMT}
255 IF NOT AVAILABLE(CardPayment
) THEN DO:
257 CardPayment.CreditorCode
= card-creditor.
258 CardPayment.PaymentStyle
= {&CARD-PYMT}.
261 /* re-assign the vouchers as being paid by the credit card
*/
262 FOR EACH BeingPaid
OF Payment
:
264 BUFFER-COPY BeingPaid
TO CardVchrPaid
ASSIGN
265 CardVchrPaid.CreditorCode
= CardPayment.CreditorCode
266 CardVchrPaid.PaymentStyle
= CardPayment.PaymentStyle.
273 /* _UIB-CODE-BLOCK-END
*/
277 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE build-payment-info Procedure
278 PROCEDURE build-payment-info
:
279 /*------------------------------------------------------------------------------
281 ------------------------------------------------------------------------------*/
282 /* Find all of the vouchers which we want to pay
*/
283 FOR EACH Voucher
WHERE Voucher.VoucherStatus
= "A" NO-LOCK:
284 IF NOT( pay-voucher
()) THEN NEXT.
285 FIND Payment
WHERE Payment.CreditorCode
= Voucher.CreditorCode
286 AND Payment.PaymentStyle
= Voucher.PaymentStyle
288 IF NOT AVAILABLE(Payment
) THEN DO:
289 FIND Creditor
OF Voucher
NO-LOCK.
291 Payment.CreditorCode
= Voucher.CreditorCode.
292 Payment.PaymentStyle
= Voucher.PaymentStyle.
294 Payment.Name
= Creditor.PayeeName.
297 BeingPaid.CreditorCode
= Voucher.CreditorCode.
298 BeingPaid.PaymentStyle
= Voucher.PaymentStyle.
299 BeingPaid.VoucherSeq
= Voucher.VoucherSeq.
300 Payment.Amount
= Payment.Amount
+ Voucher.GoodsValue
+ Voucher.TaxValue .
303 /* Remove all the creditors we don't want to pay from the process
*/
305 IF Payment.Amount
> 0 AND pay-creditor
( Payment.CreditorCode
) THEN NEXT.
306 FOR EACH BeingPaid
WHERE BeingPaid.CreditorCode
= Payment.CreditorCode
:
312 /* if there are any credit card payments
, build up the payment for that
*/
313 IF CAN-FIND( FIRST Payment
WHERE Payment.PaymentStyle
= "CARD") THEN DO:
314 RUN build-card-payment.
315 IF RETURN-VALUE <> "" THEN RETURN RETURN-VALUE.
320 /* _UIB-CODE-BLOCK-END
*/
324 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE imitate-card-transfer Procedure
325 PROCEDURE imitate-card-transfer
:
326 /*------------------------------------------------------------------------------
328 ------------------------------------------------------------------------------*/
329 DEF VAR cheque-total
AS DEC NO-UNDO.
330 DEF VAR i
AS INT NO-UNDO.
332 FIND Creditor
WHERE Creditor.CreditorCode
= Payment.CreditorCode
NO-LOCK.
334 FOR EACH BeingPaid
OF Payment
,
335 FIRST Voucher
WHERE Voucher.VoucherSeq
= BeingPaid.VoucherSeq
NO-LOCK:
336 cheque-total
= cheque-total
+ Voucher.GoodsValue
+ Voucher.TaxValue.
337 BeingPaid.ChequeNo
= PseudoCheque.ChequeNo.
342 /* _UIB-CODE-BLOCK-END
*/
346 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE imitate-cheque-run Procedure
347 PROCEDURE imitate-cheque-run
:
348 /*------------------------------------------------------------------------------
350 ------------------------------------------------------------------------------*/
352 FOR EACH Payment
WHERE Payment.PaymentStyle
<> "CARD" BY Payment.Name
:
356 FIND Payment
WHERE Payment.PaymentStyle
= {&CARD-PYMT} NO-ERROR.
357 IF AVAILABLE(Payment
) THEN DO:
358 FIND PseudoCheque
OF Payment.
359 FOR EACH Payment
WHERE Payment.PaymentStyle
= "CARD" BY Payment.Name
:
360 RUN imitate-card-transfer.
366 /* _UIB-CODE-BLOCK-END
*/
370 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE imitate-payment Procedure
371 PROCEDURE imitate-payment
:
372 /*------------------------------------------------------------------------------
374 ------------------------------------------------------------------------------*/
375 DEF VAR cheque-total
AS DEC NO-UNDO.
376 DEF VAR i
AS INT NO-UNDO.
378 DEF BUFFER PCheque
FOR PseudoCheque.
380 FIND Creditor
WHERE Creditor.CreditorCode
= Payment.CreditorCode
NO-LOCK.
381 FIND LAST PCheque
NO-ERROR.
384 ASSIGN PseudoCheque.CreditorCode
= Creditor.CreditorCode
385 PseudoCheque.PayeeName
= Creditor.PayeeName
386 PseudoCheque.ChequeNo
= 1 + (IF AVAILABLE(PCheque
) THEN PCheque.ChequeNo
ELSE 0).
389 FOR EACH BeingPaid
OF Payment
,
390 FIRST Voucher
WHERE Voucher.VoucherSeq
= BeingPaid.VoucherSeq
NO-LOCK:
391 cheque-total
= cheque-total
+ Voucher.GoodsValue
+ Voucher.TaxValue.
392 BeingPaid.ChequeNo
= PseudoCheque.ChequeNo.
395 PseudoCheque.Amount
= cheque-total.
396 Payment.ChequeNo
= PseudoCheque.ChequeNo.
400 /* _UIB-CODE-BLOCK-END
*/
404 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-page-footer Procedure
405 PROCEDURE inst-page-footer
:
406 /*------------------------------------------------------------------------------
408 ------------------------------------------------------------------------------*/
412 /* _UIB-CODE-BLOCK-END
*/
416 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-page-header Procedure
417 PROCEDURE inst-page-header
:
418 /*------------------------------------------------------------------------------
420 ------------------------------------------------------------------------------*/
421 IF on-approval-page
THEN RETURN.
424 IF NOT exporting
THEN DO:
425 pr-line
= pr-line
+ CHR(13) + SPC
(275) + "Page: " + STRING( pclrep-page-number
).
427 RUN pclrep-line
( time-font
, pr-line
).
429 RUN pclrep-line
( ?
, "").
430 RUN pclrep-line
( ?
, "").
431 IF test-client-code
= ?
THEN
432 RUN pclrep-line
( title-font
, SPC
(45) + "Vouchers Approved for Payment" ).
434 RUN pclrep-line
( title-font
, SPC
(40) + "Vouchers Approved for Payment - " + test-client-code
).
435 RUN pclrep-line
( time-font
, "").
436 RUN pclrep-line
( time-font
, "").
441 /* _UIB-CODE-BLOCK-END
*/
445 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE parse-parameters Procedure
446 PROCEDURE parse-parameters
:
447 /*------------------------------------------------------------------------------
449 ------------------------------------------------------------------------------*/
450 DEF VAR token
AS CHAR NO-UNDO.
451 DEF VAR i
AS INT NO-UNDO.
453 {inc
/showopts.i
"report-options"}
455 DO i
= 1 TO NUM-ENTRIES( report-options
, "~n" ):
456 token
= ENTRY( i
, report-options
, "~n" ).
458 CASE ENTRY( 1, token
):
459 WHEN "Preview" THEN preview
= Yes.
460 WHEN "EnforceLimit" THEN enforce-cheque-limit
= Yes.
461 WHEN "ApprovalPage" THEN print-approval-page
= Yes.
462 WHEN "PaymentStyle" THEN payment-style
= ENTRY(2,token
).
463 WHEN "DueBefore" THEN due-before
= DATE(ENTRY(2,token
)).
464 WHEN "OneClient" THEN test-client-code
= ENTRY(2,token
).
465 WHEN "CreditorList" THEN creditor-list
= SUBSTRING( token
, INDEX(token
,",") + 1).
467 WHEN "Message" THEN cheque-message
= SUBSTRING( token
, INDEX(token
,",") + 1).
469 WHEN "CreditorRange" THEN ASSIGN
470 creditor-1
= INT(ENTRY(2,token
))
471 creditor-n
= INT(ENTRY(3,token
)).
473 WHEN "ProjectRange" THEN ASSIGN
474 project-1
= INT(ENTRY(2,token
))
475 project-n
= INT(ENTRY(3,token
)).
477 WHEN "AccountRange" THEN ASSIGN
478 account-1
= INT(ENTRY(2,token
))
479 account-n
= INT(ENTRY(3,token
)).
486 DO i
= 1 TO NUM-ENTRIES(creditor-list
):
487 ENTRY(i
,creditor-list
) = STRING(INT(ENTRY(i
,creditor-list
))).
492 /* _UIB-CODE-BLOCK-END
*/
496 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-payment-summary Procedure
497 PROCEDURE print-payment-summary
:
498 /*------------------------------------------------------------------------------
500 ------------------------------------------------------------------------------*/
501 DEF VAR line
AS CHAR NO-UNDO.
502 DEF VAR payment-total
AS DEC NO-UNDO.
504 FOR EACH Payment
WHERE Payment.PaymentStyle
<> {&CARD-PYMT}
505 AND Payment.PaymentStyle
<> "CARD"
507 payment-total
= payment-total
+ print-payment
().
509 FOR EACH Payment
WHERE Payment.PaymentStyle
= {&CARD-PYMT}
511 payment-total
= payment-total
+ print-payment
().
513 line
= SPC
(90) + "==============".
514 RUN pclrep-line
( line2-font
, line
).
515 line
= STRING( "Total cost of approved vouchers", "X(90)") + STRING( payment-total
, ">>>,>>>,>>9.99CR" ).
516 RUN pclrep-line
( line2-font
, line
).
517 RUN pclrep-down-by
( 2 ).
519 IF CAN-FIND( FIRST Payment
WHERE Payment.PaymentStyle
= "CARD") THEN DO:
521 FOR EACH Payment
WHERE Payment.PaymentStyle
= "CARD"
523 payment-total
= payment-total
+ print-payment
().
525 line
= SPC
(90) + "==============".
526 RUN pclrep-line
( line2-font
, line
).
527 line
= STRING( "Total of transfers to credit card", "X(90)") + STRING( payment-total
, ">>>,>>>,>>9.99CR" ).
528 RUN pclrep-line
( line2-font
, line
).
533 /* _UIB-CODE-BLOCK-END
*/
537 /* ************************ Function Implementations
***************** */
539 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION check-client Procedure
540 FUNCTION check-client
RETURNS LOGICAL
541 ( INPUT et
AS CHAR, INPUT ec
AS INT ) :
542 /*------------------------------------------------------------------------------
543 Purpose
: Decide whether this cheque run is for the client who receives
544 expenses for this entity type
/ entity code.
545 ------------------------------------------------------------------------------*/
546 DEF VAR entity-code
AS CHAR NO-UNDO.
547 DEF VAR result
AS LOGI
NO-UNDO.
549 IF test-client-code
= ?
THEN RETURN Yes.
552 entity-code
= get-parent-entity
( et
, ec
).
553 et
= SUBSTRING( entity-code
, 1, 1).
554 ec
= INT( SUBSTRING( entity-code
, 2) ).
557 FIND Company
WHERE Company.CompanyCode
= ec
NO-LOCK NO-ERROR.
558 result
= (Company.ClientCode
= test-client-code
).
564 /* _UIB-CODE-BLOCK-END
*/
568 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION get-parent-entity Procedure
569 FUNCTION get-parent-entity
RETURNS CHARACTER
570 ( INPUT et
AS CHAR, INPUT ec
AS INT ) :
571 /*------------------------------------------------------------------------------
574 ------------------------------------------------------------------------------*/
575 DEF VAR parent-entity
AS CHAR NO-UNDO.
579 FIND Project
WHERE Project.ProjectCode
= ec
NO-LOCK NO-ERROR.
580 parent-entity
= Project.EntityType
+ STRING( Project.EntityCode
, "99999").
583 FIND Property
WHERE Property.PropertyCode
= ec
NO-LOCK NO-ERROR.
584 parent-entity
= "L" + STRING( Property.CompanyCode
, "99999").
587 FIND Tenant
WHERE Tenant.TenantCode
= ec
NO-LOCK NO-ERROR.
588 parent-entity
= Tenant.EntityType
+ STRING( Tenant.EntityCode
, "99999").
591 FIND Creditor
WHERE Creditor.CreditorCode
= ec
NO-LOCK NO-ERROR.
592 parent-entity
= "L" + STRING( Creditor.CompanyCode
, "99999").
596 RETURN parent-entity.
600 /* _UIB-CODE-BLOCK-END
*/
604 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION pay-creditor Procedure
605 FUNCTION pay-creditor
RETURNS LOGICAL
606 ( INPUT creditor-code
AS INT ) :
607 /*------------------------------------------------------------------------------
608 Purpose
: Decide whether we pay a particular creditor this time
610 ------------------------------------------------------------------------------*/
611 DEF BUFFER RecentCheque
FOR Cheque.
612 DEF BUFFER ThisCreditor
FOR Creditor.
614 DEF VAR cheque-days
AS DEC NO-UNDO.
616 IF creditor-code
< creditor-1
THEN RETURN No.
617 IF creditor-code
> creditor-n
THEN RETURN No.
619 IF TRIM(creditor-list
) <> "" AND LOOKUP(STRING(creditor-code
), creditor-list
) = 0 THEN RETURN No.
621 IF enforce-cheque-limit
THEN DO:
622 FIND LAST RecentCheque
WHERE RecentCheque.CreditorCode
= creditor-code
NO-LOCK NO-ERROR.
623 IF AVAILABLE(RecentCheque
) THEN DO:
624 FIND ThisCreditor
OF RecentCheque
NO-LOCK NO-ERROR.
625 IF AVAILABLE(ThisCreditor
) THEN DO:
626 cheque-days
= ThisCreditor.ChequesPerMonth
/ 30.
627 IF (cheque-date
- RecentCheque.Date
) < INT(cheque-days
) THEN RETURN No.
636 /* _UIB-CODE-BLOCK-END
*/
640 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION pay-voucher Procedure
641 FUNCTION pay-voucher
RETURNS LOGICAL
642 ( /* parameter-definitions
*/ ) :
643 /*------------------------------------------------------------------------------
644 Purpose
: Decide if an approved voucher should be paid in this cheque run
646 ------------------------------------------------------------------------------*/
647 IF Voucher.EntityType
= "J" THEN DO:
648 IF Voucher.EntityCode
< project-1
THEN RETURN No.
649 IF Voucher.EntityCode
> project-n
THEN RETURN No.
652 IF Voucher.AccountCode
< account-1
THEN RETURN No.
653 IF Voucher.AccountCode
> account-n
THEN RETURN No.
655 IF Voucher.DateDue
> due-before
AND Voucher.GoodsValue
> 0.0 THEN RETURN No.
657 IF payment-style
<> "" AND Voucher.PaymentStyle
<> payment-style
THEN RETURN No.
659 IF test-client-code
<> ?
THEN
660 RETURN check-client
( Voucher.EntityType
, Voucher.EntityCode
).
666 /* _UIB-CODE-BLOCK-END
*/
670 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION print-payment Procedure
671 FUNCTION print-payment
RETURNS DECIMAL
672 ( /* parameter-definitions
*/ ) :
673 /*------------------------------------------------------------------------------
676 ------------------------------------------------------------------------------*/
677 DEF VAR line
AS CHAR NO-UNDO.
678 DEF VAR cheque-total
AS DEC NO-UNDO.
680 FIND FIRST Creditor
WHERE Creditor.CreditorCode
= Payment.CreditorCode
NO-LOCK NO-ERROR.
681 IF Payment.PaymentStyle
= "CARD" THEN
682 line
= "Xfer to card ".
684 line
= "Payment " + STRING( Payment.ChequeNo
, ">999999").
686 line
= line
+ " C" + STRING( Creditor.CreditorCode
, "99999") + " "
689 IF Payment.PaymentStyle
<> "CARD" AND Payment.PaymentStyle
<> "CHEQ" THEN DO:
690 FIND PaymentStyle
OF Payment
NO-LOCK NO-ERROR.
691 line
= STRING( line
, "X(70)") + (IF AVAILABLE(PaymentStyle
) THEN PaymentStyle.Description
ELSE Payment.PaymentStyle
).
693 RUN pclrep-line
( line1-font
, line
).
696 FOR EACH BeingPaid
OF Payment
, FIRST Voucher
WHERE Voucher.VoucherSeq
= BeingPaid.VoucherSeq
NO-LOCK:
697 line
= SPC
(9) + "Voucher" + STRING( Voucher.VoucherSeq
, ">>>>>>9") + ", "
698 + STRING( Voucher.Date
, "99/99/9999" ) + " "
699 + STRING( Voucher.Description
, "X(50)" ) + " "
700 + STRING( Voucher.TaxValue
+ Voucher.GoodsValue
, ">>>,>>>,>>9.99CR" ).
701 cheque-total
= cheque-total
+ Voucher.TaxValue
+ Voucher.GoodsValue .
702 RUN pclrep-line
( line2-font
, line
).
704 line
= SPC
(90) + "--------------".
705 RUN pclrep-line
( line2-font
, line
).
706 line
= SPC
(90) + STRING( cheque-total
, ">>>,>>>,>>9.99CR" ).
707 RUN pclrep-line
( line2-font
, line
).
708 RUN pclrep-line
( ?
, ?
).
714 /* _UIB-CODE-BLOCK-END
*/