diff options
| author | Joe Carstairs <me@joeac.net> | 2025-07-15 22:23:18 +0100 |
|---|---|---|
| committer | Joe Carstairs <me@joeac.net> | 2025-07-15 22:23:18 +0100 |
| commit | d8945831d2cebeec98691a39ec19dac13cf0d66f (patch) | |
| tree | ab0f9179598bbdaac9170848aeddb0ec0934d205 /requirements/catalogue/req-030.md | |
| parent | 4b4621a18ff301708f98c8a6d89cb78e184ac795 (diff) | |
| parent | 376e5623ef0a202c391908a7a3093df4d804a052 (diff) | |
Merge branch 'main' of https://git.joeac.net/joeac/schist
Diffstat (limited to 'requirements/catalogue/req-030.md')
| -rw-r--r-- | requirements/catalogue/req-030.md | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/requirements/catalogue/req-030.md b/requirements/catalogue/req-030.md new file mode 100644 index 0000000..e09a281 --- /dev/null +++ b/requirements/catalogue/req-030.md @@ -0,0 +1,26 @@ +# req-030 + +Schist must implement the procedure described below as `calculate_bucket_balance`. + +## calculate_bucket_balance + +Inputs: + +- A bucket name, `name` + +1. If no bucket exists with the name, `name`, then return empty. +2. If more than one bucket exists with the name, `name`, then panic. +3. Let `bucket` be the bucket with the given name. +4. Let `cache_key = bucket.balance_cache_key`. +5. Let `is_up_to_date` be the result of the procedure, + `is_bucket_balance_up_to_date(bucket)`, as described in req-035. +6. If `is_up_to_date = TRUE`, then return `bucket.balance`. +7. Carry out the procedure, `update_bucket_drips(bucket)`, as described in + req-037. +8. Let `transaction_sum` be the sum over the property, `amount`, of all + transactions `t` such that `t.bucket_id = bucket.id`. +9. Let `drip_sum` be the sum over the property, `amount`, of all drips `d` such + that `d.bucket_id = bucket.id`. +10. Return `drip_sum - transaction_sum`. + +Source: req-029 |
