Skip to content

Commit

Permalink
handle groups
Browse files Browse the repository at this point in the history
  • Loading branch information
youngcw committed Feb 4, 2025
1 parent 0397b41 commit 446edf6
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions packages/loot-core/src/server/importers/ynab5.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,30 @@ async function importCategories(
if (
!equalsIgnoreCase(group.name, 'Internal Master Category') &&
!equalsIgnoreCase(group.name, 'Credit Card Payments') &&
!equalsIgnoreCase(group.name, 'Hidden Categories') &&
!equalsIgnoreCase(group.name, 'Income')
) {
groupId = await actual.createCategoryGroup({
name: group.name,
is_income: false,
});
entityIdMap.set(group.id, groupId);
let run = true;
const MAX_RETRY = 10;
let count = 1;
const origName = group.name;
while (run) {
try {
groupId = await actual.createCategoryGroup({
name: group.name,
is_income: false,
});
entityIdMap.set(group.id, groupId);
run = false;
} catch (e) {
group.name = origName + '-' + count.toString();
count += 1;
if (count >= MAX_RETRY) {
run = false;
throw Error(e.message);
}
}
}
}

if (equalsIgnoreCase(group.name, 'Income')) {
Expand Down Expand Up @@ -113,7 +130,7 @@ async function importCategories(
break;
default: {
let run = true;
const MAX_RETRY = 100;
const MAX_RETRY = 10;
let count = 1;
const origName = cat.name;
while (run) {
Expand Down

0 comments on commit 446edf6

Please sign in to comment.