feat(domain): allocation rules become a dated series
Post.standingRule becomes Post.rules: RuleVersion[], resolved by ruleAt() as the last version effective at or before a month. Per-month overrides still win outright; a post with no applicable version allocates zero rather than applying its earliest rule backwards. allocationFor keeps its signature, so the fold, the views and the ODS export are untouched. Settings gets a read-only rule summary for now; the history editor follows.
This commit is contained in:
1 parent
c74a66aea9
commit
68712e72a3
11 files changed
+252
-151
No files matched your search
+12
-1
@@ -28,6 +28,12 @@ export type Rule =
|
||||
| { kind: "fixed"; amount: Money }
|
||||
| { kind: "percentOfIncome"; percent: number };
|
||||
|
||||
export interface RuleVersion {
|
||||
/** The rule takes effect in this month and continues until the next version. */
|
||||
from: MonthId;
|
||||
rule: Rule;
|
||||
}
|
||||
|
||||
export interface Post {
|
||||
id: PostId;
|
||||
name: string;
|
||||
@@ -35,7 +41,12 @@ export interface Post {
|
||||
archived: boolean;
|
||||
/** Display currency for this post's own views only. All totals use base. */
|
||||
currency: Currency;
|
||||
standingRule: Rule;
|
||||
/**
|
||||
* The post's allocation rule over time, sorted ascending by `from`, at most
|
||||
* one entry per month. Empty means the post has never been budgeted, and its
|
||||
* allocation is zero — not the same as a rule of zero.
|
||||
*/
|
||||
rules: RuleVersion[];
|
||||
}
|
||||
|
||||
export interface Month {
|
||||
|
||||
Reference in new issue
Block a user