mirror of
https://github.com/actualbudget/actual.git
synced 2026-07-10 12:31:32 -05:00
[AI] Remove grouped option from api/categories-get
The categories-get API now always returns a flat list of categories. Use category-groups-get for grouped data instead.
This commit is contained in:
@@ -220,7 +220,7 @@ export function deleteCategoryGroup(
|
||||
}
|
||||
|
||||
export function getCategories(options: { hidden?: boolean } = {}) {
|
||||
return send('api/categories-get', { grouped: false, ...options });
|
||||
return send('api/categories-get', options);
|
||||
}
|
||||
|
||||
export function createCategory(category: Omit<APICategoryEntity, 'id'>) {
|
||||
|
||||
@@ -649,14 +649,11 @@ handlers['api/account-balance'] = withMutation(async function ({
|
||||
});
|
||||
|
||||
handlers['api/categories-get'] = async function ({
|
||||
grouped,
|
||||
hidden,
|
||||
}: { grouped?: boolean; hidden?: boolean } = {}) {
|
||||
}: { hidden?: boolean } = {}) {
|
||||
checkFileOpen();
|
||||
const result = await handlers['get-categories']({ hidden });
|
||||
return grouped
|
||||
? result.grouped.map(group => categoryGroupModel.toExternal(group))
|
||||
: result.list.map(category => categoryModel.toExternal(category));
|
||||
return result.list.map(category => categoryModel.toExternal(category));
|
||||
};
|
||||
|
||||
handlers['api/category-groups-get'] = async function ({
|
||||
|
||||
@@ -133,9 +133,7 @@ async function importTransactions(
|
||||
data: YNAB4.YFull,
|
||||
entityIdMap: Map<string, string>,
|
||||
) {
|
||||
const categories = await send('api/categories-get', {
|
||||
grouped: false,
|
||||
});
|
||||
const categories = await send('api/categories-get');
|
||||
const incomeCategoryId: string = categories.find(
|
||||
cat => cat.name === 'Income',
|
||||
).id;
|
||||
|
||||
@@ -291,9 +291,7 @@ async function importCategories(
|
||||
// Hidden categories are put in its own group by YNAB,
|
||||
// so it's already handled.
|
||||
|
||||
const categories = await send('api/categories-get', {
|
||||
grouped: false,
|
||||
});
|
||||
const categories = await send('api/categories-get');
|
||||
const incomeCatId = findIdByName(categories, 'Income');
|
||||
const ynabIncomeCategories = ['To be Budgeted', 'Inflow: Ready to Assign'];
|
||||
|
||||
@@ -572,9 +570,7 @@ async function importTransactions(
|
||||
flagNameConflicts: Set<string>,
|
||||
) {
|
||||
const payees = await send('api/payees-get');
|
||||
const categories = await send('api/categories-get', {
|
||||
grouped: false,
|
||||
});
|
||||
const categories = await send('api/categories-get');
|
||||
const incomeCatId = findIdByName(categories, 'Income');
|
||||
const startingBalanceCatId = findIdByName(categories, 'Starting Balances'); //better way to do it?
|
||||
|
||||
|
||||
@@ -165,9 +165,8 @@ export type ApiHandlers = {
|
||||
}) => Promise<number>;
|
||||
|
||||
'api/categories-get': (arg: {
|
||||
grouped?: boolean;
|
||||
hidden?: boolean;
|
||||
}) => Promise<Array<APICategoryGroupEntity | APICategoryEntity>>;
|
||||
}) => Promise<APICategoryEntity[]>;
|
||||
|
||||
'api/category-groups-get': (arg?: {
|
||||
hidden?: boolean;
|
||||
|
||||
6
upcoming-release-notes/simplify-categories-get-api.md
Normal file
6
upcoming-release-notes/simplify-categories-get-api.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
category: Enhancements
|
||||
authors: [MatissJanis]
|
||||
---
|
||||
|
||||
Simplify the getCategories API to always return a flat list of categories.
|
||||
Reference in New Issue
Block a user