import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { InvoiceRecordVO, InvoiceRecordForm, InvoiceRecordQuery } from '@/api/finance/invoiceRecord/types';

/**
 * 查询发票列表
 * @param query
 * @returns {*}
 */

export const listInvoiceRecord = (query?: InvoiceRecordQuery): AxiosPromise<{ records:InvoiceRecordVO[] }> => {
  return request({
    url: '/finance/invoice/list_page',
    method: 'post',
    data: query
  });
};

/**
 * 查询发票详细
 * @param id
 */
export const getInvoiceRecord = (id: string | number): AxiosPromise<InvoiceRecordVO> => {
  return request({
    url: '/finance/invoice/get_detial',
    method: 'post',
      data: {id}
  });
};

/**
 * 新增发票
 * @param data
 */
export const addInvoiceRecord = (data: InvoiceRecordForm) => {
  return request({
    url: '/finance/invoice/save',
    method: 'post',
    data: data
  });
};

/**
 * 修改发票
 * @param data
 */
export const updateInvoiceRecord = (data: InvoiceRecordForm) => {
  return request({
    url: '/finance/invoiceRecord',
    method: 'put',
    data: data
  });
};

/**
 * 删除发票
 * @param id
 */
export const delInvoiceRecord = (id: string | number | Array<string | number>) => {
  return request({
    url: '/finance/invoice/delete',
    method: 'post',
      data: {id}
  });
};
