export type PayeeType = 'Vendor' | 'Member';
export type CheckStatus = 'Issued' | 'Voided';

export interface PagedResult<T> {
  items: T[]; totalCount: number; page: number; pageSize: number; totalPages: number;
}

export interface ExpenseLineDto {
  expenseId: number; expenseDate: string; description: string; amount: number;
  ministryName: string; categoryName: string;
}

export interface PayeeGroupDto {
  payeeType: PayeeType; memberId: number | null; vendorKey: string | null;
  payeeName: string; address: string | null; city: string | null;
  state: string | null; zip: string | null;
  totalAmount: number; lines: ExpenseLineDto[];
}

export interface PayeeCheckInstruction {
  payeeType: PayeeType; memberId: number | null; vendorKey: string | null;
  payeeName: string; address: string | null; city: string | null;
  state: string | null; zip: string | null;
  checkNumberOverride: string | null; memo: string | null; expenseIds: number[];
}

export interface IssueChecksRequest { checkDate: string; payees: PayeeCheckInstruction[]; }

export interface IssuedCheckDto { checkId: number; checkNumber: string; payeeName: string; amount: number; }
export interface IssueChecksResultDto { created: IssuedCheckDto[]; }

export interface CheckListItemDto {
  id: number; checkNumber: string; checkDate: string; amount: number;
  payeeType: PayeeType; payeeName: string; status: CheckStatus; lineCount: number;
  signed: boolean; receiptSignedName: string | null; receiptSignedAt: string | null;
}

export interface CheckLineDto { expenseId: number; description: string; amount: number; }

export interface CheckDetailDto extends CheckListItemDto {
  memberId: number | null; address: string | null; city: string | null;
  state: string | null; zip: string | null; memo: string | null;
  voidReason: string | null; voidedAt: string | null; issuedAt: string;
  lines: CheckLineDto[];
}

export interface ChurchProfileDto {
  id: number; name: string; nameZh: string | null; phone: string | null;
  email: string | null; website: string | null; address: string | null; city: string | null;
  state: string | null; zipCode: string | null; bankName: string | null;
  bankAccountNumber: string | null; bankRoutingNumber: string | null; payerEin: string | null; nextCheckNumber: number;
  aiProvider: string;
  claudeModel: string | null; claudeApiKeyMasked: string | null;
  geminiModel: string | null; geminiApiKeyMasked: string | null;
}

export type UpdateChurchProfileRequest =
  Omit<ChurchProfileDto, 'id' | 'claudeApiKeyMasked' | 'geminiApiKeyMasked'>
  & { claudeApiKey: string | null; geminiApiKey: string | null };
