Browse Source

refactor(api): address PR review feedback on import service

pull/8467/head
KenTandrian 3 days ago
parent
commit
965d0251bb
  1. 14
      apps/api/src/services/import/import.service.ts

14
apps/api/src/services/import/import.service.ts

@ -182,12 +182,13 @@ export class ImportService {
date, date,
error, error,
quantity, quantity,
userId,
value, value,
accountId: account?.id ?? null, accountId: account?.id ?? null,
accountUserId: null, accountUserId: null,
comment: null, comment: null,
currency: null, currency: null,
createdAt: date, createdAt: new Date(),
fee: 0, fee: 0,
feeInAssetProfileCurrency: 0, feeInAssetProfileCurrency: 0,
feeInBaseCurrency: 0, feeInBaseCurrency: 0,
@ -196,8 +197,7 @@ export class ImportService {
type: 'DIVIDEND' as ActivityType, type: 'DIVIDEND' as ActivityType,
unitPrice: marketPrice, unitPrice: marketPrice,
unitPriceInAssetProfileCurrency: marketPrice, unitPriceInAssetProfileCurrency: marketPrice,
updatedAt: date, updatedAt: new Date(),
userId: account?.userId ?? '',
valueInBaseCurrency: value valueInBaseCurrency: value
} }
]; ];
@ -986,6 +986,12 @@ export class ImportService {
assetProfile.symbol ?? assetProfile.symbol ??
activity.assetProfile.symbol; activity.assetProfile.symbol;
if (!assetProfile.currency) {
throw new ImportValidationError(
`Asset profile ("${symbol}") has no currency`
);
}
const createdActivity = await this.activitiesService.createActivity({ const createdActivity = await this.activitiesService.createActivity({
comment, comment,
currency, currency,
@ -1001,7 +1007,7 @@ export class ImportService {
dataSource, dataSource,
name, name,
symbol, symbol,
currency: assetProfile.currency ?? currency, currency: assetProfile.currency,
userId: dataSource === 'MANUAL' ? user.id : undefined userId: dataSource === 'MANUAL' ? user.id : undefined
}, },
where: { where: {

Loading…
Cancel
Save