invoice.ts 8.17 KB
import { useOrderStoreWithOut } from '/@/store/modules/order';
import { defHttp } from '/@/utils/http/axios';

enum Api {
  REFUND_DATE = '/order/erp/invoice_bill/get_back_refund_date', //最后汇款日期
  INVOICE_CREATE = '/order/erp/invoice_bill/create', //创建Invoice
  INVOICE = '/order/erp/invoice_bill/list_by_page', //分页查询列表
  BASE_INVOICE = '/order/erp/invoice_bill/list_base_order_info_by', //基础订单查询
  INVOICE_ANALYSIS = '/order/erp/invoice_bill/list_analysis_by', //分析列表
  EXPORT_ANALYSIS = '/order/erp/invoice_bill/export', //导出分析列表
  UPDATE_DEDUCT = '/order/erp/invoice_bill/update_deduct_info', //更新扣款信息
  UPDATE_AMOUNT = '/order/erp/invoice_bill/update_amount_info', //更新其他金额信息
  INVOICE_DELETE = '/order/erp/invoice_bill/delete_by_id', //删除数据
  COMMIT = '/order/erp/invoice_bill/commit_apply', //提交审核
  GETINVOICEDEDUCTURL_BY_ID = '/order/erp/invoice_bill/getDeductUrl_by_id', //获取扣款信息
  REUPLOADBGURL = '/order/erp/invoice_bill/reUploadBgUrl', //更新报关单
  INVOICEEXPORTRECEIPT = '/order/erp/invoice_bill/exportReceipt', //收款单导出
  SETBACKREFUNDDATE = '/order/erp/invoice_bill/setBackRefundDate', //必须回款日期

  PRODUCT_CREATE = '/order/erp/check_bill/create', //创建生产科应付单据
  PAYED_DATE = '/order/erp/check_bill/get_payed_date', //获取生产科应回款日期
  UPDATE_DEDUCT_INFO = '/order/erp/check_bill/update_deduct_info', //更新扣款信息
  UPDATE_AMOUNT_INFO = '/order/erp/check_bill/update_amount_info', //更新其他金额信息
  UPDATE_INVOICE_INFO = '/order/erp/check_bill/update_invoice_info', //更新发票信息
  CHECK_COMMIT = '/order/erp/check_bill/commit_apply', //提交审核
  CHECK_DELETE = '/order/erp/check_bill/delete_by_id', //删除数据
  CHECK_BILL = '/order/erp/check_bill/list_by_page', //分页查询列表
  CHECK_DETAIL = '/order/erp/check_bill/list_base_order_info_by', //基础订单查询
  CHECK_ANALYSIS = '/order/erp/check_bill/list_analysis_by', //分析列表
  EXPORT_CHECK_ANALYSIS = '/order/erp/check_bill/export', //导出分析列表
  GETDEDUCTURL_BY_ID = '/order/erp/check_bill/getDeductUrl_by_id', //获取扣款信息
  GETINVOICEURL_BY_ID = '/order/erp/check_bill/getInvoiceUrl_by_id', //获取扣款信息
  EXPORTRECEIPT = '/order/erp/check_bill/exportReceipt', //付款单导出
  SETPADYEDDATE = '/order/erp/check_bill/setPayedDate', //修改应付款日期
}

export const getRefundDate = async (params: any, data?: any) => {
  const res = await defHttp.post<any>({
    url: Api.REFUND_DATE,
    params,
  });
  return res;
};

export const createInvoice = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.INVOICE_CREATE,
    params,
  });
};

