import request from '@/utils/request'

// 创建发票
export function createInvoices(data) {
  return request({
    url: '/accounting/invoices/create',
    method: 'post',
    data: data
  })
}

// 更新发票
export function updateInvoices(data) {
  return request({
    url: '/accounting/invoices/update',
    method: 'put',
    data: data
  })
}

// 关联会计凭证
export function updateArrayInvoices(data) {
  return request({
    url: '/accounting/invoices/update/array',
    method: 'put',
    data: data
  })
}

// 删除发票
export function deleteInvoices(id) {
  return request({
    url: '/accounting/invoices/delete?id=' + id,
    method: 'delete'
  })
}

// 获得发票
export function getInvoices(id) {
  return request({
    url: '/accounting/invoices/get?id=' + id,
    method: 'get'
  })
}

// 获得发票分页
export function getInvoicesPage(query) {
  return request({
    url: '/accounting/invoices/page',
    method: 'get',
    params: query
  })
}

// 获得发票分页2
export function getInvoicesPageTime(query) {
  return request({
    url: '/accounting/invoices/pageTime',
    method: 'get',
    params: query
  })
}


// 导出发票 Excel
export function exportInvoicesExcel(query) {
  return request({
    url: '/accounting/invoices/export-excel',
    method: 'get',
    params: query,
    responseType: 'blob'
  })
}


// 下载模板
export function outTemplate() {
  return request({
    url: '/accounting/invoices/outTemplate',
    method: 'get',
    responseType: 'blob'
  })
}

// 下载元数据
export function downloadXml(query) {
  return request({
    url: '/accounting/invoices/downloadXml',
    method: 'get',
    params: query,
    responseType: 'blob'
  })
}