/**
 *  管理 - 财务审核
 */

import { ResultInfo } from "@/common/methods/request";

/**
 * 通过ContractType判断  如果是采购就是收票  如果是销售就是开票
 * @param type
 */
export function invoiceStatusName(type: number): string {
    let result = "--";
    switch (type) {
        case 1:
            result = "收票"
            break;
        case -1:
            result = "开票"
            break;
    }
    return result
}

/**
 * 操作申请类型 - 1:点价 2:结算登记 3:款项登记 4:发票登记
 * @param type
 */
export function operateApplyTypeName(type: number): string {
    let result = "--";
    switch (type) {
        case 1:
            result = "点价"
            break;
        case 2:
            result = "结算登记"
            break;
        case 3:
            result = "款项登记"
            break;
        case 4:
            result = "发票登记"
            break;
    }
    return result
}

/**
 * 款项类型名称
 * @param  kxtype: number;//款项类型 1-收付款(PayAmount字段有值) 2-退款(DeductAmount字段有值) 3-收付款/退款(2个字段都有)
 */
export function kxtypeName(type: number): string {
    //     contracttype: number;//现货合同类型 - 1:采购 -1:销售
    let result = "--";
    if (type === 1) {
        result = "付款"
    } else {
        result = "收款"
    }

    return result
}

/**
 * 付款
 * @param deductamount
 * @param contracttype
 */
export function stateName(deductamount: number, contracttype: number) {
    let result = "--";
    if (deductamount === undefined || deductamount === 0) {
        if (contracttype === 1) {  // 采购
            result = "付款"
        } else {
            result = "收款"
        }
    } else {
        result = "退款"
    }
    return result;
}

// 提示
export const financeSign = new Map<number, ResultInfo>([
    [2, ['审核通过成功', '审核失败:']],
    [3, ['审核拒绝成功', '审核失败:']],
    [4, ['撤销成功', '撤销失败:']],
])

