1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*--------------------------------------------------------------------------
6 Purpose
: Transactions by Creditor report
7 Author
(s
) : Andrew McMillan
8 ------------------------------------------------------------------------*/
9 DEF INPUT PARAMETER report-options
AS CHAR NO-UNDO.
11 DEF VAR creditor-1
LIKE AcctTran.EntityCode
NO-UNDO.
12 DEF VAR creditor-2
LIKE AcctTran.EntityCode
NO-UNDO.
13 DEF VAR month-1
AS INTEGER FORMAT "9999" NO-UNDO.
14 DEF VAR month-2
AS INTEGER FORMAT "9999" NO-UNDO.
15 DEF VAR show-all
AS LOGICAL NO-UNDO.
16 DEF VAR sort-entity-type
LIKE AcctTran.EntityType
NO-UNDO.
17 DEF VAR account-selection-type
AS CHAR NO-UNDO INITIAL "1".
18 DEF VAR entity-1
LIKE AcctTran.EntityCode
NO-UNDO.
19 DEF VAR entity-2
LIKE AcctTran.EntityCode
NO-UNDO.
20 DEF VAR preview
AS LOGICAL NO-UNDO.
21 DEF VAR export-fname
AS CHAR NO-UNDO.
22 DEF VAR show-month-totals
AS LOGICAL INITIAL no
NO-UNDO.
23 DEF VAR file-name
AS CHAR NO-UNDO.
24 DEF VAR base-entity-type
AS CHAR INITIAL "C" NO-UNDO.
/* The basic entity we deal with
*/
27 DEF VAR prt-ctrl
AS CHAR NO-UNDO.
28 DEF VAR rows
AS INT NO-UNDO.
29 DEF VAR cols
AS INT NO-UNDO.
30 DEF VAR need-creditor-header
AS LOGI
NO-UNDO.
31 DEF VAR need-account-header
AS LOGI
NO-UNDO.
32 DEF VAR line
AS CHAR NO-UNDO.
34 DEF VAR fixed-font
AS CHAR NO-UNDO INITIAL "courier,fixed,cpi,18,lpi,9".
35 DEF VAR header-font
AS CHAR NO-UNDO INITIAL "univers,proportional,point,13,bold".
36 DEF VAR entity-header-font
AS CHAR NO-UNDO INITIAL "univers,proportional,point,14,bold,lpi,5".
37 DEF VAR creditor-header-font
AS CHAR NO-UNDO INITIAL "univers,proportional,point,12,bold,lpi,6".
38 DEF VAR account-header-font
AS CHAR NO-UNDO INITIAL "univers,proportional,point,11,normal,lpi,7".
40 DEF VAR user-name
AS CHAR NO-UNDO.
41 {inc
/username.i
"user-name"}
42 DEF VAR timeStamp
AS CHAR FORMAT "X(54)" NO-UNDO.
43 DEF VAR dispReference
AS CHARACTER COLUMN-LABEL "Reference" FORMAT "x(13)" NO-UNDO.
44 DEF VAR dispDescription
AS CHARACTER NO-UNDO.
45 DEF VAR dispAmount
AS CHARACTER FORMAT "X(16)" NO-UNDO.
46 DEF VAR dispName
AS CHARACTER FORMAT "X(50)" NO-UNDO.
47 DEF VAR tr-this-month
AS LOGICAL NO-UNDO.
49 DEF VAR money-format
AS CHAR NO-UNDO INITIAL ">>>,>>>,>>9.99CR".
50 DEF VAR creditor-total
LIKE AcctTran.Amount
NO-UNDO.
51 DEF VAR grand-total
LIKE AcctTran.Amount
INITIAL 0 NO-UNDO.
53 DEF VAR report-time
AS INTEGER NO-UNDO.
54 ASSIGN report-time
= TIME.
57 {inc
/ofc-acct.i
"CREDITORS" "sundry-creditors"}
58 {inc
/ofc-set-l.i
"CredTrxRep-Incld-Vouchers" "include-vouchers"}
59 {inc
/ofc-set-l.i
"CredTrxRep-Xcld-OBal" "exclude-OBal"}
60 {inc
/ofc-set-l.i
"Multi-Ledger-Creditors" "multi-ledger-creditors"}
62 /*** Get the report parameters from the user.
***/
63 DEF VAR m1-start
AS DATE NO-UNDO.
64 DEF VAR m2-end
AS DATE NO-UNDO.
66 FIND Month
WHERE Month.MonthCode
= month-1
NO-LOCK.
67 m1-start
= Month.StartDate.
69 FIND Month
WHERE Month.MonthCode
= month-2
NO-LOCK.
70 m2-end
= Month.EndDate.
72 &SCOPED-DEFINE page-width 126
73 timeStamp
= "Printed " + STRING( TODAY, "99/99/9999") + ", " + STRING( TIME, "HH:MM:SS") + " for " + user-name.
74 DEF VAR hline2
AS CHAR FORMAT "X({&page-width})" NO-UNDO.
75 DEF VAR hline3
AS CHAR FORMAT "X({&page-width})" NO-UNDO.
76 hline2
= "Transactions for Creditor " + STRING(creditor-1
,"99999") +
77 " to " + STRING(creditor-2
,"99999") +
78 ", from " + STRING( m1-start
, "99/99/9999") +
79 " to " + STRING( m2-end
, "99/99/9999").
80 hline2
= SUBSTRING( STRING("","X({&page-width})"), 1, INTEGER(({&page-width} - LENGTH(hline2) ) / 2)) + hline2.
82 IF entity-1
> 0 OR entity-2
< 99999 THEN DO:
83 hline3
= ( IF sort-entity-type
= "P" THEN "Properties" ELSE "Companies" ) +
84 STRING(entity-1
, ">>999") +
85 " to" + STRING(entity-2
, ">>999").
86 hline3
= SUBSTRING( STRING("","X({&page-width})"), 1, INTEGER(({&page-width} - LENGTH(hline3) ) / 2)) + hline3.
91 /* define all the frames for the report
*/
92 &SCOPED-DEFINE with-clause NO-BOX USE-TEXT NO-LABELS WIDTH {&page-width}
94 DEFINE FRAME default-frame
WITH DOWN {&with-clause}.
96 DEFINE FRAME heading-frame
WITH 1 DOWN {&with-clause} PAGE-TOP.
98 timeStamp
"Page " + STRING( PAGE-NUMBER ) TO {&page-width} SKIP (1)
99 hline2
FORMAT "X({&page-width})"
100 hline3
FORMAT "X({&page-width})"
101 SKIP (2) " Date Reference Amount Description Entity Account Batch Doc"
102 WITH FRAME heading-frame.
104 DEFINE FRAME total-frame-1
WITH DOWN {&with-clause}.
110 WITH FRAME total-frame-1.
112 DEFINE FRAME report-frame-1
WITH DOWN {&with-clause}.
115 Creditor.CreditorCode
116 Creditor.Name
COLUMN-LABEL "Name" FORMAT "X(50)"
117 WITH FRAME report-frame-1.
120 DEFINE FRAME report-frame-2
WITH DOWN {&with-clause}.
123 AcctTran.Date
COLUMN-LABEL "Date" FORMAT "99/99/9999"
125 AcctTran.Amount
COLUMN-LABEL "Amount" FORMAT ">>>,>>>,>>9.99CR"
126 dispDescription
COLUMN-LABEL "Description" FORMAT "X(50)"
128 AcctTran.EntityCode
COLUMN-LABEL "Entity Code"
129 AcctTran.AccountCode
COLUMN-LABEL "Account"
130 AcctTran.BatchCode
COLUMN-LABEL "Batch"
131 AcctTran.DocumentCode
COLUMN-LABEL "Doc"
132 WITH FRAME report-frame-2.
134 /* _UIB-CODE-BLOCK-END
*/
138 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
140 /* ******************** Preprocessor Definitions
******************** */
142 &Scoped-define PROCEDURE-TYPE Procedure
143 &Scoped-define DB-AWARE no
147 /* _UIB-PREPROCESSOR-BLOCK-END
*/
151 /* ************************ Function Prototypes
********************** */
153 &IF DEFINED(EXCLUDE-time-stamp) = 0 &THEN
155 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD time-stamp Procedure
156 FUNCTION time-stamp
RETURNS CHARACTER
157 ( cc
AS INT, txt
AS CHAR ) FORWARD.
159 /* _UIB-CODE-BLOCK-END
*/
165 /* *********************** Procedure Settings
************************ */
167 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
168 /* Settings for
THIS-PROCEDURE
172 Add Fields to
: Neither
173 Other Settings
: CODE-ONLY
COMPILE
175 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
177 /* ************************* Create Window
************************** */
179 &ANALYZE-SUSPEND _CREATE-WINDOW
180 /* DESIGN Window definition
(used by the UIB
)
181 CREATE WINDOW Procedure
ASSIGN
184 /* END WINDOW DEFINITION
*/
188 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Procedure
189 /* ************************* Included-Libraries
*********************** */
191 {inc
/method
/m-txtrep.i
}
193 /* _UIB-CODE-BLOCK-END
*/
200 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
203 /* *************************** Main Block
*************************** */
204 IF export-fname
= "" THEN DO:
205 RUN make-control-string
( "PCL", "reset,portrait,tm,2,a4,lm,6,courier,cpi,18,lpi,9",
206 OUTPUT prt-ctrl
, OUTPUT rows
, OUTPUT cols
).
208 RUN output-control-file
( prt-ctrl
).
209 OUTPUT TO VALUE(txtrep-print-file
) KEEP-MESSAGES PAGE-SIZE VALUE(rows
).
211 VIEW FRAME heading-frame.
214 OUTPUT TO VALUE(export-fname
) KEEP-MESSAGES .
215 PUT UNFORMATTED '
"Batch","Doc","Trn","Type","Entity","Account","Reference","Date","Amount","Narrative","Flag","Flagged By","Month code","Closing Group","Closed State"'
SKIP .
217 IF multi-ledger-creditors
THEN DO:
218 FOR EACH Company
NO-LOCK
219 WHERE Company.CompanyCode
>= entity-1
AND Company.CompanyCode
<= entity-2
220 BY Company.CompanyCode
:
221 FOR EACH Creditor
NO-LOCK
222 WHERE Creditor.CreditorCode
>= creditor-1
AND Creditor.CreditorCode
<= creditor-2
223 AND CAN-FIND( FIRST AcctTran
WHERE EntityType
= "C" AND EntityCode
= Creditor.CreditorCode
AND AccountCode
= Company.CompanyCode
224 AND MonthCode
>= month-1
AND MonthCode
<= month-2
)
225 BY Creditor.CreditorCode
:
226 RUN each-company-creditor.
230 ELSE IF sort-entity-type
<> base-entity-type
THEN DO:
231 FOR EACH Creditor
NO-LOCK
232 WHERE Creditor.CompanyCode
>= entity-1
AND Creditor.CompanyCode
<= entity-2
233 AND Creditor.CreditorCode
>= creditor-1
AND Creditor.CreditorCode
<= creditor-2
234 BY Creditor.CompanyCode
BY Creditor.CreditorCode
:
239 FOR EACH Creditor
NO-LOCK
240 WHERE Creditor.CreditorCode
>= creditor-1
AND Creditor.CreditorCode
<= creditor-2
241 BY Creditor.CreditorCode
:
246 IF export-fname
= "" THEN DO:
248 dispName
= "Entire report".
249 RUN disp-totals
(grand-total
).
251 RUN view-output-file
( preview
).
255 MESSAGE "Export Completed" VIEW-AS ALERT-BOX INFORMATION TITLE "Finished!".
258 /* _UIB-CODE-BLOCK-END
*/
262 /* ********************** Internal Procedures
*********************** */
264 &IF DEFINED(EXCLUDE-account-header) = 0 &THEN
266 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE account-header Procedure
267 PROCEDURE account-header
:
268 /*------------------------------------------------------------------------------
270 ------------------------------------------------------------------------------*/
271 need-account-header
= No.
272 IF need-creditor-header
THEN
274 ELSE IF export-fname
= "" THEN
275 RUN pclrep-down-by
( 0.2 ).
277 IF account-selection-type
= "1" THEN RETURN.
279 line
= STRING( ChartOfAccount.AccountCode
, "9999.99") + " "
280 + ChartOfAccount.Name.
281 IF export-fname
= "" THEN DO:
282 RUN pclrep-line
( account-header-font
, line
).
283 RUN pclrep-down-by
( 0.1).
286 PUT UNFORMATTED line
SKIP.
291 /* _UIB-CODE-BLOCK-END
*/
296 &IF DEFINED(EXCLUDE-creditor-header) = 0 &THEN
298 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE creditor-header Procedure
299 PROCEDURE creditor-header
:
300 /*------------------------------------------------------------------------------
302 ------------------------------------------------------------------------------*/
304 DISPLAY Creditor.Name Creditor.CreditorCode
WITH FRAME report-frame-1.
305 need-creditor-header
= No.
309 /* _UIB-CODE-BLOCK-END
*/
314 &IF DEFINED(EXCLUDE-disp-totals) = 0 &THEN
316 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disp-totals Procedure
317 PROCEDURE disp-totals
:
318 /*------------------------------------------------------------------------------
322 ------------------------------------------------------------------------------*/
323 DEF INPUT PARAMETER disp-total
AS DECIMAL NO-UNDO.
325 IF export-fname
<> "" THEN RETURN.
327 DISPLAY " " @ dispReference
328 " ----------" @ dispAmount
330 WITH FRAME total-frame-1.
331 DOWN WITH FRAME total-frame-1.
333 "Total" @ dispReference
334 STRING( disp-total
, money-format
) @ dispAmount
335 WITH FRAME total-frame-1.
336 DOWN WITH FRAME total-frame-1.
340 /* _UIB-CODE-BLOCK-END
*/
345 &IF DEFINED(EXCLUDE-each-account) = 0 &THEN
347 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-account Procedure
348 PROCEDURE each-account
:
349 /*------------------------------------------------------------------------------
351 ------------------------------------------------------------------------------*/
352 DEF BUFFER AltTran
FOR AcctTran.
354 need-creditor-header
= Yes.
356 IF NOT( exclude-OBal
= YES ) THEN RUN show-opening-balance.
357 time-stamp
( Creditor.CreditorCode
, "G").
360 RUN each-account-all-transactions.
362 RUN each-account-open-transactions.
364 /* Move up to each creditor to include Voucher totals
365 ***********************************************************
366 IF creditor-total
<> 0 OR NOT need-creditor-header
THEN DO:
367 dispName
= Creditor.Name.
368 RUN disp-totals
( creditor-total
).
369 grand-total
= grand-total
+ creditor-total.
371 ************************************************************/
375 /* _UIB-CODE-BLOCK-END
*/
380 &IF DEFINED(EXCLUDE-each-account-all-transactions) = 0 &THEN
382 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-account-all-transactions Procedure
383 PROCEDURE each-account-all-transactions
:
384 /*------------------------------------------------------------------------------
386 ------------------------------------------------------------------------------*/
387 DEF VAR account-code
AS DEC NO-UNDO.
388 IF multi-ledger-creditors
THEN
389 account-code
= Company.CompanyCode.
391 account-code
= sundry-creditors.
393 FOR EACH AcctTran
WHERE AcctTran.EntityType
= base-entity-type
394 AND AcctTran.EntityCode
= Creditor.CreditorCode
395 AND AcctTran.AccountCode
= account-code
396 AND AcctTran.MonthCode
>= month-1
397 AND AcctTran.MonthCode
<= month-2
NO-LOCK,
398 FIRST Month
OF AcctTran
NO-LOCK,
399 FIRST Document
OF AcctTran
NO-LOCK
400 BY AcctTran.EntityType
BY AcctTran.EntityCode
BY AcctTran.AccountCode
401 BY AcctTran.MonthCode
BY AcctTran.Date
402 BY AcctTran.BatchCode
BY AcctTran.DocumentCode
BY AcctTran.TransactionCode
:
403 RUN for-each-transaction .
408 /* _UIB-CODE-BLOCK-END
*/
413 &IF DEFINED(EXCLUDE-each-account-open-transactions) = 0 &THEN
415 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-account-open-transactions Procedure
416 PROCEDURE each-account-open-transactions
:
417 /*------------------------------------------------------------------------------
419 ------------------------------------------------------------------------------*/
420 DEF BUFFER AltTran
FOR AcctTran.
421 DEF VAR account-code
AS DEC NO-UNDO.
422 IF multi-ledger-creditors
THEN
423 account-code
= Company.CompanyCode.
425 account-code
= sundry-creditors.
427 time-stamp
( Creditor.CreditorCode
, "I").
428 IF CAN-FIND( FIRST AltTran
WHERE AltTran.EntityType
= base-entity-type
429 AND AltTran.EntityCode
= Creditor.CreditorCode
430 AND AltTran.AccountCode
= account-code
431 AND AltTran.MonthCode
> month-2
432 AND AltTran.ClosedState
= "F")
434 time-stamp
( Creditor.CreditorCode
, "J").
435 FOR EACH AcctTran
WHERE AcctTran.EntityType
= base-entity-type
436 AND AcctTran.EntityCode
= Creditor.CreditorCode
437 AND AcctTran.AccountCode
= account-code
438 AND AcctTran.MonthCode
>= month-1
439 AND AcctTran.MonthCode
<= month-2
440 AND (AcctTran.CLosingGroup
= ?
441 OR AcctTran.ClosedState
= "P"
442 OR CAN-FIND(FIRST AltTran
WHERE AltTran.EntityType
= base-entity-type
443 AND AltTran.EntityCode
= Creditor.CreditorCode
444 AND AltTran.AccountCode
= account-code
445 AND AltTran.MonthCode
> month-2
446 AND AltTran.ClosingGroup
= AcctTran.ClosingGroup
447 AND AltTran.ClosedState
= "F")
449 FIRST Month
OF AcctTran
NO-LOCK,
450 FIRST Document
OF AcctTran
NO-LOCK
451 BY AcctTran.EntityType
BY AcctTran.EntityCode
BY AcctTran.AccountCode
452 BY AcctTran.MonthCode
BY AcctTran.Date
453 BY AcctTran.BatchCode
BY AcctTran.DocumentCode
BY AcctTran.TransactionCode
:
454 RUN for-each-transaction.
458 time-stamp
( Creditor.CreditorCode
, "K").
459 FOR EACH AcctTran
WHERE AcctTran.EntityType
= base-entity-type
460 AND AcctTran.EntityCode
= Creditor.CreditorCode
461 AND AcctTran.AccountCode
= account-code
462 AND AcctTran.MonthCode
>= month-1
463 AND AcctTran.MonthCode
<= month-2
464 AND (AcctTran.CLosingGroup
= ?
OR AcctTran.ClosedState
= "P")
466 FIRST Month
OF AcctTran
NO-LOCK,
467 FIRST Document
OF AcctTran
NO-LOCK
468 BY AcctTran.EntityType
BY AcctTran.EntityCode
BY AcctTran.AccountCode
469 BY AcctTran.MonthCode
BY AcctTran.Date
470 BY AcctTran.BatchCode
BY AcctTran.DocumentCode
BY AcctTran.TransactionCode
:
471 RUN for-each-transaction.
474 time-stamp
( Creditor.CreditorCode
, "L").
478 /* _UIB-CODE-BLOCK-END
*/
483 &IF DEFINED(EXCLUDE-each-company-creditor) = 0 &THEN
485 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-company-creditor Procedure
486 PROCEDURE each-company-creditor
:
487 /*------------------------------------------------------------------------------
488 Purpose
: Decide whether the company creditor has suitable transactions
490 This will only be called for multi-ledger-creditors setups where there
491 are per-company creditor account balances.
492 ------------------------------------------------------------------------------*/
493 DEF BUFFER AltTran
FOR AcctTran.
494 DEF VAR has-transactions
AS LOGI
NO-UNDO INITIAL No.
495 DEF VAR printed_trx
AS LOGI
NO-UNDO INITIAL NO.
498 has-transactions
= TRUE.
501 FIND FIRST AcctTran
WHERE AcctTran.EntityType
= "C"
502 AND AcctTran.EntityCode
= Creditor.CreditorCode
503 AND AcctTran.AccountCode
= Company.CompanyCode
504 AND AcctTran.MonthCode
<= month-2
505 AND (AcctTran.CLosingGroup
= ?
OR AcctTran.ClosedState
= "P")
507 IF AVAILABLE(AcctTran
) THEN
508 has-transactions
= Yes.
510 FIND FIRST AcctTran
WHERE AcctTran.EntityType
= "C"
511 AND AcctTran.EntityCode
= Creditor.CreditorCode
512 AND AcctTran.AccountCode
= Company.CompanyCode
513 AND AcctTran.MonthCode
> month-2
514 AND AcctTran.ClosedState
= "F"
515 AND CAN-FIND(FIRST AltTran
WHERE AltTran.EntityType
= AcctTran.EntityType
516 AND AltTran.EntityCode
= AcctTran.EntityCode
517 AND AltTran.AccountCode
= AcctTran.AccountCode
518 AND AltTran.MonthCode
<= month-2
519 AND AltTran.ClosingGroup
= AcctTran.ClosingGroup
520 AND AltTran.ClosedState
= "F")
522 IF AVAILABLE(AcctTran
) THEN has-transactions
= Yes.
526 IF has-transactions
THEN DO:
527 sundry-creditors
= Company.CompanyCode.
/* A dirty hack
! */
529 ASSIGN printed_trx
= YES.
532 IF include-vouchers
THEN DO:
533 IF CAN-FIND( FIRST Voucher
OF Creditor
534 WHERE Voucher.Date
>= m1-start
AND Voucher.Date
<= m2-end
)
537 ASSIGN printed_trx
= YES.
541 /* Print Creditor Totals
*/
542 IF printed_trx
= YES THEN DO:
543 IF creditor-total
<> 0 OR NOT need-creditor-header
THEN DO:
544 dispName
= Creditor.Name.
545 RUN disp-totals
( creditor-total
).
546 ASSIGN grand-total
= grand-total
+ creditor-total
553 /* _UIB-CODE-BLOCK-END
*/
558 &IF DEFINED(EXCLUDE-each-creditor) = 0 &THEN
560 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-creditor Procedure
561 PROCEDURE each-creditor
:
562 /*------------------------------------------------------------------------------
563 Purpose
: Decide whether the creditor has suitable transactions
564 ------------------------------------------------------------------------------*/
565 DEF BUFFER AltTran
FOR AcctTran.
566 DEF VAR has-transactions
AS LOGI
NO-UNDO INITIAL No.
567 DEF VAR printed_trx
AS LOGI
NO-UNDO INITIAL NO.
569 time-stamp
( Creditor.CreditorCode
, ?
).
572 FIND FIRST AcctTran
WHERE AcctTran.EntityType
= base-entity-type
573 AND AcctTran.EntityCode
= Creditor.CreditorCode
574 AND AcctTran.AccountCode
= sundry-creditors
575 AND AcctTran.MonthCode
<= month-2
NO-LOCK NO-ERROR.
576 has-transactions
= AVAILABLE(AcctTran
).
577 time-stamp
( Creditor.CreditorCode
, "B").
580 FIND FIRST AcctTran
WHERE AcctTran.EntityType
= base-entity-type
581 AND AcctTran.EntityCode
= Creditor.CreditorCode
582 AND AcctTran.AccountCode
= sundry-creditors
583 AND AcctTran.MonthCode
<= month-2
584 AND (AcctTran.CLosingGroup
= ?
OR AcctTran.ClosedState
= "P")
586 time-stamp
( Creditor.CreditorCode
, "C").
587 IF AVAILABLE(AcctTran
) THEN has-transactions
= Yes.
589 FIND FIRST AcctTran
WHERE AcctTran.EntityType
= base-entity-type
590 AND AcctTran.EntityCode
= Creditor.CreditorCode
591 AND AcctTran.AccountCode
= sundry-creditors
592 AND AcctTran.MonthCode
> month-2
593 AND AcctTran.ClosedState
= "F"
594 AND CAN-FIND(FIRST AltTran
WHERE AltTran.EntityType
= AcctTran.EntityType
595 AND AltTran.EntityCode
= AcctTran.EntityCode
596 AND AltTran.AccountCode
= AcctTran.AccountCode
597 AND AltTran.MonthCode
<= month-2
598 AND AltTran.ClosingGroup
= AcctTran.ClosingGroup
599 AND AltTran.ClosedState
= "F")
601 IF AVAILABLE(AcctTran
) THEN has-transactions
= Yes.
602 time-stamp
( Creditor.CreditorCode
, "D").
606 IF has-transactions
THEN DO:
608 ASSIGN printed_trx
= YES.
611 IF include-vouchers
THEN DO:
612 IF CAN-FIND( FIRST Voucher
OF Creditor
613 WHERE Voucher.Date
>= m1-start
AND Voucher.Date
<= m2-end
)
616 ASSIGN printed_trx
= YES.
620 /* Print Creditor Totals
*/
621 IF printed_trx
= YES THEN DO:
622 IF creditor-total
<> 0 OR NOT need-creditor-header
THEN DO:
623 dispName
= Creditor.Name.
624 RUN disp-totals
( creditor-total
).
625 ASSIGN grand-total
= grand-total
+ creditor-total
632 /* _UIB-CODE-BLOCK-END
*/
637 &IF DEFINED(EXCLUDE-each-voucher) = 0 &THEN
639 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-voucher Procedure
640 PROCEDURE each-voucher
:
641 /*------------------------------------------------------------------------------
642 Purpose
: Print Voucher details for each Creditor
645 ------------------------------------------------------------------------------*/
647 FOR EACH Voucher
OF Creditor
NO-LOCK
648 WHERE Voucher.Date
>= m1-start
AND Voucher.Date
<= m2-end
649 BY Voucher.VoucherSeq
:
651 IF export-fname
<> "" THEN RUN export-voucher .
654 voucher.
DATE @ AcctTran.Date
655 voucher.invoicereference @ dispReference
656 ( voucher.goodsvalue
+ voucher.taxvalue
) @ AcctTran.Amount
657 voucher.
DESCRIPTION @ dispDescription
658 voucher.EntityType @ AcctTran.EntityType
659 voucher.EntityCode @ AcctTran.EntityCode
660 voucher.AccountCode @ AcctTran.AccountCode
661 voucher.BatchCode @ AcctTran.BatchCode
662 voucher.DocumentCode @ AcctTran.DocumentCode
663 WITH FRAME report-frame-2.
665 DOWN WITH FRAME report-frame-2.
668 creditor-total
= creditor-total
+ Voucher.GoodsValue .
677 /* _UIB-CODE-BLOCK-END
*/
682 &IF DEFINED(EXCLUDE-export-transaction) = 0 &THEN
684 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE export-transaction Procedure
685 PROCEDURE export-transaction
:
686 /*------------------------------------------------------------------------------
690 ------------------------------------------------------------------------------*/
691 DEF VAR FlagBy
AS CHAR INITIAL "" NO-UNDO.
692 DEF VAR v-date
AS CHAR NO-UNDO.
694 FIND Person
WHERE Person.PersonCode
= AcctTran.FlaggedBy
NO-LOCK NO-ERROR.
695 IF AVAILABLE(Person
) THEN
696 FlagBy
= Person.FirstName
+ " " + Person.LastName.
700 ELSE v-date
= STRING(AcctTran.
DATE, "99/99/9999").
703 AcctTran.BatchCode '
,'
704 AcctTran.DocumentCode '
,'
705 AcctTran.TransactionCode '
,"'
706 AcctTran.EntityType '",'
707 AcctTran.EntityCode '
,'
708 AcctTran.AccountCode '
,"'
712 dispDescription '","'
713 AcctTran.FlagAttention '","'
715 AcctTran.MonthCode '","'
716 AcctTran.ClosingGroup '","'
717 AcctTran.ClosedState '"'
722 /* _UIB-CODE-BLOCK-END
*/
727 &IF DEFINED(EXCLUDE-export-voucher) = 0 &THEN
729 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE export-voucher Procedure
730 PROCEDURE export-voucher
:
731 /*------------------------------------------------------------------------------
735 ------------------------------------------------------------------------------*/
736 DEF VAR FlagBy
AS CHAR INITIAL "" NO-UNDO.
737 DEF VAR v-date
AS CHAR NO-UNDO.
741 ELSE v-date
= STRING(Voucher.
DATE, "99/99/9999").
744 Voucher.BatchCode '
,'
745 Voucher.DocumentCode '
,'
747 Voucher.EntityType '",'
748 Voucher.EntityCode '
,'
749 Voucher.AccountCode '
,"'
750 Voucher.InvoiceReference '","'
752 (Voucher.GoodsValue
+ Voucher.TaxValue
) '
,"'
753 Voucher.Description '","'
764 /* _UIB-CODE-BLOCK-END
*/
769 &IF DEFINED(EXCLUDE-for-each-transaction) = 0 &THEN
771 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE for-each-transaction Procedure
772 PROCEDURE for-each-transaction
:
773 /*------------------------------------------------------------------------------
775 ------------------------------------------------------------------------------*/
777 IF need-creditor-header
THEN RUN creditor-header.
779 ASSIGN dispReference
= STRING( (IF (AcctTran.Reference
= "") THEN (Document.Reference
) ELSE (AcctTran.Reference
) ), "X(12)" )
780 + ( IF AcctTran.ClosingGroup
> 0 THEN (IF AcctTran.ClosedState
= "P" THEN "P" ELSE "*") ELSE " " )
781 dispDescription
= IF (AcctTran.Description
= "") THEN (Document.Description
) ELSE (AcctTran.Description
)
782 tr-this-month
= yes .
784 IF export-fname
<> "" THEN RUN export-transaction .
795 AcctTran.DocumentCode
796 WITH FRAME report-frame-2.
798 DOWN WITH FRAME report-frame-2.
801 creditor-total
= creditor-total
+ AcctTran.Amount .
805 /* _UIB-CODE-BLOCK-END
*/
810 &IF DEFINED(EXCLUDE-parse-parameters) = 0 &THEN
812 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE parse-parameters Procedure
813 PROCEDURE parse-parameters
:
814 /*------------------------------------------------------------------------------
816 ------------------------------------------------------------------------------*/
817 /* Now detail to the complex options string
*/
818 DEF VAR i
AS INT NO-UNDO.
819 DEF VAR token
AS CHAR NO-UNDO.
821 {inc
/showopts.i
"report-options"}
823 DO i
= 1 TO NUM-ENTRIES( report-options
, "~n" ):
824 token
= ENTRY( i
, report-options
, "~n" ).
825 CASE( ENTRY( 1, token
) ):
826 WHEN "EntityType" THEN sort-entity-type
= ENTRY( 2, token
).
827 WHEN "EntityRange" THEN ASSIGN
828 entity-1
= INT( ENTRY( 2, token
))
829 entity-2
= INT( ENTRY( 3, token
)).
830 WHEN "CreditorRange" THEN ASSIGN
831 creditor-1
= INT( ENTRY( 2, token
))
832 creditor-2
= INT( ENTRY( 3, token
)).
833 WHEN "MonthRange" THEN ASSIGN
834 month-1
= INT( ENTRY( 2, token
))
835 month-2
= INT( ENTRY( 3, token
)).
837 WHEN "Export" THEN export-fname
= SUBSTRING( token
, INDEX( token
, ",") + 1 ).
839 WHEN "Preview" THEN preview
= Yes.
840 WHEN "Show-All" THEN show-all
= Yes.
845 /* _UIB-CODE-BLOCK-END
*/
850 &IF DEFINED(EXCLUDE-show-opening-balance) = 0 &THEN
852 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE show-opening-balance Procedure
853 PROCEDURE show-opening-balance
:
854 /*------------------------------------------------------------------------------
855 Purpose
: Calculate and display the opening balance
856 ------------------------------------------------------------------------------*/
857 DEF BUFFER AltTran
FOR AcctTran.
862 FOR EACH AccountBalance
NO-LOCK
863 WHERE AccountBalance.EntityType
= base-entity-type
864 AND AccountBalance.EntityCode
= Creditor.CreditorCode
865 AND AccountBalance.AccountCode
= sundry-creditors
866 AND AccountBalance.MonthCode
< month-1
:
867 creditor-total
= creditor-total
+ AccountBalance.Balance.
871 FOR EACH AcctTran
WHERE AcctTran.EntityType
= base-entity-type
872 AND AcctTran.EntityCode
= Creditor.CreditorCode
873 AND AcctTran.AccountCode
= sundry-creditors
874 AND AcctTran.MonthCode
< month-1
875 AND (AcctTran.CLosingGroup
= ?
876 OR AcctTran.ClosedState
= "P"
877 OR CAN-FIND(FIRST AltTran
WHERE AltTran.EntityType
= base-entity-type
878 AND AltTran.EntityCode
= Creditor.CreditorCode
879 AND AltTran.AccountCode
= sundry-creditors
880 AND AltTran.MonthCode
> month-2
881 AND AltTran.ClosedState
= "F")
883 creditor-total
= creditor-total
+ AcctTran.Amount.
887 IF creditor-total
<> 0 THEN DO:
888 IF need-creditor-header
THEN RUN creditor-header.
889 FIND Month
WHERE Month.MonthCode
= month-1
NO-LOCK.
891 dispReference
= "O/Bal"
892 dispDescription
= "Opening Balance"
896 IF export-fname
= "" THEN DO:
897 DISPLAY Month.StartDate @ AcctTran.Date
899 creditor-total @ AcctTran.Amount
901 WITH FRAME report-frame-2.
902 DOWN WITH FRAME report-frame-2.
903 IF show-month-totals
THEN DOWN WITH FRAME report-frame-2.
906 PUT UNFORMATTED '
,,,"'
907 base-entity-type '",' Creditor.CreditorCode '
,' sundry-creditors '
,"'
918 /* _UIB-CODE-BLOCK-END
*/
923 /* ************************ Function Implementations
***************** */
925 &IF DEFINED(EXCLUDE-time-stamp) = 0 &THEN
927 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION time-stamp Procedure
928 FUNCTION time-stamp
RETURNS CHARACTER
929 ( cc
AS INT, txt
AS CHAR ) :
930 /*------------------------------------------------------------------------------
931 Purpose
: Produce a timestamp
932 ------------------------------------------------------------------------------*/
933 DEF VAR now
AS INT NO-UNDO.
934 DEF VAR elapsed
AS DEC NO-UNDO.
935 DEF VAR msg
AS CHAR NO-UNDO.
939 elapsed
= ETIME(Yes
).
940 msg
= "Creditor " + STRING(Creditor.CreditorCode
,"99999")
941 + " " + STRING(now
,"HH:MM:SS").
943 msg
= msg
+ " " + STRING(elapsed
/ 1000, ">>>>9.999")
950 /* _UIB-CODE-BLOCK-END
*/