Browse Source

Merge branch 'main' into feature/support-derived-currencies-in-currency-validation

pull/3529/head
Thomas Kaul 1 year ago
committed by GitHub
parent
commit
3e95d1617c
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 1
      apps/api/src/app/order/order.controller.ts
  3. 27
      apps/api/src/app/order/order.service.ts
  4. 2
      apps/api/src/app/user/user.module.ts
  5. 6
      apps/api/src/app/user/user.service.ts
  6. 61
      libs/common/src/lib/personal-finance-tools.ts

1
CHANGELOG.md

@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed ### Changed
- Added support for derived currencies in the currency validation - Added support for derived currencies in the currency validation
- Added support for automatic deletion of unused asset profiles when deleting activities
### Fixed ### Fixed

1
apps/api/src/app/order/order.controller.ts

@ -66,7 +66,6 @@ export class OrderController {
return this.orderService.deleteOrders({ return this.orderService.deleteOrders({
filters, filters,
userCurrency: this.request.user.Settings.settings.baseCurrency,
userId: this.request.user.id userId: this.request.user.id
}); });
} }

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

@ -184,7 +184,15 @@ export class OrderService {
where where
}); });
if (['FEE', 'INTEREST', 'ITEM', 'LIABILITY'].includes(order.type)) { const [symbolProfile] =
await this.symbolProfileService.getSymbolProfilesByIds([
order.symbolProfileId
]);
if (
['FEE', 'INTEREST', 'ITEM', 'LIABILITY'].includes(order.type) ||
symbolProfile.activitiesCount === 0
) {
await this.symbolProfileService.deleteById(order.symbolProfileId); await this.symbolProfileService.deleteById(order.symbolProfileId);
} }
@ -200,18 +208,16 @@ export class OrderService {
public async deleteOrders({ public async deleteOrders({
filters, filters,
userCurrency,
userId userId
}: { }: {
filters?: Filter[]; filters?: Filter[];
userCurrency: string;
userId: string; userId: string;
}): Promise<number> { }): Promise<number> {
const { activities } = await this.getOrders({ const { activities } = await this.getOrders({
filters, filters,
userId, userId,
userCurrency,
includeDrafts: true, includeDrafts: true,
userCurrency: undefined,
withExcludedAccounts: true withExcludedAccounts: true
}); });
@ -225,6 +231,19 @@ export class OrderService {
} }
}); });
const symbolProfiles =
await this.symbolProfileService.getSymbolProfilesByIds(
activities.map(({ symbolProfileId }) => {
return symbolProfileId;
})
);
for (const { activitiesCount, id } of symbolProfiles) {
if (activitiesCount === 0) {
await this.symbolProfileService.deleteById(id);
}
}
this.eventEmitter.emit( this.eventEmitter.emit(
PortfolioChangedEvent.getName(), PortfolioChangedEvent.getName(),
new PortfolioChangedEvent({ userId }) new PortfolioChangedEvent({ userId })

2
apps/api/src/app/user/user.module.ts

@ -1,3 +1,4 @@
import { OrderModule } from '@ghostfolio/api/app/order/order.module';
import { SubscriptionModule } from '@ghostfolio/api/app/subscription/subscription.module'; import { SubscriptionModule } from '@ghostfolio/api/app/subscription/subscription.module';
import { ConfigurationModule } from '@ghostfolio/api/services/configuration/configuration.module'; import { ConfigurationModule } from '@ghostfolio/api/services/configuration/configuration.module';
import { PrismaModule } from '@ghostfolio/api/services/prisma/prisma.module'; import { PrismaModule } from '@ghostfolio/api/services/prisma/prisma.module';
@ -19,6 +20,7 @@ import { UserService } from './user.service';
secret: process.env.JWT_SECRET_KEY, secret: process.env.JWT_SECRET_KEY,
signOptions: { expiresIn: '30 days' } signOptions: { expiresIn: '30 days' }
}), }),
OrderModule,
PrismaModule, PrismaModule,
PropertyModule, PropertyModule,
SubscriptionModule, SubscriptionModule,

6
apps/api/src/app/user/user.service.ts

