Bugfix/add fallback to default account in import (#709)
* Add fallback to default account if account id is invalid * Update changelog
This commit is contained in:
parent
dced06ebb5
commit
4ec351369b
@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Fixed the allocations by account for non-unique account names
|
- Fixed the allocations by account for non-unique account names
|
||||||
|
- Added a fallback to the default account if the `accountId` is invalid in the import functionality for activities
|
||||||
|
|
||||||
## 1.116.0 - 16.02.2022
|
## 1.116.0 - 16.02.2022
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ import { AccountService } from './account.service';
|
|||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
controllers: [AccountController],
|
controllers: [AccountController],
|
||||||
|
exports: [AccountService],
|
||||||
imports: [
|
imports: [
|
||||||
ConfigurationModule,
|
ConfigurationModule,
|
||||||
DataProviderModule,
|
DataProviderModule,
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { AccountModule } from '@ghostfolio/api/app/account/account.module';
|
||||||
import { CacheModule } from '@ghostfolio/api/app/cache/cache.module';
|
import { CacheModule } from '@ghostfolio/api/app/cache/cache.module';
|
||||||
import { OrderModule } from '@ghostfolio/api/app/order/order.module';
|
import { OrderModule } from '@ghostfolio/api/app/order/order.module';
|
||||||
import { RedisCacheModule } from '@ghostfolio/api/app/redis-cache/redis-cache.module';
|
import { RedisCacheModule } from '@ghostfolio/api/app/redis-cache/redis-cache.module';
|
||||||
@ -13,6 +14,7 @@ import { ImportService } from './import.service';
|
|||||||
@Module({
|
@Module({
|
||||||
controllers: [ImportController],
|
controllers: [ImportController],
|
||||||
imports: [
|
imports: [
|
||||||
|
AccountModule,
|
||||||
CacheModule,
|
CacheModule,
|
||||||
ConfigurationModule,
|
ConfigurationModule,
|
||||||
DataGatheringModule,
|
DataGatheringModule,
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { AccountService } from '@ghostfolio/api/app/account/account.service';
|
||||||
import { OrderService } from '@ghostfolio/api/app/order/order.service';
|
import { OrderService } from '@ghostfolio/api/app/order/order.service';
|
||||||
import { ConfigurationService } from '@ghostfolio/api/services/configuration.service';
|
import { ConfigurationService } from '@ghostfolio/api/services/configuration.service';
|
||||||
import { DataProviderService } from '@ghostfolio/api/services/data-provider/data-provider.service';
|
import { DataProviderService } from '@ghostfolio/api/services/data-provider/data-provider.service';
|
||||||
@ -8,6 +9,7 @@ import { isSameDay, parseISO } from 'date-fns';
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
export class ImportService {
|
export class ImportService {
|
||||||
public constructor(
|
public constructor(
|
||||||
|
private readonly accountService: AccountService,
|
||||||
private readonly configurationService: ConfigurationService,
|
private readonly configurationService: ConfigurationService,
|
||||||
private readonly dataProviderService: DataProviderService,
|
private readonly dataProviderService: DataProviderService,
|
||||||
private readonly orderService: OrderService
|
private readonly orderService: OrderService
|
||||||
@ -32,6 +34,12 @@ export class ImportService {
|
|||||||
|
|
||||||
await this.validateOrders({ orders, userId });
|
await this.validateOrders({ orders, userId });
|
||||||
|
|
||||||
|
const accountIds = (await this.accountService.getAccounts(userId)).map(
|
||||||
|
(account) => {
|
||||||
|
return account.id;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
for (const {
|
for (const {
|
||||||
accountId,
|
accountId,
|
||||||
currency,
|
currency,
|
||||||
@ -44,7 +52,6 @@ export class ImportService {
|
|||||||
unitPrice
|
unitPrice
|
||||||
} of orders) {
|
} of orders) {
|
||||||
await this.orderService.createOrder({
|
await this.orderService.createOrder({
|
||||||
accountId,
|
|
||||||
currency,
|
currency,
|
||||||
dataSource,
|
dataSource,
|
||||||
fee,
|
fee,
|
||||||
@ -53,6 +60,7 @@ export class ImportService {
|
|||||||
type,
|
type,
|
||||||
unitPrice,
|
unitPrice,
|
||||||
userId,
|
userId,
|
||||||
|
accountId: accountIds.includes(accountId) ? accountId : undefined,
|
||||||
date: parseISO(<string>(<unknown>date)),
|
date: parseISO(<string>(<unknown>date)),
|
||||||
SymbolProfile: {
|
SymbolProfile: {
|
||||||
connectOrCreate: {
|
connectOrCreate: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user