mirror of
https://github.com/whekin/household-bot.git
synced 2026-03-31 19:14:03 +00:00
feat(WHE-18): implement money, billing period, and typed domain ids
This commit is contained in:
44
packages/domain/src/settlement-primitives.ts
Normal file
44
packages/domain/src/settlement-primitives.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import type { BillingPeriod } from './billing-period'
|
||||
import type { BillingCycleId, MemberId, PurchaseEntryId } from './ids'
|
||||
import type { Money } from './money'
|
||||
|
||||
export type UtilitySplitMode = 'equal' | 'weighted_by_days'
|
||||
|
||||
export interface SettlementMemberInput {
|
||||
memberId: MemberId
|
||||
active: boolean
|
||||
utilityDays?: number
|
||||
}
|
||||
|
||||
export interface SettlementPurchaseInput {
|
||||
purchaseId: PurchaseEntryId
|
||||
payerId: MemberId
|
||||
amount: Money
|
||||
description?: string
|
||||
}
|
||||
|
||||
export interface SettlementInput {
|
||||
cycleId: BillingCycleId
|
||||
period: BillingPeriod
|
||||
rent: Money
|
||||
utilities: Money
|
||||
utilitySplitMode: UtilitySplitMode
|
||||
members: readonly SettlementMemberInput[]
|
||||
purchases: readonly SettlementPurchaseInput[]
|
||||
}
|
||||
|
||||
export interface SettlementMemberLine {
|
||||
memberId: MemberId
|
||||
rentShare: Money
|
||||
utilityShare: Money
|
||||
purchaseOffset: Money
|
||||
netDue: Money
|
||||
explanations: readonly string[]
|
||||
}
|
||||
|
||||
export interface SettlementResult {
|
||||
cycleId: BillingCycleId
|
||||
period: BillingPeriod
|
||||
lines: readonly SettlementMemberLine[]
|
||||
totalDue: Money
|
||||
}
|
||||
Reference in New Issue
Block a user