/** ================================= 报表 - 财务报表 ================================**/

import { getUsrId } from '@/services/bus/user';
import { commonSearch_go } from '@/services/go/index';
import * as type from './interface';

/**
 * 查询财务日报表(菜单:报表查询/财务报表/日报表)
 * @param tradedate 交易日(格式:yyyyMMdd)
 * @returns 财务日报表数据
 */
export async function QueryFinanceDayReport(tradedate: string): Promise<type.QueryFinanceDayReportRsp[]> {
    const userid = getUsrId()
    return commonSearch_go('/Ermcp/QryReportDayFinance', { tradedate, userid }).catch(err => {
        throw new Error(`查询财务日报表: ${err}`);
    });

}

/**
 * 查询财务日报表发票(菜单:报表查询/财务报表/日报表/发票)
 * @param tradedate 交易日(格式:yyyyMMdd)
 * @returns 财务发票日报表
 */
export async function QueryFinanceInvoiceDayReport(tradedate: string): Promise<type.QueryFinanceInvoiceDayReportRsp[]> {
    const userid = getUsrId()
    return commonSearch_go('/Ermcp3/QryReportDayFinanceFp', { tradedate, userid }).catch(err => {
        throw new Error(`查询财务日报表发票: ${err}`);
    });

}

/**
 * 查询财务日报表款项(菜单:报表查询/财务报表/日报表/款项)
 * @param tradedate 交易日(格式:yyyyMMdd)
 * @returns 财务付款日报表
 */
export async function QueryFinancePayDayReport(tradedate: string): Promise<type.QueryFinancePayDayReportRsp[]> {
    const userid = getUsrId()
    return commonSearch_go('/Ermcp3/QryReportDayFinanceKx', { tradedate, userid }).catch(err => {
        throw new Error(`查询财务日报表款项: ${err}`);
    });

}

/**
 * 查询财务月报表
 * @param tradedate 交易日(格式:yyyyMMdd)
 * @returns 财务月报表数据
 */
export async function QueryFinanceMonthReport(tradedate: string): Promise<type.QueryFinanceMonthReportRsp[]> {
    const userid = getUsrId()
    return commonSearch_go('/Ermcp/QryReportMonthFinance', { cycletime: tradedate, userid }).catch(err => {
        throw new Error(`查询财务月报表: ${err}`);
    });
}
