Skip to content

Commit

Permalink
fix: build error
Browse files Browse the repository at this point in the history
  • Loading branch information
dahal committed Jul 21, 2024
1 parent 0038681 commit 9e2c6df
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Share" ALTER COLUMN "companyLegends" SET DEFAULT ARRAY[]::"ShareLegendsEnum"[];
2 changes: 1 addition & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ model Share {
vestingYears Int @default(0) // 0 means immediate vesting, 1 means vesting over 1 year
vestingSchedule VestingScheduleEnum
companyLegends ShareLegendsEnum[]
companyLegends ShareLegendsEnum[] @default([])
issueDate DateTime
rule144Date DateTime?
Expand Down
28 changes: 15 additions & 13 deletions src/server/api/schema/shares.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const SecuritiesStatusArr = Object.values(SecuritiesStatusEnum) as [

export const ShareSchema = z
.object({
id: z.string().cuid().optional().openapi({
id: z.string().cuid().nullish().openapi({
description: "Share ID",
example: "clyvb2s8d0000f1ngd72y2cxw",
}),
Expand All @@ -31,7 +31,7 @@ export const ShareSchema = z
example: "DRAFT",
}),

certificateId: z.string().optional().openapi({
certificateId: z.string().nullish().openapi({
description: "Certificate ID",
example: "123",
}),
Expand All @@ -41,27 +41,27 @@ export const ShareSchema = z
example: 5000,
}),

pricePerShare: z.number().nullable().openapi({
pricePerShare: z.number().nullish().openapi({
description: "Price Per Share",
example: 1.25,
}),

capitalContribution: z.number().nullable().openapi({
capitalContribution: z.number().nullish().openapi({
description: "Total amount of money contributed",
example: 250000,
}),

ipContribution: z.number().nullable().openapi({
ipContribution: z.number().nullish().openapi({
description: "Value of the intellectual property contributed",
example: 0,
}),

debtCancelled: z.number().nullable().openapi({
debtCancelled: z.number().nullish().openapi({
description: "Amount of debt cancelled",
example: 0,
}),

otherContributions: z.number().nullable().openapi({
otherContributions: z.number().nullish().openapi({
description: "Other contributions",
example: 0,
}),
Expand All @@ -74,27 +74,29 @@ export const ShareSchema = z
companyLegends: z
.enum(ShareLegendsArr)
.array()
.default([])
.nullish()
.openapi({
description: "Company Legends",
example: ["US_SECURITIES_ACT", "SALE_AND_ROFR"],
}),

issueDate: z.string().datetime().openapi({
issueDate: z.string().datetime().nullish().openapi({
description: "Issued Date",
example: "2024-01-01T00:00:00.000Z",
}),

rule144Date: z.string().datetime().nullable().openapi({
rule144Date: z.string().datetime().nullish().openapi({
description: "Rule 144 Date",
example: "2024-01-01T00:00:00.000Z",
}),

vestingStartDate: z.string().datetime().nullable().openapi({
vestingStartDate: z.string().datetime().nullish().openapi({
description: "Vesting Start Date",
example: "2024-01-01T00:00:00.000Z",
}),

boardApprovalDate: z.string().datetime().optional().openapi({
boardApprovalDate: z.string().datetime().nullish().openapi({
description: "Board Approval Date",
example: "2024-01-01T00:00:00.000Z",
}),
Expand All @@ -114,12 +116,12 @@ export const ShareSchema = z
example: "clyvb2d8v0000f1ng1stpa38s",
}),

createdAt: z.string().datetime().optional().openapi({
createdAt: z.string().datetime().nullish().openapi({
description: "Share Created at",
example: "2024-01-01T00:00:00.000Z",
}),

updatedAt: z.string().datetime().optional().openapi({
updatedAt: z.string().datetime().nullish().openapi({
description: "Share Updated at",
example: "2024-01-01T00:00:00.000Z",
}),
Expand Down
10 changes: 8 additions & 2 deletions src/server/services/shares/update-share.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ApiError } from "@/server/api/error";
import type { UpdateShareSchemaType } from "@/server/api/schema/shares";
import { Audit } from "@/server/audit";
import { db } from "@/server/db";
import type { ShareLegendsEnum } from "@prisma/client";

export type UpdateSharePayloadType = {
shareId: string;
Expand Down Expand Up @@ -30,11 +31,16 @@ export const updateShare = async (payload: UpdateSharePayloadType) => {
};
}

console.log({ data });
const shareData = {
...existingShare,
...data,
};

const share = await db.$transaction(async (tx) => {
const share = await tx.share.update({
where: { id: shareId },
data,
// @ts-ignore
data: shareData,
});

await Audit.create(
Expand Down

0 comments on commit 9e2c6df

Please sign in to comment.