Browse Source

Apply PR feedback and fix CSV import validation

- Reorder object properties for consistency (name before symbol)
  - Use short form for variable declarations
  - Remove client-side dataSource determination logic
  - Make dataSource optional in DTO to allow backend to set default values
  - Update CHANGELOG format
pull/5787/head
Sven Günther 1 week ago
parent
commit
2e92da19db
  1. 2
      CHANGELOG.md
  2. 2
      apps/api/src/app/import/import.service.ts
  3. 3
      apps/api/src/app/order/create-order.dto.ts
  4. 2
      apps/api/src/app/order/order.service.ts
  5. 13
      apps/client/src/app/services/import-activities.service.ts

2
CHANGELOG.md

@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
## Unreleased
### Fixed

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

@ -539,9 +539,9 @@ export class ImportService {
connectOrCreate: {
create: {
dataSource,
name,
symbol,
currency: assetProfile.currency,
name,
userId: dataSource === 'MANUAL' ? user.id : undefined
},
where: {

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)

2
apps/api/src/app/order/order.service.ts

@ -129,7 +129,7 @@ export class OrderService {
const assetSubClass = data.assetSubClass;
const dataSource: DataSource = 'MANUAL';
let name: string = data.SymbolProfile.connectOrCreate.create.name;
let name = data.SymbolProfile.connectOrCreate.create.name;
let symbol: string;
if (

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

@ -58,19 +58,10 @@ export class ImportActivitiesService {
for (const [index, item] of content.entries()) {
const currency = this.parseCurrency({ content, index, item });
const dataSource = this.parseDataSource({ item });
const type = this.parseType({ content, index, item });
const symbol = this.parseSymbol({ content, index, item });
let dataSource = this.parseDataSource({ item });
// Set default dataSource if not provided in CSV
if (!dataSource) {
if (['FEE', 'INTEREST', 'LIABILITY'].includes(type)) {
dataSource = DataSource.MANUAL;
} else {
// For other types, try to determine from symbol or default to YAHOO
dataSource = DataSource.YAHOO;
}
}
activities.push({
currency,

Loading…
Cancel
Save