Skip to content

A local-first personal finance app

[Redux] Move category states from queriesSlice to budgetSlice (#5593)

Joel Jeremy Marquez21105fc25ba8
diff --git a/packages/desktop-client/src/auth/ProtectedRoute.tsx b/packages/desktop-client/src/auth/ProtectedRoute.tsx
index 9b65272899..d5e77fbc95 100644
--- a/packages/desktop-client/src/auth/ProtectedRoute.tsx
+++ b/packages/desktop-client/src/auth/ProtectedRoute.tsx
@@ -25,7 +25,7 @@ export const ProtectedRoute = ({
const { hasPermission } = useAuth();
const [permissionGranted, setPermissionGranted] = useState(false);
const [cloudFileId] = useMetadataPref('cloudFileId');
- const allFiles = useSelector(state => state.budgets.allFiles || []);
+ const allFiles = useSelector(state => state.budgetfiles.allFiles || []);
const remoteFiles = allFiles.filter(
(f): f is SyncedLocalFile | RemoteFile =>
f.state === 'remote' || f.state === 'synced' || f.state === 'detached',
diff --git a/packages/desktop-client/src/budget/budgetSlice.ts b/packages/desktop-client/src/budget/budgetSlice.ts
new file mode 100644
index 0000000000..92590b3294
--- /dev/null
+++ b/packages/desktop-client/src/budget/budgetSlice.ts
@@ -0,0 +1,594 @@
+import { createSlice } from '@reduxjs/toolkit';
+import { t } from 'i18next';
+import memoizeOne from 'memoize-one';
+
+import { send } from 'loot-core/platform/client/fetch';
+import {
+ type CategoryEntity,
+ type CategoryGroupEntity,
+} from 'loot-core/types/models';
+
+import { resetApp } from '@desktop-client/app/appSlice';
+import {
+ addGenericErrorNotification,
+ addNotification,
+} from '@desktop-client/notifications/notificationsSlice';
+import { createAppAsyncThunk } from '@desktop-client/redux';
+
+const sliceName = 'budget';
+
+type CategoryViews = {
+ grouped: CategoryGroupEntity[];
+ list: CategoryEntity[];
+};
+
+type BudgetState = {
+ categories: CategoryViews;
+ isCategoriesLoading: boolean;
+ isCategoriesLoaded: boolean;
+ isCategoriesDirty: boolean;
+};
+
+const initialState: BudgetState = {
+ categories: {
+ grouped: [],
+ list: [],
+ },
+ isCategoriesLoading: false,
+ isCategoriesLoaded: false,
+ isCategoriesDirty: false,
+};
+
+const budgetSlice = createSlice({
+ name: sliceName,
+ initialState,
+ reducers: {
+ markCategoriesDirty(state) {
+ _markCategoriesDirty(state);
+ },
+ },
+ extraReducers: builder => {
+ builder.addCase(resetApp, () => initialState);
+
+ builder.addCase(createCategoryGroup.fulfilled, _markCategoriesDirty);
+ builder.addCase(updateCategoryGroup.fulfilled, _markCategoriesDirty);
+ builder.addCase(deleteCategoryGroup.fulfilled, _markCategoriesDirty);
+ builder.addCase(createCategory.fulfilled, _markCategoriesDirty);
+ builder.addCase(updateCategory.fulfilled, _markCategoriesDirty);
+ builder.addCase(deleteCategory.fulfilled, _markCategoriesDirty);
+ builder.addCase(moveCategoryGroup.fulfilled, _markCategoriesDirty);
+ builder.addCase(moveCategory.fulfilled, _markCategoriesDirty);
+
+ builder.addCase(reloadCategories.fulfilled, (state, action) => {
+ _loadCategories(state, action.payload);
+ });
+
+ builder.addCase(reloadCategories.rejected, state => {
+ state.isCategoriesLoading = false;
+ });
+
+ builder.addCase(reloadCategories.pending, state => {
+ state.isCategoriesLoading = true;
+ });
+
+ builder.addCase(getCategories.fulfilled, (state, action) => {
+ _loadCategories(state, action.payload);
+ });
+
+ builder.addCase(getCategories.rejected, state => {
+ state.isCategoriesLoading = false;
+ });
+
+ builder.addCase(getCategories.pending, state => {
+ state.isCategoriesLoading = true;
+ });
+ },
+});
+
+type CreateCategoryGroupPayload = {
+ name: CategoryGroupEntity['name'];
+};
+
+export const createCategoryGroup = createAppAsyncThunk(
+ `${sliceName}/createCategoryGroup`,
+ async ({ name }: CreateCategoryGroupPayload) => {
+ const id = await send('category-group-create', { name });
+ return id;
+ },
+);
+
+type UpdateCategoryGroupPayload = {
+ group: CategoryGroupEntity;
+};
+
+export const updateCategoryGroup = createAppAsyncThunk(
+ `${sliceName}/updateCategoryGroup`,
+ async ({ group }: UpdateCategoryGroupPayload) => {
+ // Strip off the categories field if it exist. It's not a real db
+ // field but groups have this extra field in the client most of the time
+ const { categories: _, ...groupNoCategories } = group;
+ await send('category-group-update', groupNoCategories);
+ },
+);
+
+type DeleteCategoryGroupPayload = {
+ id: CategoryGroupEntity['id'];
+ transferId?: CategoryGroupEntity['id'] | null;
+};
+
+export const deleteCategoryGroup = createAppAsyncThunk(
+ `${sliceName}/deleteCategoryGroup`,
+ async ({ id, transferId }: DeleteCategoryGroupPayload) => {
+ await send('category-group-delete', { id, transferId });
+ },
+);
+
+type CreateCategoryPayload = {
+ name: CategoryEntity['name'];
+ groupId: CategoryGroupEntity['id'];
+ isIncome: boolean;
+ isHidden: boolean;
+};
+export const createCategory = createAppAsyncThunk(
+ `${sliceName}/createCategory`,
+ async ({ name, groupId, isIncome, isHidden }: CreateCategoryPayload) => {
+ const id = await send('category-create', {
+ name,
+ groupId,
+ isIncome,
+ hidden: isHidden,
+ });
+ return id;
+ },
+);
+
+type UpdateCategoryPayload = {
+ category: CategoryEntity;
+};
+
+export const updateCategory = createAppAsyncThunk(
+ `${sliceName}/updateCategory`,
+ async ({ category }: UpdateCategoryPayload) => {
+ await send('category-update', category);
+ },
+);
+
+type DeleteCategoryPayload = {
+ id: CategoryEntity['id'];
+ transferId?: CategoryEntity['id'] | null;
+};
+
+export const deleteCategory = createAppAsyncThunk(
+ `${sliceName}/deleteCategory`,
+ async ({ id, transferId }: DeleteCategoryPayload, { dispatch }) => {
+ const { error } = await send('category-delete', { id, transferId });
+
+ if (error) {
+ switch (error) {
+ case 'category-type':
+ dispatch(
+ addNotification({
+ notification: {
+ id: `${sliceName}/deleteCategory/transfer`,
+ type: 'error',
+ message: t(
+ 'A category must be transferred to another of the same type (expense or income)',
+ ),
+ },
+ }),
+ );
+ break;
+ default:
+ dispatch(addGenericErrorNotification());
+ }
+
+ throw new Error(error);
+ }
+ },
+);
+
+type MoveCategoryPayload = {
+ id: CategoryEntity['id'];
+ groupId: CategoryGroupEntity['id'];
+ targetId: CategoryEntity['id'] | null;
+};
+
+export const moveCategory = createAppAsyncThunk(
+ `${sliceName}/moveCategory`,
+ async ({ id, groupId, targetId }: MoveCategoryPayload) => {
+ await send('category-move', { id, groupId, targetId });
+ },
+);
+
+type MoveCategoryGroupPayload = {
+ id: CategoryGroupEntity['id'];
+ targetId: CategoryGroupEntity['id'] | null;
+};
+
+export const moveCategoryGroup = createAppAsyncThunk(
+ `${sliceName}/moveCategoryGroup`,
+ async ({ id, targetId }: MoveCategoryGroupPayload) => {
+ await send('category-group-move', { id, targetId });
+ },
+);
+
+export const getCategories = createAppAsyncThunk(
+ `${sliceName}/getCategories`,
+ async () => {
+ const categories: CategoryViews = await send('get-categories');
+ return categories;
+ },
+ {
+ condition: (_, { getState }) => {
+ const { budget } = getState();
+ return (
+ !budget.isCategoriesLoading &&
+ (budget.isCategoriesDirty || !budget.isCategoriesLoaded)
+ );
+ },
+ },
+);
+
+export const reloadCategories = createAppAsyncThunk(
+ `${sliceName}/reloadCategories`,
+ async () => {
+ const categories: CategoryViews = await send('get-categories');
+ return categories;
+ },
+);
+
+type ApplyBudgetActionPayload =
+ | {
+ type: 'budget-amount';
+ month: string;
+ args: {
+ category: CategoryEntity['id'];
+ amount: number;
+ };
+ }
+ | {
+ type: 'copy-last';
+ month: string;
+ args: never;
+ }
+ | {
+ type: 'set-zero';
+ month: string;
+ args: never;
+ }
+ | {
+ type: 'set-3-avg';
+ month: string;
+ args: never;
+ }
+ | {
+ type: 'set-6-avg';
+ month: string;
+ args: never;
+ }
+ | {
+ type: 'set-12-avg';
+ month: string;
+ args: never;
+ }
+ | {
+ type: 'check-templates';
+ month: never;
+ args: never;
+ }
+ | {
+ type: 'apply-goal-template';
+ month: string;
+ args: never;
+ }
+ | {
+ type: 'overwrite-goal-template';
+ month: string;
+ args: never;
+ }
+ | {
+ type: 'cleanup-goal-template';
+ month: string;
+ args: never;
+ }
+ | {
+ type: 'hold';
+ month: string;
+ args: {
+ amount: number;
+ };
+ }
+ | {
+ type: 'reset-hold';
+ month: string;
+ args: never;
+ }
+ | {
+ type: 'cover-overspending';
+ month: string;
+ args: {
+ to: CategoryEntity['id'];
+ from: CategoryEntity['id'];
+ };
+ }
+ | {
+ type: 'transfer-available';
+ month: string;
+ args: {
+ amount: number;
+ category: CategoryEntity['id'];
+ };
+ }
+ | {
+ type: 'cover-overbudgeted';
+ month: string;
+ args: {
+ category: CategoryEntity['id'];
+ };
+ }
+ | {
+ type: 'transfer-category';
+ month: string;
+ args: {
+ amount: number;
+ from: CategoryEntity['id'];
+ to: CategoryEntity['id'];
+ };
+ }
+ | {
+ type: 'carryover';
+ month: string;
+ args: {
+ category: CategoryEntity['id'];
+ flag: boolean;
+ };
+ }
+ | {
+ type: 'reset-income-carryover';
+ month: string;
+ args: never;
+ }
+ | {
+ type: 'apply-single-category-template';
+ month: string;
+ args: {
+ category: CategoryEntity['id'];
+ };
+ }
+ | {
+ type: 'apply-multiple-templates';
+ month: string;
+ args: {
+ categories: Array<CategoryEntity['id']>;
+ };
+ }
+ | {
+ type: 'set-single-3-avg';
+ month: string;
+ args: {
+ category: CategoryEntity['id'];
+ };
+ }
+ | {
+ type: 'set-single-6-avg';
+ month: string;
+ args: {
+ category: CategoryEntity['id'];
+ };
+ }
+ | {
+ type: 'set-single-12-avg';
+ month: string;
+ args: {
+ category: CategoryEntity['id'];
+ };
+ }
+ | {
+ type: 'copy-single-last';
+ month: string;
+ args: {
+ category: CategoryEntity['id'];
+ };
+ };
+
+export const applyBudgetAction = createAppAsyncThunk(
+ `${sliceName}/applyBudgetAction`,
+ async ({ month, type, args }: ApplyBudgetActionPayload, { dispatch }) => {
+ switch (type) {
+ case 'budget-amount':
+ await send('budget/budget-amount', {
+ month,
+ category: args.category,
+ amount: args.amount,
+ });
+ break;
+ case 'copy-last':
+ await send('budget/copy-previous-month', { month });
+ break;
+ case 'set-zero':
+ await send('budget/set-zero', { month });
+ break;
+ case 'set-3-avg':
+ await send('budget/set-3month-avg', { month });
+ break;
+ case 'set-6-avg':
+ await send('budget/set-6month-avg', { month });
+ break;
+ case 'set-12-avg':
+ await send('budget/set-12month-avg', { month });
+ break;
+ case 'check-templates':
+ dispatch(
+ addNotification({
+ notification: await send('budget/check-templates'),
+ }),
+ );
+ break;
+ case 'apply-goal-template':
+ dispatch(
+ addNotification({
+ notification: await send('budget/apply-goal-template', { month }),
+ }),
+ );
+ break;
+ case 'overwrite-goal-template':
+ dispatch(
+ addNotification({
+ notification: await send('budget/overwrite-goal-template', {
+ month,
+ }),
+ }),
+ );
+ break;
+ case 'apply-single-category-template':
+ dispatch(
+ addNotification({
+ notification: await send('budget/apply-single-template', {
+ month,
+ category: args.category,
+ }),
+ }),
+ );
+ break;
+ case 'cleanup-goal-template':
+ dispatch(
+ addNotification({
+ notification: await send('budget/cleanup-goal-template', { month }),
+ }),
+ );
+ break;
+ case 'hold':
+ await send('budget/hold-for-next-month', {
+ month,
+ amount: args.amount,
+ });
+ break;
+ case 'reset-hold':
+ await send('budget/reset-hold', { month });
+ break;
+ case 'cover-overspending':
+ await send('budget/cover-overspending', {
+ month,
+ to: args.to,
+ from: args.from,
+ });
+ break;
+ case 'transfer-available':
+ await send('budget/transfer-available', {
+ month,
+ amount: args.amount,
+ category: args.category,
+ });
+ break;
+ case 'cover-overbudgeted':
+ await send('budget/cover-overbudgeted', {
+ month,
+ category: args.category,
+ });
+ break;
+ case 'transfer-category':
+ await send('budget/transfer-category', {
+ month,
+ amount: args.amount,
+ from: args.from,
+ to: args.to,
+ });
+ break;
+ case 'carryover': {
+ await send('budget/set-carryover', {
+ startMonth: month,
+ category: args.category,
+ flag: args.flag,
+ });
+ break;
+ }
+ case 'reset-income-carryover':
+ await send('budget/reset-income-carryover', { month });
+ break;
+ case 'apply-multiple-templates':
+ dispatch(
+ addNotification({
+ notification: await send('budget/apply-multiple-templates', {
+ month,
+ categoryIds: args.categories,
+ }),
+ }),
+ );
+ break;
+ case 'set-single-3-avg':
+ await send('budget/set-n-month-avg', {
+ month,
+ N: 3,
+ category: args.category,
+ });
+ break;
+ case 'set-single-6-avg':
+ await send('budget/set-n-month-avg', {
+ month,
+ N: 6,
+ category: args.category,
+ });
+ break;
+ case 'set-single-12-avg':
+ await send('budget/set-n-month-avg', {
+ month,
+ N: 12,
+ category: args.category,
+ });
+ break;
+ case 'copy-single-last':
+ await send('budget/copy-single-month', {
+ month,
+ category: args.category,
+ });
+ break;
+ default:
+ console.log(`Invalid action type: ${type}`);
+ }
+ },
+);
+
+export const getCategoriesById = memoizeOne(
+ (categoryGroups: CategoryGroupEntity[] | null | undefined) => {
+ const res: { [id: CategoryEntity['id']]: CategoryEntity } = {};
+ categoryGroups?.forEach(group => {
+ group.categories?.forEach(cat => {
+ res[cat.id] = cat;
+ });
+ });
+ return res;
+ },
+);
+
+export const { name, reducer, getInitialState } = budgetSlice;
+
+export const actions = {
+ ...budgetSlice.actions,
+ applyBudgetAction,
+ getCategories,
+ reloadCategories,
+ createCategoryGroup,
+ updateCategoryGroup,
+ deleteCategoryGroup,
+ createCategory,
+ updateCategory,
+ deleteCategory,
+ moveCategory,
+ moveCategoryGroup,
+};
+
+export const { markCategoriesDirty } = budgetSlice.actions;
+
+function _loadCategories(
+ state: BudgetState,
+ categories: BudgetState['categories'],
+) {
+ state.categories = categories;
+ state.isCategoriesLoading = false;
+ state.isCategoriesLoaded = true;
+ state.isCategoriesDirty = false;
+}
+
+function _markCategoriesDirty(state: BudgetState) {
+ state.isCategoriesDirty = true;
+}
diff --git a/packages/desktop-client/src/budgets/budgetsSlice.ts b/packages/desktop-client/src/budgetfiles/budgetfilesSlice.ts
similarity index 98%
rename from packages/desktop-client/src/budgets/budgetsSlice.ts
rename to packages/desktop-client/src/budgetfiles/budgetfilesSlice.ts
index 5e6f34fece..4daf57ade8 100644
--- a/packages/desktop-client/src/budgets/budgetsSlice.ts
+++ b/packages/desktop-client/src/budgetfiles/budgetfilesSlice.ts
@@ -14,7 +14,7 @@ import { loadGlobalPrefs, loadPrefs } from '@desktop-client/prefs/prefsSlice';
import { createAppAsyncThunk } from '@desktop-client/redux';
import { signOut } from '@desktop-client/users/usersSlice';
-const sliceName = 'budgets';
+const sliceName = 'budgetfiles';
export const loadBudgets = createAppAsyncThunk(
`${sliceName}/loadBudgets`,
@@ -42,7 +42,7 @@ export const loadAllFiles = createAppAsyncThunk(
await dispatch(setAllFiles({ budgets, remoteFiles: files }));
- return getState().budgets.allFiles;
+ return getState().budgetfiles.allFiles;
},
);
@@ -432,8 +432,8 @@ type SetAllFilesPayload = {
remoteFiles: RemoteFile[];
};
-const budgetsSlice = createSlice({
- name: 'budgets',
+const budgetfilesSlice = createSlice({
+ name: sliceName,
initialState,
reducers: {
setBudgets(state, action: PayloadAction<SetBudgetsPayload>) {
@@ -467,10 +467,10 @@ const budgetsSlice = createSlice({
},
});
-export const { name, reducer, getInitialState } = budgetsSlice;
+export const { name, reducer, getInitialState } = budgetfilesSlice;
export const actions = {
- ...budgetsSlice.actions,
+ ...budgetfilesSlice.actions,
loadBudgets,
loadRemoteFiles,
loadAllFiles,
diff --git a/packages/desktop-client/src/components/App.tsx b/packages/desktop-client/src/components/App.tsx
index c2add500fc..dedb6bbfd0 100644
--- a/packages/desktop-client/src/components/App.tsx
+++ b/packages/desktop-client/src/components/App.tsx
@@ -28,7 +28,10 @@ import { SidebarProvider } from './sidebar/SidebarProvider';
import { UpdateNotification } from './UpdateNotification';
import { setAppState, sync } from '@desktop-client/app/appSlice';
-import { closeBudget, loadBudget } from '@desktop-client/budgets/budgetsSlice';
+import {
+ closeBudget,
+ loadBudget,
+} from '@desktop-client/budgetfiles/budgetfilesSlice';
import { handleGlobalEvents } from '@desktop-client/global-events';
import { useMetadataPref } from '@desktop-client/hooks/useMetadataPref';
import { SpreadsheetProvider } from '@desktop-client/hooks/useSpreadsheet';
diff --git a/packages/desktop-client/src/components/LoggedInUser.tsx b/packages/desktop-client/src/components/LoggedInUser.tsx
index 4270bd813f..3f3321c74d 100644
--- a/packages/desktop-client/src/components/LoggedInUser.tsx
+++ b/packages/desktop-client/src/components/LoggedInUser.tsx
@@ -19,7 +19,7 @@ import { useMultiuserEnabled, useServerURL } from './ServerContext';
import { useAuth } from '@desktop-client/auth/AuthProvider';
import { Permissions } from '@desktop-client/auth/types';
-import { closeBudget } from '@desktop-client/budgets/budgetsSlice';
+import { closeBudget } from '@desktop-client/budgetfiles/budgetfilesSlice';
import { useMetadataPref } from '@desktop-client/hooks/useMetadataPref';
import { useNavigate } from '@desktop-client/hooks/useNavigate';
import { useSelector, useDispatch } from '@desktop-client/redux';
@@ -49,7 +49,7 @@ export function LoggedInUser({
const location = useLocation();
const { hasPermission } = useAuth();
const multiuserEnabled = useMultiuserEnabled();
- const allFiles = useSelector(state => state.budgets.allFiles || []);
+ const allFiles = useSelector(state => state.budgetfiles.allFiles || []);
const remoteFiles = allFiles.filter(
f => f.state === 'remote' || f.state === 'synced' || f.state === 'detached',
) as (SyncedLocalFile | RemoteFile)[];
diff --git a/packages/desktop-client/src/components/budget/index.tsx b/packages/desktop-client/src/components/budget/index.tsx
index 6455923376..9ded2df849 100644
--- a/packages/desktop-client/src/components/budget/index.tsx
+++ b/packages/desktop-client/src/components/budget/index.tsx
@@ -15,15 +15,6 @@ import * as trackingBudget from './tracking/TrackingBudgetComponents';
import { TrackingBudgetProvider } from './tracking/TrackingBudgetContext';
import { prewarmAllMonths, prewarmMonth } from './util';
-import { useCategories } from '@desktop-client/hooks/useCategories';
-import { useGlobalPref } from '@desktop-client/hooks/useGlobalPref';
-import { useLocalPref } from '@desktop-client/hooks/useLocalPref';
-import { useNavigate } from '@desktop-client/hooks/useNavigate';
-import { SheetNameProvider } from '@desktop-client/hooks/useSheetName';
-import { useSpreadsheet } from '@desktop-client/hooks/useSpreadsheet';
-import { useSyncedPref } from '@desktop-client/hooks/useSyncedPref';
-import { pushModal } from '@desktop-client/modals/modalsSlice';
-import { addNotification } from '@desktop-client/notifications/notificationsSlice';
import {
applyBudgetAction,
createCategory,
@@ -35,7 +26,16 @@ import {
moveCategoryGroup,
updateCategory,
updateCategoryGroup,
-} from '@desktop-client/queries/queriesSlice';
+} from '@desktop-client/budget/budgetSlice';
+import { useCategories } from '@desktop-client/hooks/useCategories';
+import { useGlobalPref } from '@desktop-client/hooks/useGlobalPref';
+import { useLocalPref } from '@desktop-client/hooks/useLocalPref';
+import { useNavigate } from '@desktop-client/hooks/useNavigate';
+import { SheetNameProvider } from '@desktop-client/hooks/useSheetName';
+import { useSpreadsheet } from '@desktop-client/hooks/useSpreadsheet';
+import { useSyncedPref } from '@desktop-client/hooks/useSyncedPref';
+import { pushModal } from '@desktop-client/modals/modalsSlice';
+import { addNotification } from '@desktop-client/notifications/notificationsSlice';
import { useDispatch } from '@desktop-client/redux';
type TrackingReportComponents = {
diff --git a/packages/desktop-client/src/components/manager/BudgetFileSelection.tsx b/packages/desktop-client/src/components/manager/BudgetFileSelection.tsx
index 82cec47836..c0db185616 100644
--- a/packages/desktop-client/src/components/manager/BudgetFileSelection.tsx
+++ b/packages/desktop-client/src/components/manager/BudgetFileSelection.tsx
@@ -55,7 +55,7 @@ import {
downloadBudget,
loadAllFiles,
loadBudget,
-} from '@desktop-client/budgets/budgetsSlice';
+} from '@desktop-client/budgetfiles/budgetfilesSlice';
import { useMultiuserEnabled } from '@desktop-client/components/ServerContext';
import { useInitialMount } from '@desktop-client/hooks/useInitialMount';
import { useMetadataPref } from '@desktop-client/hooks/useMetadataPref';
@@ -544,7 +544,7 @@ export function BudgetFileSelection({
quickSwitchMode = false,
}: BudgetFileSelectionProps) {
const dispatch = useDispatch();
- const allFiles = useSelector(state => state.budgets.allFiles || []);
+ const allFiles = useSelector(state => state.budgetfiles.allFiles || []);
const multiuserEnabled = useMultiuserEnabled();
const [id] = useMetadataPref('id');
const [currentUserId, setCurrentUserId] = useState('');
@@ -730,7 +730,7 @@ type UserAccessForFileProps = {
function UserAccessForFile({ fileId, currentUserId }: UserAccessForFileProps) {
const { t } = useTranslation();
- const allFiles = useSelector(state => state.budgets.allFiles || []);
+ const allFiles = useSelector(state => state.budgetfiles.allFiles || []);
const remoteFiles = allFiles.filter(
f => f.state === 'remote' || f.state === 'synced' || f.state === 'detached',
) as (SyncedLocalFile | RemoteFile)[];
diff --git a/packages/desktop-client/src/components/manager/ConfigServer.tsx b/packages/desktop-client/src/components/manager/ConfigServer.tsx
index 2e72d1335c..ec851e8108 100644
--- a/packages/desktop-client/src/components/manager/ConfigServer.tsx
+++ b/packages/desktop-client/src/components/manager/ConfigServer.tsx
@@ -17,7 +17,7 @@ import {
import { Title } from './subscribe/common';
-import { createBudget } from '@desktop-client/budgets/budgetsSlice';
+import { createBudget } from '@desktop-client/budgetfiles/budgetfilesSlice';
import { Link } from '@desktop-client/components/common/Link';
import {
useServerURL,
diff --git a/packages/desktop-client/src/components/manager/ManagementApp.tsx b/packages/desktop-client/src/components/manager/ManagementApp.tsx
index 57fb6b4d36..cd895ade58 100644
--- a/packages/desktop-client/src/components/manager/ManagementApp.tsx
+++ b/packages/desktop-client/src/components/manager/ManagementApp.tsx
@@ -66,7 +66,7 @@ export function ManagementApp() {
isNarrowWidth ? theme.mobileConfigServerViewTheme : undefined,
);
- const files = useSelector(state => state.budgets.allFiles);
+ const files = useSelector(state => state.budgetfiles.allFiles);
const isLoading = useSelector(state => state.app.loadingText !== null);
const userData = useSelector(state => state.user.data);
const multiuserEnabled = useMultiuserEnabled();
diff --git a/packages/desktop-client/src/components/manager/WelcomeScreen.tsx b/packages/desktop-client/src/components/manager/WelcomeScreen.tsx
index 7c58dabcd6..5aa1aa2f20 100644
--- a/packages/desktop-client/src/components/manager/WelcomeScreen.tsx
+++ b/packages/desktop-client/src/components/manager/WelcomeScreen.tsx
@@ -8,7 +8,7 @@ import { Text } from '@actual-app/components/text';
import { theme } from '@actual-app/components/theme';
import { View } from '@actual-app/components/view';
-import { createBudget } from '@desktop-client/budgets/budgetsSlice';
+import { createBudget } from '@desktop-client/budgetfiles/budgetfilesSlice';
import { Link } from '@desktop-client/components/common/Link';
import { pushModal } from '@desktop-client/modals/modalsSlice';
import { useDispatch } from '@desktop-client/redux';
diff --git a/packages/desktop-client/src/components/manager/subscribe/Bootstrap.tsx b/packages/desktop-client/src/components/manager/subscribe/Bootstrap.tsx
index a5d79bd6f6..c467734ef6 100644
--- a/packages/desktop-client/src/components/manager/subscribe/Bootstrap.tsx
+++ b/packages/desktop-client/src/components/manager/subscribe/Bootstrap.tsx
@@ -13,7 +13,7 @@ import { send } from 'loot-core/platform/client/fetch';
import { useBootstrapped, Title } from './common';
import { ConfirmPasswordForm } from './ConfirmPasswordForm';
-import { createBudget } from '@desktop-client/budgets/budgetsSlice';
+import { createBudget } from '@desktop-client/budgetfiles/budgetfilesSlice';
import { Link } from '@desktop-client/components/common/Link';
import { useRefreshLoginMethods } from '@desktop-client/components/ServerContext';
import { useNavigate } from '@desktop-client/hooks/useNavigate';
diff --git a/packages/desktop-client/src/components/mobile/budget/BudgetPage.tsx b/packages/desktop-client/src/components/mobile/budget/BudgetPage.tsx
index b26eb00d35..f3f2fcd823 100644
--- a/packages/desktop-client/src/components/mobile/budget/BudgetPage.tsx
+++ b/packages/desktop-client/src/components/mobile/budget/BudgetPage.tsx
@@ -28,6 +28,15 @@ import { groupById } from 'loot-core/shared/util';
import { BudgetTable, PILL_STYLE } from './BudgetTable';
import { sync } from '@desktop-client/app/appSlice';
+import {
+ applyBudgetAction,
+ createCategory,
+ createCategoryGroup,
+ deleteCategory,
+ deleteCategoryGroup,
+ updateCategory,
+ updateCategoryGroup,
+} from '@desktop-client/budget/budgetSlice';
import { prewarmMonth } from '@desktop-client/components/budget/util';
import { MobilePageHeader, Page } from '@desktop-client/components/Page';
import { SyncRefresh } from '@desktop-client/components/SyncRefresh';
@@ -42,15 +51,6 @@ import { useSpreadsheet } from '@desktop-client/hooks/useSpreadsheet';
import { useSyncedPref } from '@desktop-client/hooks/useSyncedPref';
import { useUndo } from '@desktop-client/hooks/useUndo';
import { collapseModals, pushModal } from '@desktop-client/modals/modalsSlice';
-import {
- applyBudgetAction,
- createCategory,
- createCategoryGroup,
- deleteCategory,
- deleteCategoryGroup,
- updateCategory,
- updateCategoryGroup,
-} from '@desktop-client/queries/queriesSlice';
import { useDispatch } from '@desktop-client/redux';
import {
envelopeBudget,
diff --git a/packages/desktop-client/src/components/mobile/budget/ExpenseCategoryList.tsx b/packages/desktop-client/src/components/mobile/budget/ExpenseCategoryList.tsx
index 9c8a204eb5..5d24d66738 100644
--- a/packages/desktop-client/src/components/mobile/budget/ExpenseCategoryList.tsx
+++ b/packages/desktop-client/src/components/mobile/budget/ExpenseCategoryList.tsx
@@ -12,7 +12,7 @@ import {
import { ExpenseCategoryListItem } from './ExpenseCategoryListItem';
-import { moveCategory } from '@desktop-client/queries/queriesSlice';
+import { moveCategory } from '@desktop-client/budget/budgetSlice';
import { useDispatch } from '@desktop-client/redux';
type ExpenseCategoryListProps = {
diff --git a/packages/desktop-client/src/components/mobile/budget/ExpenseGroupList.tsx b/packages/desktop-client/src/components/mobile/budget/ExpenseGroupList.tsx
index 1f5ea9c65f..455e9873c4 100644
--- a/packages/desktop-client/src/components/mobile/budget/ExpenseGroupList.tsx
+++ b/packages/desktop-client/src/components/mobile/budget/ExpenseGroupList.tsx
@@ -15,7 +15,7 @@ import {
ExpenseGroupListItem,
} from './ExpenseGroupListItem';
-import { moveCategoryGroup } from '@desktop-client/queries/queriesSlice';
+import { moveCategoryGroup } from '@desktop-client/budget/budgetSlice';
import { useDispatch } from '@desktop-client/redux';
type ExpenseGroupListProps = {
diff --git a/packages/desktop-client/src/components/mobile/budget/IncomeCategoryList.tsx b/packages/desktop-client/src/components/mobile/budget/IncomeCategoryList.tsx
index f9c47f07a9..0960778881 100644
--- a/packages/desktop-client/src/components/mobile/budget/IncomeCategoryList.tsx
+++ b/packages/desktop-client/src/components/mobile/budget/IncomeCategoryList.tsx
@@ -9,7 +9,7 @@ import { type CategoryEntity } from 'loot-core/types/models';
import { IncomeCategoryListItem } from './IncomeCategoryListItem';
-import { moveCategory } from '@desktop-client/queries/queriesSlice';
+import { moveCategory } from '@desktop-client/budget/budgetSlice';
import { useDispatch } from '@desktop-client/redux';
type IncomeCategoryListProps = {
diff --git a/packages/desktop-client/src/components/modals/BudgetFileSelectionModal.tsx b/packages/desktop-client/src/components/modals/BudgetFileSelectionModal.tsx
index 44e13913a0..9c62fb67d8 100644
--- a/packages/desktop-client/src/components/modals/BudgetFileSelectionModal.tsx
+++ b/packages/desktop-client/src/components/modals/BudgetFileSelectionModal.tsx
@@ -17,7 +17,7 @@ export function BudgetFileSelectionModal() {
const { t } = useTranslation();
const [id] = useMetadataPref('id');
const currentFile = useSelector(state =>
- state.budgets.allFiles?.find(f => 'id' in f && f.id === id),
+ state.budgetfiles.allFiles?.find(f => 'id' in f && f.id === id),
);
return (
diff --git a/packages/desktop-client/src/components/modals/CreateEncryptionKeyModal.tsx b/packages/desktop-client/src/components/modals/CreateEncryptionKeyModal.tsx
index b04259b1b4..49be6359f1 100644
--- a/packages/desktop-client/src/components/modals/CreateEncryptionKeyModal.tsx
+++ b/packages/desktop-client/src/components/modals/CreateEncryptionKeyModal.tsx
@@ -18,7 +18,7 @@ import { send } from 'loot-core/platform/client/fetch';
import { getCreateKeyError } from 'loot-core/shared/errors';
import { sync } from '@desktop-client/app/appSlice';
-import { loadAllFiles } from '@desktop-client/budgets/budgetsSlice';
+import { loadAllFiles } from '@desktop-client/budgetfiles/budgetfilesSlice';
import { Link } from '@desktop-client/components/common/Link';
import {
Modal,
diff --git a/packages/desktop-client/src/components/modals/LoadBackupModal.tsx b/packages/desktop-client/src/components/modals/LoadBackupModal.tsx
index 00cd105f1a..8dc1ff9c27 100644
--- a/packages/desktop-client/src/components/modals/LoadBackupModal.tsx
+++ b/packages/desktop-client/src/components/modals/LoadBackupModal.tsx
@@ -10,7 +10,10 @@ import { View } from '@actual-app/components/view';
import { send, listen } from 'loot-core/platform/client/fetch';
import { type Backup } from 'loot-core/server/budgetfiles/backups';
-import { loadBackup, makeBackup } from '@desktop-client/budgets/budgetsSlice';
+import {
+ loadBackup,
+ makeBackup,
+} from '@desktop-client/budgetfiles/budgetfilesSlice';
import {
Modal,
ModalCloseButton,
diff --git a/packages/desktop-client/src/components/modals/OpenIDEnableModal.tsx b/packages/desktop-client/src/components/modals/OpenIDEnableModal.tsx
index 6edb6f5898..6df2d115de 100644
--- a/packages/desktop-client/src/components/modals/OpenIDEnableModal.tsx
+++ b/packages/desktop-client/src/components/modals/OpenIDEnableModal.tsx
@@ -12,7 +12,7 @@ import * as asyncStorage from 'loot-core/platform/server/asyncStorage';
import { getOpenIdErrors } from 'loot-core/shared/errors';
import { type OpenIdConfig } from 'loot-core/types/models';
-import { closeBudget } from '@desktop-client/budgets/budgetsSlice';
+import { closeBudget } from '@desktop-client/budgetfiles/budgetfilesSlice';
import { Error } from '@desktop-client/components/alerts';
import {
Modal,
diff --git a/packages/desktop-client/src/components/modals/OutOfSyncMigrationsModal.tsx b/packages/desktop-client/src/components/modals/OutOfSyncMigrationsModal.tsx
index a21b1c668b..1e3445ed3a 100644
--- a/packages/desktop-client/src/components/modals/OutOfSyncMigrationsModal.tsx
+++ b/packages/desktop-client/src/components/modals/OutOfSyncMigrationsModal.tsx
@@ -6,7 +6,7 @@ import { Paragraph } from '@actual-app/components/paragraph';
import { Text } from '@actual-app/components/text';
import { View } from '@actual-app/components/view';
-import { closeBudget } from '@desktop-client/budgets/budgetsSlice';
+import { closeBudget } from '@desktop-client/budgetfiles/budgetfilesSlice';
import { Link } from '@desktop-client/components/common/Link';
import {
Modal,
diff --git a/packages/desktop-client/src/components/modals/PasswordEnableModal.tsx b/packages/desktop-client/src/components/modals/PasswordEnableModal.tsx
index dc699dfe65..2ab1e49ac6 100644
--- a/packages/desktop-client/src/components/modals/PasswordEnableModal.tsx
+++ b/packages/desktop-client/src/components/modals/PasswordEnableModal.tsx
@@ -10,7 +10,7 @@ import { View } from '@actual-app/components/view';
import { send } from 'loot-core/platform/client/fetch';
import * as asyncStorage from 'loot-core/platform/server/asyncStorage';
-import { closeBudget } from '@desktop-client/budgets/budgetsSlice';
+import { closeBudget } from '@desktop-client/budgetfiles/budgetfilesSlice';
import { Error as ErrorAlert } from '@desktop-client/components/alerts';
import {
Modal,
diff --git a/packages/desktop-client/src/components/modals/TransferOwnership.tsx b/packages/desktop-client/src/components/modals/TransferOwnership.tsx
index 32d0619a39..6a67ef910a 100644
--- a/packages/desktop-client/src/components/modals/TransferOwnership.tsx
+++ b/packages/desktop-client/src/components/modals/TransferOwnership.tsx
@@ -15,7 +15,7 @@ import { type Budget } from 'loot-core/types/budget';
import { type RemoteFile, type SyncedLocalFile } from 'loot-core/types/file';
import { type Handlers } from 'loot-core/types/handlers';
-import { closeAndLoadBudget } from '@desktop-client/budgets/budgetsSlice';
+import { closeAndLoadBudget } from '@desktop-client/budgetfiles/budgetfilesSlice';
import {
Modal,
ModalCloseButton,
@@ -45,7 +45,7 @@ export function TransferOwnership({
const [error, setError] = useState<string | null>(null);
const [availableUsers, setAvailableUsers] = useState<[string, string][]>([]);
const [cloudFileId] = useMetadataPref('cloudFileId');
- const allFiles = useSelector(state => state.budgets.allFiles || []);
+ const allFiles = useSelector(state => state.budgetfiles.allFiles || []);
const remoteFiles = allFiles.filter(
f => f.state === 'remote' || f.state === 'synced' || f.state === 'detached',
) as (SyncedLocalFile | RemoteFile)[];
diff --git a/packages/desktop-client/src/components/modals/manager/DeleteFileModal.tsx b/packages/desktop-client/src/components/modals/manager/DeleteFileModal.tsx
index f5e5f1d021..a5222f035d 100644
--- a/packages/desktop-client/src/components/modals/manager/DeleteFileModal.tsx
+++ b/packages/desktop-client/src/components/modals/manager/DeleteFileModal.tsx
@@ -6,7 +6,7 @@ import { Text } from '@actual-app/components/text';
import { theme } from '@actual-app/components/theme';
import { View } from '@actual-app/components/view';
-import { deleteBudget } from '@desktop-client/budgets/budgetsSlice';
+import { deleteBudget } from '@desktop-client/budgetfiles/budgetfilesSlice';
import {
Modal,
ModalCloseButton,
diff --git a/packages/desktop-client/src/components/modals/manager/DuplicateFileModal.tsx b/packages/desktop-client/src/components/modals/manager/DuplicateFileModal.tsx
index 1e583758ec..3c6cf9f0ef 100644
--- a/packages/desktop-client/src/components/modals/manager/DuplicateFileModal.tsx
+++ b/packages/desktop-client/src/components/modals/manager/DuplicateFileModal.tsx
@@ -12,7 +12,7 @@ import { View } from '@actual-app/components/view';
import { send } from 'loot-core/platform/client/fetch';
-import { duplicateBudget } from '@desktop-client/budgets/budgetsSlice';
+import { duplicateBudget } from '@desktop-client/budgetfiles/budgetfilesSlice';
import {
Modal,
ModalButtons,
diff --git a/packages/desktop-client/src/components/modals/manager/FilesSettingsModal.tsx b/packages/desktop-client/src/components/modals/manager/FilesSettingsModal.tsx
index e6faa7d822..482cdb728e 100644
--- a/packages/desktop-client/src/components/modals/manager/FilesSettingsModal.tsx
+++ b/packages/desktop-client/src/components/modals/manager/FilesSettingsModal.tsx
@@ -8,7 +8,7 @@ import { Text } from '@actual-app/components/text';
import { theme } from '@actual-app/components/theme';
import { View } from '@actual-app/components/view';
-import { loadAllFiles } from '@desktop-client/budgets/budgetsSlice';
+import { loadAllFiles } from '@desktop-client/budgetfiles/budgetfilesSlice';
import {
Modal,
ModalCloseButton,
diff --git a/packages/desktop-client/src/components/modals/manager/ImportActualModal.tsx b/packages/desktop-client/src/components/modals/manager/ImportActualModal.tsx
index b97c8f3347..10afc8927f 100644
--- a/packages/desktop-client/src/components/modals/manager/ImportActualModal.tsx
+++ b/packages/desktop-client/src/components/modals/manager/ImportActualModal.tsx
@@ -9,7 +9,7 @@ import { styles } from '@actual-app/components/styles';
import { theme } from '@actual-app/components/theme';
import { View } from '@actual-app/components/view';
-import { importBudget } from '@desktop-client/budgets/budgetsSlice';
+import { importBudget } from '@desktop-client/budgetfiles/budgetfilesSlice';
import {
Modal,
ModalCloseButton,
diff --git a/packages/desktop-client/src/components/modals/manager/ImportYNAB4Modal.tsx b/packages/desktop-client/src/components/modals/manager/ImportYNAB4Modal.tsx
index dfa72e3413..214017eff4 100644
--- a/packages/desktop-client/src/components/modals/manager/ImportYNAB4Modal.tsx
+++ b/packages/desktop-client/src/components/modals/manager/ImportYNAB4Modal.tsx
@@ -9,7 +9,7 @@ import { styles } from '@actual-app/components/styles';
import { theme } from '@actual-app/components/theme';
import { View } from '@actual-app/components/view';
-import { importBudget } from '@desktop-client/budgets/budgetsSlice';
+import { importBudget } from '@desktop-client/budgetfiles/budgetfilesSlice';
import {
Modal,
ModalCloseButton,
diff --git a/packages/desktop-client/src/components/modals/manager/ImportYNAB5Modal.tsx b/packages/desktop-client/src/components/modals/manager/ImportYNAB5Modal.tsx
index 996967c583..cd94a4c68e 100644
--- a/packages/desktop-client/src/components/modals/manager/ImportYNAB5Modal.tsx
+++ b/packages/desktop-client/src/components/modals/manager/ImportYNAB5Modal.tsx
@@ -9,7 +9,7 @@ import { styles } from '@actual-app/components/styles';
import { theme } from '@actual-app/components/theme';
import { View } from '@actual-app/components/view';
-import { importBudget } from '@desktop-client/budgets/budgetsSlice';
+import { importBudget } from '@desktop-client/budgetfiles/budgetfilesSlice';
import { Link } from '@desktop-client/components/common/Link';
import {
Modal,
diff --git a/packages/desktop-client/src/components/settings/index.tsx b/packages/desktop-client/src/components/settings/index.tsx
index 0a15a0f093..53f6b0e3f5 100644
--- a/packages/desktop-client/src/components/settings/index.tsx
+++ b/packages/desktop-client/src/components/settings/index.tsx
@@ -27,7 +27,7 @@ import { ResetCache, ResetSync } from './Reset';
import { ThemeSettings } from './Themes';
import { AdvancedToggle, Setting } from './UI';
-import { closeBudget } from '@desktop-client/budgets/budgetsSlice';
+import { closeBudget } from '@desktop-client/budgetfiles/budgetfilesSlice';
import { Link } from '@desktop-client/components/common/Link';
import { FormField, FormLabel } from '@desktop-client/components/forms';
import { MOBILE_NAV_HEIGHT } from '@desktop-client/components/mobile/MobileNavTabs';
diff --git a/packages/desktop-client/src/components/sidebar/BudgetName.tsx b/packages/desktop-client/src/components/sidebar/BudgetName.tsx
index 1d3ddce992..c02c28681e 100644
--- a/packages/desktop-client/src/components/sidebar/BudgetName.tsx
+++ b/packages/desktop-client/src/components/sidebar/BudgetName.tsx
@@ -13,7 +13,7 @@ import { View } from '@actual-app/components/view';
import * as Platform from 'loot-core/shared/platform';
-import { closeBudget } from '@desktop-client/budgets/budgetsSlice';
+import { closeBudget } from '@desktop-client/budgetfiles/budgetfilesSlice';
import { useContextMenu } from '@desktop-client/hooks/useContextMenu';
import { useMetadataPref } from '@desktop-client/hooks/useMetadataPref';
import { useNavigate } from '@desktop-client/hooks/useNavigate';
diff --git a/packages/desktop-client/src/components/transactions/TransactionsTable.tsx b/packages/desktop-client/src/components/transactions/TransactionsTable.tsx
index 1ce84d9d94..54ecce6bc7 100644
--- a/packages/desktop-client/src/components/transactions/TransactionsTable.tsx
+++ b/packages/desktop-client/src/components/transactions/TransactionsTable.tsx
@@ -83,6 +83,7 @@ import {
import { TransactionMenu } from './TransactionMenu';
import { getAccountsById } from '@desktop-client/accounts/accountsSlice';
+import { getCategoriesById } from '@desktop-client/budget/budgetSlice';
import { AccountAutocomplete } from '@desktop-client/components/autocomplete/AccountAutocomplete';
import { CategoryAutocomplete } from '@desktop-client/components/autocomplete/CategoryAutocomplete';
import { PayeeAutocomplete } from '@desktop-client/components/autocomplete/PayeeAutocomplete';
@@ -127,7 +128,6 @@ import { pushModal } from '@desktop-client/modals/modalsSlice';
import { NotesTagFormatter } from '@desktop-client/notes/NotesTagFormatter';
import { addNotification } from '@desktop-client/notifications/notificationsSlice';
import { getPayeesById } from '@desktop-client/payees/payeesSlice';
-import { getCategoriesById } from '@desktop-client/queries/queriesSlice';
import { useDispatch } from '@desktop-client/redux';
type TransactionHeaderProps = {
diff --git a/packages/desktop-client/src/global-events.ts b/packages/desktop-client/src/global-events.ts
index 81e3a30903..d35f375b8f 100644
--- a/packages/desktop-client/src/global-events.ts
+++ b/packages/desktop-client/src/global-events.ts
@@ -4,7 +4,8 @@ import * as undo from 'loot-core/platform/client/undo';
import { reloadAccounts } from './accounts/accountsSlice';
import { setAppState } from './app/appSlice';
-import { closeBudgetUI } from './budgets/budgetsSlice';
+import { reloadCategories } from './budget/budgetSlice';
+import { closeBudgetUI } from './budgetfiles/budgetfilesSlice';
import { closeModal, pushModal, replaceModal } from './modals/modalsSlice';
import {
addGenericErrorNotification,
@@ -12,7 +13,6 @@ import {
} from './notifications/notificationsSlice';
import { reloadPayees } from './payees/payeesSlice';
import { loadPrefs } from './prefs/prefsSlice';
-import { reloadCategories } from './queries/queriesSlice';
import { type AppStore } from './redux/store';
import * as syncEvents from './sync-events';
diff --git a/packages/desktop-client/src/hooks/useCategories.ts b/packages/desktop-client/src/hooks/useCategories.ts
index 7a4a33462e..7064cf5b03 100644
--- a/packages/desktop-client/src/hooks/useCategories.ts
+++ b/packages/desktop-client/src/hooks/useCategories.ts
@@ -2,14 +2,14 @@ import { useEffect } from 'react';
import { useInitialMount } from './useInitialMount';
-import { getCategories } from '@desktop-client/queries/queriesSlice';
+import { getCategories } from '@desktop-client/budget/budgetSlice';
import { useSelector, useDispatch } from '@desktop-client/redux';
export function useCategories() {
const dispatch = useDispatch();
const isInitialMount = useInitialMount();
const isCategoriesDirty = useSelector(
- state => state.queries.isCategoriesDirty,
+ state => state.budget.isCategoriesDirty,
);
useEffect(() => {
@@ -18,5 +18,5 @@ export function useCategories() {
}
}, [dispatch, isInitialMount, isCategoriesDirty]);
- return useSelector(state => state.queries.categories);
+ return useSelector(state => state.budget.categories);
}
diff --git a/packages/desktop-client/src/index.tsx b/packages/desktop-client/src/index.tsx
index bd9e6665a9..7ef9a3ba6a 100644
--- a/packages/desktop-client/src/index.tsx
+++ b/packages/desktop-client/src/index.tsx
@@ -19,7 +19,8 @@ import { q } from 'loot-core/shared/query';
import * as accountsSlice from './accounts/accountsSlice';
import * as appSlice from './app/appSlice';
import { AuthProvider } from './auth/AuthProvider';
-import * as budgetsSlice from './budgets/budgetsSlice';
+import * as budgetSlice from './budget/budgetSlice';
+import * as budgetfilesSlice from './budgetfiles/budgetfilesSlice';
// See https://github.com/WICG/focus-visible. Only makes the blue
// focus outline appear from keyboard events.
import 'focus-visible';
@@ -27,6 +28,7 @@ import { App } from './components/App';
import { ServerProvider } from './components/ServerContext';
import * as modalsSlice from './modals/modalsSlice';
import * as notificationsSlice from './notifications/notificationsSlice';
+import * as payeesSlice from './payees/payeesSlice';
import * as prefsSlice from './prefs/prefsSlice';
import { aqlQuery } from './queries/aqlQuery';
import * as queriesSlice from './queries/queriesSlice';
@@ -38,9 +40,11 @@ const boundActions = bindActionCreators(
{
...accountsSlice.actions,
...appSlice.actions,
- ...budgetsSlice.actions,
+ ...budgetSlice.actions,
+ ...budgetfilesSlice.actions,
...modalsSlice.actions,
...notificationsSlice.actions,
+ ...payeesSlice.actions,
...prefsSlice.actions,
...queriesSlice.actions,
...usersSlice.actions,
diff --git a/packages/desktop-client/src/queries/queriesSlice.ts b/packages/desktop-client/src/queries/queriesSlice.ts
index 27158e2822..56951c2e17 100644
--- a/packages/desktop-client/src/queries/queriesSlice.ts
+++ b/packages/desktop-client/src/queries/queriesSlice.ts
@@ -1,39 +1,20 @@
// @ts-strict-ignore
import { createSlice, type PayloadAction } from '@reduxjs/toolkit';
-import { t } from 'i18next';
-import memoizeOne from 'memoize-one';
import { send } from 'loot-core/platform/client/fetch';
-import {
- type CategoryEntity,
- type CategoryGroupEntity,
- type TransactionEntity,
- type Tag,
-} from 'loot-core/types/models';
+import { type TransactionEntity, type Tag } from 'loot-core/types/models';
import { markUpdatedAccounts } from '@desktop-client/accounts/accountsSlice';
import { resetApp } from '@desktop-client/app/appSlice';
-import {
- addGenericErrorNotification,
- addNotification,
-} from '@desktop-client/notifications/notificationsSlice';
+import { addNotification } from '@desktop-client/notifications/notificationsSlice';
import { createAppAsyncThunk } from '@desktop-client/redux';
const sliceName = 'queries';
-type CategoryViews = {
- grouped: CategoryGroupEntity[];
- list: CategoryEntity[];
-};
-
type QueriesState = {
newTransactions: Array<TransactionEntity['id']>;
matchedTransactions: Array<TransactionEntity['id']>;
lastTransaction: TransactionEntity | null;
- categories: CategoryViews;
- isCategoriesLoading: boolean;
- isCategoriesLoaded: boolean;
- isCategoriesDirty: boolean;
tags: Tag[];
isTagsLoading: boolean;
isTagsLoaded: boolean;
@@ -44,13 +25,6 @@ const initialState: QueriesState = {
newTransactions: [],
matchedTransactions: [],
lastTransaction: null,
- categories: {
- grouped: [],
- list: [],
- },
- isCategoriesLoading: false,
- isCategoriesLoaded: false,
- isCategoriesDirty: false,
tags: [],
isTagsLoading: false,
isTagsLoaded: false,
@@ -103,49 +77,11 @@ const queriesSlice = createSlice({
) {
state.lastTransaction = action.payload.transaction;
},
- markCategoriesDirty(state) {
- _markCategoriesDirty(state);
- },
markTagsDirty(state) {
_markTagsDirty(state);
},
},
extraReducers: builder => {
- // Categories
-
- builder.addCase(createCategoryGroup.fulfilled, _markCategoriesDirty);
- builder.addCase(updateCategoryGroup.fulfilled, _markCategoriesDirty);
- builder.addCase(deleteCategoryGroup.fulfilled, _markCategoriesDirty);
- builder.addCase(createCategory.fulfilled, _markCategoriesDirty);
- builder.addCase(updateCategory.fulfilled, _markCategoriesDirty);
- builder.addCase(deleteCategory.fulfilled, _markCategoriesDirty);
- builder.addCase(moveCategoryGroup.fulfilled, _markCategoriesDirty);
- builder.addCase(moveCategory.fulfilled, _markCategoriesDirty);
-
- builder.addCase(reloadCategories.fulfilled, (state, action) => {
- _loadCategories(state, action.payload);
- });
-
- builder.addCase(reloadCategories.rejected, state => {
- state.isCategoriesLoading = false;
- });
-
- builder.addCase(reloadCategories.pending, state => {
- state.isCategoriesLoading = true;
- });
-
- builder.addCase(getCategories.fulfilled, (state, action) => {
- _loadCategories(state, action.payload);
- });
-
- builder.addCase(getCategories.rejected, state => {
- state.isCategoriesLoading = false;
- });
-
- builder.addCase(getCategories.pending, state => {
- state.isCategoriesLoading = true;
- });
-
// App
builder.addCase(resetApp, () => initialState);
@@ -195,160 +131,6 @@ const queriesSlice = createSlice({
},
});
-// Category actions
-
-type CreateCategoryGroupPayload = {
- name: CategoryGroupEntity['name'];
-};
-
-export const createCategoryGroup = createAppAsyncThunk(
- `${sliceName}/createCategoryGroup`,
- async ({ name }: CreateCategoryGroupPayload) => {
- const id = await send('category-group-create', { name });
- return id;
- },
-);
-
-type UpdateCategoryGroupPayload = {
- group: CategoryGroupEntity;
-};
-
-export const updateCategoryGroup = createAppAsyncThunk(
- `${sliceName}/updateCategoryGroup`,
- async ({ group }: UpdateCategoryGroupPayload) => {
- // Strip off the categories field if it exist. It's not a real db
- // field but groups have this extra field in the client most of the time
- const { categories: _, ...groupNoCategories } = group;
- await send('category-group-update', groupNoCategories);
- },
-);
-
-type DeleteCategoryGroupPayload = {
- id: CategoryGroupEntity['id'];
- transferId?: CategoryGroupEntity['id'];
-};
-
-export const deleteCategoryGroup = createAppAsyncThunk(
- `${sliceName}/deleteCategoryGroup`,
- async ({ id, transferId }: DeleteCategoryGroupPayload) => {
- await send('category-group-delete', { id, transferId });
- },
-);
-
-type CreateCategoryPayload = {
- name: CategoryEntity['name'];
- groupId: CategoryGroupEntity['id'];
- isIncome: boolean;
- isHidden: boolean;
-};
-export const createCategory = createAppAsyncThunk(
- `${sliceName}/createCategory`,
- async ({ name, groupId, isIncome, isHidden }: CreateCategoryPayload) => {
- const id = await send('category-create', {
- name,
- groupId,
- isIncome,
- hidden: isHidden,
- });
- return id;
- },
-);
-
-type UpdateCategoryPayload = {
- category: CategoryEntity;
-};
-
-export const updateCategory = createAppAsyncThunk(
- `${sliceName}/updateCategory`,
- async ({ category }: UpdateCategoryPayload) => {
- await send('category-update', category);
- },
-);
-
-type DeleteCategoryPayload = {
- id: CategoryEntity['id'];
- transferId?: CategoryEntity['id'];
-};
-
-export const deleteCategory = createAppAsyncThunk(
- `${sliceName}/deleteCategory`,
- async ({ id, transferId }: DeleteCategoryPayload, { dispatch }) => {
- const { error } = await send('category-delete', { id, transferId });
-
- if (error) {
- switch (error) {
- case 'category-type':
- dispatch(
- addNotification({
- notification: {
- id: `${sliceName}/deleteCategory/transfer`,
- type: 'error',
- message: t(
- 'A category must be transferred to another of the same type (expense or income)',
- ),
- },
- }),
- );
- break;
- default:
- dispatch(addGenericErrorNotification());
- }
-
- throw new Error(error);
- }
- },
-);
-
-type MoveCategoryPayload = {
- id: CategoryEntity['id'];
- groupId: CategoryGroupEntity['id'];
- targetId: CategoryEntity['id'] | null;
-};
-
-export const moveCategory = createAppAsyncThunk(
- `${sliceName}/moveCategory`,
- async ({ id, groupId, targetId }: MoveCategoryPayload) => {
- await send('category-move', { id, groupId, targetId });
- },
-);
-
-type MoveCategoryGroupPayload = {
- id: CategoryGroupEntity['id'];
- targetId: CategoryGroupEntity['id'] | null;
-};
-
-export const moveCategoryGroup = createAppAsyncThunk(
- `${sliceName}/moveCategoryGroup`,
- async ({ id, targetId }: MoveCategoryGroupPayload) => {
- await send('category-group-move', { id, targetId });
- },
-);
-
-export const getCategories = createAppAsyncThunk(
- `${sliceName}/getCategories`,
- async () => {
- const categories: CategoryViews = await send('get-categories');
- return categories;
- },
- {
- condition: (_, { getState }) => {
- const { queries } = getState();
- return (
- !queries.isCategoriesLoading &&
- (queries.isCategoriesDirty || !queries.isCategoriesLoaded)
- );
- },
- },
-);
-
-export const reloadCategories = createAppAsyncThunk(
- `${sliceName}/reloadCategories`,
- async () => {
- const categories: CategoryViews = await send('get-categories');
- return categories;
- },
-);
-
export const getTags = createAppAsyncThunk(
`${sliceName}/getTags`,
async () => {
@@ -413,319 +195,6 @@ export const findTags = createAppAsyncThunk(
},
);
-// Budget actions
-
-type ApplyBudgetActionPayload =
- | {
- type: 'budget-amount';
- month: string;
- args: {
- category: CategoryEntity['id'];
- amount: number;
- };
- }
- | {
- type: 'copy-last';
- month: string;
- args: never;
- }
- | {
- type: 'set-zero';
- month: string;
- args: never;
- }
- | {
- type: 'set-3-avg';
- month: string;
- args: never;
- }
- | {
- type: 'set-6-avg';
- month: string;
- args: never;
- }
- | {
- type: 'set-12-avg';
- month: string;
- args: never;
- }
- | {
- type: 'check-templates';
- month: never;
- args: never;
- }
- | {
- type: 'apply-goal-template';
- month: string;
- args: never;
- }
- | {
- type: 'overwrite-goal-template';
- month: string;
- args: never;
- }
- | {
- type: 'cleanup-goal-template';
- month: string;
- args: never;
- }
- | {
- type: 'hold';
- month: string;
- args: {
- amount: number;
- };
- }
- | {
- type: 'reset-hold';
- month: string;
- args: never;
- }
- | {
- type: 'cover-overspending';
- month: string;
- args: {
- to: CategoryEntity['id'];
- from: CategoryEntity['id'];
- };
- }
- | {
- type: 'transfer-available';
- month: string;
- args: {
- amount: number;
- category: CategoryEntity['id'];
- };
- }
- | {
- type: 'cover-overbudgeted';
- month: string;
- args: {
- category: CategoryEntity['id'];
- };
- }
- | {
- type: 'transfer-category';
- month: string;
- args: {
- amount: number;
- from: CategoryEntity['id'];
- to: CategoryEntity['id'];
- };
- }
- | {
- type: 'carryover';
- month: string;
- args: {
- category: CategoryEntity['id'];
- flag: boolean;
- };
- }
- | {
- type: 'reset-income-carryover';
- month: string;
- args: never;
- }
- | {
- type: 'apply-single-category-template';
- month: string;
- args: {
- category: CategoryEntity['id'];
- };
- }
- | {
- type: 'apply-multiple-templates';
- month: string;
- args: {
- categories: Array<CategoryEntity['id']>;
- };
- }
- | {
- type: 'set-single-3-avg';
- month: string;
- args: {
- category: CategoryEntity['id'];
- };
- }
- | {
- type: 'set-single-6-avg';
- month: string;
- args: {
- category: CategoryEntity['id'];
- };
- }
- | {
- type: 'set-single-12-avg';
- month: string;
- args: {
- category: CategoryEntity['id'];
- };
- }
- | {
- type: 'copy-single-last';
- month: string;
- args: {
- category: CategoryEntity['id'];
- };
- };
-
-export const applyBudgetAction = createAppAsyncThunk(
- `${sliceName}/applyBudgetAction`,
- async ({ month, type, args }: ApplyBudgetActionPayload, { dispatch }) => {
- switch (type) {
- case 'budget-amount':
- await send('budget/budget-amount', {
- month,
- category: args.category,
- amount: args.amount,
- });
- break;
- case 'copy-last':
- await send('budget/copy-previous-month', { month });
- break;
- case 'set-zero':
- await send('budget/set-zero', { month });
- break;
- case 'set-3-avg':
- await send('budget/set-3month-avg', { month });
- break;
- case 'set-6-avg':
- await send('budget/set-6month-avg', { month });
- break;
- case 'set-12-avg':
- await send('budget/set-12month-avg', { month });
- break;
- case 'check-templates':
- dispatch(
- addNotification({
- notification: await send('budget/check-templates'),
- }),
- );
- break;
- case 'apply-goal-template':
- dispatch(
- addNotification({
- notification: await send('budget/apply-goal-template', { month }),
- }),
- );
- break;
- case 'overwrite-goal-template':
- dispatch(
- addNotification({
- notification: await send('budget/overwrite-goal-template', {
- month,
- }),
- }),
- );
- break;
- case 'apply-single-category-template':
- dispatch(
- addNotification({
- notification: await send('budget/apply-single-template', {
- month,
- category: args.category,
- }),
- }),
- );
- break;
- case 'cleanup-goal-template':
- dispatch(
- addNotification({
- notification: await send('budget/cleanup-goal-template', { month }),
- }),
- );
- break;
- case 'hold':
- await send('budget/hold-for-next-month', {
- month,
- amount: args.amount,
- });
- break;
- case 'reset-hold':
- await send('budget/reset-hold', { month });
- break;
- case 'cover-overspending':
- await send('budget/cover-overspending', {
- month,
- to: args.to,
- from: args.from,
- });
- break;
- case 'transfer-available':
- await send('budget/transfer-available', {
- month,
- amount: args.amount,
- category: args.category,
- });
- break;
- case 'cover-overbudgeted':
- await send('budget/cover-overbudgeted', {
- month,
- category: args.category,
- });
- break;
- case 'transfer-category':
- await send('budget/transfer-category', {
- month,
- amount: args.amount,
- from: args.from,
- to: args.to,
- });
- break;
- case 'carryover': {
- await send('budget/set-carryover', {
- startMonth: month,
- category: args.category,
- flag: args.flag,
- });
- break;
- }
- case 'reset-income-carryover':
- await send('budget/reset-income-carryover', { month });
- break;
- case 'apply-multiple-templates':
- dispatch(
- addNotification({
- notification: await send('budget/apply-multiple-templates', {
- month,
- categoryIds: args.categories,
- }),
- }),
- );
- break;
- case 'set-single-3-avg':
- await send('budget/set-n-month-avg', {
- month,
- N: 3,
- category: args.category,
- });
- break;
- case 'set-single-6-avg':
- await send('budget/set-n-month-avg', {
- month,
- N: 6,
- category: args.category,
- });
- break;
- case 'set-single-12-avg':
- await send('budget/set-n-month-avg', {
- month,
- N: 12,
- category: args.category,
- });
- break;
- case 'copy-single-last':
- await send('budget/copy-single-month', {
- month,
- category: args.category,
- });
- break;
- default:
- console.log(`Invalid action type: ${type}`);
- }
- },
-);
-
// Transaction actions
type ImportPreviewTransactionsPayload = {
@@ -821,20 +290,6 @@ export const importTransactions = createAppAsyncThunk(
},
);
-// Helper functions
-
-export const getCategoriesById = memoizeOne(
- (categoryGroups: CategoryGroupEntity[] | null | undefined) => {
- const res: { [id: CategoryGroupEntity['id']]: CategoryEntity } = {};
- categoryGroups?.forEach(group => {
- group.categories.forEach(cat => {
- res[cat.id] = cat;
- });
- });
- return res;
- },
-);
-
// Slice exports
export const { name, reducer, getInitialState } = queriesSlice;
@@ -842,17 +297,6 @@ export const actions = {
...queriesSlice.actions,
importPreviewTransactions,
importTransactions,
- applyBudgetAction,
- getCategories,
- reloadCategories,
- createCategoryGroup,
- updateCategoryGroup,
- deleteCategoryGroup,
- createCategory,
- updateCategory,
- deleteCategory,
- moveCategory,
- moveCategoryGroup,
getTags,
createTag,
updateTag,
@@ -865,24 +309,9 @@ export const {
setNewTransactions,
updateNewTransactions,
setLastTransaction,
- markCategoriesDirty,
markTagsDirty,
} = queriesSlice.actions;
-function _loadCategories(
- state: QueriesState,
- categories: QueriesState['categories'],
-) {
- state.categories = categories;
- state.isCategoriesLoading = false;
- state.isCategoriesLoaded = true;
- state.isCategoriesDirty = false;
-}
-
-function _markCategoriesDirty(state: QueriesState) {
- state.isCategoriesDirty = true;
-}
-
function _loadTags(state: QueriesState, tags: QueriesState['tags']) {
state.tags = tags;
state.isTagsLoading = false;
diff --git a/packages/desktop-client/src/redux/mock.tsx b/packages/desktop-client/src/redux/mock.tsx
index 93cf515a86..bc09170844 100644
--- a/packages/desktop-client/src/redux/mock.tsx
+++ b/packages/desktop-client/src/redux/mock.tsx
@@ -14,9 +14,13 @@ import {
reducer as appSliceReducer,
} from '@desktop-client/app/appSlice';
import {
- name as budgetsSliceName,
- reducer as budgetsSliceReducer,
-} from '@desktop-client/budgets/budgetsSlice';
+ name as budgetSliceName,
+ reducer as budgetSliceReducer,
+} from '@desktop-client/budget/budgetSlice';
+import {
+ name as budgetfilesSliceName,
+ reducer as budgetfilesSliceReducer,
+} from '@desktop-client/budgetfiles/budgetfilesSlice';
import {
name as modalsSliceName,
reducer as modalsSliceReducer,
@@ -45,7 +49,8 @@ import {
const appReducer = combineReducers({
[accountsSliceName]: accountsSliceReducer,
[appSliceName]: appSliceReducer,
- [budgetsSliceName]: budgetsSliceReducer,
+ [budgetSliceName]: budgetSliceReducer,
+ [budgetfilesSliceName]: budgetfilesSliceReducer,
[modalsSliceName]: modalsSliceReducer,
[notificationsSliceName]: notificationsSliceReducer,
[payeesSliceName]: payeesSliceReducer,
diff --git a/packages/desktop-client/src/redux/store.ts b/packages/desktop-client/src/redux/store.ts
index 198edb4f83..72d8059f88 100644
--- a/packages/desktop-client/src/redux/store.ts
+++ b/packages/desktop-client/src/redux/store.ts
@@ -14,9 +14,13 @@ import {
reducer as appSliceReducer,
} from '@desktop-client/app/appSlice';
import {
- name as budgetsSliceName,
- reducer as budgetsSliceReducer,
-} from '@desktop-client/budgets/budgetsSlice';
+ name as budgetSliceName,
+ reducer as budgetSliceReducer,
+} from '@desktop-client/budget/budgetSlice';
+import {
+ name as budgetfilesSliceName,
+ reducer as budgetfilesSliceReducer,
+} from '@desktop-client/budgetfiles/budgetfilesSlice';
import {
name as modalsSliceName,
reducer as modalsSliceReducer,
@@ -46,7 +50,8 @@ import {
const rootReducer = combineReducers({
[accountsSliceName]: accountsSliceReducer,
[appSliceName]: appSliceReducer,
- [budgetsSliceName]: budgetsSliceReducer,
+ [budgetSliceName]: budgetSliceReducer,
+ [budgetfilesSliceName]: budgetfilesSliceReducer,
[modalsSliceName]: modalsSliceReducer,
[notificationsSliceName]: notificationsSliceReducer,
[payeesSliceName]: payeesSliceReducer,
diff --git a/packages/desktop-client/src/sync-events.ts b/packages/desktop-client/src/sync-events.ts
index 41233dc850..32bf365fea 100644
--- a/packages/desktop-client/src/sync-events.ts
+++ b/packages/desktop-client/src/sync-events.ts
@@ -5,7 +5,11 @@ import { listen, send } from 'loot-core/platform/client/fetch';
import { reloadAccounts } from './accounts/accountsSlice';
import { resetSync, sync } from './app/appSlice';
-import { closeAndDownloadBudget, uploadBudget } from './budgets/budgetsSlice';
+import { reloadCategories } from './budget/budgetSlice';
+import {
+ closeAndDownloadBudget,
+ uploadBudget,
+} from './budgetfiles/budgetfilesSlice';
import { pushModal } from './modals/modalsSlice';
import {
addNotification,
@@ -13,7 +17,6 @@ import {
} from './notifications/notificationsSlice';
import { reloadPayees } from './payees/payeesSlice';
import { loadPrefs } from './prefs/prefsSlice';
-import { reloadCategories } from './queries/queriesSlice';
import { type AppStore } from './redux/store';
import { signOut } from './users/usersSlice';
diff --git a/packages/desktop-client/src/users/usersSlice.ts b/packages/desktop-client/src/users/usersSlice.ts
index e58a1b9a0f..abd8689af9 100644
--- a/packages/desktop-client/src/users/usersSlice.ts
+++ b/packages/desktop-client/src/users/usersSlice.ts
@@ -7,7 +7,7 @@ import { resetApp } from '@desktop-client/app/appSlice';
import {
closeBudget,
loadAllFiles,
-} from '@desktop-client/budgets/budgetsSlice';
+} from '@desktop-client/budgetfiles/budgetfilesSlice';
import { loadGlobalPrefs } from '@desktop-client/prefs/prefsSlice';
import { createAppAsyncThunk } from '@desktop-client/redux';
diff --git a/packages/loot-core/src/server/budget/app.ts b/packages/loot-core/src/server/budget/app.ts
index aae2c31326..75b13c3522 100644
--- a/packages/loot-core/src/server/budget/app.ts
+++ b/packages/loot-core/src/server/budget/app.ts
@@ -316,7 +316,7 @@ async function moveCategory({
}: {
id: CategoryEntity['id'];
groupId: CategoryGroupEntity['id'];
- targetId: CategoryEntity['id'];
+ targetId: CategoryEntity['id'] | null;
}): Promise<void> {
await batchMessages(async () => {
await db.moveCategory(id, groupId, targetId);
@@ -328,7 +328,7 @@ async function deleteCategory({
transferId,
}: {
id: CategoryEntity['id'];
- transferId?: CategoryEntity['id'];
+ transferId?: CategoryEntity['id'] | null;
}): Promise<{ error?: 'no-categories' | 'category-type' }> {
let result = {};
await batchMessages(async () => {
@@ -407,7 +407,7 @@ async function moveCategoryGroup({
targetId,
}: {
id: CategoryGroupEntity['id'];
- targetId: CategoryGroupEntity['id'];
+ targetId: CategoryGroupEntity['id'] | null;
}): Promise<void> {
await batchMessages(async () => {
await db.moveCategoryGroup(id, targetId);
@@ -419,7 +419,7 @@ async function deleteCategoryGroup({
transferId,
}: {
id: CategoryGroupEntity['id'];
- transferId: CategoryGroupEntity['id'];
+ transferId?: CategoryGroupEntity['id'] | null;
}): Promise<void> {
const groupCategories = await db.all<Pick<CategoryEntity, 'id'>>(
'SELECT id FROM categories WHERE cat_group = ? AND tombstone = 0',
diff --git a/packages/loot-core/src/server/db/index.ts b/packages/loot-core/src/server/db/index.ts
index eabd79effe..4e3e68ef35 100644
--- a/packages/loot-core/src/server/db/index.ts
+++ b/packages/loot-core/src/server/db/index.ts
@@ -394,7 +394,7 @@ export function updateCategoryGroup(
export async function moveCategoryGroup(
id: DbCategoryGroup['id'],
- targetId: DbCategoryGroup['id'],
+ targetId?: DbCategoryGroup['id'] | null,
) {
const groups = await all<Pick<DbCategoryGroup, 'id' | 'sort_order'>>(
`SELECT id, sort_order FROM category_groups WHERE tombstone = 0 ORDER BY sort_order, id`,
@@ -409,7 +409,7 @@ export async function moveCategoryGroup(
export async function deleteCategoryGroup(
group: Pick<DbCategoryGroup, 'id'>,
- transferId?: DbCategory['id'],
+ transferId?: DbCategory['id'] | null,
) {
const categories = await all<DbCategory>(
'SELECT * FROM categories WHERE cat_group = ?',
@@ -491,7 +491,7 @@ export function updateCategory(
export async function moveCategory(
id: DbCategory['id'],
groupId: DbCategoryGroup['id'],
- targetId: DbCategory['id'] | null,
+ targetId?: DbCategory['id'] | null,
) {
if (!groupId) {
throw new Error('moveCategory: groupId is required');
@@ -511,7 +511,7 @@ export async function moveCategory(
export async function deleteCategory(
category: Pick<DbCategory, 'id'>,
- transferId?: DbCategory['id'],
+ transferId?: DbCategory['id'] | null,
) {
if (transferId) {
// We need to update all the deleted categories that currently
diff --git a/upcoming-release-notes/5593.md b/upcoming-release-notes/5593.md
new file mode 100644
index 0000000000..faa2e16dac
--- /dev/null
+++ b/upcoming-release-notes/5593.md
@@ -0,0 +1,6 @@
+---
+category: Maintenance
+authors: [joel-jeremy]
+---
+
+[Redux] Move category states from queriesSlice to budgetSlice