Browse Source

- Only create synthetic asset profiles for MANUAL data sources that are NOT FEE/INTEREST/LIABILITY

- Skip asset profile validation for FEE/INTEREST/LIABILITY transaction types
- Made dataSource optional in the DTO to allow CSV imports without DataSource column
pull/5749/head
Sven Günther 2 weeks ago
parent
commit
50a3284821
  1. 11
      apps/api/src/app/import/import.service.ts
  2. 3
      apps/api/src/app/order/create-order.dto.ts
  3. 9
      apps/client/src/app/services/import-activities.service.ts

11
apps/api/src/app/import/import.service.ts

@ -743,6 +743,17 @@ export class ImportService {
}
if (!assetProfiles[getAssetProfileIdentifier({ dataSource, symbol })]) {
// Skip asset profile validation for FEE, INTEREST, and LIABILITY
// as these transaction types don't require asset profiles
if (['FEE', 'INTEREST', 'LIABILITY'].includes(type)) {
assetProfiles[getAssetProfileIdentifier({ dataSource, symbol })] = {
currency,
dataSource,
symbol
};
continue;
}
const assetProfile = {
currency,
...(

3
apps/api/src/app/order/create-order.dto.ts

@ -44,7 +44,8 @@ export class CreateOrderDto {
customCurrency?: string;
@IsEnum(DataSource)
dataSource: DataSource;
@IsOptional()
dataSource?: DataSource;
@IsISO8601()
@Validate(IsAfter1970Constraint)

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

@ -60,23 +60,28 @@ export class ImportActivitiesService {
const dataSource = this.parseDataSource({ item });
const symbol = this.parseSymbol({ content, index, item });
const currency = this.parseCurrency({ content, index, item });
const type = this.parseType({ content, index, item });
activities.push({
currency,
dataSource,
symbol,
type,
accountId: this.parseAccount({ item, userAccounts }),
comment: this.parseComment({ item }),
date: this.parseDate({ content, index, item }),
fee: this.parseFee({ content, index, item }),
quantity: this.parseQuantity({ content, index, item }),
type: this.parseType({ content, index, item }),
unitPrice: this.parseUnitPrice({ content, index, item }),
updateAccountBalance: false
});
if (dataSource === DataSource.MANUAL) {
if (
dataSource === DataSource.MANUAL &&
!['FEE', 'INTEREST', 'LIABILITY'].includes(type)
) {
// Create synthetic asset profile for MANUAL data source
// (except for FEE, INTEREST, and LIABILITY which don't require asset profiles)
assetProfiles.push({
currency,
symbol,

Loading…
Cancel
Save