import { z } from "zod";
import { tenantsSchema } from "./tenant.schema";
import { transactionsSchema } from "./transaction.schema";

export const duesSchema = z.object({
  id: z.number(),
  occupancyId: z.number(),
  tenantId: z.number(),
  roomId: z.number(),
  propId: z.number(),
  clientId: z.number(),
  amount: z.number().gt(-1),
  dueDate: z.string().datetime(),
  rentStartDate: z.string().date(),
  rentEndDate: z.string().date(),
  type: z.number(),
  status: z.number(),
  description: z.string(),
  title: z.string(),
  createdAt: z.string().datetime(),
  updatedAt: z.string().datetime(),
  balance: z.number(),
  ledgerReferenceId: z.string(),
  remarks: z.string(),
  discount: z.number(),
  hideFromTenant: z.number(),
  tallyStatus: z.number(),
  tallyBillRef: z.string(),
  tallyGuid: z.string(),
});

export const clientDuesListSchema = z.object({
  propId: z.number().nullable(),
  tenantId: z.number().nullable(),
  pageNum: z.number(),
});

export const tenantDueListSchema = z.object({
  tenantId: tenantsSchema.shape.id,
  date: z.string().date(),
});

export const editDuesSchema = z.object({
  dueId: duesSchema.shape.id,
  newAmount: duesSchema.shape.amount,
  isTemp: z.boolean(),
});

export const addDuesSchema = z.object({
  tenantId: tenantsSchema.shape.id,
  amount: duesSchema.shape.amount,
  type: z.number(),
});

export const markPaidSchema = z.object({
  id: duesSchema.shape.id,
  amount: duesSchema.shape.amount,
  mode: transactionsSchema.shape.mode,
  collectionDate: z.string().datetime(),
});

type duesTypes = z.infer<typeof duesSchema>;

export default duesTypes;
