Added estimate for accounts listing browser, same as the chart of accounts. Requested
[capital-apms-progress.git] / trigger / deactbal.p
blobc30fccb281445856c74250891f0e8eb1385e64e3
1 TRIGGER PROCEDURE FOR DELETE OF AccountBalance.
3 DEF VAR d-bal LIKE AccountBalance.Balance INITIAL 0 NO-UNDO.
4 DEF VAR d-bud LIKE AccountBalance.Budget INITIAL 0 NO-UNDO.
5 DEF VAR d-rbd LIKE AccountBalance.RevisedBudget INITIAL 0 NO-UNDO.
7 ASSIGN
8 d-bal = 0 - AccountBalance.Balance
9 d-bud = 0 - AccountBalance.Budget
10 d-rbd = 0 - AccountBalance.RevisedBudget
13 /* update consequential GL budget record */
14 IF AccountBalance.EntityType <> "L" AND (d-bud <> 0 OR d-rbd <> 0) THEN DO:
15 DEF BUFFER cons FOR AccountBalance.
16 CASE AccountBalance.EntityType:
17 WHEN "P" THEN DO:
18 FIND Property WHERE Property.PropertyCode = AccountBalance.EntityCode NO-LOCK.
19 FIND cons WHERE cons.EntityType = "L"
20 AND cons.EntityCode = Property.CompanyCode
21 AND cons.AccountCode = AccountBalance.AccountCode
22 EXCLUSIVE-LOCK NO-ERROR.
23 IF NOT AVAILABLE(cons) THEN DO:
24 CREATE cons.
25 ASSIGN
26 cons.EntityType = "L"
27 cons.EntityCode = Property.CompanyCode
28 cons.AccountCode = AccountBalance.AccountCode
30 END.
31 ASSIGN
32 cons.Budget = cons.Budget + d-bud
33 cons.RevisedBudget = cons.RevisedBudget + d-rbd
36 END.
37 END CASE.
38 END.
40 /* update account summary record */
41 IF d-bal <> 0 OR d-bud <> 0 OR d-rbd <> 0 THEN DO:
42 FIND AccountSummary WHERE AccountSummary.Entitytype = AccountBalance.EntityType
43 AND AccountSummary.EntityCode = AccountBalance.EntityCode
44 AND AccountSummary.AccountCode = AccountBalance.AccountCode
45 EXCLUSIVE-LOCK NO-ERROR.
47 IF NOT AVAILABLE(AccountSummary) THEN DO:
48 CREATE AccountSummary.
49 ASSIGN
50 AccountSummary.Entitytype = AccountBalance.EntityType
51 AccountSummary.EntityCode = AccountBalance.EntityCode
52 AccountSummary.AccountCode = AccountBalance.AccountCode
54 END.
56 ASSIGN
57 AccountSummary.Balance = AccountSummary.Balance + d-bal
58 AccountSummary.Budget = AccountSummary.Budget + d-bud
59 AccountSummary.RevisedBudget = AccountSummary.Revised + d-rbd
62 IF AccountSummary.Balance = 0 AND
63 AccountSummary.Budget = 0 AND
64 AccountSummary.RevisedBudget = 0 THEN
65 DELETE AccountSummary.
67 ASSIGN d-bud = d-bud NO-ERROR. /* clear any error status */
68 END.