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
});
return this.assetProfilesService.deleteSplit({ id, symbolProfileId });
return this.assetProfilesService.deleteSplit({
dataSource,
id,
symbol,
symbolProfileId
});
}
@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,
null,
null,
{ emit } as unknown as EventEmitter2,
null,
{ order: { findMany } } as never,
null,
{ emit } as unknown as EventEmitter2
null
);
});
@ -83,10 +83,10 @@ describe('AssetProfilesService', () => {
{ gatherSymbol } as unknown as DataGatheringService,
null,
null,
{ emit } as unknown as EventEmitter2,
null,
{ order: { findMany } } as never,
null,
{ emit } as unknown as EventEmitter2
null
);
await assetProfilesService.createSplit({
@ -117,7 +117,9 @@ describe('AssetProfilesService', () => {
await expect(
assetProfilesService.deleteSplit({
dataSource: DataSource.YAHOO,
id: 'split-id',
symbol: 'AAPL',
symbolProfileId: 'profile-id'
})
).rejects.toBeInstanceOf(NotFoundException);
@ -131,7 +133,9 @@ describe('AssetProfilesService', () => {
await expect(
assetProfilesService.deleteSplit({
dataSource: DataSource.YAHOO,
id: 'split-id',
symbol: 'AAPL',
symbolProfileId: 'profile-id'
})
).resolves.toBeUndefined();
@ -143,6 +147,10 @@ describe('AssetProfilesService', () => {
expect(emit.mock.calls.map(([, event]) => event.getUserId())).toEqual([
'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({
dataSource,
id,
symbol,
symbolProfileId
}: {
id: string;
symbolProfileId: string;
}) {
} & AssetProfileIdentifier) {
const isDeleted = await this.assetProfileSplitService.deleteById({
id,
symbolProfileId
@ -88,6 +90,7 @@ export class AssetProfilesService {
}
await this.emitPortfolioChangedEvents(symbolProfileId);
await this.dataGatheringService.gatherSymbol({ dataSource, symbol });
}
private async emitPortfolioChangedEvents(symbolProfileId: string) {

Loading…
Cancel
Save