summaryrefslogtreecommitdiff
path: root/requirements/catalogue/req-092.md
blob: 665e8d1ef07d1b75d1158a2650517d082a9738e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# req-092

As a user, when I'm creating, updating and deleting my buckets and pipes, I want
to see the result of the procedure, `calculate_tank_balance`, described below,
so that I see a prominent number which I know summarises what the difference
between my incomings and outgoings has actually been in the past, so that my
incomings and outgoings are roughly equal in the long run.

Source: req-091

Satisfied by: dml-drip, ass-009, ass-021, req-093, req-094, req-108, req-027

## calculate_tank_balance

1. Let `drip_sum` be the sum of all `drip.amount` for all drips `drip`.
2. Let `transaction_sum` be the sum of all `transaction.amount` for all
   transactions `transaction`.
3. Let `bucket_overdraw_sum` be the sum of all `bucket.balance` for all buckets
   `bucket` such that `bucket.balance < 0`.
4. Return `transaction_sum + bucket_overdraw_sum - drip_sum`.