import request from '@/utils/request'

// 创建会计凭证
export function createVoucher(data) {
  return request({
    url: '/accounting/voucher/create',
    method: 'post',
    data: data
  })
}

// 更新会计凭证
export function updateVoucher(data) {
  return request({
    url: '/accounting/voucher/update',
    method: 'put',
    data: data
  })
}

// 归档
export function updateVoucherRecord(query) {
  return request({
    url: '/archives/record/recordAssociation',
    method: 'put',
    params: query
  })
}

// 删除会计凭证
export function deleteVoucher(id) {
  return request({
    url: '/accounting/voucher/delete?id=' + id,
    method: 'delete'
  })
}

// 获得会计凭证
export function getVoucher(id) {
  return request({
    url: '/accounting/voucher/get?id=' + id,
    method: 'get'
  })
}

// 获得会计凭证分页
export function getVoucherPage(query) {
  return request({
    url: '/accounting/voucher/page',
    method: 'get',
    params: query
  })
}

// 导出会计凭证 Excel
export function exportVoucherExcel(query) {
  return request({
    url: '/accounting/voucher/export-excel',
    method: 'get',
    params: query,
    responseType: 'blob'
  })
}

// 获得会计凭证行分页
export function getVoucherDetailsPage(query) {
  return request({
    url: '/accounting/voucher-details/page',
    method: 'get',
    params: query
  })
}

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