diff options
| author | Joe Carstairs <jcarstairs@scottlogic.com> | 2025-07-15 15:09:31 +0100 |
|---|---|---|
| committer | Joe Carstairs <jcarstairs@scottlogic.com> | 2025-07-15 15:10:04 +0100 |
| commit | 519721cd14e31fcc6998b387a27eaf3ad34d2869 (patch) | |
| tree | b47613ceced8be37c466d68a355d7eeae35b48c1 /requirements/catalogue/req-037.md | |
| parent | 136650f884576da871e48f6c1b2a927edea636d1 (diff) | |
add req-037
Diffstat (limited to 'requirements/catalogue/req-037.md')
| -rw-r--r-- | requirements/catalogue/req-037.md | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/requirements/catalogue/req-037.md b/requirements/catalogue/req-037.md new file mode 100644 index 0000000..0d27984 --- /dev/null +++ b/requirements/catalogue/req-037.md @@ -0,0 +1,48 @@ +# req-037 + +Schist must implement the procedure, described below as +`update_budget_drips_for_bucket`. + +## update_budget_drips_for_bucket + +Inputs: + +- A bucket, `bucket` + +1. For each pipe `p` such that `p.bucket_id = bucket.id`, carry out the + sub-procedure, `update_budget_drips_for_pipe(pipe)`, as described below. + +## update_budget_drips_for_pipe + +Inputs: + +- A pipe, `pipe` + +1. Let `prev_drip` be a drip `d` with a most recent value for the property + `date` such that `d.pipe_id = pipe.id` +2. For each calendar date `d` in the range `(prev_drip.date, today]`, insert + a new drip for `pipe`: + - `bucket_id`: `pipe.bucket_id` + - `pipe_id`: `pipe.id` + - `date`: `d` + - `amount`: the result of the sub-procedure, `pipe_amount_for_day(pipe, d)` + as described below + - `timestamp`: now as a Unix timestamp + +## pipe_amount_for_date + +Inputs: + +- A pipe, `pipe` +- A calendar date, `date` + +1. If `pipe.period` is `day`, return `pipe.amount`. +2. If `pipe.period` is `week`, return `pipe.amount ÷ 7`. +3. Let `days_in_month` be the number of days in the month to which `date` + belongs. +4. If `pipe.period` is `month`, return `pipe.amount ÷ days_in_month`. +5. Let `days_in_year` be the number of days in the year to which `date` belongs. +6. If `period` is not `year`, panic. +7. Return `pipe.amount ÷ days_in_year`. + +Source: req-030
\ No newline at end of file |
