mirror of
https://github.com/whekin/household-bot.git
synced 2026-03-31 21:04:03 +00:00
feat(finance): support weighted rent split
This commit is contained in:
@@ -159,6 +159,7 @@ function createHouseholdConfigurationRepository(): HouseholdConfigurationReposit
|
||||
displayName: input.displayName,
|
||||
preferredLocale: input.preferredLocale ?? null,
|
||||
householdDefaultLocale: 'ru',
|
||||
rentShareWeight: 1,
|
||||
isAdmin: input.isAdmin === true
|
||||
}),
|
||||
getHouseholdMember: async () => null,
|
||||
@@ -171,6 +172,7 @@ function createHouseholdConfigurationRepository(): HouseholdConfigurationReposit
|
||||
displayName: 'Stan',
|
||||
preferredLocale: null,
|
||||
householdDefaultLocale: 'ru',
|
||||
rentShareWeight: 1,
|
||||
isAdmin: false
|
||||
}
|
||||
],
|
||||
@@ -191,6 +193,7 @@ function createHouseholdConfigurationRepository(): HouseholdConfigurationReposit
|
||||
displayName: 'Stan',
|
||||
preferredLocale: locale,
|
||||
householdDefaultLocale: 'ru',
|
||||
rentShareWeight: 1,
|
||||
isAdmin: false
|
||||
}),
|
||||
getHouseholdBillingSettings: async (householdId) => ({
|
||||
@@ -222,7 +225,8 @@ function createHouseholdConfigurationRepository(): HouseholdConfigurationReposit
|
||||
sortOrder: input.sortOrder,
|
||||
isActive: input.isActive
|
||||
}),
|
||||
promoteHouseholdAdmin: async () => null
|
||||
promoteHouseholdAdmin: async () => null,
|
||||
updateHouseholdMemberRentShareWeight: async () => null
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ function onboardingRepository(): HouseholdConfigurationRepository {
|
||||
displayName: string
|
||||
preferredLocale: 'en' | 'ru' | null
|
||||
householdDefaultLocale: 'en' | 'ru'
|
||||
rentShareWeight: number
|
||||
isAdmin: boolean
|
||||
}
|
||||
>()
|
||||
@@ -97,6 +98,7 @@ function onboardingRepository(): HouseholdConfigurationRepository {
|
||||
displayName: input.displayName,
|
||||
preferredLocale: input.preferredLocale ?? null,
|
||||
householdDefaultLocale: household.defaultLocale,
|
||||
rentShareWeight: 1,
|
||||
isAdmin: input.isAdmin === true
|
||||
}
|
||||
members.set(input.telegramUserId, member)
|
||||
@@ -122,6 +124,7 @@ function onboardingRepository(): HouseholdConfigurationRepository {
|
||||
displayName: pending.displayName,
|
||||
preferredLocale: null,
|
||||
householdDefaultLocale: household.defaultLocale,
|
||||
rentShareWeight: 1,
|
||||
isAdmin: input.isAdmin === true
|
||||
}
|
||||
members.set(pending.telegramUserId, member)
|
||||
@@ -141,6 +144,15 @@ function onboardingRepository(): HouseholdConfigurationRepository {
|
||||
}
|
||||
: null
|
||||
},
|
||||
updateHouseholdMemberRentShareWeight: async (_householdId, memberId, rentShareWeight) => {
|
||||
const member = [...members.values()].find((entry) => entry.id === memberId)
|
||||
return member
|
||||
? {
|
||||
...member,
|
||||
rentShareWeight
|
||||
}
|
||||
: null
|
||||
},
|
||||
getHouseholdBillingSettings: async (householdId) => ({
|
||||
householdId,
|
||||
rentAmountMinor: null,
|
||||
|
||||
@@ -70,6 +70,7 @@ function onboardingRepository(): HouseholdConfigurationRepository {
|
||||
displayName: input.displayName,
|
||||
preferredLocale: input.preferredLocale ?? null,
|
||||
householdDefaultLocale: household.defaultLocale,
|
||||
rentShareWeight: 1,
|
||||
isAdmin: input.isAdmin === true
|
||||
}),
|
||||
getHouseholdMember: async () => null,
|
||||
@@ -111,6 +112,7 @@ function onboardingRepository(): HouseholdConfigurationRepository {
|
||||
displayName: 'Stan',
|
||||
preferredLocale: null,
|
||||
householdDefaultLocale: 'ru',
|
||||
rentShareWeight: 1,
|
||||
isAdmin: true
|
||||
}
|
||||
],
|
||||
@@ -121,7 +123,8 @@ function onboardingRepository(): HouseholdConfigurationRepository {
|
||||
defaultLocale: locale
|
||||
}),
|
||||
updateMemberPreferredLocale: async () => null,
|
||||
promoteHouseholdAdmin: async () => null
|
||||
promoteHouseholdAdmin: async () => null,
|
||||
updateHouseholdMemberRentShareWeight: async () => null
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ function repository(
|
||||
id: 'member-1',
|
||||
telegramUserId: '123456',
|
||||
displayName: 'Stan',
|
||||
rentShareWeight: 1,
|
||||
isAdmin: true
|
||||
}
|
||||
],
|
||||
@@ -124,6 +125,7 @@ function onboardingRepository(): HouseholdConfigurationRepository {
|
||||
displayName: input.displayName,
|
||||
preferredLocale: input.preferredLocale ?? null,
|
||||
householdDefaultLocale: household.defaultLocale,
|
||||
rentShareWeight: 1,
|
||||
isAdmin: input.isAdmin === true
|
||||
}),
|
||||
getHouseholdMember: async () => null,
|
||||
@@ -165,7 +167,8 @@ function onboardingRepository(): HouseholdConfigurationRepository {
|
||||
sortOrder: input.sortOrder,
|
||||
isActive: input.isActive
|
||||
}),
|
||||
promoteHouseholdAdmin: async () => null
|
||||
promoteHouseholdAdmin: async () => null,
|
||||
updateHouseholdMemberRentShareWeight: async () => null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,6 +180,7 @@ describe('createMiniAppDashboardHandler', () => {
|
||||
id: 'member-1',
|
||||
telegramUserId: '123456',
|
||||
displayName: 'Stan',
|
||||
rentShareWeight: 1,
|
||||
isAdmin: true
|
||||
})
|
||||
)
|
||||
@@ -189,6 +193,7 @@ describe('createMiniAppDashboardHandler', () => {
|
||||
displayName: 'Stan',
|
||||
preferredLocale: null,
|
||||
householdDefaultLocale: 'ru',
|
||||
rentShareWeight: 1,
|
||||
isAdmin: true
|
||||
}
|
||||
]
|
||||
@@ -255,6 +260,7 @@ describe('createMiniAppDashboardHandler', () => {
|
||||
id: 'member-1',
|
||||
telegramUserId: '123456',
|
||||
displayName: 'Stan',
|
||||
rentShareWeight: 1,
|
||||
isAdmin: true
|
||||
})
|
||||
)
|
||||
@@ -267,6 +273,7 @@ describe('createMiniAppDashboardHandler', () => {
|
||||
displayName: 'Stan',
|
||||
preferredLocale: null,
|
||||
householdDefaultLocale: 'ru',
|
||||
rentShareWeight: 1,
|
||||
isAdmin: true
|
||||
}
|
||||
]
|
||||
|
||||
@@ -33,6 +33,7 @@ function repository(): HouseholdConfigurationRepository {
|
||||
displayName: 'Stan',
|
||||
preferredLocale: null,
|
||||
householdDefaultLocale: household.defaultLocale,
|
||||
rentShareWeight: 1,
|
||||
isAdmin: true
|
||||
}
|
||||
],
|
||||
@@ -45,6 +46,7 @@ function repository(): HouseholdConfigurationRepository {
|
||||
displayName: 'Mia',
|
||||
preferredLocale: null,
|
||||
householdDefaultLocale: household.defaultLocale,
|
||||
rentShareWeight: 1,
|
||||
isAdmin: false
|
||||
}
|
||||
]
|
||||
@@ -92,6 +94,7 @@ function repository(): HouseholdConfigurationRepository {
|
||||
displayName: input.displayName,
|
||||
preferredLocale: input.preferredLocale ?? null,
|
||||
householdDefaultLocale: household.defaultLocale,
|
||||
rentShareWeight: 1,
|
||||
isAdmin: input.isAdmin === true
|
||||
},
|
||||
getHouseholdMember: async (_householdId, telegramUserId) => members.get(telegramUserId) ?? null,
|
||||
@@ -154,7 +157,8 @@ function repository(): HouseholdConfigurationRepository {
|
||||
sortOrder: input.sortOrder,
|
||||
isActive: input.isActive
|
||||
}),
|
||||
promoteHouseholdAdmin: async () => null
|
||||
promoteHouseholdAdmin: async () => null,
|
||||
updateHouseholdMemberRentShareWeight: async () => null
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user