1 TRIGGER PROCEDURE FOR WRITE OF AccountBalance
2 NEW BUFFER post-write
OLD BUFFER pre-write.
4 IF AVAILABLE(post-write
) THEN DO:
6 DEF VAR d-bal
LIKE AccountBalance.Balance
INITIAL 0 NO-UNDO.
7 DEF VAR d-bud
LIKE AccountBalance.Budget
INITIAL 0 NO-UNDO.
8 DEF VAR d-rbd
LIKE AccountBalance.RevisedBudget
INITIAL 0 NO-UNDO.
10 ASSIGN d-bal
= post-write.Balance
- pre-write.Balance
11 d-bud
= post-write.Budget
- pre-write.Budget
12 d-rbd
= post-write.RevisedBudget
- pre-write.RevisedBudget .
14 /* update consequential GL budget record
*/
15 IF post-write.EntityType
<> "L" AND (d-bud
<> 0 OR d-rbd
<> 0)
16 AND post-write.MonthCode
<> ?
THEN DO:
17 DEF BUFFER cons
FOR AccountBalance.
18 CASE post-write.EntityType
:
20 FIND Property
WHERE Property.PropertyCode
= post-write.EntityCode
NO-LOCK.
21 FIND cons
WHERE cons.EntityType
= "L"
22 AND cons.EntityCode
= Property.CompanyCode
23 AND cons.AccountCode
= post-write.AccountCode
24 AND cons.MonthCode
= post-write.MonthCode
25 EXCLUSIVE-LOCK NO-ERROR.
26 IF NOT AVAILABLE(cons
) THEN DO:
28 ASSIGN cons.EntityType
= "L"
29 cons.EntityCode
= Property.CompanyCode
30 cons.AccountCode
= post-write.AccountCode
31 cons.MonthCode
= post-write.MonthCode
34 ASSIGN cons.Budget
= cons.Budget
+ d-bud
35 cons.RevisedBudget
= cons.Revised
+ d-rbd
37 ERROR-STATUS:ERROR = No.
42 /* update account summary record
*/
43 IF d-bal
<> 0 OR d-bud
<> 0 OR d-rbd
<> 0 THEN DO:
44 FIND AccountSummary
WHERE AccountSummary.Entitytype
= post-write.EntityType
45 AND AccountSummary.EntityCode
= post-write.EntityCode
46 AND AccountSummary.AccountCode
= post-write.AccountCode
47 EXCLUSIVE-LOCK NO-ERROR.
49 IF NOT AVAILABLE(AccountSummary
) THEN DO:
50 CREATE AccountSummary.
51 ASSIGN AccountSummary.Entitytype
= post-write.EntityType
52 AccountSummary.EntityCode
= post-write.EntityCode
53 AccountSummary.AccountCode
= post-write.AccountCode .
56 ASSIGN AccountSummary.Balance
= AccountSummary.Balance
+ d-bal
57 AccountSummary.Budget
= AccountSummary.Budget
+ d-bud
58 AccountSummary.RevisedBudget
= AccountSummary.Revised
+ d-rbd .
60 IF AccountSummary.Balance
= 0 AND
61 AccountSummary.Budget
= 0 AND
62 AccountSummary.RevisedBudget
= 0 THEN
63 DELETE AccountSummary.
65 ASSIGN d-bud
= d-bud
NO-ERROR.
/* clear any error status
*/