Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle null Instruction.tradeDate #1405

Merged
merged 2 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/api/entities/Instruction/__tests__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,27 @@ describe('Instruction class', () => {

expect(result.venue).toBeNull();
expect(result.memo).toBeNull();

dsMockUtils.createApolloQueryMock(
instructionsQuery(false, {
id: id.toString(),
}),
{
instructions: {
nodes: [
{
...middlewareInstruction,
valueDate: undefined,
tradeDate: undefined,
},
],
},
}
);
result = await instruction.details();

expect(result.tradeDate).toBeNull();
expect(result.valueDate).toBeNull();
});

it('should throw an error if an Instruction is not yet processed by middleware', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/api/entities/Instruction/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,8 @@ export class Instruction extends Entity<UniqueIdentifiers, string> {
return {
status: middlewareInstructionStatusToInstructionStatus(status),
createdAt: new Date(createdBlock!.datetime),
tradeDate: new Date(tradeDate),
valueDate: new Date(valueDate),
tradeDate: tradeDate ? new Date(tradeDate) : null,
valueDate: valueDate ? new Date(valueDate) : null,
venue: venueId ? new Venue({ id: new BigNumber(venueId) }, context) : null,
memo: memo ?? null,
...endCondition,
Expand Down
Loading