mirror of
https://github.com/whekin/household-bot.git
synced 2026-03-31 11:54:03 +00:00
feat(miniapp): improve mobile billing and utility controls
This commit is contained in:
@@ -121,6 +121,14 @@ class FinanceRepositoryStub implements FinanceRepository {
|
||||
this.lastUtilityBill = input
|
||||
}
|
||||
|
||||
async updateUtilityBill() {
|
||||
return null
|
||||
}
|
||||
|
||||
async deleteUtilityBill() {
|
||||
return false
|
||||
}
|
||||
|
||||
async getRentRuleForPeriod(): Promise<FinanceRentRuleRecord | null> {
|
||||
return this.rentRule
|
||||
}
|
||||
|
||||
@@ -466,6 +466,17 @@ export interface FinanceCommandService {
|
||||
currency: CurrencyCode
|
||||
period: string
|
||||
} | null>
|
||||
updateUtilityBill(
|
||||
billId: string,
|
||||
billName: string,
|
||||
amountArg: string,
|
||||
currencyArg?: string
|
||||
): Promise<{
|
||||
billId: string
|
||||
amount: Money
|
||||
currency: CurrencyCode
|
||||
} | null>
|
||||
deleteUtilityBill(billId: string): Promise<boolean>
|
||||
generateDashboard(periodArg?: string): Promise<FinanceDashboard | null>
|
||||
generateStatement(periodArg?: string): Promise<string | null>
|
||||
}
|
||||
@@ -596,6 +607,34 @@ export function createFinanceCommandService(
|
||||
}
|
||||
},
|
||||
|
||||
async updateUtilityBill(billId, billName, amountArg, currencyArg) {
|
||||
const settings = await householdConfigurationRepository.getHouseholdBillingSettings(
|
||||
dependencies.householdId
|
||||
)
|
||||
const currency = parseCurrency(currencyArg, settings.settlementCurrency)
|
||||
const amount = Money.fromMajor(amountArg, currency)
|
||||
const updated = await repository.updateUtilityBill({
|
||||
billId,
|
||||
billName,
|
||||
amountMinor: amount.amountMinor,
|
||||
currency
|
||||
})
|
||||
|
||||
if (!updated) {
|
||||
return null
|
||||
}
|
||||
|
||||
return {
|
||||
billId: updated.id,
|
||||
amount,
|
||||
currency
|
||||
}
|
||||
},
|
||||
|
||||
deleteUtilityBill(billId) {
|
||||
return repository.deleteUtilityBill(billId)
|
||||
},
|
||||
|
||||
async generateStatement(periodArg) {
|
||||
const dashboard = await buildFinanceDashboard(dependencies, periodArg)
|
||||
if (!dashboard) {
|
||||
|
||||
Reference in New Issue
Block a user