import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { InvoiceApplicationVO, InvoiceApplicationForm, InvoiceApplicationQuery } from '@/api/bill/invoiceApplication/types';

/**
 * 查询开票申请单列表
 * @param query
 * @returns {*}
 */

export const listInvoiceApplication = (query?: InvoiceApplicationQuery): AxiosPromise<InvoiceApplicationVO[]> => {
  return request({
    url: '/bill/invoiceApplication/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询开票申请单详细
 * @param id
 */
export const getInvoiceApplication = (id: string | number): AxiosPromise<InvoiceApplicationVO> => {
  return request({
    url: '/bill/invoiceApplication/' + id,
    method: 'get'
  });
};

/**
 * 新增开票申请单
 * @param data
 */
export const addInvoiceApplication = (data: InvoiceApplicationForm) => {
  return request({
    url: '/bill/invoiceApplication',
    method: 'post',
    data: data
  });
};

/**
 * 修改开票申请单
 * @param data
 */
export const updateInvoiceApplication = (data: InvoiceApplicationForm) => {
  return request({
    url: '/bill/invoiceApplication',
    method: 'put',
    data: data
  });
};

/**
 * 删除开票申请单
 * @param id
 */
export const delInvoiceApplication = (id: string | number | Array<string | number>) => {
  return request({
    url: '/bill/invoiceApplication/' + id,
    method: 'delete'
  });
};

/**
 * 审核开票申请
 * @param id
 * @param orderStatus
 */
export function auditApplication(data: InvoiceApplicationForm) {
  return request({
    url: '/bill/invoiceApplication/auditApplication',
    method: 'put',
    data: data
  });
}
