Browse Source

Seperate raw type parsing from parseType and into helper. Fixes issue with duplicate default type warnings. #2288

pull/4056/head
Brandon Wortman 9 months ago
parent
commit
7d6f6128b2
No known key found for this signature in database GPG Key ID: C63DB7DA05AEC086
  1. 25
      apps/client/src/app/services/import-activities.service.ts

25
apps/client/src/app/services/import-activities.service.ts

@ -261,7 +261,7 @@ export class ImportActivitiesService {
} }
// If no data source specified, check the type // 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') { if (type === 'ITEM' || type === 'LIABILITY') {
return DataSource.MANUAL; return DataSource.MANUAL;
} }
@ -355,13 +355,7 @@ export class ImportActivitiesService {
}; };
} }
private parseType({ private getRawType({ item }: { item: any }): ActivityType {
index,
item
}: {
index: number;
item: any;
}): ActivityType {
item = this.lowercaseKeys(item); item = this.lowercaseKeys(item);
for (const key of ImportActivitiesService.TYPE_KEYS) { 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( this.warnings.push(
`activities.${index}.type is missing, defaulting to BUY` `activities.${index}.type is missing, defaulting to BUY`

Loading…
Cancel
Save