export type DetailArchiveStatus = 'active' | 'archived';

export interface LeaseBusinessDetailRow {
  id: string;
  year: number;
  month: number;
  businessDept: string;
  salesperson: string;
  paymentDate: string;
  plateNo: string;
  vehicleType: string;
  customerName: string;
  valueAddedService: string;
  exemptionPolicy: string;
  pickupDate: string;
  contractStartDate: string;
  contractEndDate: string;
  periodStartDate: string;
  returnDate: string;
  avgDays: number;
  deposit: number | string;
  contractRent: number;
  receivableTotal: number;
  receivableRent: number;
  monthlyIncome: number;
  monthlyRent: number;
  maintenanceIncome: number;
  insuranceSurcharge: number;
  opsFeeIncome: number;
  otherIncome: number;
  mileageDeduction: number;
  otherDeduction: number;
  receivedAmount: number;
  outstanding: number;
  invoiceDate: string;
  actualPaymentDate: string;
  paymentMethod: string;
  vehicleStandardCost: number;
  vehicleActualCost: number;
  insuranceFee: number;
  hydrogenFee: number;
  opsFeeCost: number;
  brokerageFee: number;
  otherCost: number;
  totalCost: number;
  profitLoss: number;
  gpsMileage: string;
  otherDeductionDetail: string;
  assetOwner: string;
  signingCompany: string;
  remark: string;
  /** 未对账可编辑；已对账后仅业务管理部主管可改 */
  archiveStatus?: DetailArchiveStatus;
  /** 完成对账日期 YYYY-MM-DD */
  reconciledAt?: string;
}

export interface LeaseDetailFilters {
  statMonth: string;
  businessDept: string;
  salesperson: string;
  /** 客户名称模糊匹配 */
  customerName: string;
  /** 收款状态：已结清 / 部分收款 / 未收款 */
  paymentStatus: string;
  plateNos: string[];
}

/** 对齐 Excel「租赁车辆收入明细表」表头上方 SUBTOTAL 汇总行 */
export interface LeaseDetailKpiSummary {
  deposit: number;
  contractRent: number;
  receivableTotal: number;
  receivableRent: number;
  monthlyIncome: number;
  monthlyRent: number;
  maintenanceIncome: number;
  insuranceSurcharge: number;
  opsFeeIncome: number;
  otherIncome: number;
  mileageDeduction: number;
  otherDeduction: number;
  receivedAmount: number;
  outstanding: number;
  vehicleStandardCost: number;
  vehicleActualCost: number;
  insuranceFee: number;
  hydrogenFee: number;
  opsFeeCost: number;
  brokerageFee: number;
  otherCost: number;
  totalCost: number;
  profitLoss: number;
}

export const EMPTY_LEASE_DETAIL_KPI: LeaseDetailKpiSummary = {
  deposit: 0,
  contractRent: 0,
  receivableTotal: 0,
  receivableRent: 0,
  monthlyIncome: 0,
  monthlyRent: 0,
  maintenanceIncome: 0,
  insuranceSurcharge: 0,
  opsFeeIncome: 0,
  otherIncome: 0,
  mileageDeduction: 0,
  otherDeduction: 0,
  receivedAmount: 0,
  outstanding: 0,
  vehicleStandardCost: 0,
  vehicleActualCost: 0,
  insuranceFee: 0,
  hydrogenFee: 0,
  opsFeeCost: 0,
  brokerageFee: 0,
  otherCost: 0,
  totalCost: 0,
  profitLoss: 0,
};

export const EMPTY_LEASE_DETAIL_FILTERS: LeaseDetailFilters = {
  statMonth: '',
  businessDept: '',
  salesperson: '',
  customerName: '',
  paymentStatus: '',
  plateNos: [],
};
