mirror of
https://github.com/whekin/household-bot.git
synced 2026-04-01 07:24:02 +00:00
fix(finance): gracefully handle initial state without rent rules
Allow building the finance dashboard even if no rent rule is configured for the cycle. Defaults to 0 rent in the cycle's currency. Added regression tests in application service and miniapp dashboard handler.
This commit is contained in:
@@ -312,9 +312,8 @@ async function buildFinanceDashboard(
|
||||
throw new Error('No household members configured')
|
||||
}
|
||||
|
||||
if (!rentRule) {
|
||||
throw new Error('No rent rule configured for this cycle period')
|
||||
}
|
||||
const rentAmountMinor = rentRule?.amountMinor ?? 0n
|
||||
const rentCurrency = rentRule?.currency ?? cycle.currency
|
||||
|
||||
const period = BillingPeriod.fromString(cycle.period)
|
||||
const { start, end } = monthRange(period)
|
||||
@@ -344,7 +343,7 @@ async function buildFinanceDashboard(
|
||||
period,
|
||||
lockDay: settings.rentWarningDay,
|
||||
timezone: settings.timezone,
|
||||
amount: Money.fromMinor(rentRule.amountMinor, rentRule.currency)
|
||||
amount: Money.fromMinor(rentAmountMinor, rentCurrency)
|
||||
})
|
||||
|
||||
const convertedUtilityBills = await Promise.all(
|
||||
|
||||
Reference in New Issue
Block a user