export interface PaymentMethod {
  id: string;
  code: string;
  label: string;
  kind: 'cash' | 'card' | 'other';
}

export interface PaymentAllocation {
  id: string;
  methodCode: string;
  methodLabel: string;
  kind: PaymentMethod['kind'];
  amountCents: number;
  tenderedCents?: number;
  changeCents: number;
}

export interface ReceiptItem {
  name: string;
  sku: string;
  quantity: number;
  unitPriceCents: number;
  subtotalCents: number;
  discountCents: number;
  taxCents: number;
  totalCents: number;
  freeItem: boolean;
}

export interface ReceiptPayment {
  methodCode: string;
  methodLabel: string;
  kind: PaymentMethod['kind'];
  amountCents: number;
  tenderedCents: number | null;
  changeCents: number;
}

export interface PosReceipt {
  receiptNumber: string;
  orderId: string;
  issuedAt: string;
  company: {
    name: string;
    address: string | null;
    taxId: string | null;
    email: string | null;
    phone: string | null;
  };
  logoUrl: string | null;
  terminal: { id: string; name: string };
  cashier: string;
  sessionId: string;
  customerEmail: string | null;
  items: ReceiptItem[];
  subtotalCents: number;
  discountCents: number;
  taxCents: number;
  totalCents: number;
  payments: ReceiptPayment[];
  changeCents: number;
  header: string | null;
  returnPolicy: string;
  footer: string | null;
  originalReceiptNumber?: string;
  isReturn?: boolean;
}

export interface PosSaleResponse {
  orderId: string;
  receiptNumber: string;
  state: 'PENDING' | 'COMPLETED';
  totalCents: number;
  paidCents: number;
  outstandingCents: number;
  changeCents: number;
  receipt: PosReceipt;
  clubEarnedCents: number;
  clubMemberCode?: string;
}

export interface PosPendingSale {
  id: string;
  state: 'PENDING' | 'COMPLETED';
  totalCents: number;
  paidCents: number;
  outstandingCents: number;
  subtotalCents: number;
  discountCents: number;
  createdAt: string;
  cashierEmail?: string | null;
  receiptNumber?: string | null;
  posLabel?: string | null;
}

export interface RecoveredOrderItem {
  id: string;
  name: string;
  sku: string;
  quantity: number;
  returnedQuantity: number;
  freeItem: boolean;
  unitPriceCents: number;
  discountCents: number;
}
