38 lines
1.4 KiB
TypeScript
38 lines
1.4 KiB
TypeScript
import * as z from 'zod';
|
|
import type { Prisma } from '../../../generated/prisma';
|
|
import { PaymentMethodSchema } from '../enums/PaymentMethod.schema'
|
|
|
|
import { DecimalJSLikeSchema, isValidDecimalInput } from '../../helpers/decimal-helpers';
|
|
|
|
import Decimal from "decimal.js";
|
|
const makeSchema = () => z.object({
|
|
id: z.number().int().optional(),
|
|
serviceLineId: z.number().int(),
|
|
transactionId: z.string().optional().nullable(),
|
|
paidAmount: z.union([
|
|
z.number(),
|
|
z.string(),
|
|
z.instanceof(Decimal),
|
|
z.instanceof(Decimal),
|
|
DecimalJSLikeSchema,
|
|
]).refine((v) => isValidDecimalInput(v), {
|
|
message: "Field 'paidAmount' must be a Decimal",
|
|
}),
|
|
adjustedAmount: z.union([
|
|
z.number(),
|
|
z.string(),
|
|
z.instanceof(Decimal),
|
|
z.instanceof(Decimal),
|
|
DecimalJSLikeSchema,
|
|
]).refine((v) => isValidDecimalInput(v), {
|
|
message: "Field 'adjustedAmount' must be a Decimal",
|
|
}).optional(),
|
|
method: PaymentMethodSchema,
|
|
receivedDate: z.coerce.date(),
|
|
payerName: z.string().optional().nullable(),
|
|
notes: z.string().optional().nullable(),
|
|
createdAt: z.coerce.date().optional()
|
|
}).strict();
|
|
export const ServiceLineTransactionUncheckedCreateWithoutPaymentInputObjectSchema: z.ZodType<Prisma.ServiceLineTransactionUncheckedCreateWithoutPaymentInput> = makeSchema() as unknown as z.ZodType<Prisma.ServiceLineTransactionUncheckedCreateWithoutPaymentInput>;
|
|
export const ServiceLineTransactionUncheckedCreateWithoutPaymentInputObjectZodSchema = makeSchema();
|