feat(costs): show what the trip finally costs each participant

The settle-up view says who owes whom, but nothing on the Costs screen
answers "what did the trip cost me": the balances move every time a
payment is recorded, and the tiles only describe the signed-in user.

The settlement response now carries finalBudgets, one row per participant
in the ledger: expenses (what they fronted on split expenses), reimbursed
(recorded transfers, received minus sent), pending (their current
balance) and final = expenses - reimbursed - pending.

- Computed in calculateSettlement from the same integer trip cents as the
  balances, filled by the same loops, so the breakdown can never
  contradict the balance printed next to it. Each component is converted
  to the display currency as its own set and the final is subtracted in
  display cents, so the three lines add up to the total in any currency.
- A "Final budget" card on desktop, the narrow desktop layout and the
  mobile Costs tab: one amount per traveler, and a tap opens the three
  lines plus the expenses, transfers and open flows behind them. The
  filtering lives in CostsPanel.helpers so both shells share it.
- Contract in shared (budgetParticipantFinalSchema); the MCP
  get_settlement_summary description mentions the new field it returns.
- Four new costs.* keys, translated in every locale.
This commit is contained in:
RemEx
2026-09-11 12:15:31 +00:00
committed by Maurice
parent a635e31bd4
commit e0c9a8d1b6
36 changed files with 735 additions and 23 deletions
+29
View File
@@ -256,6 +256,35 @@ export const budgetUpdateSettlementRequestSchema = z.object({
});
export type BudgetUpdateSettlementRequest = z.infer<typeof budgetUpdateSettlementRequestSchema>;
/**
* What the trip actually costs one participant, as GET …/budget/settlement
* returns it alongside the balances and the suggested flows.
*
* `final = expenses - reimbursed - pending`, and the identity holds to the cent
* in whatever display currency was asked for: the server derives all four
* figures from the one integer-cent ledger the balances come from, so a
* breakdown can never disagree with the balance shown next to it. Every amount
* is in that display currency.
*
* A participant who fronted nothing and owes nothing is absent, exactly like
* they are from `balances` — a client listing the trip's roster fills the gap
* with zeroes rather than expecting a row per member.
*/
export const budgetParticipantFinalSchema = z.object({
user_id: z.number(),
username: z.string(),
avatar_url: z.string().nullable(),
/** Gross outlay: what this participant fronted as a payer on split expenses. */
expenses: z.number(),
/** Recorded settle-up transfers, netted: received minus sent. */
reimbursed: z.number(),
/** Still to be squared up — the participant's current balance, positive when owed. */
pending: z.number(),
/** What the trip leaves them out of pocket once everything has been settled. */
final: z.number(),
});
export type BudgetParticipantFinal = z.infer<typeof budgetParticipantFinalSchema>;
export const budgetUpdateMembersRequestSchema = z.object({
user_ids: z.array(z.number()),
});
+4
View File
@@ -80,6 +80,10 @@ const budget: TranslationStrings = {
'costs.pays': 'يدفع',
'costs.settle': 'تسوية',
'costs.balances': 'الأرصدة',
'costs.finalBudget': 'الميزانية النهائية',
'costs.finalExpenses': 'المصاريف المدفوعة',
'costs.finalReimbursed': 'المبالغ المستردة المستلمة',
'costs.finalPending': 'المبالغ المستردة المعلقة',
'costs.byCategory': 'حسب الفئة',
'costs.noCategories': 'لا توجد مصروفات بعد.',
'costs.settleHistory': 'سجل التسويات',
+4
View File
@@ -80,6 +80,10 @@ const budget: TranslationStrings = {
'costs.pays': 'paga',
'costs.settle': 'Acertar',
'costs.balances': 'Saldos',
'costs.finalBudget': 'Orçamento final',
'costs.finalExpenses': 'Despesas pagas',
'costs.finalReimbursed': 'Reembolsos recebidos',
'costs.finalPending': 'Reembolsos pendentes',
'costs.byCategory': 'Por categoria',
'costs.noCategories': 'Nenhuma despesa ainda.',
'costs.settleHistory': 'Histórico de acertos',
+4
View File
@@ -78,6 +78,10 @@ const budget: TranslationStrings = {
'costs.pays': 'paga',
'costs.settle': 'Liquidar',
'costs.balances': 'Balanços',
'costs.finalBudget': 'Pressupost final',
'costs.finalExpenses': 'Despeses pagades',
'costs.finalReimbursed': 'Reemborsaments rebuts',
'costs.finalPending': 'Reemborsaments pendents',
'costs.byCategory': 'Per categoria',
'costs.noCategories': 'Encara no hi ha despeses.',
'costs.settleHistory': 'Historial de liquidacions',
+4
View File
@@ -80,6 +80,10 @@ const budget: TranslationStrings = {
'costs.pays': 'zaplatí',
'costs.settle': 'Vyrovnat',
'costs.balances': 'Zůstatky',
'costs.finalBudget': 'Konečný rozpočet',
'costs.finalExpenses': 'Zaplacené výdaje',
'costs.finalReimbursed': 'Přijaté náhrady',
'costs.finalPending': 'Nevyřízené náhrady',
'costs.byCategory': 'Podle kategorie',
'costs.noCategories': 'Zatím žádné výdaje.',
'costs.settleHistory': 'Historie vyrovnání',
+4
View File
@@ -83,6 +83,10 @@ const budget: TranslationStrings = {
'costs.pays': 'zahlt',
'costs.settle': 'Ausgleichen',
'costs.balances': 'Salden',
'costs.finalBudget': 'Endbudget',
'costs.finalExpenses': 'Bezahlte Ausgaben',
'costs.finalReimbursed': 'Erhaltene Rückzahlungen',
'costs.finalPending': 'Ausstehende Rückzahlungen',
'costs.byCategory': 'Nach Kategorie',
'costs.noCategories': 'Noch keine Ausgaben.',
'costs.settleHistory': 'Ausgleichs-Verlauf',
+4
View File
@@ -83,6 +83,10 @@ const budget: TranslationStrings = {
'costs.pays': 'pays',
'costs.settle': 'Settle',
'costs.balances': 'Balances',
'costs.finalBudget': 'Final budget',
'costs.finalExpenses': 'Expenses paid',
'costs.finalReimbursed': 'Reimbursements received',
'costs.finalPending': 'Pending reimbursements',
'costs.byCategory': 'By category',
'costs.noCategories': 'No expenses yet.',
'costs.settleHistory': 'Settle history',
+4
View File
@@ -80,6 +80,10 @@ const budget: TranslationStrings = {
'costs.pays': 'paga',
'costs.settle': 'Saldar',
'costs.balances': 'Saldos',
'costs.finalBudget': 'Presupuesto final',
'costs.finalExpenses': 'Gastos pagados',
'costs.finalReimbursed': 'Reembolsos recibidos',
'costs.finalPending': 'Reembolsos pendientes',
'costs.byCategory': 'Por categoría',
'costs.noCategories': 'Aún no hay gastos.',
'costs.settleHistory': 'Historial de pagos',
+4
View File
@@ -80,6 +80,10 @@ const budget: TranslationStrings = {
'costs.pays': 'paie',
'costs.settle': 'Régler',
'costs.balances': 'Soldes',
'costs.finalBudget': 'Budget final',
'costs.finalExpenses': 'Dépenses payées',
'costs.finalReimbursed': 'Remboursements reçus',
'costs.finalPending': 'Remboursements en attente',
'costs.byCategory': 'Par catégorie',
'costs.noCategories': 'Aucune dépense pour le moment.',
'costs.settleHistory': 'Historique des règlements',
+4
View File
@@ -81,6 +81,10 @@ const budget: TranslationStrings = {
'costs.pays': 'πληρώνει',
'costs.settle': 'Εξόφληση',
'costs.balances': 'Υπόλοιπα',
'costs.finalBudget': 'Τελικός προϋπολογισμός',
'costs.finalExpenses': 'Πληρωμένα έξοδα',
'costs.finalReimbursed': 'Επιστροφές που ελήφθησαν',
'costs.finalPending': 'Εκκρεμείς επιστροφές',
'costs.byCategory': 'Ανά κατηγορία',
'costs.noCategories': 'Δεν υπάρχουν έξοδα ακόμη.',
'costs.settleHistory': 'Ιστορικό εξοφλήσεων',
+4
View File
@@ -80,6 +80,10 @@ const budget: TranslationStrings = {
'costs.pays': 'fizet',
'costs.settle': 'Elszámol',
'costs.balances': 'Egyenlegek',
'costs.finalBudget': 'Végső költségvetés',
'costs.finalExpenses': 'Kifizetett kiadások',
'costs.finalReimbursed': 'Kapott visszatérítések',
'costs.finalPending': 'Függőben lévő visszatérítések',
'costs.byCategory': 'Kategóriánként',
'costs.noCategories': 'Még nincs költség.',
'costs.settleHistory': 'Elszámolási előzmények',
+4
View File
@@ -80,6 +80,10 @@ const budget: TranslationStrings = {
'costs.pays': 'membayar',
'costs.settle': 'Lunasi',
'costs.balances': 'Saldo',
'costs.finalBudget': 'Anggaran akhir',
'costs.finalExpenses': 'Pengeluaran yang dibayar',
'costs.finalReimbursed': 'Penggantian diterima',
'costs.finalPending': 'Penggantian tertunda',
'costs.byCategory': 'Per kategori',
'costs.noCategories': 'Belum ada pengeluaran.',
'costs.settleHistory': 'Riwayat pelunasan',
+4
View File
@@ -80,6 +80,10 @@ const budget: TranslationStrings = {
'costs.pays': 'paga',
'costs.settle': 'Salda',
'costs.balances': 'Saldi',
'costs.finalBudget': 'Budget finale',
'costs.finalExpenses': 'Spese pagate',
'costs.finalReimbursed': 'Rimborsi ricevuti',
'costs.finalPending': 'Rimborsi in sospeso',
'costs.byCategory': 'Per categoria',
'costs.noCategories': 'Ancora nessuna spesa.',
'costs.settleHistory': 'Cronologia saldi',
+4
View File
@@ -80,6 +80,10 @@ const budget: TranslationStrings = {
'costs.pays': '支払う',
'costs.settle': '精算',
'costs.balances': '残高',
'costs.finalBudget': '最終負担額',
'costs.finalExpenses': '支払った費用',
'costs.finalReimbursed': '受け取った精算',
'costs.finalPending': '未精算の金額',
'costs.byCategory': 'カテゴリ別',
'costs.noCategories': '支出はまだありません。',
'costs.settleHistory': '精算履歴',
+4
View File
@@ -80,6 +80,10 @@ const budget: TranslationStrings = {
'costs.pays': '지불',
'costs.settle': '정산',
'costs.balances': '잔액',
'costs.finalBudget': '최종 부담액',
'costs.finalExpenses': '지불한 지출',
'costs.finalReimbursed': '받은 정산',
'costs.finalPending': '미정산 금액',
'costs.byCategory': '카테고리별',
'costs.noCategories': '아직 지출이 없습니다.',
'costs.settleHistory': '정산 내역',
+4
View File
@@ -80,6 +80,10 @@ const budget: TranslationStrings = {
'costs.pays': 'betaalt',
'costs.settle': 'Afrekenen',
'costs.balances': 'Saldi',
'costs.finalBudget': 'Eindbudget',
'costs.finalExpenses': 'Betaalde uitgaven',
'costs.finalReimbursed': 'Ontvangen terugbetalingen',
'costs.finalPending': 'Openstaande terugbetalingen',
'costs.byCategory': 'Per categorie',
'costs.noCategories': 'Nog geen uitgaven.',
'costs.settleHistory': 'Afrekengeschiedenis',
+4
View File
@@ -80,6 +80,10 @@ const budget: TranslationStrings = {
'costs.pays': 'płaci',
'costs.settle': 'Rozlicz',
'costs.balances': 'Salda',
'costs.finalBudget': 'Budżet końcowy',
'costs.finalExpenses': 'Zapłacone wydatki',
'costs.finalReimbursed': 'Otrzymane zwroty',
'costs.finalPending': 'Oczekujące zwroty',
'costs.byCategory': 'Według kategorii',
'costs.noCategories': 'Brak wydatków.',
'costs.settleHistory': 'Historia rozliczeń',
+4
View File
@@ -80,6 +80,10 @@ const budget: TranslationStrings = {
'costs.pays': 'платит',
'costs.settle': 'Рассчитать',
'costs.balances': 'Балансы',
'costs.finalBudget': 'Итоговый бюджет',
'costs.finalExpenses': 'Оплаченные расходы',
'costs.finalReimbursed': 'Полученные возмещения',
'costs.finalPending': 'Ожидаемые возмещения',
'costs.byCategory': 'По категориям',
'costs.noCategories': 'Расходов пока нет.',
'costs.settleHistory': 'История расчётов',
+4
View File
@@ -80,6 +80,10 @@ const budget: TranslationStrings = {
'costs.pays': 'betalar',
'costs.settle': 'Lösa',
'costs.balances': 'Balanser',
'costs.finalBudget': 'Slutlig budget',
'costs.finalExpenses': 'Betalda utgifter',
'costs.finalReimbursed': 'Mottagna återbetalningar',
'costs.finalPending': 'Väntande återbetalningar',
'costs.byCategory': 'Via kategori',
'costs.noCategories': 'Inga utgifter än.',
'costs.settleHistory': 'Historik över reglering',
+4
View File
@@ -80,6 +80,10 @@ const budget: TranslationStrings = {
'costs.pays': 'ödüyor',
'costs.settle': 'Hesaplaş',
'costs.balances': 'Bakiyeler',
'costs.finalBudget': 'Nihai bütçe',
'costs.finalExpenses': 'Ödenen harcamalar',
'costs.finalReimbursed': 'Alınan geri ödemeler',
'costs.finalPending': 'Bekleyen geri ödemeler',
'costs.byCategory': 'Kategoriye göre',
'costs.noCategories': 'Henüz harcama yok.',
'costs.settleHistory': 'Hesaplaşma geçmişi',
+4
View File
@@ -80,6 +80,10 @@ const budget: TranslationStrings = {
'costs.pays': 'платить',
'costs.settle': 'Розрахувати',
'costs.balances': 'Баланси',
'costs.finalBudget': 'Підсумковий бюджет',
'costs.finalExpenses': 'Оплачені витрати',
'costs.finalReimbursed': 'Отримані відшкодування',
'costs.finalPending': 'Очікувані відшкодування',
'costs.byCategory': 'За категоріями',
'costs.noCategories': 'Витрат ще немає.',
'costs.settleHistory': 'Історія розрахунків',
+4
View File
@@ -80,6 +80,10 @@ const budget: TranslationStrings = {
'costs.pays': 'trả tiền',
'costs.settle': 'Thanh toán',
'costs.balances': 'Số dư',
'costs.finalBudget': 'Ngân sách cuối cùng',
'costs.finalExpenses': 'Chi phí đã trả',
'costs.finalReimbursed': 'Khoản hoàn trả đã nhận',
'costs.finalPending': 'Khoản hoàn trả đang chờ',
'costs.byCategory': 'Theo danh mục',
'costs.noCategories': 'Chưa có chi phí nào.',
'costs.settleHistory': 'Lịch sử thanh toán',
+4
View File
@@ -79,6 +79,10 @@ const budget: TranslationStrings = {
'costs.pays': '支付',
'costs.settle': '結算',
'costs.balances': '餘額',
'costs.finalBudget': '最終花費',
'costs.finalExpenses': '已支付的支出',
'costs.finalReimbursed': '已收到的還款',
'costs.finalPending': '待還款項',
'costs.byCategory': '按分類',
'costs.noCategories': '尚無支出。',
'costs.settleHistory': '結算紀錄',
+4
View File
@@ -79,6 +79,10 @@ const budget: TranslationStrings = {
'costs.pays': '支付',
'costs.settle': '结算',
'costs.balances': '余额',
'costs.finalBudget': '最终花费',
'costs.finalExpenses': '已支付的支出',
'costs.finalReimbursed': '已收到的还款',
'costs.finalPending': '待还款项',
'costs.byCategory': '按分类',
'costs.noCategories': '暂无支出。',
'costs.settleHistory': '结算历史',