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:
2026-03-15 01:38:54 +04:00
parent f4e5a49621
commit d0475743f8
3 changed files with 102 additions and 4 deletions

View File

@@ -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(