package com.dxhy.jxpt.baseService.sign.service.qsgz.impl;

import com.dxhy.api.model.config.Tax;
import com.dxhy.api.model.config.UserInfo;
import com.dxhy.api.model.invoice.TDxRecordInvoice;
import com.dxhy.jxpt.baseService.sign.service.qsgz.RulesService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service("1010")
public class Rules1010ServiceImpl implements RulesService {

    @Override
    public String validationRules(UserInfo userInfo, String qsType, Map<String, String> pramsMap, TDxRecordInvoice recordInvoice, String invoiceType) {
        // 1010 购方名称强制校验（与1003规则冲突）
        List<Tax> taxList = userInfo.getOrg();
        Map<String, String> map = new HashMap<>();

        for (Tax tax : taxList) {
            tax.setTaxname(tax.getTaxname().trim());
            map.put(tax.getTaxno(), tax.getTaxname());

        }
        String taxname = map.get(recordInvoice.getGfTaxNo());
        if (!taxname.equals(recordInvoice.getGfName().trim())) {
            return "登录人公司名称与发票的购方名称不一致";
        }
        return "";
    }

    @Override
    public String getEdiType() {
        return "1010";
    }
}
