Browse Source

Refresh asset data after deleting stock splits

pull/7568/head
David Requeno 3 weeks ago
parent
commit
df5aeb37a0
  1. 7
      apps/api/src/app/endpoints/asset-profiles/asset-profiles.controller.ts
  2. 16
      apps/api/src/app/endpoints/asset-profiles/asset-profiles.service.spec.ts
  3. 5
      apps/api/src/app/endpoints/asset-profiles/asset-profiles.service.ts

7
apps/api/src/app/endpoints/asset-profiles/asset-profiles.controller.ts

@ -167,7 +167,12 @@ export class AssetProfilesController {
permissions.deleteAssetProfileSplitOfOwnAssetProfile permissions.deleteAssetProfileSplitOfOwnAssetProfile
}); });
return this.assetProfilesService.deleteSplit({ id, symbolProfileId }); return this.assetProfilesService.deleteSplit({
dataSource,
id,
symbol,
symbolProfileId
});
} }
@HasPermission(permissions.accessAdminControl) @HasPermission(permissions.accessAdminControl)

16
apps/api/src/app/endpoints/asset-profiles/asset-profiles.service.spec.ts

@ -33,10 +33,10 @@ describe('AssetProfilesService', () => {
{ gatherSymbol } as unknown as DataGatheringService, { gatherSymbol } as unknown as DataGatheringService,
null, null,
null, null,
{ emit } as unknown as EventEmitter2,
null, null,
{ order: { findMany } } as never, { order: { findMany } } as never,
null, null
{ emit } as unknown as EventEmitter2
); );
}); });
@ -83,10 +83,10 @@ describe('AssetProfilesService', () => {
{ gatherSymbol } as unknown as DataGatheringService, { gatherSymbol } as unknown as DataGatheringService,
null, null,
null, null,
{ emit } as unknown as EventEmitter2,
null, null,
{ order: { findMany } } as never, { order: { findMany } } as never,
null, null
{ emit } as unknown as EventEmitter2
); );
await assetProfilesService.createSplit({ await assetProfilesService.createSplit({
@ -117,7 +117,9 @@ describe('AssetProfilesService', () => {
await expect( await expect(
assetProfilesService.deleteSplit({ assetProfilesService.deleteSplit({
dataSource: DataSource.YAHOO,
id: 'split-id', id: 'split-id',
symbol: 'AAPL',
symbolProfileId: 'profile-id' symbolProfileId: 'profile-id'
}) })
).rejects.toBeInstanceOf(NotFoundException); ).rejects.toBeInstanceOf(NotFoundException);
@ -131,7 +133,9 @@ describe('AssetProfilesService', () => {
await expect( await expect(
assetProfilesService.deleteSplit({ assetProfilesService.deleteSplit({
dataSource: DataSource.YAHOO,
id: 'split-id', id: 'split-id',
symbol: 'AAPL',
symbolProfileId: 'profile-id' symbolProfileId: 'profile-id'
}) })
).resolves.toBeUndefined(); ).resolves.toBeUndefined();
@ -143,6 +147,10 @@ describe('AssetProfilesService', () => {
expect(emit.mock.calls.map(([, event]) => event.getUserId())).toEqual([ expect(emit.mock.calls.map(([, event]) => event.getUserId())).toEqual([
'user-1' 'user-1'
]); ]);
expect(gatherSymbol).toHaveBeenCalledWith({
dataSource: DataSource.YAHOO,
symbol: 'AAPL'
});
}); });
}); });
}); });

5
apps/api/src/app/endpoints/asset-profiles/asset-profiles.service.ts

@ -72,12 +72,14 @@ export class AssetProfilesService {
} }
public async deleteSplit({ public async deleteSplit({
dataSource,
id, id,
symbol,
symbolProfileId symbolProfileId
}: { }: {
id: string; id: string;
symbolProfileId: string; symbolProfileId: string;
}) { } & AssetProfileIdentifier) {
const isDeleted = await this.assetProfileSplitService.deleteById({ const isDeleted = await this.assetProfileSplitService.deleteById({
id, id,
symbolProfileId symbolProfileId
@ -88,6 +90,7 @@ export class AssetProfilesService {
} }
await this.emitPortfolioChangedEvents(symbolProfileId); await this.emitPortfolioChangedEvents(symbolProfileId);
await this.dataGatheringService.gatherSymbol({ dataSource, symbol });
} }
private async emitPortfolioChangedEvents(symbolProfileId: string) { private async emitPortfolioChangedEvents(symbolProfileId: string) {

Loading…
Cancel
Save