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.
8 DEF VAR scenario-code
LIKE Scenario.ScenarioCode
NO-UNDO.
9 DEF VAR scenario-set
AS CHAR NO-UNDO INITIAL "".
10 DEF VAR debug-mode
AS LOGI
NO-UNDO INITIAL Yes.
11 DEF VAR to-clear
AS CHAR NO-UNDO.
12 DEF VAR forecast-from
AS DATE NO-UNDO INITIAL ?.
13 DEF VAR forecast-to
AS DATE NO-UNDO INITIAL ?.
14 DEF VAR entity-t
AS CHAR NO-UNDO INITIAL "".
15 DEF VAR entity-1
AS INT NO-UNDO INITIAL 0.
16 DEF VAR entity-n
AS INT NO-UNDO INITIAL 99999.
18 IF RETURN-VALUE = "FAIL" THEN RETURN.
20 DEF VAR user-name
AS CHAR NO-UNDO.
21 {inc
/username.i
"user-name"}
23 DEF VAR m-1
AS INT NO-UNDO.
24 DEF VAR m-n
AS INT NO-UNDO.
25 DEF VAR m-budget-closed
AS INT NO-UNDO.
26 DEF VAR m-forecast-closed
AS INT NO-UNDO.
28 DEF VAR header-list
AS CHAR NO-UNDO.
29 DEF VAR bucket-months
AS CHAR NO-UNDO.
30 DEF VAR empty-buckets
AS CHAR NO-UNDO.
31 DEF VAR bucket-list
AS CHAR NO-UNDO.
32 DEF VAR delim
AS CHAR NO-UNDO INIT "|".
34 DEF VAR all-existing-amounts-cleared
AS LOGICAL NO-UNDO INITIAL No.
37 {inc
/ofc-acct.i
"CREDITORS" "sundry-creditors" "ERROR"}
38 DEF VAR creditors-ledger
AS INT NO-UNDO.
39 creditors-ledger
= OfficeControlAccount.EntityCode.
41 DEF VAR n-buckets As
INT NO-UNDO.
43 DEF TEMP-TABLE FlowBucket
NO-UNDO
44 FIELD EntityType
AS CHAR
45 FIELD EntityCode
AS INT
46 FIELD AccountCode
AS DEC
47 FIELD AmountList
AS CHAR
49 INDEX FlowBucket
IS UNIQUE PRIMARY EntityType EntityCode AccountCode.
51 DEF TEMP-TABLE Affected
NO-UNDO
52 FIELD EntityType
AS CHAR
53 FIELD EntityCode
AS INT
54 INDEX ent
IS UNIQUE PRIMARY EntityType EntityCode.
56 /* _UIB-CODE-BLOCK-END
*/
60 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
62 /* ******************** Preprocessor Definitions
******************** */
64 &Scoped-define PROCEDURE-TYPE Procedure
68 /* _UIB-PREPROCESSOR-BLOCK-END
*/
72 /* ************************ Function Prototypes
********************** */
74 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD exclude-cash-flow Procedure
75 FUNCTION exclude-cash-flow
RETURNS LOGICAL
78 /* _UIB-CODE-BLOCK-END
*/
82 /* *********************** Procedure Settings
************************ */
84 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
85 /* Settings for
THIS-PROCEDURE
89 Add Fields to
: Neither
90 Other Settings
: CODE-ONLY
COMPILE
92 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
94 /* ************************* Create Window
************************** */
96 &ANALYZE-SUSPEND _CREATE-WINDOW
97 /* DESIGN Window definition
(used by the UIB
)
98 CREATE WINDOW Procedure
ASSIGN
101 /* END WINDOW DEFINITION
*/
107 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Procedure
108 /* ************************* Included-Libraries
*********************** */
110 {inc
/method
/m-debug.i
}
114 /* _UIB-CODE-BLOCK-END
*/
119 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
122 /* *************************** Main Block
*************************** */
123 &SCOP KEEP-DEBUG-MESSAGES KEEP-MESSAGES
126 debug-event
("Starting forecast export").
127 FIND Scenario
WHERE Scenario.ScenarioCode
= scenario-code
NO-LOCK NO-ERROR.
128 IF NOT AVAILABLE(Scenario
) THEN DO:
129 MESSAGE "Scenario" scenario-code
"not found."
130 VIEW-AS ALERT-BOX ERROR TITLE "No Such Scenario".
134 /* Get the column headings
& initialize the empty buckets */
135 RUN get-forecast-period.
136 IF RETURN-VALUE = "FAIL" THEN DO:
137 debug-event
( "Problems with forecast period - bugging out" ).
142 RUN split-cash-flow
(forecast-from
, forecast-to
, "MNTH", forecast-from
, forecast-to
, "MNTH", 0, No
,
143 OUTPUT header-list
, OUTPUT empty-buckets
).
144 n-buckets
= NUM-ENTRIES(header-list
).
145 RUN get-bucket-months.
146 IF RETURN-VALUE = "FAIL" THEN DO:
151 IF scenario-set
<> "" THEN
152 RUN process-scenario-set.
156 RUN apply-to-forecasts.
158 MESSAGE "Budget/Forecast figures updated" VIEW-AS ALERT-BOX INFORMATION TITLE "Done".
160 debug-event
("Finished").
164 /* _UIB-CODE-BLOCK-END
*/
168 /* ********************** Internal Procedures
*********************** */
170 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE add-to-bucket Procedure
171 PROCEDURE add-to-bucket
:
172 /*------------------------------------------------------------------------------
176 ------------------------------------------------------------------------------*/
177 DEF INPUT PARAMETER et
AS CHAR NO-UNDO.
178 DEF INPUT PARAMETER ec
AS INT NO-UNDO.
179 DEF INPUT PARAMETER ac
AS DEC NO-UNDO.
180 DEF INPUT PARAMETER split-name
AS CHAR NO-UNDO.
181 DEF INPUT PARAMETER split-flow
AS CHAR NO-UNDO.
183 FIND FIRST FlowBucket
WHERE FlowBucket.EntityType
= et
AND FlowBucket.EntityCode
= ec
184 AND FlowBucket.AccountCode
= ac
NO-ERROR.
186 IF NOT AVAILABLE FlowBucket
THEN DO:
188 ASSIGN FlowBucket.EntityType
= et
189 FlowBucket.EntityCode
= ec
190 FlowBucket.AccountCode
= ac
191 FlowBucket.AmountList
= FILL( "0" + delim
, n-buckets
- 1) + "0".
194 /* Add the split information to the bucket
*/
195 DEF VAR i
AS INT NO-UNDO.
196 DEF VAR idx
AS INT NO-UNDO.
197 DEF VAR amt
AS DEC NO-UNDO.
198 DEF VAR n-splits
AS INT NO-UNDO.
200 n-splits
= NUM-ENTRIES(split-name
).
201 DO i
= 1 TO n-splits
:
202 idx
= LOOKUP( ENTRY(i
, split-name
), header-list
).
204 MESSAGE "Adding to bucket..." CashFlow.EntityType CashFlow.EntityCode CashFlow.AccountCode CashFlow.RelatedKey.
205 MESSAGE "Names:" split-name.
206 MESSAGE "Flows:" split-flow.
209 amt
= DEC(ENTRY(idx
, FlowBucket.AmountList
, delim
)) + DEC(ENTRY(i
, split-flow
)).
210 ENTRY(idx
, FlowBucket.AmountList
, delim
) = STRING(amt
).
216 /* _UIB-CODE-BLOCK-END
*/
220 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE apply-flows Procedure
221 PROCEDURE apply-flows
:
222 /*------------------------------------------------------------------------------
224 ------------------------------------------------------------------------------*/
225 DEF VAR amt
AS DEC NO-UNDO.
226 DEF VAR mth
AS INT NO-UNDO.
227 DEF VAR i
AS INT NO-UNDO.
229 debug-event
("Applying flow figures to forecast").
230 FOR EACH FlowBucket
NO-LOCK BREAK BY EntityType
BY EntityCode
BY AccountCode
:
231 debug-event
("Flows for: " + FlowBucket.EntityType
+ STRING(FlowBucket.EntityCode
,"99999")
232 + "-" + STRING(FlowBucket.AccountCode
,"9999.99") ).
233 DO i
= 1 TO n-buckets
:
234 amt
= DEC( ENTRY( i
, FlowBucket.AmountList
, "|" ) ).
235 IF amt
= 0 THEN NEXT.
236 mth
= INT( ENTRY( i
, bucket-months
) ).
238 FIND AccountBalance
OF FlowBucket
WHERE AccountBalance.MonthCode
= mth
EXCLUSIVE-LOCK NO-ERROR.
239 IF NOT AVAILABLE(AccountBalance
) THEN DO:
240 CREATE AccountBalance.
241 ASSIGN AccountBalance.EntityType
= FlowBucket.EntityType
242 AccountBalance.EntityCode
= FlowBucket.EntityCode
243 AccountBalance.AccountCode
= FlowBucket.AccountCode
244 AccountBalance.MonthCode
= mth
245 AccountBalance.Balance
= 0
246 AccountBalance.Budget
= 0
247 AccountBalance.RevisedBudget
= 0 .
249 RUN set-forecast
( amt
).
255 /* _UIB-CODE-BLOCK-END
*/
259 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE apply-to-forecasts Procedure
260 PROCEDURE apply-to-forecasts
:
261 /*------------------------------------------------------------------------------
263 ------------------------------------------------------------------------------*/
265 DO WHILE CAN-FIND(FIRST FlowBucket
):
268 RUN evolve-flow-consequences.
273 /* _UIB-CODE-BLOCK-END
*/
277 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE clear-accounts Procedure
278 PROCEDURE clear-accounts
:
279 /*------------------------------------------------------------------------------
281 ------------------------------------------------------------------------------*/
282 FOR EACH FlowBucket
NO-LOCK BREAK BY EntityType
BY EntityCode
BY AccountCode
:
283 /* set the balances for the account to zero
*/
284 FOR EACH AccountBalance
OF Flowbucket
WHERE AccountBalance.MonthCode
>= m-1
285 AND AccountBalance.MonthCode
<= m-n
:
286 RUN set-forecast
( 0.0 ).
289 IF FlowBucket.EntityType
= "P" THEN DO:
290 /* Set the appropriate balance for the owning ledger to
0 also
*/
291 FIND Property
WHERE Property.PropertyCode
= FlowBucket.EntityCode
NO-LOCK NO-ERROR.
292 IF AVAILABLE(Property
) THEN DO:
293 FOR EACH AccountBalance
OF Flowbucket
WHERE AccountBalance.EntityType
= "L"
294 AND AccountBalance.EntityCode
= Property.CompanyCode
295 AND AccountBalance.AccountCode
= FlowBucket.AccountCode
296 AND AccountBalance.MonthCode
>= m-1
297 AND AccountBalance.MonthCode
<= m-n
:
298 RUN set-forecast
( 0.0 ).
307 /* _UIB-CODE-BLOCK-END
*/
311 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE clear-all Procedure
312 PROCEDURE clear-all
:
313 /*------------------------------------------------------------------------------
314 Purpose
: Clear all property and gl budget
/forecast figures
315 ------------------------------------------------------------------------------*/
316 IF all-existing-amounts-cleared
THEN RETURN.
318 FOR EACH AccountBalance
WHERE AccountBalance.EntityType
= "P"
319 AND AccountBalance.MonthCode
>= m-1
320 AND AccountBalance.MonthCode
<= m-n
:
321 RUN set-forecast
( 0.0 ).
324 FOR EACH AccountBalance
WHERE AccountBalance.EntityType
= "L"
325 AND AccountBalance.MonthCode
>= m-1
326 AND AccountBalance.MonthCode
<= m-n
:
327 RUN set-forecast
( 0.0 ).
330 all-existing-amounts-cleared
= Yes.
334 /* _UIB-CODE-BLOCK-END
*/
338 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE clear-entities Procedure
339 PROCEDURE clear-entities
:
340 /*------------------------------------------------------------------------------
342 ------------------------------------------------------------------------------*/
344 FOR EACH FlowBucket
NO-LOCK BREAK BY EntityType
BY EntityCode
BY AccountCode
:
345 FIND Affected
OF FlowBucket
NO-LOCK NO-ERROR.
346 IF NOT AVAILABLE(Affected
) THEN DO:
348 Affected.EntityType
= FlowBucket.EntityType.
349 Affected.EntityCode
= FlowBucket.EntityCode.
353 IF FlowBucket.EntityType
= "P" THEN DO:
354 FIND Property
WHERE Property.PropertyCode
= FlowBucket.EntityCode
NO-LOCK NO-ERROR.
355 IF AVAILABLE(Property
) THEN DO:
356 FIND Affected
WHERE Affected.EntityType
= "L"
357 AND Affected.EntityCode
= Property.CompanyCode
NO-LOCK NO-ERROR.
358 IF NOT AVAILABLE(Affected
) THEN DO:
360 Affected.EntityType
= "L".
361 Affected.EntityCode
= Property.CompanyCode.
368 /* Now clear all accounts for each of the entities we have discovered
*/
370 FOR EACH AccountBalance
OF Affected
WHERE AccountBalance.MonthCode
>= m-1
371 AND AccountBalance.MonthCode
<= m-n
:
372 RUN set-forecast
( 0.0 ).
379 /* _UIB-CODE-BLOCK-END
*/
383 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE clear-forecasts Procedure
384 PROCEDURE clear-forecasts
:
385 /*------------------------------------------------------------------------------
387 ------------------------------------------------------------------------------*/
389 debug-event
("Clearing " + to-clear
).
391 WHEN "accounts" THEN RUN clear-accounts.
392 WHEN "entities" THEN RUN clear-entities.
393 WHEN "all" THEN RUN clear-all.
398 /* _UIB-CODE-BLOCK-END
*/
402 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE evolve-flow-consequences Procedure
403 PROCEDURE evolve-flow-consequences
:
404 /*------------------------------------------------------------------------------
406 ------------------------------------------------------------------------------*/
408 debug-event
("Evolving flow consequences from existing flows").
409 FOR EACH FlowBucket
BY ROWID(FlowBucket
):
410 CASE FlowBucket.EntityType
:
411 WHEN "T" THEN ASSIGN FlowBucket.EntityType
= "L".
412 WHEN "C" THEN ASSIGN FlowBucket.EntityType
= "L"
413 FlowBucket.EntityCode
= creditors-ledger.
414 WHEN "L" THEN DELETE FlowBucket.
417 FIND Property
NO-LOCK WHERE Property.PropertyCode
= FlowBucket.EntityCode
NO-ERROR.
418 IF AVAILABLE(Property
) THEN ASSIGN FlowBucket.EntityType
= "L"
419 FlowBucket.EntityCode
= Property.CompanyCode.
423 FIND ProjectBudget
WHERE ProjectBudget.ProjectCode
= FlowBucket.EntityCode
424 AND ProjectBudget.AccountCode
= FlowBucket.AccountCode
NO-LOCK NO-ERROR.
425 IF AVAILABLE(ProjectBudget
) THEN
426 ASSIGN FlowBucket.EntityType
= ProjectBudget.EntityType
427 FlowBucket.EntityCode
= ProjectBudget.EntityCode
428 FlowBucket.AccountCode
= ProjectBudget.EntityAccount.
431 /* Handle fixed assets when they arrive...
433 FIND FixedAsset
WHERE FixedAsset.AssetCode
= FlowBucket.EntityCode
NO-LOCK NO-ERROR.
434 IF AVAILABLE(FixedAsset
) THEN
435 ASSIGN FlowBucket.EntityType
= FixedAsset.EntityType
436 FlowBucket.EntityCode
= FixedAsset.EntityCode.
444 /* _UIB-CODE-BLOCK-END
*/
448 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE generate-flows Procedure
449 PROCEDURE generate-flows
:
450 /*------------------------------------------------------------------------------
452 ------------------------------------------------------------------------------*/
453 DEF VAR split-name
AS CHAR NO-UNDO.
454 DEF VAR split-flow
AS CHAR NO-UNDO.
455 DEF VAR i
AS INT NO-UNDO.
457 RUN get-forecast-period.
458 IF RETURN-VALUE = "FAIL" THEN RETURN.
460 FOR EACH CashFlow
OF Scenario
NO-LOCK:
461 IF exclude-cash-flow
() THEN NEXT.
463 RUN split-cash-flow
( forecast-from
, forecast-to
, "MNTH",
464 CashFlow.StartDate
, CashFlow.EndDate
, CashFlow.FrequencyCode
, CashFlow.Amount
,
465 flow-on-1st
(CashFlow.CashFlowType
, CashFlow.FrequencyCode
),
466 OUTPUT split-name
, OUTPUT split-flow
).
469 RUN dump-cash-flow
( split-name
, split-flow
, "" ).
471 RUN add-to-bucket
( CashFlow.EntityType
, CashFlow.EntityCode
, CashFlow.AccountCode
, split-name
, split-flow
).
477 /* _UIB-CODE-BLOCK-END
*/
481 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-bucket-months Procedure
482 PROCEDURE get-bucket-months
:
483 /*------------------------------------------------------------------------------
485 ------------------------------------------------------------------------------*/
486 DEF VAR i
AS INT NO-UNDO.
489 DO i
= 1 TO n-buckets
:
490 FIND Month
WHERE Month.StartDate
= start-of-bucket
(ENTRY(i
,header-list
)) NO-LOCK NO-ERROR.
491 IF NOT AVAILABLE(Month
) THEN DO:
492 debug-event
("Couldn't find Month for '" + ENTRY(i
,header-list
) + "'").
495 bucket-months
= bucket-months
+ STRING(Month.MonthCode
) + ",".
497 bucket-months
= TRIM(bucket-months
, ",").
501 /* _UIB-CODE-BLOCK-END
*/
505 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-forecast-period Procedure
506 PROCEDURE get-forecast-period
:
507 /*------------------------------------------------------------------------------
509 ------------------------------------------------------------------------------*/
513 FIND Month
WHERE Month.MonthCode
= m-1
NO-LOCK NO-ERROR.
514 IF NOT AVAILABLE(Month
) THEN DO:
515 debug-event
( "Scenario " + STRING(Scenario.ScenarioCode
)
516 + " - cannot find Month for start of forecast period" ).
517 MESSAGE "Cannot find first month of scenario period to apply forecasts"
518 VIEW-AS ALERT-BOX ERROR TITLE "Start Month not found!".
521 forecast-from
= Month.StartDate.
523 FIND Month
WHERE Month.MonthCode
= m-n
NO-LOCK NO-ERROR.
524 IF NOT AVAILABLE(Month
) THEN DO:
525 debug-event
( "Scenario " + STRING(Scenario.ScenarioCode
)
526 + " - cannot find Month for end of forecast period" ).
527 MESSAGE "Cannot find first month of scenario period to apply forecasts"
528 VIEW-AS ALERT-BOX ERROR TITLE "Start Month not found!".
531 forecast-to
= Month.EndDate.
534 {inc
/ofc-set.i
"Budget-Closed-To" "budget-closed-to" "ERROR"}
535 DEF VAR budget-closed-date
AS DATE NO-UNDO INITIAL ?.
536 ASSIGN budget-closed-date
= DATE(budget-closed-to
) NO-ERROR.
537 IF budget-closed-date
= ?
THEN DO:
538 debug-event
( "Budget-Closed-To not set to a valid date." ).
539 MESSAGE "Office Setting 'Budget-Closed-To' is not a valid date."
540 VIEW-AS ALERT-BOX ERROR TITLE "Invalid 'Budget-Closed-To' date".
544 FIND FIRST Month
WHERE Month.StartDate
> budget-closed-date
NO-LOCK NO-ERROR.
545 IF NOT AVAILABLE(Month
) THEN DO:
546 debug-event
( "Cannot find Month for budget closed date" ).
547 MESSAGE "Cannot find month for budget closed date"
548 VIEW-AS ALERT-BOX ERROR TITLE "Start Month not found!".
551 m-budget-closed
= Month.MonthCode.
553 {inc
/ofc-set.i
"Forecast-Closed-To" "forecast-closed-to" "ERROR"}
554 DEF VAR forecast-closed-date
AS DATE NO-UNDO INITIAL ?.
555 ASSIGN forecast-closed-date
= DATE(forecast-closed-to
) NO-ERROR.
556 IF forecast-closed-date
= ?
THEN DO:
557 debug-event
( "Forecast-Closed-To not set to a valid date." ).
558 MESSAGE "Office Setting 'Forecast-Closed-To' is not a valid date."
559 VIEW-AS ALERT-BOX ERROR TITLE "Invalid 'Forecast-Closed-To' date".
563 FIND FIRST Month
WHERE Month.StartDate
> forecast-closed-date
NO-LOCK NO-ERROR.
564 IF NOT AVAILABLE(Month
) THEN DO:
565 debug-event
( "Cannot find Month for forecast closed date" ).
566 MESSAGE "Cannot find month for forecast closed date"
567 VIEW-AS ALERT-BOX ERROR TITLE "Start Month not found!".
570 m-forecast-closed
= Month.MonthCode.
574 /* _UIB-CODE-BLOCK-END
*/
578 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE parse-parameters Procedure
579 PROCEDURE parse-parameters
:
580 /*------------------------------------------------------------------------------
582 ------------------------------------------------------------------------------*/
583 DEF VAR i
AS INT NO-UNDO.
584 DEF VAR token
AS CHAR NO-UNDO.
585 DEF VAR attrib-desc
AS CHAR NO-UNDO.
587 MESSAGE report-options.
589 DO i
= 1 TO NUM-ENTRIES( report-options
, "~n" ):
591 token
= ENTRY( i
, report-options
, "~n" ).
592 CASE( ENTRY( 1, token
) ):
594 WHEN "Clear" THEN to-clear
= ENTRY( 2, token
).
595 WHEN "Scenario" THEN scenario-code
= INT( ENTRY( 2, token
) ).
596 WHEN "ScenarioSet" THEN scenario-set
= SUBSTRING( token
, 13 ).
597 WHEN "Debug" THEN debug-mode
= Yes.
599 WHEN "MonthRange" THEN ASSIGN
600 m-1
= INT( ENTRY( 2, token
))
601 m-n
= INT( ENTRY( 3, token
)).
603 WHEN "EntityType" THEN entity-t
= SUBSTRING( ENTRY( 2, token
), 1, 1).
604 WHEN "EntityRange" THEN ASSIGN
605 entity-1
= INT( ENTRY( 2, token
))
606 entity-n
= INT( ENTRY( 3, token
)).
611 IF scenario-set
<> "" THEN DO:
612 FIND FIRST Scenario
WHERE CAN-FIND( ScenarioParameter
OF Scenario
613 WHERE ScenarioParameter.ParameterID
= "Member-Of"
614 AND LOOKUP( scenario-set
, ScenarioParameter.Data
) > 0 )
616 IF AVAILABLE(Scenario
) THEN
617 scenario-code
= Scenario.ScenarioCode.
619 MESSAGE "No scenarios are members of set '" + scenario-set
+ "'"
620 VIEW-AS ALERT-BOX ERROR TITLE "Set is Empty".
627 /* _UIB-CODE-BLOCK-END
*/
631 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE process-scenario-set Procedure
632 PROCEDURE process-scenario-set
:
633 /*------------------------------------------------------------------------------
637 ------------------------------------------------------------------------------*/
639 FOR EACH Scenario
WHERE CAN-FIND( ScenarioParameter
OF Scenario
640 WHERE ScenarioParameter.ParameterID
= "Member-Of"
641 AND LOOKUP( scenario-set
, ScenarioParameter.Data
) > 0 )
647 /* _UIB-CODE-BLOCK-END
*/
651 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE set-forecast Procedure
652 PROCEDURE set-forecast
:
653 /*------------------------------------------------------------------------------
654 Purpose
: Set the forecast figures and
, if applicable
, the budget figures
655 ------------------------------------------------------------------------------*/
656 DEF INPUT PARAMETER new-value
AS DEC NO-UNDO.
658 IF AccountBalance.MonthCode
>= m-forecast-closed
THEN DO:
660 AccountBalance.RevisedBudget
= new-value.
662 IF AccountBalance.MonthCode
>= m-budget-closed
THEN
663 AccountBalance.Budget
= new-value.
668 /* _UIB-CODE-BLOCK-END
*/
672 /* ************************ Function Implementations
***************** */
674 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION exclude-cash-flow Procedure
675 FUNCTION exclude-cash-flow
RETURNS LOGICAL
677 /*------------------------------------------------------------------
678 Decides whether or not to include the current the current cash flow
680 Note
: CashFlow record must be available
681 ------------------------------------------------------------------*/
683 /* exclude if outside date period
*/
684 IF CashFlow.StartDate
> forecast-to
OR CashFlow.EndDate
< forecast-from
THEN RETURN Yes.
686 /* exclude if wrong entity type
*/
687 IF entity-t
<> "" AND CashFlow.EntityType
<> entity-t
THEN DO:
688 debug-event
( "Cash flow excluded: wrong entity type '" + CashFlow.EntityType
+ "' vs '" + entity-t
+ "'").
692 /* exclude if it's outside the entity range
*/
693 IF CashFlow.EntityCode
< entity-1
OR CashFlow.EntityCode
> entity-n
THEN DO:
694 debug-event
( "Cash flow excluded: outside entity range, " + STRING(CashFlow.EntityCode
) + " vs " + STRING(entity-1
) + "-" + STRING(entity-n
)).
698 /* otherwise include it
*/
703 /* _UIB-CODE-BLOCK-END
*/