1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# req-088
As a user, when I'm creating, updating and deleting my buckets and pipes, I want
to see the result of the procedure,
`calculate_long_term_expected_monthly_tank_change`, described below,
prominently, so that I see a prominent number which I know summarises what the
long-term difference between what my incomings and outgoings will be in the
future if I control what I do with my money.
Source: req-085
Satisfied by: ass-009, req-089, req-090, ass-021, dml-pipe
## calculate_long_term_expected_monthly_tank_change
Explanation: the least common multiple of a day, a week, a month and a year is
28 years. This procedure works by summing what the tank draw of each pipe over
28 years would be, and then dividing by 28 x 12 to get the long-term monthly
tank draw.
1. Let `factor` be `12 x 28`, that is, `336`.
2. Let `tank_change_over_28_years` be the sum of
`calculate_tank_draw_for_pipe_over_28_years(pipe)` for each pipe, `pipe`.
3. Return `tank_change_over_28_years / factor`.
## calculate_tank_draw_for_pipe_over_28_years
Inputs:
- `pipe`: a pipe
1. If `pipe.period` is `day`, let `factor` be `(365 x 3 + 366) x 7`, that is,
`10,227`.
2. If `pipe.period` is `week`, let `factor` be `365 x 3 + 366`, that is, `1461`.
3. If `pipe.period` is `month`, let `factor` be `12 x 28`, that is, `336`.
4. If `pipe.period` is `year`, let `factor` be `28`.
5. Return `pipe.amount x factor`.
|