blob: cde945e6bc13d7d32e1057d04a45c086b900bd1d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# 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, dml-transaction, dml-bucket, ass-009, ass-021, req-093, req-094
## 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`.
|