Import category notes from YNAB4 exports (#1515)

Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
This commit is contained in:
Johannes Löthberg
2023-08-12 14:32:20 +02:00
committed by GitHub
parent b325bd9b18
commit 71f885b899
3 changed files with 15 additions and 0 deletions

View File

@@ -16,6 +16,7 @@ export namespace YNAB4 {
export interface MasterCategory {
entityType: string;
expanded: boolean;
note?: string;
name: string;
type: string;
deleteable: boolean;
@@ -31,6 +32,7 @@ export namespace YNAB4 {
export interface SubCategory {
entityType: string;
name: string;
note?: string;
type: string;
// cachedBalance: null;
masterCategoryId: string;

View File

@@ -2,6 +2,7 @@
// into Actual itself. We only want to pull in the methods in that
// case and ignore everything else; otherwise we'd be pulling in the
// entire backend bundle from the API
import { send } from '@actual-app/api/injected';
import * as actual from '@actual-app/api/methods';
import { amountToInteger } from '@actual-app/api/utils';
import AdmZip from 'adm-zip';
@@ -54,6 +55,9 @@ async function importCategories(
is_income: false,
});
entityIdMap.set(masterCategory.entityId, id);
if (masterCategory.note) {
send('notes-save', { id, note: masterCategory.note });
}
if (masterCategory.subCategories) {
const subCategories = sortByKey(
@@ -71,6 +75,9 @@ async function importCategories(
group_id: entityIdMap.get(category.masterCategoryId),
});
entityIdMap.set(category.entityId, id);
if (category.note) {
send('notes-save', { id, note: category.note });
}
}
}
}

View File

@@ -0,0 +1,6 @@
---
category: Enhancements
authors: [kyrias]
---
Import category notes from YNAB4 exports.