From 7d6f6128b24ffc877f1b5ea4a90aabb28ecfb4a7 Mon Sep 17 00:00:00 2001 From: Brandon Wortman Date: Wed, 4 Dec 2024 16:19:51 -0500 Subject: [PATCH] Seperate raw type parsing from parseType and into helper. Fixes issue with duplicate default type warnings. #2288 --- .../app/services/import-activities.service.ts | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/apps/client/src/app/services/import-activities.service.ts b/apps/client/src/app/services/import-activities.service.ts index 5cde8ef5c..1febb533d 100644 --- a/apps/client/src/app/services/import-activities.service.ts +++ b/apps/client/src/app/services/import-activities.service.ts @@ -261,7 +261,7 @@ export class ImportActivitiesService { } // If no data source specified, check the type - const type = this.parseType({ index: 0, item }); + const type = this.getRawType({ item }); if (type === 'ITEM' || type === 'LIABILITY') { return DataSource.MANUAL; } @@ -355,13 +355,7 @@ export class ImportActivitiesService { }; } - private parseType({ - index, - item - }: { - index: number; - item: any; - }): ActivityType { + private getRawType({ item }: { item: any }): ActivityType { item = this.lowercaseKeys(item); for (const key of ImportActivitiesService.TYPE_KEYS) { @@ -386,6 +380,21 @@ export class ImportActivitiesService { } } } + return undefined; + } + + private parseType({ + index, + item + }: { + index: number; + item: any; + }): ActivityType { + item = this.lowercaseKeys(item); + const type = this.getRawType({ item }); + if (type) { + return type; + } this.warnings.push( `activities.${index}.type is missing, defaulting to BUY`