export const getInvoice = async (params: any) => {
  const res = await defHttp.post<any>({
    url: Api.INVOICE,
    params,
  });
  const formattedRecords = res.records.map((record: any) => {
    return {
      ...record,
      actualPayedAmount1: record.actualPayedAmount1?.toFixed(2),
      actualPayedAmount2: record.actualPayedAmount2?.toFixed(2),
      actualPayedAmount3: record.actualPayedAmount3?.toFixed(2),
      actualReceivableAmount: record.actualReceivableAmount?.toFixed(2),
      deductAmount: record.deductAmount?.toFixed(2),
      otherAmount: record.otherAmount?.toFixed(2),
      totalCustomerAmount: record.totalCustomerAmount?.toFixed(2),
      totalPayAmount: record.totalPayAmount?.toFixed(2),
    };
  });
  const orderStore = useOrderStoreWithOut();
  orderStore.setTotal(res.total);
  return new Promise((resolve) => {
    resolve({
      items: formattedRecords,
      total: res.total,
    });
  });
};
export const getBaseInvoice = async (params: any) => {
  const res = await defHttp.post<any>({
    url: Api.BASE_INVOICE,
    params,
  });
  return res;
};
export const invoiceAnalysis = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.INVOICE_ANALYSIS,
    params,
  });
};
export const exportAnalysis = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.EXPORT_ANALYSIS,
    params,
  });
};

export const updateDeduct = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.UPDATE_DEDUCT,
    params,
  });
};
// export const updateAmount = async (params: any, p0?: { id: any; bgUrl: any }) => {
export const updateAmount = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.UPDATE_AMOUNT,
    params,
  });
};
export const deleteInvoice = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.INVOICE_DELETE,
    params,
  });
};
export const commit = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.COMMIT,
    params,
  });
};

export const checkCreate = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.PRODUCT_CREATE,
    params,
  });
};
export const payDate = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.PAYED_DATE,
    params,
  });
};
export const updateDeductInfo = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.UPDATE_DEDUCT_INFO,
    params,
  });
};
export const updateAmountInfo = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.UPDATE_AMOUNT_INFO,
    params,
  });
};
export const checkCommit = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.CHECK_COMMIT,
    params,
  });
};
export const checkDelete = async (params: any, id?: string[]) => {
  return await defHttp.post<any>({
    url: Api.CHECK_DELETE,
    params,
  });
};
export const getCheck = async (params: any) => {
  const res = await defHttp.post<any>({
    url: Api.CHECK_BILL,
    params,
  });
  const formattedRecords = res.records.map((record: any) => {
    return {
      ...record,
      actualPayedAmount1: record.actualPayedAmount1?.toFixed(2),
      actualPayedAmount2: record.actualPayedAmount2?.toFixed(2),
      actualPayedAmount3: record.actualPayedAmount3?.toFixed(2),
      actualPayedAmount: record.actualPayedAmount?.toFixed(2),
      deductAmount: record.deductAmount?.toFixed(2),
      unPayedAmount: record.unPayedAmount?.toFixed(2),
      totalActualPayedAmount: record.totalActualPayedAmount?.toFixed(2),
      totalProductionAmount: record.totalProductionAmount?.toFixed(2),
    };
  });
  const orderStore = useOrderStoreWithOut();
  orderStore.setTotal(res.total);
  // return res.records;
  return new Promise((resolve) => {
    resolve({
      items: formattedRecords,
      total: res.total,
    });
  });
};
export const checkDetail = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.CHECK_DETAIL,
    params,
  });
};
export const checkAnalysis = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.CHECK_ANALYSIS,
    params,
  });
};
export const updateInvoiceInfo = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.UPDATE_INVOICE_INFO,
    params,
  });
};
export const exportCheckAnalysis = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.EXPORT_CHECK_ANALYSIS,
    params,
  });
};

export const getInvoiceDeductUrlById = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.GETINVOICEDEDUCTURL_BY_ID,
    params,
  });
};

export const getDeductUrlById = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.GETDEDUCTURL_BY_ID,
    params,
  });
};

export const getInvoiceUrlById = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.GETINVOICEURL_BY_ID,
    params,
  });
};

export const reUploadBgUrl = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.REUPLOADBGURL,
    params,
  });
};

export const getExportReceipt = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.EXPORTRECEIPT,
    params,
  });
};

export const getInvoiceExportReceipt = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.INVOICEEXPORTRECEIPT,
    params,
  });
};

export const getSetBackRefundDate = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.SETBACKREFUNDDATE,
    params,
  });
};

export const getSetPayedDate = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.SETPADYEDDATE,
    params,
  });
};