|
|
@ -15,6 +15,7 @@ import { catchError } from 'rxjs/operators';
|
|
|
|
})
|
|
|
|
})
|
|
|
|
export class ImportActivitiesService {
|
|
|
|
export class ImportActivitiesService {
|
|
|
|
private static ACCOUNT_KEYS = ['account', 'accountid'];
|
|
|
|
private static ACCOUNT_KEYS = ['account', 'accountid'];
|
|
|
|
|
|
|
|
private static COMMENT_KEYS = ['comment', 'note'];
|
|
|
|
private static CURRENCY_KEYS = ['ccy', 'currency', 'currencyprimary'];
|
|
|
|
private static CURRENCY_KEYS = ['ccy', 'currency', 'currencyprimary'];
|
|
|
|
private static DATA_SOURCE_KEYS = ['datasource'];
|
|
|
|
private static DATA_SOURCE_KEYS = ['datasource'];
|
|
|
|
private static DATE_KEYS = ['date', 'tradedate'];
|
|
|
|
private static DATE_KEYS = ['date', 'tradedate'];
|
|
|
@ -52,6 +53,7 @@ export class ImportActivitiesService {
|
|
|
|
for (const [index, item] of content.entries()) {
|
|
|
|
for (const [index, item] of content.entries()) {
|
|
|
|
activities.push({
|
|
|
|
activities.push({
|
|
|
|
accountId: this.parseAccount({ item, userAccounts }),
|
|
|
|
accountId: this.parseAccount({ item, userAccounts }),
|
|
|
|
|
|
|
|
comment: this.parseComment({ item }),
|
|
|
|
currency: this.parseCurrency({ content, index, item }),
|
|
|
|
currency: this.parseCurrency({ content, index, item }),
|
|
|
|
dataSource: this.parseDataSource({ item }),
|
|
|
|
dataSource: this.parseDataSource({ item }),
|
|
|
|
date: this.parseDate({ content, index, item }),
|
|
|
|
date: this.parseDate({ content, index, item }),
|
|
|
@ -122,6 +124,7 @@ export class ImportActivitiesService {
|
|
|
|
|
|
|
|
|
|
|
|
private convertToCreateOrderDto({
|
|
|
|
private convertToCreateOrderDto({
|
|
|
|
accountId,
|
|
|
|
accountId,
|
|
|
|
|
|
|
|
comment,
|
|
|
|
date,
|
|
|
|
date,
|
|
|
|
fee,
|
|
|
|
fee,
|
|
|
|
quantity,
|
|
|
|
quantity,
|
|
|
@ -132,6 +135,7 @@ export class ImportActivitiesService {
|
|
|
|
}: Activity): CreateOrderDto {
|
|
|
|
}: Activity): CreateOrderDto {
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
accountId,
|
|
|
|
accountId,
|
|
|
|
|
|
|
|
comment,
|
|
|
|
fee,
|
|
|
|
fee,
|
|
|
|
quantity,
|
|
|
|
quantity,
|
|
|
|
type,
|
|
|
|
type,
|
|
|
@ -174,6 +178,18 @@ export class ImportActivitiesService {
|
|
|
|
return undefined;
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private parseComment({ item }: { item: any }) {
|
|
|
|
|
|
|
|
item = this.lowercaseKeys(item);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (const key of ImportActivitiesService.COMMENT_KEYS) {
|
|
|
|
|
|
|
|
if (item[key]) {
|
|
|
|
|
|
|
|
return item[key];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return undefined;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private parseCurrency({
|
|
|
|
private parseCurrency({
|
|
|
|
content,
|
|
|
|
content,
|
|
|
|
index,
|
|
|
|
index,
|
|
|
|