import api, { unwrap } from './request';

export interface VatReportResp extends Record<string, unknown> {
  reportId: number;
  reportYear: number;
  reportQuarter: number;
  salesAmount: number;
  salesVat: number;
  purchaseAmount: number;
  purchaseVat: number;
  payableVat: number;
  status?: string;
  statusName?: string;
  reportedAt?: string;
  createdAt?: string;
  updatedAt?: string;
}

export interface VatSearchParam {
  reportYear?: number;
  reportQuarter?: number;
  status?: string;
  pageNum?: number;
  pageSize?: number;
}

export interface VatRegenerateReq {
  reportYear: number;
  reportQuarter: number;
}

export interface VatReportCompleteReq {
  ids: number[];
}

export const vatApi = {
  list: (params?: VatSearchParam) =>
    unwrap<{ list: VatReportResp[]; total: number }>(
      api.get('/api/vat-reports', { params })
    ),
  detail: (id: number) =>
    unwrap<VatReportResp>(api.get(`/api/vat-reports/${id}`)),
  regenerate: (req: VatRegenerateReq) =>
    unwrap<void>(api.post('/api/vat-reports/regenerate', req)),
  complete: (req: VatReportCompleteReq) =>
    unwrap<void>(api.put('/api/vat-reports/complete', req)),
};
