-
Notifications
You must be signed in to change notification settings - Fork 0
[PROD RELEASE] - Trolley #72
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
Changes from 53 commits
9c88752
7ad1504
e95b40f
1f65854
87cd639
86c1b99
f4097ff
5f5a74a
1c6ff07
41b95c1
1b38436
067aacd
031731c
24f0d33
e7a1de3
0b22a6b
af99bf6
48a6b7d
4a82736
b593395
e6308fe
6b0b056
14379bf
2d38155
129e1ea
73a3a1f
9827b18
1a488ff
e96c144
35899be
6d982fe
e628580
6be5bd7
c49fa49
b199ca5
1473e1a
e942094
6a1d7c1
c318b0a
983158e
7c0e199
257d0e9
b0a52dc
6529ecb
95d291f
4098635
4817c67
b26e0d5
9570210
2010f0a
bb3f230
205ee00
aa1190c
03fc187
53b095d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,11 @@ ALTER TABLE "paypal_payment_method" ALTER COLUMN "user_payment_method_id" DROP N | |
UPDATE payoneer_payment_method SET user_payment_method_id = NULL; | ||
UPDATE paypal_payment_method SET user_payment_method_id = NULL; | ||
|
||
DELETE FROM user_default_payment_method; | ||
DELETE FROM user_payment_methods; | ||
DROP TABLE user_default_payment_method; | ||
|
||
DELETE FROM user_payment_methods | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. medium |
||
WHERE payment_method_id NOT IN ( | ||
SELECT payment_method_id | ||
FROM payment_method | ||
WHERE payment_method_type IN ('Wipro Payroll', 'Trolley') | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
-- Update all payments witha "owed" status to "on_hold" for users that don't have a trolley_id | ||
-- and no trolley_recipient_payment_method set. | ||
|
||
UPDATE payment | ||
SET payment_status = 'ON_HOLD' | ||
WHERE winnings_id IN ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. medium |
||
SELECT winnings.winning_id | ||
FROM winnings | ||
LEFT JOIN trolley_recipient ON winnings.winner_id = trolley_recipient.user_id | ||
LEFT JOIN trolley_recipient_payment_method ON trolley_recipient.id = trolley_recipient_payment_method.trolley_recipient_id | ||
WHERE payment.payment_status = 'OWED' AND ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. high |
||
trolley_recipient.trolley_id IS NULL OR | ||
trolley_recipient_payment_method.id IS NULL | ||
) | ||
); | ||
|
||
-- To test & see the updated payments: | ||
-- | ||
-- SELECT payment.payment_id, | ||
-- payment.total_amount, | ||
-- payment.installment_number, | ||
-- payment.payment_method_id, | ||
-- payment.version, | ||
-- payment.payment_status, | ||
-- winnings.winner_id, | ||
-- trolley_recipient.trolley_id, | ||
-- trolley_recipient_payment_method.recipient_account_id | ||
-- FROM payment | ||
-- LEFT JOIN winnings ON payment.winnings_id = winnings.winning_id | ||
-- LEFT JOIN trolley_recipient ON winnings.winner_id = trolley_recipient.user_id | ||
-- LEFT JOIN trolley_recipient_payment_method ON trolley_recipient.id = trolley_recipient_payment_method.trolley_recipient_id | ||
-- WHERE payment.payment_status = 'OWED' | ||
-- AND trolley_recipient.trolley_id IS NULL | ||
-- AND trolley_recipient_payment_method.id IS NULL; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
-- AlterTable | ||
ALTER TABLE "payment" ADD COLUMN "challenge_fee" DECIMAL(12,2), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. medium |
||
ADD COLUMN "challenge_markup" DECIMAL(12,2); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
-- CreateEnum | ||
CREATE TYPE "verification_status" AS ENUM ('ACTIVE', 'INACTIVE'); | ||
|
||
-- CreateTable | ||
CREATE TABLE "user_identity_verification_associations" ( | ||
"id" UUID NOT NULL DEFAULT uuid_generate_v4(), | ||
"user_id" VARCHAR(80) NOT NULL, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. medium |
||
"verification_id" TEXT NOT NULL, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. medium |
||
"date_filed" TIMESTAMP(6) WITHOUT TIME ZONE NOT NULL, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. medium |
||
"verification_status" "verification_status" NOT NULL, | ||
|
||
CONSTRAINT "user_identity_verification_associations_pkey" PRIMARY KEY ("id") | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
Warnings: | ||
- You are about to drop the column `transaction_id` on the `otp` table. All the data in the column will be lost. | ||
- You are about to drop the `transaction` table. If the table is not empty, all the data it contains will be lost. | ||
*/ | ||
-- AlterTable | ||
ALTER TABLE "otp" DROP COLUMN "transaction_id"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. high |
||
|
||
-- DropTable | ||
DROP TABLE "transaction"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. high |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,6 @@ model otp { | |
email String @db.VarChar(255) | ||
otp_hash String @db.VarChar(255) | ||
expiration_time DateTime @default(dbgenerated("(CURRENT_TIMESTAMP + '00:05:00'::interval)")) @db.Timestamp(6) | ||
transaction_id String @db.VarChar(255) | ||
action_type reference_type | ||
created_at DateTime? @default(now()) @db.Timestamp(6) | ||
updated_at DateTime? @default(now()) @db.Timestamp(6) | ||
|
@@ -55,6 +54,8 @@ model payment { | |
release_date DateTime? @default(dbgenerated("(CURRENT_TIMESTAMP + '15 days'::interval)")) @db.Timestamp(6) | ||
payment_status payment_status? | ||
billing_account String @db.VarChar(80) | ||
challenge_markup Decimal? @db.Decimal(12, 2) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. medium |
||
challenge_fee Decimal? @db.Decimal(12, 2) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. medium |
||
payment_method payment_method? @relation(fields: [payment_method_id], references: [payment_method_id], onDelete: NoAction, onUpdate: NoAction) | ||
winnings winnings @relation(fields: [winnings_id], references: [winning_id], onDelete: NoAction, onUpdate: NoAction) | ||
payment_release_associations payment_release_associations[] | ||
|
@@ -67,7 +68,6 @@ model payment_method { | |
description String? | ||
payment payment[] | ||
payment_releases payment_releases[] | ||
user_default_payment_method user_default_payment_method[] | ||
user_payment_methods user_payment_methods[] | ||
} | ||
|
||
|
@@ -128,22 +128,6 @@ model reward { | |
winnings winnings @relation(fields: [winnings_id], references: [winning_id], onDelete: NoAction, onUpdate: NoAction) | ||
} | ||
|
||
model transaction { | ||
id String @id @default(dbgenerated("uuid_generate_v4()")) @db.Uuid | ||
user_id String @db.VarChar(255) | ||
reference_id String @db.Uuid | ||
reference_type reference_type | ||
status transaction_status @default(INITIATED) | ||
created_at DateTime? @default(now()) @db.Timestamp(6) | ||
updated_at DateTime? @default(now()) @db.Timestamp(6) | ||
} | ||
|
||
model user_default_payment_method { | ||
user_id String @id @db.VarChar(80) | ||
payment_method_id Int | ||
payment_method payment_method @relation(fields: [payment_method_id], references: [payment_method_id], onDelete: Cascade, onUpdate: NoAction, map: "fk_default_payment_method") | ||
} | ||
|
||
model user_payment_methods { | ||
id String @id @default(dbgenerated("uuid_generate_v4()")) @db.Uuid | ||
user_id String @db.VarChar(80) | ||
|
@@ -212,13 +196,26 @@ model trolley_webhook_log { | |
created_at DateTime? @default(now()) @db.Timestamp(6) | ||
} | ||
|
||
model user_identity_verification_associations { | ||
id String @id @default(dbgenerated("uuid_generate_v4()")) @db.Uuid | ||
user_id String @db.VarChar(80) | ||
verification_id String @db.Text | ||
date_filed DateTime @db.Timestamp(6) | ||
verification_status verification_status | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. medium |
||
} | ||
|
||
model trolley_recipient_payment_method { | ||
id String @id @default(dbgenerated("uuid_generate_v4()")) @db.Uuid | ||
trolley_recipient_id Int | ||
recipient_account_id String @unique @db.VarChar(80) | ||
trolley_recipient trolley_recipient @relation(fields: [trolley_recipient_id], references: [id], onDelete: Cascade, onUpdate: NoAction, map: "fk_trolley_recipient_trolley_recipient_payment_method") | ||
} | ||
|
||
enum verification_status { | ||
ACTIVE | ||
INACTIVE | ||
} | ||
|
||
enum action_type { | ||
INITIATE_WITHDRAWAL | ||
ADD_WITHDRAWAL_METHOD | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -164,19 +164,24 @@ export class AdminController { | |
@Body() body: WinningUpdateRequestDto, | ||
@User() user: UserInfo, | ||
): Promise<ResponseDto<string>> { | ||
if (!body.paymentAmount && !body.releaseDate && !body.paymentStatus) { | ||
if ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. medium |
||
!body.paymentAmount && | ||
!body.releaseDate && | ||
!body.paymentStatus && | ||
!body.description | ||
) { | ||
throw new BadRequestException( | ||
'paymentStatus, releaseDate and paymentAmount cannot be null at the same time.', | ||
'description, paymentStatus, releaseDate and paymentAmount cannot be null at the same time.', | ||
); | ||
} | ||
|
||
const result = await this.adminService.updateWinnings(body, user.id); | ||
|
||
result.status = ResponseStatusType.SUCCESS; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. high |
||
if (result.error) { | ||
result.status = ResponseStatusType.ERROR; | ||
} | ||
|
||
result.status = ResponseStatusType.SUCCESS; | ||
|
||
return result; | ||
} | ||
|
||
|
@@ -200,12 +205,12 @@ export class AdminController { | |
@Param('winningID') winningId: string, | ||
): Promise<ResponseDto<WinningAuditDto[]>> { | ||
const result = await this.adminService.getWinningAudit(winningId); | ||
|
||
result.status = ResponseStatusType.SUCCESS; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. high |
||
if (result.error) { | ||
result.status = ResponseStatusType.ERROR; | ||
} | ||
|
||
result.status = ResponseStatusType.SUCCESS; | ||
|
||
return result; | ||
} | ||
|
||
|
@@ -230,12 +235,12 @@ export class AdminController { | |
@Param('winningID') winningId: string, | ||
): Promise<ResponseDto<AuditPayoutDto[]>> { | ||
const result = await this.adminService.getWinningAuditPayout(winningId); | ||
|
||
result.status = ResponseStatusType.SUCCESS; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. high |
||
if (result.error) { | ||
result.status = ResponseStatusType.ERROR; | ||
} | ||
|
||
result.status = ResponseStatusType.SUCCESS; | ||
|
||
return result; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,13 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { AdminController } from './admin.controller'; | ||
import { AdminService } from './admin.service'; | ||
import { TaxFormRepository } from '../repository/taxForm.repo'; | ||
import { PaymentMethodRepository } from '../repository/paymentMethod.repo'; | ||
import { WinningsRepository } from '../repository/winnings.repo'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. high |
||
import { TopcoderModule } from 'src/shared/topcoder/topcoder.module'; | ||
import { PaymentsModule } from 'src/shared/payments'; | ||
|
||
@Module({ | ||
imports: [TopcoderModule, PaymentsModule], | ||
controllers: [AdminController], | ||
providers: [ | ||
AdminService, | ||
TaxFormRepository, | ||
PaymentMethodRepository, | ||
WinningsRepository, | ||
], | ||
providers: [AdminService, WinningsRepository], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. high |
||
}) | ||
export class AdminModule {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
high
correctness
Dropping the
user_default_payment_method
table is a destructive operation. Ensure that this table is no longer needed and that any dependent systems or processes have been updated accordingly.