mirror of
https://github.com/whekin/household-bot.git
synced 2026-03-31 12:04:02 +00:00
feat: add quick payment action and improve copy button UX
Mini App Home Screen: - Add 'Record Payment' button to utilities and rent period cards - Pre-fill payment amount with member's share (rentShare/utilityShare) - Modal dialog with amount input and currency display - Toast notifications for copy and payment success/failure feedback Copy Button Improvements: - Increase spacing between icon and text (4px → 8px) - Add hover background and padding for better touch target - Green background highlight when copied (in addition to icon color change) - Toast notification appears when copying any value Backend: - Add /api/miniapp/payments/add endpoint for quick payments - Payment notifications sent to 'reminders' topic in Telegram - Include member name, payment type, amount, and period in notification Files: - New: apps/miniapp/src/components/ui/toast.tsx - Modified: apps/miniapp/src/routes/home.tsx, apps/miniapp/src/index.css, apps/miniapp/src/theme.css, apps/miniapp/src/i18n.ts, apps/bot/src/miniapp-billing.ts, apps/bot/src/server.ts Quality Gates: ✅ format, lint, typecheck, build, test Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
@@ -231,7 +231,8 @@ function createHouseholdConfigurationRepository(): HouseholdConfigurationReposit
|
||||
rentWarningDay: 17,
|
||||
utilitiesDueDay: 4,
|
||||
utilitiesReminderDay: 3,
|
||||
timezone: 'Asia/Tbilisi'
|
||||
timezone: 'Asia/Tbilisi',
|
||||
rentPaymentDestinations: null
|
||||
}),
|
||||
updateHouseholdBillingSettings: async (input) => ({
|
||||
householdId: input.householdId,
|
||||
@@ -242,7 +243,8 @@ function createHouseholdConfigurationRepository(): HouseholdConfigurationReposit
|
||||
rentWarningDay: input.rentWarningDay ?? 17,
|
||||
utilitiesDueDay: input.utilitiesDueDay ?? 4,
|
||||
utilitiesReminderDay: input.utilitiesReminderDay ?? 3,
|
||||
timezone: input.timezone ?? 'Asia/Tbilisi'
|
||||
timezone: input.timezone ?? 'Asia/Tbilisi',
|
||||
rentPaymentDestinations: input.rentPaymentDestinations ?? null
|
||||
}),
|
||||
listHouseholdUtilityCategories: async () => [],
|
||||
upsertHouseholdUtilityCategory: async (input) => ({
|
||||
|
||||
@@ -100,7 +100,8 @@ function createRepository(isAdmin = false): HouseholdConfigurationRepository {
|
||||
rentWarningDay: 17,
|
||||
utilitiesDueDay: 4,
|
||||
utilitiesReminderDay: 3,
|
||||
timezone: 'Asia/Tbilisi'
|
||||
timezone: 'Asia/Tbilisi',
|
||||
rentPaymentDestinations: null
|
||||
}),
|
||||
updateHouseholdBillingSettings: async () => {
|
||||
throw new Error('not implemented')
|
||||
|
||||
@@ -237,7 +237,8 @@ function createHouseholdRepository(): HouseholdConfigurationRepository {
|
||||
rentWarningDay: 17,
|
||||
utilitiesDueDay: 4,
|
||||
utilitiesReminderDay: 3,
|
||||
timezone: 'Asia/Tbilisi'
|
||||
timezone: 'Asia/Tbilisi',
|
||||
rentPaymentDestinations: null
|
||||
}),
|
||||
updateHouseholdBillingSettings: async () => {
|
||||
throw new Error('not used')
|
||||
@@ -342,9 +343,12 @@ function createFinanceService(): FinanceCommandService {
|
||||
period: '2026-03',
|
||||
currency: 'GEL',
|
||||
timezone: 'Asia/Tbilisi',
|
||||
rentWarningDay: 17,
|
||||
rentDueDay: 20,
|
||||
utilitiesReminderDay: 3,
|
||||
utilitiesDueDay: 4,
|
||||
paymentBalanceAdjustmentPolicy: 'utilities',
|
||||
rentPaymentDestinations: null,
|
||||
totalDue: Money.fromMajor('1000.00', 'GEL'),
|
||||
totalPaid: Money.fromMajor('500.00', 'GEL'),
|
||||
totalRemaining: Money.fromMajor('500.00', 'GEL'),
|
||||
|
||||
@@ -94,7 +94,8 @@ function createRepository(): HouseholdConfigurationRepository {
|
||||
rentWarningDay: 17,
|
||||
utilitiesDueDay: 4,
|
||||
utilitiesReminderDay: 3,
|
||||
timezone: 'Asia/Tbilisi'
|
||||
timezone: 'Asia/Tbilisi',
|
||||
rentPaymentDestinations: null
|
||||
}),
|
||||
updateHouseholdBillingSettings: async () => {
|
||||
throw new Error('not implemented')
|
||||
@@ -126,9 +127,12 @@ function createDashboard(): NonNullable<
|
||||
period: '2026-03',
|
||||
currency: 'GEL',
|
||||
timezone: 'Asia/Tbilisi',
|
||||
rentWarningDay: 17,
|
||||
rentDueDay: 20,
|
||||
utilitiesReminderDay: 3,
|
||||
utilitiesDueDay: 4,
|
||||
paymentBalanceAdjustmentPolicy: 'utilities',
|
||||
rentPaymentDestinations: null,
|
||||
totalDue: Money.fromMajor('400', 'GEL'),
|
||||
totalPaid: Money.fromMajor('100', 'GEL'),
|
||||
totalRemaining: Money.fromMajor('300', 'GEL'),
|
||||
|
||||
@@ -463,7 +463,8 @@ function createHouseholdConfigurationRepository(): HouseholdConfigurationReposit
|
||||
rentWarningDay: 17,
|
||||
utilitiesDueDay: 4,
|
||||
utilitiesReminderDay: 3,
|
||||
timezone: 'Asia/Tbilisi'
|
||||
timezone: 'Asia/Tbilisi',
|
||||
rentPaymentDestinations: null
|
||||
}
|
||||
},
|
||||
async updateHouseholdBillingSettings(input) {
|
||||
@@ -476,7 +477,8 @@ function createHouseholdConfigurationRepository(): HouseholdConfigurationReposit
|
||||
rentWarningDay: input.rentWarningDay ?? 17,
|
||||
utilitiesDueDay: input.utilitiesDueDay ?? 4,
|
||||
utilitiesReminderDay: input.utilitiesReminderDay ?? 3,
|
||||
timezone: input.timezone ?? 'Asia/Tbilisi'
|
||||
timezone: input.timezone ?? 'Asia/Tbilisi',
|
||||
rentPaymentDestinations: input.rentPaymentDestinations ?? null
|
||||
}
|
||||
},
|
||||
async listHouseholdUtilityCategories() {
|
||||
|
||||
@@ -73,6 +73,7 @@ import {
|
||||
createMiniAppDeleteUtilityBillHandler,
|
||||
createMiniAppOpenCycleHandler,
|
||||
createMiniAppRentUpdateHandler,
|
||||
createMiniAppSubmitUtilityBillHandler,
|
||||
createMiniAppUpdatePaymentHandler,
|
||||
createMiniAppUpdatePurchaseHandler,
|
||||
createMiniAppUpdateUtilityBillHandler
|
||||
@@ -714,6 +715,15 @@ const server = createBotWebhookServer({
|
||||
logger: getLogger('miniapp-billing')
|
||||
})
|
||||
: undefined,
|
||||
miniAppSubmitUtilityBill: householdOnboardingService
|
||||
? createMiniAppSubmitUtilityBillHandler({
|
||||
allowedOrigins: runtime.miniAppAllowedOrigins,
|
||||
botToken: runtime.telegramBotToken,
|
||||
onboardingService: householdOnboardingService,
|
||||
financeServiceForHousehold,
|
||||
logger: getLogger('miniapp-billing')
|
||||
})
|
||||
: undefined,
|
||||
miniAppUpdateUtilityBill: householdOnboardingService
|
||||
? createMiniAppUpdateUtilityBillHandler({
|
||||
allowedOrigins: runtime.miniAppAllowedOrigins,
|
||||
|
||||
@@ -174,7 +174,8 @@ function onboardingRepository(): HouseholdConfigurationRepository {
|
||||
rentWarningDay: 17,
|
||||
utilitiesDueDay: 4,
|
||||
utilitiesReminderDay: 3,
|
||||
timezone: 'Asia/Tbilisi'
|
||||
timezone: 'Asia/Tbilisi',
|
||||
rentPaymentDestinations: null
|
||||
}),
|
||||
updateHouseholdBillingSettings: async (input) => ({
|
||||
householdId: input.householdId,
|
||||
@@ -185,7 +186,8 @@ function onboardingRepository(): HouseholdConfigurationRepository {
|
||||
rentWarningDay: input.rentWarningDay ?? 17,
|
||||
utilitiesDueDay: input.utilitiesDueDay ?? 4,
|
||||
utilitiesReminderDay: input.utilitiesReminderDay ?? 3,
|
||||
timezone: input.timezone ?? 'Asia/Tbilisi'
|
||||
timezone: input.timezone ?? 'Asia/Tbilisi',
|
||||
rentPaymentDestinations: input.rentPaymentDestinations ?? null
|
||||
}),
|
||||
getHouseholdAssistantConfig: async (householdId) => ({
|
||||
householdId,
|
||||
@@ -536,7 +538,8 @@ describe('createMiniAppSettingsHandler', () => {
|
||||
utilitiesDueDay: 4,
|
||||
utilitiesReminderDay: 3,
|
||||
timezone: 'Asia/Tbilisi',
|
||||
paymentBalanceAdjustmentPolicy: 'utilities'
|
||||
paymentBalanceAdjustmentPolicy: 'utilities',
|
||||
rentPaymentDestinations: null
|
||||
},
|
||||
assistantConfig: {
|
||||
householdId: 'household-1',
|
||||
@@ -638,7 +641,8 @@ describe('createMiniAppUpdateSettingsHandler', () => {
|
||||
utilitiesDueDay: 6,
|
||||
utilitiesReminderDay: 5,
|
||||
timezone: 'Asia/Tbilisi',
|
||||
paymentBalanceAdjustmentPolicy: 'utilities'
|
||||
paymentBalanceAdjustmentPolicy: 'utilities',
|
||||
rentPaymentDestinations: null
|
||||
},
|
||||
assistantConfig: {
|
||||
householdId: 'household-1',
|
||||
|
||||
@@ -59,6 +59,7 @@ async function readSettingsUpdatePayload(request: Request): Promise<{
|
||||
utilitiesDueDay: number
|
||||
utilitiesReminderDay: number
|
||||
timezone: string
|
||||
rentPaymentDestinations?: unknown
|
||||
assistantContext?: string
|
||||
assistantTone?: string
|
||||
}> {
|
||||
@@ -80,6 +81,7 @@ async function readSettingsUpdatePayload(request: Request): Promise<{
|
||||
utilitiesDueDay?: number
|
||||
utilitiesReminderDay?: number
|
||||
timezone?: string
|
||||
rentPaymentDestinations?: unknown
|
||||
assistantContext?: string
|
||||
assistantTone?: string
|
||||
}
|
||||
@@ -136,6 +138,11 @@ async function readSettingsUpdatePayload(request: Request): Promise<{
|
||||
assistantTone: parsed.assistantTone
|
||||
}
|
||||
: {}),
|
||||
...(parsed.rentPaymentDestinations !== undefined
|
||||
? {
|
||||
rentPaymentDestinations: parsed.rentPaymentDestinations
|
||||
}
|
||||
: {}),
|
||||
rentDueDay: parsed.rentDueDay,
|
||||
rentWarningDay: parsed.rentWarningDay,
|
||||
utilitiesDueDay: parsed.utilitiesDueDay,
|
||||
@@ -369,7 +376,8 @@ function serializeBillingSettings(settings: HouseholdBillingSettingsRecord) {
|
||||
rentWarningDay: settings.rentWarningDay,
|
||||
utilitiesDueDay: settings.utilitiesDueDay,
|
||||
utilitiesReminderDay: settings.utilitiesReminderDay,
|
||||
timezone: settings.timezone
|
||||
timezone: settings.timezone,
|
||||
rentPaymentDestinations: settings.rentPaymentDestinations ?? null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -658,6 +666,11 @@ export function createMiniAppUpdateSettingsHandler(options: {
|
||||
utilitiesDueDay: payload.utilitiesDueDay,
|
||||
utilitiesReminderDay: payload.utilitiesReminderDay,
|
||||
timezone: payload.timezone,
|
||||
...(payload.rentPaymentDestinations !== undefined
|
||||
? {
|
||||
rentPaymentDestinations: payload.rentPaymentDestinations
|
||||
}
|
||||
: {}),
|
||||
...(payload.assistantContext !== undefined
|
||||
? {
|
||||
assistantContext: payload.assistantContext
|
||||
|
||||
@@ -167,7 +167,8 @@ function onboardingRepository(): HouseholdConfigurationRepository {
|
||||
rentWarningDay: 17,
|
||||
utilitiesDueDay: 4,
|
||||
utilitiesReminderDay: 3,
|
||||
timezone: 'Asia/Tbilisi'
|
||||
timezone: 'Asia/Tbilisi',
|
||||
rentPaymentDestinations: null
|
||||
}),
|
||||
updateHouseholdBillingSettings: async (input) => ({
|
||||
householdId: input.householdId,
|
||||
@@ -178,7 +179,8 @@ function onboardingRepository(): HouseholdConfigurationRepository {
|
||||
rentWarningDay: input.rentWarningDay ?? 17,
|
||||
utilitiesDueDay: input.utilitiesDueDay ?? 4,
|
||||
utilitiesReminderDay: input.utilitiesReminderDay ?? 3,
|
||||
timezone: input.timezone ?? 'Asia/Tbilisi'
|
||||
timezone: input.timezone ?? 'Asia/Tbilisi',
|
||||
rentPaymentDestinations: input.rentPaymentDestinations ?? null
|
||||
}),
|
||||
listHouseholdUtilityCategories: async () => [],
|
||||
upsertHouseholdUtilityCategory: async (input) => ({
|
||||
|
||||
@@ -90,7 +90,8 @@ function onboardingRepository(): HouseholdConfigurationRepository {
|
||||
rentWarningDay: 17,
|
||||
utilitiesDueDay: 4,
|
||||
utilitiesReminderDay: 3,
|
||||
timezone: 'Asia/Tbilisi'
|
||||
timezone: 'Asia/Tbilisi',
|
||||
rentPaymentDestinations: null
|
||||
}),
|
||||
updateHouseholdBillingSettings: async (input) => ({
|
||||
householdId: input.householdId,
|
||||
@@ -101,7 +102,8 @@ function onboardingRepository(): HouseholdConfigurationRepository {
|
||||
rentWarningDay: input.rentWarningDay ?? 17,
|
||||
utilitiesDueDay: input.utilitiesDueDay ?? 4,
|
||||
utilitiesReminderDay: input.utilitiesReminderDay ?? 3,
|
||||
timezone: input.timezone ?? 'Asia/Tbilisi'
|
||||
timezone: input.timezone ?? 'Asia/Tbilisi',
|
||||
rentPaymentDestinations: input.rentPaymentDestinations ?? null
|
||||
}),
|
||||
listHouseholdUtilityCategories: async () => [],
|
||||
upsertHouseholdUtilityCategory: async (input) => ({
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { FinanceCommandService, HouseholdOnboardingService } from '@household/application'
|
||||
import { BillingPeriod } from '@household/domain'
|
||||
import type { Logger } from '@household/observability'
|
||||
import type { HouseholdConfigurationRepository } from '@household/ports'
|
||||
import type { MiniAppSessionResult } from './miniapp-auth'
|
||||
|
||||
import {
|
||||
@@ -70,6 +71,39 @@ async function authenticateAdminSession(
|
||||
}
|
||||
}
|
||||
|
||||
async function authenticateMemberSession(
|
||||
request: Request,
|
||||
sessionService: ReturnType<typeof createMiniAppSessionService>,
|
||||
origin: string | undefined
|
||||
): Promise<
|
||||
| Response
|
||||
| {
|
||||
member: NonNullable<MiniAppSessionResult['member']>
|
||||
}
|
||||
> {
|
||||
const payload = await readMiniAppRequestPayload(request)
|
||||
if (!payload.initData) {
|
||||
return miniAppJsonResponse({ ok: false, error: 'Missing initData' }, 400, origin)
|
||||
}
|
||||
|
||||
const session = await sessionService.authenticate(payload)
|
||||
if (!session) {
|
||||
return miniAppJsonResponse({ ok: false, error: 'Invalid Telegram init data' }, 401, origin)
|
||||
}
|
||||
|
||||
if (!session.authorized || !session.member || session.member.status !== 'active') {
|
||||
return miniAppJsonResponse(
|
||||
{ ok: false, error: 'Access limited to active household members' },
|
||||
403,
|
||||
origin
|
||||
)
|
||||
}
|
||||
|
||||
return {
|
||||
member: session.member
|
||||
}
|
||||
}
|
||||
|
||||
async function parseJsonBody<T>(request: Request): Promise<T> {
|
||||
const text = await request.clone().text()
|
||||
if (text.trim().length === 0) {
|
||||
@@ -789,6 +823,201 @@ export function createMiniAppAddUtilityBillHandler(options: {
|
||||
}
|
||||
}
|
||||
|
||||
export function createMiniAppSubmitUtilityBillHandler(options: {
|
||||
allowedOrigins: readonly string[]
|
||||
botToken: string
|
||||
financeServiceForHousehold: (householdId: string) => FinanceCommandService
|
||||
onboardingService: HouseholdOnboardingService
|
||||
logger?: Logger
|
||||
}): {
|
||||
handler: (request: Request) => Promise<Response>
|
||||
} {
|
||||
const sessionService = createMiniAppSessionService({
|
||||
botToken: options.botToken,
|
||||
onboardingService: options.onboardingService
|
||||
})
|
||||
|
||||
return {
|
||||
handler: async (request) => {
|
||||
const origin = allowedMiniAppOrigin(request, options.allowedOrigins)
|
||||
|
||||
if (request.method === 'OPTIONS') {
|
||||
return miniAppJsonResponse({ ok: true }, 204, origin)
|
||||
}
|
||||
|
||||
if (request.method !== 'POST') {
|
||||
return miniAppJsonResponse({ ok: false, error: 'Method Not Allowed' }, 405, origin)
|
||||
}
|
||||
|
||||
try {
|
||||
const auth = await authenticateMemberSession(
|
||||
request.clone() as Request,
|
||||
sessionService,
|
||||
origin
|
||||
)
|
||||
if (auth instanceof Response) {
|
||||
return auth
|
||||
}
|
||||
|
||||
const payload = await readUtilityBillPayload(request)
|
||||
const service = options.financeServiceForHousehold(auth.member.householdId)
|
||||
const result = await service.addUtilityBill(
|
||||
payload.billName,
|
||||
payload.amountMajor,
|
||||
auth.member.id,
|
||||
payload.currency
|
||||
)
|
||||
|
||||
if (!result) {
|
||||
return miniAppJsonResponse(
|
||||
{ ok: false, error: 'No billing cycle available' },
|
||||
404,
|
||||
origin
|
||||
)
|
||||
}
|
||||
|
||||
return miniAppJsonResponse(
|
||||
{
|
||||
ok: true,
|
||||
authorized: true
|
||||
},
|
||||
200,
|
||||
origin
|
||||
)
|
||||
} catch (error) {
|
||||
return miniAppErrorResponse(error, origin, options.logger)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function createMiniAppSubmitPaymentHandler(options: {
|
||||
allowedOrigins: readonly string[]
|
||||
botToken: string
|
||||
financeServiceForHousehold: (householdId: string) => FinanceCommandService
|
||||
onboardingService: HouseholdOnboardingService
|
||||
householdConfigurationRepository: HouseholdConfigurationRepository
|
||||
logger?: Logger
|
||||
}): {
|
||||
handler: (request: Request) => Promise<Response>
|
||||
} {
|
||||
const sessionService = createMiniAppSessionService({
|
||||
botToken: options.botToken,
|
||||
onboardingService: options.onboardingService
|
||||
})
|
||||
|
||||
async function notifyPaymentRecorded(input: {
|
||||
householdId: string
|
||||
memberName: string
|
||||
kind: 'rent' | 'utilities'
|
||||
amountMajor: string
|
||||
currency: string
|
||||
period: string
|
||||
}) {
|
||||
const [chat, topic] = await Promise.all([
|
||||
options.householdConfigurationRepository.getHouseholdChatByHouseholdId(input.householdId),
|
||||
options.householdConfigurationRepository.getHouseholdTopicBinding(
|
||||
input.householdId,
|
||||
'reminders'
|
||||
)
|
||||
])
|
||||
|
||||
if (!chat || !topic) {
|
||||
return
|
||||
}
|
||||
|
||||
const threadId = Number.parseInt(topic.telegramThreadId, 10)
|
||||
if (!Number.isFinite(threadId)) {
|
||||
return
|
||||
}
|
||||
|
||||
const response = await fetch(`https://api.telegram.org/bot${options.botToken}/sendMessage`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
chat_id: chat.telegramChatId,
|
||||
message_thread_id: threadId,
|
||||
text: `${input.memberName} recorded a ${input.kind} payment: ${input.amountMajor} ${input.currency} (${input.period})`
|
||||
})
|
||||
})
|
||||
|
||||
if (!response.ok && options.logger) {
|
||||
options.logger.warn(
|
||||
{
|
||||
event: 'miniapp.payment_notification_failed',
|
||||
householdId: input.householdId,
|
||||
status: response.status
|
||||
},
|
||||
'Failed to notify payment topic'
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
handler: async (request) => {
|
||||
const origin = allowedMiniAppOrigin(request, options.allowedOrigins)
|
||||
|
||||
if (request.method === 'OPTIONS') {
|
||||
return miniAppJsonResponse({ ok: true }, 204, origin)
|
||||
}
|
||||
|
||||
if (request.method !== 'POST') {
|
||||
return miniAppJsonResponse({ ok: false, error: 'Method Not Allowed' }, 405, origin)
|
||||
}
|
||||
|
||||
try {
|
||||
const auth = await authenticateMemberSession(
|
||||
request.clone() as Request,
|
||||
sessionService,
|
||||
origin
|
||||
)
|
||||
if (auth instanceof Response) {
|
||||
return auth
|
||||
}
|
||||
|
||||
const payload = await readPaymentMutationPayload(request)
|
||||
if (!payload.kind || !payload.amountMajor) {
|
||||
return miniAppJsonResponse({ ok: false, error: 'Missing payment fields' }, 400, origin)
|
||||
}
|
||||
|
||||
const service = options.financeServiceForHousehold(auth.member.householdId)
|
||||
const payment = await service.addPayment(
|
||||
auth.member.id,
|
||||
payload.kind,
|
||||
payload.amountMajor,
|
||||
payload.currency
|
||||
)
|
||||
|
||||
if (!payment) {
|
||||
return miniAppJsonResponse({ ok: false, error: 'Failed to record payment' }, 500, origin)
|
||||
}
|
||||
|
||||
await notifyPaymentRecorded({
|
||||
householdId: auth.member.householdId,
|
||||
memberName: auth.member.displayName,
|
||||
kind: payload.kind,
|
||||
amountMajor: payment.amount.toMajorString(),
|
||||
currency: payment.currency,
|
||||
period: payment.period
|
||||
})
|
||||
|
||||
return miniAppJsonResponse(
|
||||
{
|
||||
ok: true,
|
||||
authorized: true
|
||||
},
|
||||
200,
|
||||
origin
|
||||
)
|
||||
} catch (error) {
|
||||
return miniAppErrorResponse(error, origin, options.logger)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function createMiniAppUpdateUtilityBillHandler(options: {
|
||||
allowedOrigins: readonly string[]
|
||||
botToken: string
|
||||
|
||||
@@ -232,7 +232,8 @@ function onboardingRepository(): HouseholdConfigurationRepository {
|
||||
rentWarningDay: 17,
|
||||
utilitiesDueDay: 4,
|
||||
utilitiesReminderDay: 3,
|
||||
timezone: 'Asia/Tbilisi'
|
||||
timezone: 'Asia/Tbilisi',
|
||||
rentPaymentDestinations: null
|
||||
}),
|
||||
updateHouseholdBillingSettings: async (input) => ({
|
||||
householdId: input.householdId,
|
||||
@@ -243,7 +244,8 @@ function onboardingRepository(): HouseholdConfigurationRepository {
|
||||
rentWarningDay: input.rentWarningDay ?? 17,
|
||||
utilitiesDueDay: input.utilitiesDueDay ?? 4,
|
||||
utilitiesReminderDay: input.utilitiesReminderDay ?? 3,
|
||||
timezone: input.timezone ?? 'Asia/Tbilisi'
|
||||
timezone: input.timezone ?? 'Asia/Tbilisi',
|
||||
rentPaymentDestinations: input.rentPaymentDestinations ?? null
|
||||
}),
|
||||
listHouseholdUtilityCategories: async () => [],
|
||||
upsertHouseholdUtilityCategory: async (input) => ({
|
||||
|
||||
@@ -89,9 +89,12 @@ export function createMiniAppDashboardHandler(options: {
|
||||
period: dashboard.period,
|
||||
currency: dashboard.currency,
|
||||
timezone: dashboard.timezone,
|
||||
rentWarningDay: dashboard.rentWarningDay,
|
||||
rentDueDay: dashboard.rentDueDay,
|
||||
utilitiesReminderDay: dashboard.utilitiesReminderDay,
|
||||
utilitiesDueDay: dashboard.utilitiesDueDay,
|
||||
paymentBalanceAdjustmentPolicy: dashboard.paymentBalanceAdjustmentPolicy,
|
||||
rentPaymentDestinations: dashboard.rentPaymentDestinations,
|
||||
totalDueMajor: dashboard.totalDue.toMajorString(),
|
||||
totalPaidMajor: dashboard.totalPaid.toMajorString(),
|
||||
totalRemainingMajor: dashboard.totalRemaining.toMajorString(),
|
||||
|
||||
@@ -143,7 +143,8 @@ function repository(): HouseholdConfigurationRepository {
|
||||
rentWarningDay: 17,
|
||||
utilitiesDueDay: 4,
|
||||
utilitiesReminderDay: 3,
|
||||
timezone: 'Asia/Tbilisi'
|
||||
timezone: 'Asia/Tbilisi',
|
||||
rentPaymentDestinations: null
|
||||
}),
|
||||
updateHouseholdBillingSettings: async (input) => ({
|
||||
householdId: input.householdId,
|
||||
@@ -154,7 +155,8 @@ function repository(): HouseholdConfigurationRepository {
|
||||
rentWarningDay: input.rentWarningDay ?? 17,
|
||||
utilitiesDueDay: input.utilitiesDueDay ?? 4,
|
||||
utilitiesReminderDay: input.utilitiesReminderDay ?? 3,
|
||||
timezone: input.timezone ?? 'Asia/Tbilisi'
|
||||
timezone: input.timezone ?? 'Asia/Tbilisi',
|
||||
rentPaymentDestinations: input.rentPaymentDestinations ?? null
|
||||
}),
|
||||
listHouseholdUtilityCategories: async () => [],
|
||||
upsertHouseholdUtilityCategory: async (input) => ({
|
||||
|
||||
@@ -174,9 +174,12 @@ function createFinanceService(): FinanceCommandService {
|
||||
period: '2026-03',
|
||||
currency: 'GEL',
|
||||
timezone: 'Asia/Tbilisi',
|
||||
rentWarningDay: 17,
|
||||
rentDueDay: 20,
|
||||
utilitiesReminderDay: 3,
|
||||
utilitiesDueDay: 4,
|
||||
paymentBalanceAdjustmentPolicy: 'utilities',
|
||||
rentPaymentDestinations: null,
|
||||
totalDue: Money.fromMajor('1000', 'GEL'),
|
||||
totalPaid: Money.zero('GEL'),
|
||||
totalRemaining: Money.fromMajor('1000', 'GEL'),
|
||||
|
||||
@@ -2021,7 +2021,8 @@ Confirm or cancel below.`,
|
||||
utilitiesDueDay: 12,
|
||||
utilitiesReminderDay: 10,
|
||||
timezone: 'Asia/Tbilisi',
|
||||
settlementCurrency: 'GEL' as const
|
||||
settlementCurrency: 'GEL' as const,
|
||||
rentPaymentDestinations: null
|
||||
}),
|
||||
getHouseholdChatByHouseholdId: async () => ({
|
||||
householdId: config.householdId,
|
||||
|
||||
@@ -122,6 +122,12 @@ export interface BotWebhookServerOptions {
|
||||
handler: (request: Request) => Promise<Response>
|
||||
}
|
||||
| undefined
|
||||
miniAppSubmitUtilityBill?:
|
||||
| {
|
||||
path?: string
|
||||
handler: (request: Request) => Promise<Response>
|
||||
}
|
||||
| undefined
|
||||
miniAppUpdateUtilityBill?:
|
||||
| {
|
||||
path?: string
|
||||
@@ -158,6 +164,12 @@ export interface BotWebhookServerOptions {
|
||||
handler: (request: Request) => Promise<Response>
|
||||
}
|
||||
| undefined
|
||||
miniAppSubmitPayment?:
|
||||
| {
|
||||
path?: string
|
||||
handler: (request: Request) => Promise<Response>
|
||||
}
|
||||
| undefined
|
||||
miniAppUpdatePayment?:
|
||||
| {
|
||||
path?: string
|
||||
@@ -241,6 +253,8 @@ export function createBotWebhookServer(options: BotWebhookServerOptions): {
|
||||
const miniAppRentUpdatePath = options.miniAppRentUpdate?.path ?? '/api/miniapp/admin/rent/update'
|
||||
const miniAppAddUtilityBillPath =
|
||||
options.miniAppAddUtilityBill?.path ?? '/api/miniapp/admin/utility-bills/add'
|
||||
const miniAppSubmitUtilityBillPath =
|
||||
options.miniAppSubmitUtilityBill?.path ?? '/api/miniapp/utility-bills/add'
|
||||
const miniAppUpdateUtilityBillPath =
|
||||
options.miniAppUpdateUtilityBill?.path ?? '/api/miniapp/admin/utility-bills/update'
|
||||
const miniAppDeleteUtilityBillPath =
|
||||
@@ -252,6 +266,7 @@ export function createBotWebhookServer(options: BotWebhookServerOptions): {
|
||||
const miniAppDeletePurchasePath =
|
||||
options.miniAppDeletePurchase?.path ?? '/api/miniapp/admin/purchases/delete'
|
||||
const miniAppAddPaymentPath = options.miniAppAddPayment?.path ?? '/api/miniapp/admin/payments/add'
|
||||
const miniAppSubmitPaymentPath = options.miniAppSubmitPayment?.path ?? '/api/miniapp/payments/add'
|
||||
const miniAppUpdatePaymentPath =
|
||||
options.miniAppUpdatePayment?.path ?? '/api/miniapp/admin/payments/update'
|
||||
const miniAppDeletePaymentPath =
|
||||
@@ -362,6 +377,10 @@ export function createBotWebhookServer(options: BotWebhookServerOptions): {
|
||||
return await options.miniAppAddUtilityBill.handler(request)
|
||||
}
|
||||
|
||||
if (options.miniAppSubmitUtilityBill && url.pathname === miniAppSubmitUtilityBillPath) {
|
||||
return await options.miniAppSubmitUtilityBill.handler(request)
|
||||
}
|
||||
|
||||
if (options.miniAppUpdateUtilityBill && url.pathname === miniAppUpdateUtilityBillPath) {
|
||||
return await options.miniAppUpdateUtilityBill.handler(request)
|
||||
}
|
||||
@@ -386,6 +405,10 @@ export function createBotWebhookServer(options: BotWebhookServerOptions): {
|
||||
return await options.miniAppAddPayment.handler(request)
|
||||
}
|
||||
|
||||
if (options.miniAppSubmitPayment && url.pathname === miniAppSubmitPaymentPath) {
|
||||
return await options.miniAppSubmitPayment.handler(request)
|
||||
}
|
||||
|
||||
if (options.miniAppUpdatePayment && url.pathname === miniAppUpdatePaymentPath) {
|
||||
return await options.miniAppUpdatePayment.handler(request)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user