mirror of
https://github.com/whekin/household-bot.git
synced 2026-03-31 19:04:02 +00:00
feat: add payer control for purchases
- Add explicit payerMemberId field to purchase ledger entries - Add 'Paid by' selector in mini app purchase add/edit forms - Default payer to current user when creating new purchases - Allow admins to change who made existing purchases - Update backend handlers to accept and persist payerMemberId - Add i18n translations for 'Paid by' label (EN/RU) All quality gates pass: build, typecheck, lint, format, test Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
@@ -139,6 +139,7 @@ export interface FinanceDashboardLedgerEntry {
|
||||
included: boolean
|
||||
shareAmount: Money | null
|
||||
}[]
|
||||
payerMemberId?: string
|
||||
}
|
||||
|
||||
export interface FinanceDashboard {
|
||||
@@ -528,6 +529,7 @@ async function buildFinanceDashboard(
|
||||
kind: 'purchase',
|
||||
title: purchase.description ?? 'Shared purchase',
|
||||
memberId: purchase.payerMemberId,
|
||||
payerMemberId: purchase.payerMemberId,
|
||||
amount: converted.originalAmount,
|
||||
currency: purchase.currency,
|
||||
displayAmount: converted.settlementAmount,
|
||||
@@ -653,7 +655,8 @@ export interface FinanceCommandService {
|
||||
included?: boolean
|
||||
shareAmountMajor?: string
|
||||
}[]
|
||||
}
|
||||
},
|
||||
payerMemberId?: string
|
||||
): Promise<{
|
||||
purchaseId: string
|
||||
amount: Money
|
||||
@@ -888,7 +891,7 @@ export function createFinanceCommandService(
|
||||
return repository.deleteUtilityBill(billId)
|
||||
},
|
||||
|
||||
async updatePurchase(purchaseId, description, amountArg, currencyArg, split) {
|
||||
async updatePurchase(purchaseId, description, amountArg, currencyArg, split, payerMemberId) {
|
||||
const settings = await householdConfigurationRepository.getHouseholdBillingSettings(
|
||||
dependencies.householdId
|
||||
)
|
||||
@@ -920,6 +923,11 @@ export function createFinanceCommandService(
|
||||
amountMinor: amount.amountMinor,
|
||||
currency,
|
||||
description: description.trim().length > 0 ? description.trim() : null,
|
||||
...(payerMemberId
|
||||
? {
|
||||
payerMemberId
|
||||
}
|
||||
: {}),
|
||||
...(split
|
||||
? {
|
||||
splitMode: split.mode,
|
||||
|
||||
Reference in New Issue
Block a user