import { z } from 'zod'; import { Money } from './billing'; import { ListSchema } from './common'; export const InvoicePaymentStatusSchema = z .enum([ 'SENT', 'PENDING', 'PAID', 'PROCESSED', 'TECHNICAL_ERROR', 'FAILED', 'CREDIT_MANAGEMENT', 'VALIDATION_ERROR', ]) .nullable(); export const InvoiceSchema = z.object({ id: z.number(), /** * @deprecated use `totalPriceInclVat` or `totalPriceExclVat` instead */ amount: z.number(), totalPriceInclVat: Money, totalPriceExclVat: Money, totalVat: Money, amountOpen: Money, invoiceNumber: z.string(), issueDate: z.iso.date(), dueDate: z.iso.date().nullable(), paymentStatus: InvoicePaymentStatusSchema, paymentUrl: z.string().nullable(), }); export type Invoice = z.infer; export const InvoiceLineItemSchema = z.object({ description: z.string(), quantity: z.number(), vatPercentage: z.number(), priceInclVat: Money, priceExclVat: Money, totalPriceInclVat: Money, totalPriceExclVat: Money, totalVat: Money, }); export type InvoiceLineItem = z.infer; export const InvoiceHalSchema = InvoiceSchema.extend({ _embedded: z .object({ lineItems: z.array(InvoiceLineItemSchema), }) .optional(), _links: z.object({ self: z.object({ href: z.string(), }), invoiceUrl: z.object({ href: z.string(), }), }), }); export type InvoiceHal = z.infer; export const InvoiceHalListSchema = ListSchema.extend({ _embedded: z.object({ invoices: z.array(InvoiceHalSchema), }), }); export type InvoiceHalList = z.infer; export const InvoiceDownloadSchema = z.object({}); export type InvoiceDownload = z.infer; export const InvoiceDownloadHalSchema = InvoiceDownloadSchema.extend({ _links: z.object({ self: z.object({ href: z.string(), }), pdf: z.object({ href: z.string(), }), }), }); export type InvoiceDownloadHal = z.infer; export const InvoiceDownloadInputSchema = z.object({ invoiceId: z.string(), }); export type InvoiceDownloadInput = z.infer;