@ -1,3 +1,4 @@
import { OrderService } from '@ghostfolio/api/app/order/order.service';
import { SubscriptionService } from '@ghostfolio/api/app/subscription/subscription.service'; import { SubscriptionService } from '@ghostfolio/api/app/subscription/subscription.service';
import { environment } from '@ghostfolio/api/environments/environment'; import { environment } from '@ghostfolio/api/environments/environment';
import { PortfolioChangedEvent } from '@ghostfolio/api/events/portfolio-changed.event'; import { PortfolioChangedEvent } from '@ghostfolio/api/events/portfolio-changed.event';
@ -40,6 +41,7 @@ export class UserService {
public constructor( public constructor(
private readonly configurationService: ConfigurationService, private readonly configurationService: ConfigurationService,
private readonly eventEmitter: EventEmitter2, private readonly eventEmitter: EventEmitter2,
private readonly orderService: OrderService,
private readonly prismaService: PrismaService, private readonly prismaService: PrismaService,
private readonly propertyService: PropertyService, private readonly propertyService: PropertyService,
private readonly subscriptionService: SubscriptionService, private readonly subscriptionService: SubscriptionService,
@ -398,8 +400,8 @@ export class UserService {
} catch {} } catch {}
try { try {
await this.prismaService.order.deleteMany({ await this.orderService.deleteOrders({
where: { userId: where.id } userId: where.id
}); });
} catch {} } catch {}

61
libs/common/src/lib/personal-finance-tools.ts

@ -18,6 +18,13 @@ export const personalFinanceTools: Product[] = [
origin: `United States`, origin: `United States`,
slogan: 'Investment Software Suite' slogan: 'Investment Software Suite'
}, },
{
founded: 2016,
key: 'alphatrackr',
languages: ['English'],
name: 'AlphaTrackr',
slogan: 'Investment Portfolio Tracking Tool'
},
{ {
founded: 2017, founded: 2017,
hasSelfHostingAbility: false, hasSelfHostingAbility: false,
@ -26,6 +33,17 @@ export const personalFinanceTools: Product[] = [
origin: `Switzerland`, origin: `Switzerland`,
slogan: 'Simplicity for Complex Wealth' slogan: 'Simplicity for Complex Wealth'
}, },
{
founded: 2018,
hasFreePlan: true,
hasSelfHostingAbility: false,
key: 'anlage.app',
languages: ['English'],
name: 'Anlage.App',
origin: `Austria`,
pricingPerYear: '$120',
slogan: 'Analyze and track your portfolio.'
},
{ {
founded: 2022, founded: 2022,
hasFreePlan: true, hasFreePlan: true,
@ -190,6 +208,16 @@ export const personalFinanceTools: Product[] = [
origin: `Germany`, origin: `Germany`,
slogan: 'Volle Kontrolle über deine Investitionen' slogan: 'Volle Kontrolle über deine Investitionen'
}, },
{
hasFreePlan: true,
hasSelfHostingAbility: false,
key: 'holistic-capital',
languages: ['Deutsch'],
name: 'Holistic',
origin: `Germany`,
slogan: 'Die All-in-One Lösung für dein Vermögen.',
useAnonymously: true
},
{ {
hasFreePlan: true, hasFreePlan: true,
hasSelfHostingAbility: false, hasSelfHostingAbility: false,
@ -264,6 +292,17 @@ export const personalFinanceTools: Product[] = [
region: `United States`, region: `United States`,
slogan: 'Your financial future, in your control' slogan: 'Your financial future, in your control'
}, },
{
hasFreePlan: false,
hasSelfHostingAbility: false,
key: 'merlincrypto',
languages: ['English'],
name: 'Merlin',
origin: `United States`,
pricingPerYear: '$204',
region: 'Canada, United States',
slogan: 'The smartest way to track your crypto'
},
{ {
founded: 2019, founded: 2019,
hasFreePlan: false, hasFreePlan: false,
@ -331,6 +370,14 @@ export const personalFinanceTools: Product[] = [
pricingPerYear: '$360', pricingPerYear: '$360',
slogan: 'Tools for Better Investors' slogan: 'Tools for Better Investors'
}, },
{
hasFreePlan: true,
key: 'portfoloo',
name: 'Portfoloo',
note: 'Portfoloo has discontinued',
slogan:
'Free Stock Portfolio Tracker with unlimited portfolio and stocks for DIY investors'
},
{ {
founded: 2021, founded: 2021,
hasFreePlan: true, hasFreePlan: true,
@ -370,6 +417,13 @@ export const personalFinanceTools: Product[] = [
pricingPerYear: '$239', pricingPerYear: '$239',
slogan: 'Stock Market Analysis & Tools for Investors' slogan: 'Stock Market Analysis & Tools for Investors'
}, },
{
founded: 2022,
key: 'segmio',
name: 'Segmio',
origin: `Romania`,
slogan: 'Wealth Management and Net Worth Tracking'
},
{ {
founded: 2007, founded: 2007,
hasFreePlan: true, hasFreePlan: true,
@ -381,6 +435,13 @@ export const personalFinanceTools: Product[] = [
region: `Global`, region: `Global`,
slogan: 'Stock Portfolio Tracker' slogan: 'Stock Portfolio Tracker'
}, },
{
hasFreePlan: true,
key: 'sharesmaster',
name: 'SharesMaster',
note: 'SharesMaster has discontinued',
slogan: 'Free Stock Portfolio Tracker'
},
{ {
hasFreePlan: true, hasFreePlan: true,
hasSelfHostingAbility: false, hasSelfHostingAbility: false,

Loading…
Cancel
Save