From 846e64fa0f14b02df86eaf6ecac4cd0f8b1cc538 Mon Sep 17 00:00:00 2001 From: Daan van Berkel Date: Tue, 30 Apr 2024 20:56:06 +0200 Subject: [PATCH] #271 - (feature/bill-in-form) --- src/components/Forms/TransactionSplitForm.tsx | 19 +++++++++++++++++++ src/i18n/locale/translations/en-US.ts | 1 + src/models/transactions.ts | 6 ++++++ 3 files changed, 26 insertions(+) diff --git a/src/components/Forms/TransactionSplitForm.tsx b/src/components/Forms/TransactionSplitForm.tsx index 2538be4..3c9d8a5 100644 --- a/src/components/Forms/TransactionSplitForm.tsx +++ b/src/components/Forms/TransactionSplitForm.tsx @@ -379,6 +379,23 @@ export default function TransactionSplitForm({ routeApi="budgets" /> + setTransaction({ + ...formData, + billName: value, + })} + onSelectAutocomplete={(autocomplete) => setTransaction({ + ...formData, + billId: autocomplete.id, + billName: autocomplete.name, + })} + InputRightElement={deleteBtn(['billId', 'billName'])} + routeApi="bills" + /> + diff --git a/src/i18n/locale/translations/en-US.ts b/src/i18n/locale/translations/en-US.ts index 1960a1c..6835e52 100644 --- a/src/i18n/locale/translations/en-US.ts +++ b/src/i18n/locale/translations/en-US.ts @@ -147,4 +147,5 @@ export default { home_bills: 'Bills', bills_paid: 'Paid', bills_not_expected: 'Not expected', + transaction_form_bill_label: 'Bill', }; diff --git a/src/models/transactions.ts b/src/models/transactions.ts index 2db72c5..899611c 100644 --- a/src/models/transactions.ts +++ b/src/models/transactions.ts @@ -23,6 +23,8 @@ export type TransactionSplitType = { foreignAmount: string, foreignCurrencyId: string, foreignCurrencyCode?: string, + billId: string, + billName: string, } export type TransactionType = { @@ -85,6 +87,8 @@ export const initialSplit = () => ({ budgetId: '', tags: [], notes: '', + billId: '', + billName: '', }) as TransactionSplitType; export const types = [ @@ -328,6 +332,8 @@ export default createModel()({ budget_name: transaction.budgetName, type: transaction.type, amount: transaction.amount ? parseFloat(transaction.amount.replace(',', '.')) : 0, + bill_id: transaction.billId, + bill_name: transaction.billName, })), error_if_duplicate_hash: false, apply_rules: true,