Skip to content

Commit 8b51e3f

Browse files
committedApr 29, 2025·
PM-1143 - update tax form enum
1 parent 5359570 commit 8b51e3f

File tree

4 files changed

+19
-23
lines changed

4 files changed

+19
-23
lines changed
 

‎src/api/webhooks/trolley/handlers/tax-form.handler.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Injectable } from '@nestjs/common';
22
import { WebhookEvent } from '../../webhooks.decorators';
33
import {
4-
TaxFormStatus,
4+
TrolleyTaxFormStatus,
55
TaxFormStatusUpdatedEvent,
66
TaxFormStatusUpdatedEventData,
77
TrolleyWebhookEvent,
@@ -25,7 +25,7 @@ export class TaxFormHandler {
2525
taxFormData: TaxFormStatusUpdatedEventData,
2626
) {
2727
const taxFormStatus =
28-
taxFormData.status === TaxFormStatus.Reviewed
28+
taxFormData.status === TrolleyTaxFormStatus.Reviewed
2929
? tax_form_status.ACTIVE
3030
: tax_form_status.INACTIVE;
3131

@@ -38,6 +38,18 @@ export class TaxFormHandler {
3838
},
3939
});
4040

41+
// voided forms associations are removed from DB
42+
if (
43+
taxFormData.status === TrolleyTaxFormStatus.Voided &&
44+
existingFormAssociation
45+
) {
46+
return this.prisma.user_tax_form_associations.delete({
47+
where: {
48+
id: existingFormAssociation.id,
49+
},
50+
});
51+
}
52+
4153
if (!existingFormAssociation) {
4254
return this.prisma.user_tax_form_associations.create({
4355
data: {
@@ -49,15 +61,6 @@ export class TaxFormHandler {
4961
});
5062
}
5163

52-
// voided forms associations are removed from DB
53-
if (taxFormData.status === TaxFormStatus.Voided) {
54-
return this.prisma.user_tax_form_associations.delete({
55-
where: {
56-
id: existingFormAssociation.id,
57-
},
58-
});
59-
}
60-
6164
return this.prisma.user_tax_form_associations.update({
6265
where: { id: existingFormAssociation?.id },
6366
data: {

‎src/api/webhooks/trolley/trolley.types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export enum TrolleyWebhookEvent {
66

77
export type TrolleyEventHandler = (eventPayload: any) => Promise<unknown>;
88

9-
export enum TaxFormStatus {
9+
export enum TrolleyTaxFormStatus {
1010
Incomplete = 'incomplete',
1111
Submitted = 'submitted',
1212
Reviewed = 'reviewed',
@@ -16,7 +16,7 @@ export enum TaxFormStatus {
1616
export interface TaxFormStatusUpdatedEventData {
1717
recipientId: string;
1818
taxFormId: string;
19-
status: TaxFormStatus;
19+
status: TrolleyTaxFormStatus;
2020
taxFormType: string;
2121
taxFormAddressCountry: string;
2222
mailingAddressCountry: string | null;
@@ -34,7 +34,7 @@ export interface TaxFormStatusUpdatedEventData {
3434
export interface TaxFormStatusUpdatedEvent {
3535
taxForm: {
3636
previousFields: {
37-
status: TaxFormStatus;
37+
status: TrolleyTaxFormStatus;
3838
};
3939
data: TaxFormStatusUpdatedEventData;
4040
};

‎src/dto/adminWinning.dto.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,6 @@ export enum WinningsCategory {
9292
TASK_COPILOT_PAYMENT = 'TASK_COPILOT_PAYMENT',
9393
}
9494

95-
export enum TaxFormStatus {
96-
Incomplete = 'incomplete',
97-
Submitted = 'submitted',
98-
Reviewed = 'reviewed',
99-
Voided = 'voided',
100-
}
101-
10295
export enum PaymentStatus {
10396
PAID = 'PAID',
10497
ON_HOLD = 'ON_HOLD',

‎src/dto/taxForm.dto.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { TaxFormStatus } from './adminWinning.dto';
1+
import { tax_form_status } from '@prisma/client';
22

33
export class TaxFormQueryResult {
44
id: string;
55
user_id: string;
66
tax_form_id: string;
77
date_filed: Date;
8-
tax_form_status: TaxFormStatus;
8+
tax_form_status: tax_form_status;
99
}

0 commit comments

Comments
 (0)
Please sign in to comment.