diff --git a/packages/desktop-client/src/components/Modals.tsx b/packages/desktop-client/src/components/Modals.tsx index 4c80bd67a67..481891ef4de 100644 --- a/packages/desktop-client/src/components/Modals.tsx +++ b/packages/desktop-client/src/components/Modals.tsx @@ -284,6 +284,7 @@ export function Modals() { onSelect: options.onSelect, showHiddenCategories: options.showHiddenCategories, }} + month={options.month} onClose={options.onClose} /> ); @@ -531,6 +532,7 @@ export function Modals() { ); diff --git a/packages/desktop-client/src/components/autocomplete/CategoryAutocomplete.tsx b/packages/desktop-client/src/components/autocomplete/CategoryAutocomplete.tsx index d33776c527b..60cb799d505 100644 --- a/packages/desktop-client/src/components/autocomplete/CategoryAutocomplete.tsx +++ b/packages/desktop-client/src/components/autocomplete/CategoryAutocomplete.tsx @@ -379,7 +379,9 @@ function CategoryItem({ }} > {isToBeBudgetedItem - ? integerToCurrency(toBudget || 0) + ? toBudget != null + ? integerToCurrency(toBudget || 0) + : null : balance != null ? integerToCurrency(balance || 0) : null} diff --git a/packages/desktop-client/src/components/mobile/budget/BudgetTable.jsx b/packages/desktop-client/src/components/mobile/budget/BudgetTable.jsx index 4eb5cad5626..4539514777a 100644 --- a/packages/desktop-client/src/components/mobile/budget/BudgetTable.jsx +++ b/packages/desktop-client/src/components/mobile/budget/BudgetTable.jsx @@ -276,6 +276,7 @@ const ExpenseCategory = memo(function ExpenseCategory({ dispatch( pushModal('transfer', { title: `Transfer: ${category.name}`, + month, amount: catBalance, onSubmit: (amount, toCategoryId) => { onBudgetAction(month, 'transfer-category', { @@ -294,6 +295,7 @@ const ExpenseCategory = memo(function ExpenseCategory({ dispatch( pushModal('cover', { categoryId: category.id, + month, onSubmit: fromCategoryId => { onBudgetAction(month, 'cover', { to: category.id, diff --git a/packages/desktop-client/src/components/mobile/transactions/TransactionEdit.jsx b/packages/desktop-client/src/components/mobile/transactions/TransactionEdit.jsx index eaccd1d7dcc..8873ec3abce 100644 --- a/packages/desktop-client/src/components/mobile/transactions/TransactionEdit.jsx +++ b/packages/desktop-client/src/components/mobile/transactions/TransactionEdit.jsx @@ -545,11 +545,15 @@ const TransactionEditInner = memo(function TransactionEditInner({ const onClick = (transactionId, name) => { onRequestActiveEdit?.(getFieldName(transaction.id, name), () => { const transactionToEdit = transactions.find(t => t.id === transactionId); + const unserializedTransaction = unserializedTransactions.find( + t => t.id === transactionId, + ); switch (name) { case 'category': dispatch( pushModal('category-autocomplete', { categoryGroups, + month: monthUtils.monthFromDate(unserializedTransaction.date), onSelect: categoryId => { onEdit(transactionToEdit, name, categoryId); }, @@ -587,7 +591,7 @@ const TransactionEditInner = memo(function TransactionEditInner({ dispatch( pushModal('edit-field', { name, - month: monthUtils.monthFromDate(transaction.date), + month: monthUtils.monthFromDate(unserializedTransaction.date), onSubmit: (name, value) => { onEdit(transactionToEdit, name, value); }, diff --git a/packages/desktop-client/src/components/modals/CategoryAutocompleteModal.tsx b/packages/desktop-client/src/components/modals/CategoryAutocompleteModal.tsx index 9712696555e..1c83d881d24 100644 --- a/packages/desktop-client/src/components/modals/CategoryAutocompleteModal.tsx +++ b/packages/desktop-client/src/components/modals/CategoryAutocompleteModal.tsx @@ -1,5 +1,7 @@ import React, { type ComponentPropsWithoutRef } from 'react'; +import * as monthUtils from 'loot-core/src/shared/months'; + import { useResponsive } from '../../ResponsiveProvider'; import { theme } from '../../style'; import { CategoryAutocomplete } from '../autocomplete/CategoryAutocomplete'; @@ -7,16 +9,19 @@ import { ModalCloseButton, Modal, ModalTitle } from '../common/Modal'; import { View } from '../common/View'; import { SectionLabel } from '../forms'; import { type CommonModalProps } from '../Modals'; +import { NamespaceContext } from '../spreadsheet/NamespaceContext'; type CategoryAutocompleteModalProps = { modalProps: CommonModalProps; autocompleteProps: ComponentPropsWithoutRef; onClose: () => void; + month?: string; }; export function CategoryAutocompleteModal({ modalProps, autocompleteProps, + month, onClose, }: CategoryAutocompleteModalProps) { const _onClose = () => { @@ -71,15 +76,19 @@ export function CategoryAutocompleteModal({ /> )} - + + + )} diff --git a/packages/desktop-client/src/components/modals/CoverModal.tsx b/packages/desktop-client/src/components/modals/CoverModal.tsx index 90f4369da98..e11baeb6e98 100644 --- a/packages/desktop-client/src/components/modals/CoverModal.tsx +++ b/packages/desktop-client/src/components/modals/CoverModal.tsx @@ -16,12 +16,14 @@ import { type CommonModalProps } from '../Modals'; type CoverModalProps = { modalProps: CommonModalProps; categoryId: string; + month: string; onSubmit: (categoryId: string) => void; }; export function CoverModal({ modalProps, categoryId, + month, onSubmit, }: CoverModalProps) { const { grouped: originalCategoryGroups, list: categories } = useCategories(); @@ -36,12 +38,13 @@ export function CoverModal({ dispatch( pushModal('category-autocomplete', { categoryGroups, + month, onSelect: categoryId => { setFromCategoryId(categoryId); }, }), ); - }, [categoryGroups, dispatch]); + }, [categoryGroups, dispatch, month]); const _onSubmit = (categoryId: string | null) => { if (categoryId) { diff --git a/packages/desktop-client/src/components/modals/RolloverBudgetSummaryModal.tsx b/packages/desktop-client/src/components/modals/RolloverBudgetSummaryModal.tsx index 2839c3ee666..0cbb9bea8a0 100644 --- a/packages/desktop-client/src/components/modals/RolloverBudgetSummaryModal.tsx +++ b/packages/desktop-client/src/components/modals/RolloverBudgetSummaryModal.tsx @@ -35,6 +35,7 @@ export function RolloverBudgetSummaryModal({ dispatch( pushModal('transfer', { title: 'Transfer', + month, amount: sheetValue, onSubmit: (amount, toCategoryId) => { onBudgetAction?.(month, 'transfer-available', { diff --git a/packages/desktop-client/src/components/modals/TransferModal.tsx b/packages/desktop-client/src/components/modals/TransferModal.tsx index 7def9a00471..0e5577f46f1 100644 --- a/packages/desktop-client/src/components/modals/TransferModal.tsx +++ b/packages/desktop-client/src/components/modals/TransferModal.tsx @@ -18,6 +18,7 @@ import { type CommonModalProps } from '../Modals'; type TransferModalProps = { modalProps: CommonModalProps; title: string; + month: string; amount: number; showToBeBudgeted: boolean; onSubmit: (amount: number, toCategoryId: string) => void; @@ -26,6 +27,7 @@ type TransferModalProps = { export function TransferModal({ modalProps, title, + month, amount: initialAmount, showToBeBudgeted, onSubmit, @@ -45,6 +47,7 @@ export function TransferModal({ dispatch( pushModal('category-autocomplete', { categoryGroups, + month, showHiddenCategories: true, onSelect: categoryId => { setToCategoryId(categoryId); diff --git a/packages/loot-core/src/client/state-types/modals.d.ts b/packages/loot-core/src/client/state-types/modals.d.ts index 6e5696002e9..ab757db87d5 100644 --- a/packages/loot-core/src/client/state-types/modals.d.ts +++ b/packages/loot-core/src/client/state-types/modals.d.ts @@ -107,6 +107,7 @@ type FinanceModals = { 'category-autocomplete': { categoryGroups: CategoryGroupEntity[]; onSelect: (categoryId: string, categoryName: string) => void; + month?: string; showHiddenCategories?: boolean; onClose?: () => void; }; @@ -200,12 +201,14 @@ type FinanceModals = { }; transfer: { title: string; + month: string; amount: number; onSubmit: (amount: number, toCategoryId: string) => void; showToBeBudgeted?: boolean; }; cover: { categoryId: string; + month: string; onSubmit: (fromCategoryId: string) => void; }; 'hold-buffer': {