Skip to content

Commit

Permalink
#271 - (feature/bill-in-form)
Browse files Browse the repository at this point in the history
  • Loading branch information
daanvanberkel authored Apr 30, 2024
1 parent c38224e commit 846e64f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/components/Forms/TransactionSplitForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,23 @@ export default function TransactionSplitForm({
routeApi="budgets"
/>

<AutocompleteField
label={translate('transaction_form_bill_label')}
placeholder={translate('transaction_form_bill_label')}
value={formData.billName}
onChangeText={(value: string) => setTransaction({
...formData,
billName: value,
})}
onSelectAutocomplete={(autocomplete) => setTransaction({
...formData,
billId: autocomplete.id,
billName: autocomplete.name,
})}
InputRightElement={deleteBtn(['billId', 'billName'])}
routeApi="bills"
/>

<AutocompleteField
multiple
label={translate('transaction_form_tags_label')}
Expand Down Expand Up @@ -436,6 +453,8 @@ export default function TransactionSplitForm({
notes: '',
currencySymbol: '',
currencyCode: '',
billId: '',
billName: '',
});
}}
>
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locale/translations/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,5 @@ export default {
home_bills: 'Bills',
bills_paid: 'Paid',
bills_not_expected: 'Not expected',
transaction_form_bill_label: 'Bill',
};
6 changes: 6 additions & 0 deletions src/models/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export type TransactionSplitType = {
foreignAmount: string,
foreignCurrencyId: string,
foreignCurrencyCode?: string,
billId: string,
billName: string,
}

export type TransactionType = {
Expand Down Expand Up @@ -85,6 +87,8 @@ export const initialSplit = () => ({
budgetId: '',
tags: [],
notes: '',
billId: '',
billName: '',
}) as TransactionSplitType;

export const types = [
Expand Down Expand Up @@ -328,6 +332,8 @@ export default createModel<RootModel>()({
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,
Expand Down

0 comments on commit 846e64f

Please sign in to comment.