import { requestClient } from '#/api/request';

export namespace ErpPurchaseInvoiceAiApi {
  /** 识别发票响应 */
  export interface OcrResultVO {
    /** 发票号码 */
    invoiceNo?: string;
    /** 发票抬头（购买方名称） */
    invoiceTitle?: string;
    /** 销售方名称（文本，供核对供应商） */
    supplierName?: string;
    /** 来票金额（价税合计），单位：元 */
    price?: number;
    /** 开票日期，格式 yyyy-MM-dd */
    invoiceTime?: string;
    /** 发票类型 */
    invoiceType?: string;
    /** 税率（百分比） */
    taxRate?: number;
    /** 备注 */
    remark?: string;
    /** 原始识别文本（识别失败时为错误提示） */
    rawText?: string;
  }
}

/** 识别发票文件 */
export function ocrPurchaseInvoice(blobId: number) {
  return requestClient.post<ErpPurchaseInvoiceAiApi.OcrResultVO>(
    '/erp/purchase-invoice/ai/ocr',
    { blobId },
  );
}
