123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035 |
- package com.kingdee.eas.custom.shuiyou.taxCal.service;
- import cn.com.servyou.dto.ApiResponse;
- import cn.com.servyou.dto.Head;
- import cn.com.servyou.dto.employee.EmployeeDeclareFeedback;
- import cn.com.servyou.dto.tax.*;
- import cn.com.servyou.rmi.client.ClientProxyFactory;
- import cn.com.servyou.service.TaxRequest;
- import com.fasterxml.jackson.core.JsonProcessingException;
- import com.fasterxml.jackson.databind.ObjectMapper;
- import com.kingdee.bos.BOSException;
- import com.kingdee.bos.Context;
- import com.kingdee.bos.bsf.service.app.IHRMsfService;
- import com.kingdee.bos.metadata.entity.*;
- import com.kingdee.bos.metadata.query.util.CompareType;
- import com.kingdee.eas.common.EASBizException;
- import com.kingdee.eas.custom.shuiyou.interfacelog.ILogInfo;
- import com.kingdee.eas.custom.shuiyou.interfacelog.LogInfoFactory;
- import com.kingdee.eas.custom.shuiyou.interfacelog.LogInfoInfo;
- import com.kingdee.eas.custom.shuiyou.task.MessageResult;
- import com.kingdee.eas.custom.shuiyou.utils.ClientProxyFactoryUtils;
- import com.kingdee.eas.hr.ats.AtsUtil;
- import com.kingdee.eas.hr.ats.util.AtsDateUtils;
- import com.kingdee.eas.util.app.DbUtil;
- import com.kingdee.jdbc.rowset.IRowSet;
- import com.kingdee.shr.compensation.app.incomeTax.TaxPersonRecordCollection;
- import com.kingdee.shr.compensation.app.incomeTax.TaxPersonRecordFactory;
- import com.kingdee.shr.compensation.app.incomeTax.TaxPersonRecordInfo;
- import com.kingdee.shr.compensation.app.tax.base.*;
- import com.kingdee.shr.compensation.app.taxCal.*;
- import com.kingdee.util.StringUtils;
- import org.apache.log4j.Logger;
- import java.math.BigDecimal;
- import java.sql.SQLException;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.*;
- /**
- * @Description 获取异步算税反馈结果
- * @Date 2024/9/10 15:26
- * @Created by Heyuan
- */
- public class GetASynIndividualIncomeTaxFeedback implements IHRMsfService {
- private static Logger logger = Logger.getLogger(GetASynIndividualIncomeTaxFeedback.class);
- private String taxUnitId = null;//纳税单位id
- private String period = null;//税款所属期 yyyy-MM
- private String creator = null;//创建人id
- private String periodBegin = null;//税款所属期起 yyyy-MM-dd
- private String periodEnd = null;//税款所属期止 yyyy-MM-dd
- private ObjectMapper objectMapper = new ObjectMapper();
- //证件类型map
- //private static Map<String, String> cardTypeEnumMap = null;
- private Map<String, String> incomeItemMap = null;//所有启用的所得项目
- private Map<String, String> taxItemInitMap = null;//初算个税项目
- private Map<String, String> taxItemConfigMap = null;//明细个税项目
- private Map<String, String> taxPersonRecordMap = null;//报送人员信息 key:证件号码+证件类型,value:员工id
- @Override
- public MessageResult process(Context ctx, Map paramMap) throws EASBizException, BOSException {
- ILogInfo iLogInfo = LogInfoFactory.getLocalInstance(ctx);
- //接口日志实体
- LogInfoInfo logInfo = new LogInfoInfo();
- //入口
- logInfo.setEntrance(this.getClass().getName());
- logInfo.setBizDate(new Date());
- try {
- logger.info("调用 GetASynIndividualIncomeTaxFeedback, 参数 " + objectMapper.writeValueAsString(paramMap));
- MessageResult messageResult = null;
- String this_taskId = (String) paramMap.get("this_taskId");//任务id
- String paramData = (String) paramMap.get("paramData");
- Map<String, String> paramDataMap = objectMapper.readValue(paramData, Map.class);
- taxUnitId = paramDataMap.get("TAXUNITID");//纳税单位id
- period = paramDataMap.get("PERIOD");//周期yyyy-MM
- creator = paramDataMap.get("creator");//创建人id
- String requestId = paramDataMap.get("requestId");
- StringBuilder errorMsg = new StringBuilder();
- if (StringUtils.isEmpty(taxUnitId)) {
- errorMsg.append("纳税单位id不能为空!\n");
- }
- if (StringUtils.isEmpty(period)) {
- errorMsg.append("周期yyyy-MM不能为空!\n");
- }
- if (StringUtils.isEmpty(requestId)) {
- errorMsg.append("requestId不能为空!\n");
- }
- if (errorMsg.length() > 0) {
- throw new BOSException(errorMsg.toString());
- }
- SimpleDateFormat shortsdf = new SimpleDateFormat("yyyy-MM");
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
- Date parse = shortsdf.parse(period);
- periodBegin = sdf.format(AtsDateUtils.getMonthFirstDay(parse));
- periodEnd = sdf.format(AtsDateUtils.getMonthLastDay(parse));
- //客户端代理工厂
- ClientProxyFactory clientProxyFactory = ClientProxyFactoryUtils.getClientProxyFactory();
- logInfo.setInterfaceAddress("/gateway/iit/calculateTax/getASynIndividualIncomeTaxFeedback");//接口地址
- logInfo.setInterfaceName("getASynIndividualIncomeTaxFeedback");//接口名
- logInfo.setInParameter("{\"requestId\":\"" + requestId + "\"}");//入参
- //算税请求接口
- TaxRequest taxRequest = clientProxyFactory.getTaxRequest();
- //调用异步算税接口
- ApiResponse<CalculateTaxResultRequest> apiResponse = taxRequest.getASynIndividualIncomeTaxFeedback(requestId);
- ObjectMapper mapper = new ObjectMapper();
- logInfo.setOutParameter(mapper.writeValueAsString(apiResponse));//回参
- Head head = apiResponse.getHead();
- String status = head.getStatus();
- String code = head.getCode();
- if ("100004".equals(code)) {
- //请求处理中
- messageResult = MessageResult.AGAIN(head.getMsg());
- logInfo.setErrorInfo(head.getMsg());//错误信息
- logInfo.setStatus("处理中");
- } else if ("000004".equals(code)) {
- //请求失败
- messageResult = MessageResult.FAILED(head.getMsg());
- logInfo.setErrorInfo(head.getMsg());//错误信息
- logInfo.setStatus("失败");
- } else if ("00000000".equals(code)) {
- logger.info("成功");
- //获取所有启用的所得项目
- incomeItemMap = getIncomeItemMap(ctx);
- logger.info("objectMapper.writeValueAsString(incomeItemMap) " + objectMapper.writeValueAsString(incomeItemMap));
- //获取个税项目
- getTaxItemMap(ctx);
- logger.info("objectMapper.writeValueAsString(taxItemInitMap) " + objectMapper.writeValueAsString(taxItemInitMap));
- logger.info("objectMapper.writeValueAsString(taxItemConfigMap) " + objectMapper.writeValueAsString(taxItemConfigMap));
- //获取报送人员信息
- getTaxPersonRecordMap(ctx);
- //请求成功
- CalculateTaxResultRequest body = apiResponse.getBody();
- //企业名称
- // String qymc = body.getName();
- // //税号
- // String nsrsbh = body.getTaxNo();
- // //部门编号
- // String bmbh = body.getDeptNo();
- // //部门名称
- // String bmmc = body.getDeptName();
- // //行政区划代码
- // String areaid = body.getArea();
- // //税款所属期
- // String skssq = body.getMonth();
- // //外部业务订单号
- // String bizNo = body.getBizNo();
- //综合所得
- ComplexIncomeResultRequest complexIncomeResult = body.getComplexIncomeResultRequest();
- //人员申报失败列表
- // List<EmployeeDeclareFeedback> employeeDeclareFeedbacks = complexIncomeResult.getEmployeeDeclareFeedbacks();
- // for (int i = 0; employeeDeclareFeedbacks != null && i < employeeDeclareFeedbacks.size(); i++) {
- // EmployeeDeclareFeedback employeeDeclareFeedback = employeeDeclareFeedbacks.get(i);
- // //姓名
- // String name = employeeDeclareFeedback.getName();
- // //证件类型名称
- // String licenseType = employeeDeclareFeedback.getLicenseType();
- // //证件号码
- // String licenseNumber = employeeDeclareFeedback.getLicenseNumber();
- // //报送状态 1 待报送 2 代报中 3 代报失败 4 代报成功
- // String submissionState = employeeDeclareFeedback.getSubmissionState();
- // //人员验证状态 0 若是身份证,状态为验证中;其他证件为暂不验证 1 验证通过 2 验证不通过 4 待验证 9 同代码0处理
- // String authenticationState = employeeDeclareFeedback.getAuthenticationState();
- // //失败原因
- // String message = employeeDeclareFeedback.getMessage();
- // //专项报送状态 2 代报成功 3 代报失败
- // String deductionSubmissionState = employeeDeclareFeedback.getDeductionSubmissionState();
- // //专项报送结果原因
- // String deductionMessage = employeeDeclareFeedback.getDeductionMessage();
- // }
- logger.info("正常工资薪金算税结果对象");
- //正常工资薪金算税结果对象
- ComplexTaxCalculateResult normalSalarySpecIncome = complexIncomeResult.getNormalSalarySpecIncome();
- handleComplexTaxCalculateResult(ctx, normalSalarySpecIncome);
- logger.info("全年一次性奖金收入算税结果对象");
- //全年一次性奖金收入算税结果对象
- ComplexTaxCalculateResult annualOneTimeBonusIncome = complexIncomeResult.getAnnualOneTimeBonusIncome();
- handleComplexTaxCalculateResult(ctx, annualOneTimeBonusIncome);
- logger.info("一般劳务报酬算税结果对象");
- //一般劳务报酬算税结果对象
- ComplexTaxCalculateResult laborRemunerationIncome = complexIncomeResult.getLaborRemunerationIncome();
- handleComplexTaxCalculateResult(ctx, laborRemunerationIncome);
- logger.info("解除劳动合同一次性补偿金算税结果对象");
- //解除劳动合同一次性补偿金算税结果对象
- ComplexTaxCalculateResult compensateIncome = complexIncomeResult.getCompensateIncome();
- handleComplexTaxCalculateResult(ctx, compensateIncome);
- messageResult = MessageResult.SUCCESS();
- }
- logger.info("保存日志对象");
- iLogInfo.addnew(logInfo);
- logger.info("返回结果");
- return messageResult;
- } catch (Exception e) {
- e.printStackTrace();
- logInfo.setErrorInfo(e.getMessage());//错误信息
- iLogInfo.addnew(logInfo);
- return MessageResult.ERROR(e.getMessage());
- }
- }
- /**
- * 处理所得项目算税结果
- *
- * @param ctx
- * @param normalSalarySpecIncome
- * @throws BOSException
- */
- private void handleComplexTaxCalculateResult(
- Context ctx,
- ComplexTaxCalculateResult normalSalarySpecIncome)
- throws BOSException, JsonProcessingException {
- logger.info("handleComplexTaxCalculateResult:" + objectMapper.writeValueAsString(normalSalarySpecIncome));
- if (normalSalarySpecIncome != null) {
- //算税总人数
- Integer totalPeople = normalSalarySpecIncome.getTotalPeople();
- //算税失败人数
- Integer failedPeople = normalSalarySpecIncome.getFailedPeople();
- //年金上限
- BigDecimal annuityLimit = normalSalarySpecIncome.getAnnuityLimit();
- //公积金上限
- BigDecimal houseProvidentFundLimit = normalSalarySpecIncome.getHouseProvidentFundLimit();
- //年平均工资
- BigDecimal averageAnnual = normalSalarySpecIncome.getAverageAnnual();
- //企业在电子税务局上月是否已申报(仅正常工资薪金有效) 0:上月未申报 1:上月已申报 2:上上月未申报
- String etaxDeclaredLastMonth = normalSalarySpecIncome.getEtaxDeclaredLastMonth();
- //综合算税成功列表
- List<ComplexIncome> successComplexIncomes = normalSalarySpecIncome.getSuccessComplexIncomes();
- handleSuccessComplexIncome(ctx, successComplexIncomes);
- //综合算税失败薪资列表
- List<ComplexIncome> failedComplexIncomes = normalSalarySpecIncome.getFailedComplexIncomes();
- //handleFailedComplexIncome(failedComplexIncomes);
- //失败算税原因列表
- List<CheckTaxCalResult> failedCheckTaxCalResult = normalSalarySpecIncome.getFailedCheckTaxCalResult();
- handleFailedCheckTaxCalResult(ctx, failedCheckTaxCalResult);
- }
- }
- /**
- * 处理综合算税成功列表
- */
- private void handleSuccessComplexIncome(Context ctx, List<ComplexIncome> successComplexIncomes) throws BOSException {
- if (successComplexIncomes != null) {
- //SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
- StringBuilder updateSql = new StringBuilder();
- updateSql.append("/*dialect*/update T_HR_STaxCalInitDetail set FSTATE = '40', ");
- for (String key : taxItemInitMap.keySet()) {
- String tableField = taxItemInitMap.get(key);
- updateSql.append(tableField).append("=?, ");
- }
- updateSql.deleteCharAt(updateSql.lastIndexOf(","));
- updateSql.append(" where fpersonId = ? ");
- updateSql.append(" and FTAXUNITID=? and to_char(FPERIODBEGIN,'yyyy-mm-dd') >= ? and to_char(FPERIODEND,'yyyy-mm-dd') <= ? and FINCOMEITEMID=? and FSTATE =30");
- List<Object[]> sqlParams = new ArrayList<>();
- Set<String> personIds = new HashSet<>();
- Set<String> incomeitemIds = new HashSet<>();
- for (int i = 0; successComplexIncomes != null && i < successComplexIncomes.size(); i++) {
- ComplexIncome complexIncome = successComplexIncomes.get(i);
- Map incomeDataMap = new HashMap();
- List updateList = new ArrayList();
- //姓名
- String name = complexIncome.getName();
- //证件类型名称
- String licenseType = complexIncome.getLicenseType();
- //String cardTypeValue = cardTypeEnumMap.get(licenseType);
- //证件号码
- String licenseNumber = complexIncome.getLicenseNumber();
- //员工id
- String personId = taxPersonRecordMap.get(licenseNumber + licenseType);
- if (StringUtils.isEmpty(personId)) {
- logger.error("未匹配到人员 证件号: " + licenseNumber + " 证件类型: " + licenseType);
- continue;
- }
- //受雇日期
- //String employedDate = complexIncome.getEmployedDate();
- //离职日期
- //String resignDate = complexIncome.getResignDate();
- //是否明细申报
- //String isDetailedDeclaration = complexIncome.getIsDetailedDeclaration();
- //当期收入额
- BigDecimal income = complexIncome.getIncome();
- incomeDataMap.put("sre", income);
- //免税收入
- BigDecimal exemptIncome = complexIncome.getExemptIncome();
- incomeDataMap.put("mssd", exemptIncome);
- //基本养老保险
- BigDecimal endowmentInsurance = complexIncome.getEndowmentInsurance();
- incomeDataMap.put("jbylaobxf", endowmentInsurance);
- //基本医疗保险
- BigDecimal medicalInsurance = complexIncome.getMedicalInsurance();
- incomeDataMap.put("jbylbxf", medicalInsurance);
- //失业保险
- BigDecimal unemploymentInsurance = complexIncome.getUnemploymentInsurance();
- incomeDataMap.put("sybxf", unemploymentInsurance);
- //住房公积金
- BigDecimal houseProvidentFund = complexIncome.getHouseProvidentFund();
- incomeDataMap.put("zfgjj", houseProvidentFund);
- //原始住房公积金
- BigDecimal originalHouseProvidentFund = complexIncome.getOriginalHouseProvidentFund();
- //子女教育支出
- BigDecimal childEducationExpenditure = complexIncome.getChildEducationExpenditure();
- incomeDataMap.put("znjyzc_ex", childEducationExpenditure);
- //赡养老人支出
- BigDecimal supportElderExpenditure = complexIncome.getSupportElderExpenditure();
- incomeDataMap.put("sylrzc_ex", supportElderExpenditure);
- //住房租金支出
- BigDecimal houseRentExpenditure = complexIncome.getHouseRentExpenditure();
- incomeDataMap.put("zfzjzc_ex", houseRentExpenditure);
- //房屋贷款支出
- BigDecimal houseLoanExpenditure = complexIncome.getHouseLoanExpenditure();
- incomeDataMap.put("zfdklxzc_ex", houseLoanExpenditure);
- //继续教育支出
- BigDecimal continueEducationExpenditure = complexIncome.getContinueEducationExpenditure();
- incomeDataMap.put("jxjyzc_ex", continueEducationExpenditure);
- //非学历继续教育支出
- BigDecimal unDegreeContinueEducationExpenditure = complexIncome.getUnDegreeContinueEducationExpenditure();
- incomeDataMap.put("fxljxjyzc_ex", unDegreeContinueEducationExpenditure);
- //婴幼儿照护支出
- BigDecimal babyCareExpenditure = complexIncome.getBabyCareExpenditure();
- incomeDataMap.put("yyezhzc_ex", babyCareExpenditure);
- //企业年金/职业年金
- BigDecimal annuity = complexIncome.getAnnuity();
- incomeDataMap.put("nj", annuity);
- //商业健康保险
- BigDecimal commercialHealthInsurance = complexIncome.getCommercialHealthInsurance();
- incomeDataMap.put("syjkbx", commercialHealthInsurance);
- //税延养老保险
- BigDecimal extensionEndowmentInsurance = complexIncome.getExtensionEndowmentInsurance();
- incomeDataMap.put("syylbx", extensionEndowmentInsurance);
- //其他
- BigDecimal other = complexIncome.getOther();
- incomeDataMap.put("qt", other);
- //减免税额
- BigDecimal taxDeduction = complexIncome.getTaxDeduction();
- incomeDataMap.put("jmse", taxDeduction);
- //备注 根据政策要求,填写【其他】项,一定在备注中写明具体扣除项目名称
- String remark = complexIncome.getRemark();
- incomeDataMap.put("bz", remark);
- //减除费用
- BigDecimal deductionAmount = complexIncome.getDeductionAmount();
- incomeDataMap.put("qzd", deductionAmount);
- //其他扣除合计
- BigDecimal otherDeductionSum = complexIncome.getOtherDeductionSum();
- incomeDataMap.put("qtckhj", otherDeductionSum);
- //应纳税所得额
- BigDecimal taxableIncome = complexIncome.getTaxableIncome();
- incomeDataMap.put("ynssde", taxableIncome);
- //应纳税额
- BigDecimal payableAmount = complexIncome.getPayableAmount();
- //已缴税额
- BigDecimal paidAmount = complexIncome.getPaidAmount();
- //应扣缴税额
- BigDecimal withholdingAmount = complexIncome.getWithholdingAmount();
- //税率
- BigDecimal taxRate = complexIncome.getTaxRate();
- incomeDataMap.put("sl", taxRate);
- //速算扣除数
- BigDecimal quickDeduction = complexIncome.getQuickDeduction();
- incomeDataMap.put("sskcs", quickDeduction);
- //所得项目名称
- String incomeItemName = complexIncome.getIncomeItemName();
- if (!incomeItemMap.containsKey(incomeItemName)) {
- logger.error("未匹配到所得项目 名称为: " + incomeItemName);
- continue;
- }
- String incomeItemId = incomeItemMap.get(incomeItemName);
- incomeDataMap.put("sdxm", incomeItemId);
- //应补退税额 累计应扣缴税额-累计已缴税额
- BigDecimal refundTax = complexIncome.getRefundTax();
- incomeDataMap.put("bqybtse", refundTax);
- //累计收入额 本年累计收入=本期所有的工资薪金所得收入之和+往期工资薪金所得收入之和(见税款计算)
- BigDecimal accumulatedIncome = complexIncome.getAccumulatedIncome();
- incomeDataMap.put("bqljsre", accumulatedIncome);
- //累计免税收入额
- BigDecimal accumulatedExemptIncome = complexIncome.getAccumulatedExemptIncome();
- incomeDataMap.put("bqljmssr", accumulatedExemptIncome);
- //累计专项扣除额
- BigDecimal accumulatedSpecDeduction = complexIncome.getAccumulatedSpecDeduction();
- incomeDataMap.put("zxkchj", accumulatedSpecDeduction);
- //累计专项(附加)扣除额
- BigDecimal accumulatedSpecAttachDeduction = complexIncome.getAccumulatedSpecAttachDeduction();
- incomeDataMap.put("zxfjkchj", accumulatedSpecAttachDeduction);
- //累计其他扣除额
- BigDecimal accumulatedOtherDeduction = complexIncome.getAccumulatedOtherDeduction();
- incomeDataMap.put("qtckhj", accumulatedOtherDeduction);
- //累计减免税额
- BigDecimal accumulatedTaxDeduction = complexIncome.getAccumulatedTaxDeduction();
- incomeDataMap.put("ljjmse", accumulatedTaxDeduction);
- //累计减除费用额
- BigDecimal accumulatedDeductionAmount = complexIncome.getAccumulatedDeductionAmount();
- incomeDataMap.put("jcfy", accumulatedDeductionAmount);
- //todo 累计月减除费用
- BigDecimal accumulatedMonthDeduction = complexIncome.getAccumulatedMonthDeduction();
- //累计应纳税所得额
- BigDecimal accumulatedTaxableIncome = complexIncome.getAccumulatedTaxableIncome();
- incomeDataMap.put("ljynssde", accumulatedTaxableIncome);
- //累计应纳税额
- BigDecimal accumulatedPayableAmount = complexIncome.getAccumulatedPayableAmount();
- incomeDataMap.put("ljynse", accumulatedPayableAmount);
- //累计应扣缴税额 累计应纳税额 - 累计减免税额
- BigDecimal accumulatedWithholdingAmount = complexIncome.getAccumulatedWithholdingAmount();
- incomeDataMap.put("ljyingkjse", accumulatedWithholdingAmount);
- //累计子女教育支出
- BigDecimal accumulatedChildEducation = complexIncome.getAccumulatedChildEducation();
- incomeDataMap.put("znjyzc", accumulatedChildEducation);
- //累计继续教育支出
- BigDecimal accumulatedContinueEducation = complexIncome.getAccumulatedContinueEducation();
- incomeDataMap.put("jxjyzc", accumulatedContinueEducation);
- //累计学历继续教育支出
- BigDecimal accumulatedDegreeContinueEducationLimit = complexIncome.getAccumulatedDegreeContinueEducationLimit();
- incomeDataMap.put("ljxljxjyzc_ex", accumulatedDegreeContinueEducationLimit);
- //累计非学历继续教育支出
- BigDecimal accumulatedUnDegreeContinueEducationLimit = complexIncome.getAccumulatedUnDegreeContinueEducationLimit();
- incomeDataMap.put("ljfxljxjyzc_ex", accumulatedUnDegreeContinueEducationLimit);
- //累计住房租金支出
- BigDecimal accumulatedHouseRent = complexIncome.getAccumulatedHouseRent();
- incomeDataMap.put("zfzjzc", accumulatedHouseRent);
- //累计房屋贷款支出
- BigDecimal accumulatedHouseLoan = complexIncome.getAccumulatedHouseLoan();
- incomeDataMap.put("zfdklxzc", accumulatedHouseLoan);
- //累计赡养老人支出
- BigDecimal accumulatedSupportElder = complexIncome.getAccumulatedSupportElder();
- incomeDataMap.put("sylrzc", accumulatedSupportElder);
- //todo 累计3岁以下婴幼儿照护支出
- BigDecimal accumulatedBabyCare = complexIncome.getAccumulatedBabyCare();
- incomeDataMap.put("ljyyezhzc_ex", accumulatedBabyCare);
- //累计准予扣除的捐赠额
- BigDecimal accumulatedDeductibleDonation = complexIncome.getAccumulatedDeductibleDonation();
- incomeDataMap.put("ljzykcdjze", accumulatedDeductibleDonation);
- //累计个人养老金
- BigDecimal accumulatedPersonalPension = complexIncome.getAccumulatedPersonalPension();
- incomeDataMap.put("grylj", accumulatedPersonalPension);
- //todo 累计个人养老金校验码
- String accumulatedPersonalPensionCheckCode = complexIncome.getAccumulatedPersonalPensionCheckCode();
- //准予扣除的捐赠额
- BigDecimal deductibleDonation = complexIncome.getDeductibleDonation();
- incomeDataMap.put("zykcjze", deductibleDonation);
- //累计已缴税额
- BigDecimal accumulatedPaidAmount = complexIncome.getAccumulatedPaidAmount();
- //incomeDataMap.put("ykjse", accumulatedPaidAmount);
- //企业上月是否已申报
- String etaxDeclaredLastMonth = complexIncome.getEtaxDeclaredLastMonth();
- //员工在税局累计已扣缴的税额
- BigDecimal etaxAccumulatedPaidAmount = complexIncome.getEtaxAccumulatedPaidAmount();
- //incomeDataMap.put("ykjse", etaxAccumulatedPaidAmount);
- //本月已累计扣除税额
- BigDecimal monthAccumulatedWithholdingAmount = complexIncome.getMonthAccumulatedWithholdingAmount();
- incomeDataMap.put("ykjse", etaxAccumulatedPaidAmount);
- //本次应扣缴税额
- BigDecimal currentWithholdingAmount = complexIncome.getCurrentWithholdingAmount();
- incomeDataMap.put("ykjse", etaxAccumulatedPaidAmount);
- //允许扣除的税费
- BigDecimal taxDeductible = complexIncome.getTaxDeductible();
- incomeDataMap.put("yxkcsf", taxDeductible);
- //展业成本
- BigDecimal exhibitionCost = complexIncome.getExhibitionCost();
- incomeDataMap.put("zycb", exhibitionCost);
- //月减除费用
- BigDecimal monthDeduction = complexIncome.getMonthDeduction();
- incomeDataMap.put("qzd", monthDeduction);
- //分摊年度数
- Integer apportionYears = complexIncome.getApportionYears();
- //年减除费用 默认为60000
- BigDecimal yearDeduction = complexIncome.getYearDeduction();
- //封装更新参数
- for (String key : taxItemInitMap.keySet()) {
- updateList.add(incomeDataMap.get(key));
- }
- updateList.add(personId);
- updateList.add(taxUnitId);
- updateList.add(periodBegin);
- updateList.add(periodEnd);
- updateList.add(incomeItemId);
- sqlParams.add(updateList.toArray());
- if (!personIds.contains(personId)) {
- personIds.add(personId);
- }
- if (!incomeitemIds.contains(incomeItemId)) {
- incomeitemIds.add(incomeItemId);
- }
- }
- try {
- logger.info("updateSql: " + updateSql);
- logger.info("处理综合算税成功列表 sqlParams " + objectMapper.writeValueAsString(sqlParams));
- if (!sqlParams.isEmpty()) {
- DbUtil.executeBatch(ctx, updateSql.toString(), sqlParams);
- }
- } catch (Exception e) {
- e.printStackTrace();
- throw new BOSException("处理处理综合算税成功列表,更新初算数据报错:" + e.getMessage());
- }
- //生成个税应用+税款计算最终拆分明细表
- try {
- logger.info("处理综合算税成功列表 personIds " + objectMapper.writeValueAsString(personIds));
- logger.info("处理综合算税成功列表 incomeitemIds " + objectMapper.writeValueAsString(incomeitemIds));
- if (!personIds.isEmpty() && !incomeitemIds.isEmpty()) {
- generateOrUpdateTaxCalConfigDetail(ctx, personIds, incomeitemIds);
- }
- } catch (Exception e) {
- e.printStackTrace();
- throw new BOSException("处理处理综合算税成功列表,生成个税应用+税款计算最终拆分明细表报错:" + e.getMessage());
- }
- }
- }
- /**
- * 处理综合算税失败薪资列表
- *
- * @param failedComplexIncomes
- */
- private void handleFailedComplexIncome(List<ComplexIncome> failedComplexIncomes) {
- for (int i = 0; failedComplexIncomes != null && i < failedComplexIncomes.size(); i++) {
- ComplexIncome complexIncome = failedComplexIncomes.get(i);
- //姓名
- String name = complexIncome.getName();
- //证件类型名称
- String licenseType = complexIncome.getLicenseType();
- //证件号码
- String licenseNumber = complexIncome.getLicenseNumber();
- //受雇日期
- String employedDate = complexIncome.getEmployedDate();
- //离职日期
- String resignDate = complexIncome.getResignDate();
- //是否明细申报
- String isDetailedDeclaration = complexIncome.getIsDetailedDeclaration();
- //当期收入额
- BigDecimal income = complexIncome.getIncome();
- //免税收入
- BigDecimal exemptIncome = complexIncome.getExemptIncome();
- //基本养老保险
- BigDecimal endowmentInsurance = complexIncome.getEndowmentInsurance();
- //基本医疗保险
- BigDecimal medicalInsurance = complexIncome.getMedicalInsurance();
- //失业保险
- BigDecimal unemploymentInsurance = complexIncome.getUnemploymentInsurance();
- //住房公积金
- BigDecimal houseProvidentFund = complexIncome.getHouseProvidentFund();
- //原始住房公积金
- //BigDecimal originalHouseProvidentFund = complexIncome.getOriginalHouseProvidentFund();
- //子女教育支出
- BigDecimal childEducationExpenditure = complexIncome.getChildEducationExpenditure();
- //赡养老人支出
- BigDecimal supportElderExpenditure = complexIncome.getSupportElderExpenditure();
- //住房租金支出
- BigDecimal houseRentExpenditure = complexIncome.getHouseRentExpenditure();
- //房屋贷款支出
- BigDecimal houseLoanExpenditure = complexIncome.getHouseLoanExpenditure();
- //继续教育支出
- BigDecimal continueEducationExpenditure = complexIncome.getContinueEducationExpenditure();
- //非学历继续教育支出
- BigDecimal unDegreeContinueEducationExpenditure = complexIncome.getUnDegreeContinueEducationExpenditure();
- //婴幼儿照护支出
- BigDecimal babyCareExpenditure = complexIncome.getBabyCareExpenditure();
- //企业年金/职业年金
- BigDecimal annuity = complexIncome.getAnnuity();
- //商业健康保险
- BigDecimal commercialHealthInsurance = complexIncome.getCommercialHealthInsurance();
- //税延养老保险
- BigDecimal extensionEndowmentInsurance = complexIncome.getExtensionEndowmentInsurance();
- //其他
- BigDecimal other = complexIncome.getOther();
- //减免税额
- BigDecimal taxDeduction = complexIncome.getTaxDeduction();
- //备注
- String remark = complexIncome.getRemark();
- //减除费用
- BigDecimal deductionAmount = complexIncome.getDeductionAmount();
- //其他扣除合计
- BigDecimal otherDeductionSum = complexIncome.getOtherDeductionSum();
- //应纳税所得额
- BigDecimal taxableIncome = complexIncome.getTaxableIncome();
- //应纳税额
- BigDecimal payableAmount = complexIncome.getPayableAmount();
- //已缴税额
- BigDecimal paidAmount = complexIncome.getPaidAmount();
- //应扣缴税额
- BigDecimal withholdingAmount = complexIncome.getWithholdingAmount();
- //税率
- BigDecimal taxRate = complexIncome.getTaxRate();
- //速算扣除数
- BigDecimal quickDeduction = complexIncome.getQuickDeduction();
- //所得项目名称
- String incomeItemName = complexIncome.getIncomeItemName();
- //应补退税额
- BigDecimal refundTax = complexIncome.getRefundTax();
- //累计收入额
- BigDecimal accumulatedIncome = complexIncome.getAccumulatedIncome();
- //累计免税收入额
- BigDecimal accumulatedExemptIncome = complexIncome.getAccumulatedExemptIncome();
- //累计专项扣除额
- BigDecimal accumulatedSpecDeduction = complexIncome.getAccumulatedSpecDeduction();
- //累计专项(附加)扣除额
- BigDecimal accumulatedSpecAttachDeduction = complexIncome.getAccumulatedSpecAttachDeduction();
- //累计其他扣除额
- BigDecimal accumulatedOtherDeduction = complexIncome.getAccumulatedOtherDeduction();
- //累计减免税额
- BigDecimal accumulatedTaxDeduction = complexIncome.getAccumulatedTaxDeduction();
- //累计减除费用额
- BigDecimal accumulatedDeductionAmount = complexIncome.getAccumulatedDeductionAmount();
- //累计月减除费用
- BigDecimal accumulatedMonthDeduction = complexIncome.getAccumulatedMonthDeduction();
- //累计应纳税所得额
- BigDecimal accumulatedTaxableIncome = complexIncome.getAccumulatedTaxableIncome();
- //累计应纳税额
- BigDecimal accumulatedPayableAmount = complexIncome.getAccumulatedPayableAmount();
- //累计应扣缴税额
- BigDecimal accumulatedWithholdingAmount = complexIncome.getAccumulatedWithholdingAmount();
- //累计子女教育支出
- BigDecimal accumulatedChildEducation = complexIncome.getAccumulatedChildEducation();
- //累计继续教育支出
- BigDecimal accumulatedContinueEducation = complexIncome.getAccumulatedContinueEducation();
- //累计学历继续教育支出
- BigDecimal accumulatedDegreeContinueEducationLimit = complexIncome.getAccumulatedDegreeContinueEducationLimit();
- //累计非学历继续教育支出
- BigDecimal accumulatedUnDegreeContinueEducationLimit = complexIncome.getAccumulatedUnDegreeContinueEducationLimit();
- //累计住房租金支出
- BigDecimal accumulatedHouseRent = complexIncome.getAccumulatedHouseRent();
- //累计房屋贷款支出
- BigDecimal accumulatedHouseLoan = complexIncome.getAccumulatedHouseLoan();
- //累计赡养老人支出
- BigDecimal accumulatedSupportElder = complexIncome.getAccumulatedSupportElder();
- //累计3岁以下婴幼儿照护支出
- BigDecimal accumulatedBabyCare = complexIncome.getAccumulatedBabyCare();
- //累计准予扣除的捐赠额
- BigDecimal accumulatedDeductibleDonation = complexIncome.getAccumulatedDeductibleDonation();
- //累计个人养老金
- BigDecimal accumulatedPersonalPension = complexIncome.getAccumulatedPersonalPension();
- //累计个人养老金校验码
- String accumulatedPersonalPensionCheckCode = complexIncome.getAccumulatedPersonalPensionCheckCode();
- //准予扣除的捐赠额
- BigDecimal deductibleDonation = complexIncome.getDeductibleDonation();
- //累计已缴税额
- BigDecimal accumulatedPaidAmount = complexIncome.getAccumulatedPaidAmount();
- //企业上月是否已申报:
- String etaxDeclaredLastMonth = complexIncome.getEtaxDeclaredLastMonth();
- //员工在税局累计已扣缴的税额
- BigDecimal etaxAccumulatedPaidAmount = complexIncome.getEtaxAccumulatedPaidAmount();
- //本月已累计扣除税额
- BigDecimal monthAccumulatedWithholdingAmount = complexIncome.getMonthAccumulatedWithholdingAmount();
- //本次应扣缴税额
- BigDecimal currentWithholdingAmount = complexIncome.getCurrentWithholdingAmount();
- //允许扣除的税费
- BigDecimal taxDeductible = complexIncome.getTaxDeductible();
- //展业成本
- BigDecimal exhibitionCost = complexIncome.getExhibitionCost();
- //月减除费用
- BigDecimal monthDeduction = complexIncome.getMonthDeduction();
- //分摊年度数
- Integer apportionYears = complexIncome.getApportionYears();
- //年减除费用 默认为60000
- BigDecimal yearDeduction = complexIncome.getYearDeduction();
- }
- }
- /**
- * 处理失败算税原因列表
- *
- * @param failedCheckTaxCalResult
- */
- private void handleFailedCheckTaxCalResult(
- Context ctx,
- List<CheckTaxCalResult> failedCheckTaxCalResult)
- throws BOSException, JsonProcessingException {
- logger.info("handleFailedCheckTaxCalResult:" + objectMapper.writeValueAsString(failedCheckTaxCalResult));
- if (failedCheckTaxCalResult != null) {
- String updateSql = "/*dialect*/update T_HR_STaxCalInitDetail set FERRORINFO = ?,FSTATE = '50' " +
- "where fpersonId = ? " +
- "and FTAXUNITID=? and to_char(FPERIODBEGIN,'yyyy-mm-dd') >= ? and to_char(FPERIODEND,'yyyy-mm-dd') <= ? and FINCOMEITEMID=? and FSTATE =30";
- List<Object[]> udpateParameter = new ArrayList<>();
- for (int i = 0; failedCheckTaxCalResult != null && i < failedCheckTaxCalResult.size(); i++) {
- List list = new ArrayList();
- CheckTaxCalResult checkTaxCalResult = failedCheckTaxCalResult.get(i);
- //证件类型名称
- String licenseType = checkTaxCalResult.getLicenseType();
- //String cardTypeValue = cardTypeEnumMap.get(licenseType);
- //证件号码
- String licenseNumber = checkTaxCalResult.getLicenseNumber();
- //员工id
- String personId = taxPersonRecordMap.get(licenseNumber + licenseType);
- if (StringUtils.isEmpty(personId)) {
- logger.error("未匹配到人员 证件号: " + licenseNumber + " 证件类型: " + licenseType);
- continue;
- }
- //人员id
- Long employeeId = checkTaxCalResult.getEmployeeId();
- //人员名称
- String employeeName = checkTaxCalResult.getEmployeeName();
- //错误码
- String errorCode = checkTaxCalResult.getErrorCode();
- //错误信息
- String errorMessage = checkTaxCalResult.getErrorMessage();
- //所得税表的code
- String incomeItemCode = checkTaxCalResult.getIncomeItemCode();
- //所得税表的name
- String incomeItemName = checkTaxCalResult.getIncomeItemName();
- if (!incomeItemMap.containsKey(incomeItemName)) {
- logger.error("未匹配到所得项目 名称为: " + incomeItemName);
- continue;
- }
- String incomeItemId = incomeItemMap.get(incomeItemName);
- list.add(errorMessage);
- list.add(personId);
- list.add(taxUnitId);
- list.add(periodBegin);
- list.add(periodEnd);
- list.add(incomeItemId);
- udpateParameter.add(list.toArray());
- }
- try {
- logger.error("处理失败算税原因列表 updateSql " + updateSql);
- logger.error("处理失败算税原因列表 udpateParameter " + objectMapper.writeValueAsString(udpateParameter));
- if (!udpateParameter.isEmpty()) {
- DbUtil.executeBatch(ctx, updateSql, udpateParameter);
- }
- } catch (BOSException e) {
- e.printStackTrace();
- throw new BOSException("更新处理失败算税原因列表报错: " + e.getMessage());
- }
- }
- }
- /**
- * 生成个税应用+税款计算最终拆分明细表
- * 先新增再更新
- */
- private void generateOrUpdateTaxCalConfigDetail(Context ctx,
- Set<String> personIds,
- Set<String> incomeitemIds) throws BOSException, SQLException, ParseException, JsonProcessingException {
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
- Date periodBeginDate = sdf.parse(periodBegin);
- Date periodEndDate = sdf.parse(periodEnd);
- //先查出计算成功的初算数据(人员、纳税单位id、周期、所得项目、状态=成功)
- ITaxCalConfigDetail iTaxCalConfigDetail = TaxCalConfigDetailFactory.getLocalInstance(ctx);
- StringBuilder querySql = new StringBuilder();
- querySql.append("SELECT fid,fpersonId,fincomeitemid,FCALSCHEMEID,FCMPCALTABLEID,FTAXUNITID from T_HR_STaxCalInitDetail where").append("\n");
- querySql.append(" fpersonId in(").append(AtsUtil.convertSetToString(personIds)).append(")").append("\n");
- querySql.append(" and to_char(FPERIODBEGIN, 'yyyy-mm-dd') >= '").append(periodBegin).append("'").append("\n");
- querySql.append(" and to_char(FPERIODEND, 'yyyy-mm-dd') <= '").append(periodEnd).append("'").append("\n");
- querySql.append(" and FINCOMEITEMID in(").append(AtsUtil.convertSetToString(incomeitemIds)).append(")").append("\n");
- querySql.append(" and FTAXUNITID = '").append(taxUnitId).append("'").append("\n");
- querySql.append(" and FSTATE = '40'").append("\n");
- logger.info("generateOrUpdateTaxCalConfigDetail.sql: " + querySql);
- IRowSet iRowSet = DbUtil.executeQuery(ctx, querySql.toString());
- List<Map<String, String>> list = new ArrayList<>();
- while (iRowSet.next()) {
- Map<String, String> map = new HashMap<>();
- map.put("initId", iRowSet.getString("fid"));
- map.put("personId", iRowSet.getString("fpersonId"));
- map.put("incomeitemid", iRowSet.getString("FINCOMEITEMID"));
- map.put("calSchemeId", iRowSet.getString("FCALSCHEMEID"));
- map.put("cmpCalTableId", iRowSet.getString("FCMPCALTABLEID"));
- map.put("taxUnitId", iRowSet.getString("FTAXUNITID"));
- list.add(map);
- }
- //用初算数据生成明细表(需要判断明细表数据是否已经生成过)
- Set<String> initIds = new HashSet<>();
- Set<String> configIds = new HashSet<>();
- for (int i = 0; i < list.size(); i++) {
- try {
- String detailId = null;
- Map<String, String> map = list.get(i);
- String initId = map.get("initId");//初算id
- String personId = map.get("personId");
- String taxUnitId = map.get("taxUnitId");
- String incomeitemid = map.get("incomeitemid");
- String calSchemeId = map.get("calSchemeId");
- String cmpCalTableId = map.get("cmpCalTableId");
- FilterInfo filterInfo = new FilterInfo();
- FilterItemCollection filterItems = filterInfo.getFilterItems();
- filterItems.add(new FilterItemInfo("person", personId));
- filterItems.add(new FilterItemInfo("taxUnit", taxUnitId));
- filterItems.add(new FilterItemInfo("periodBegin", periodBeginDate, CompareType.GREATER));
- filterItems.add(new FilterItemInfo("periodEnd", periodEndDate, CompareType.LESS_EQUALS));
- filterItems.add(new FilterItemInfo("incomeItem", incomeitemid));
- filterItems.add(new FilterItemInfo("calScheme", calSchemeId));
- filterItems.add(new FilterItemInfo("cmpCalTable", cmpCalTableId));
- SelectorItemCollection sic = new SelectorItemCollection();
- sic.add("state");
- EntityViewInfo instance = EntityViewInfo.getInstance(filterInfo, sic, null);
- TaxCalConfigDetailCollection taxCalConfigDetailCol = iTaxCalConfigDetail.getTaxCalConfigDetailCollection(instance);
- if (taxCalConfigDetailCol.size() > 0) {
- TaxCalConfigDetailInfo taxCalConfigDetailInfo = taxCalConfigDetailCol.get(0);
- if (TaxResultStateEnum.UN_CONFIRM.equals(taxCalConfigDetailInfo.getState())) {
- //未确认,更新数据
- detailId = taxCalConfigDetailInfo.getId().toString();
- configIds.add(detailId);
- } else {
- //已确认,不能更新
- logger.error("更新明细表数据 已确认,不能更新");
- continue;
- }
- } else {
- //没有找到明细数据,创建数据
- //个税应用+税款计算最终拆分明细表
- TaxCalConfigDetailInfo taxCalConfigDetailInfo = new TaxCalConfigDetailInfo();
- //计算规则
- taxCalConfigDetailInfo.put("calScheme", map.get("calSchemeId"));
- //核算表id
- taxCalConfigDetailInfo.put("cmpCalTable", map.get("cmpCalTableId"));
- //状态
- taxCalConfigDetailInfo.setState(TaxResultStateEnum.UN_CONFIRM);
- //依赖id
- //taxCalConfigDetailInfo.setRelay();
- //是否最后一条
- //taxCalConfigDetailInfo.setIsLast();
- //是否生成个税申报
- taxCalConfigDetailInfo.setIsGenerateTaxDeclare(false);
- //申报批次号
- //taxCalConfigDetailInfo.setBatchNo();
- //员工
- taxCalConfigDetailInfo.put("person", map.get("personId"));
- //纳税单位
- taxCalConfigDetailInfo.put("taxUnit", map.get("taxUnitId"));
- //税款所属期间起
- taxCalConfigDetailInfo.setPeriodBegin(periodBeginDate);
- //税款所属期间止
- taxCalConfigDetailInfo.setPeriodEnd(periodEndDate);
- //所得项目
- taxCalConfigDetailInfo.put("incomeItem", map.get("incomeitemid"));
- detailId = iTaxCalConfigDetail.addnew(taxCalConfigDetailInfo).toString();
- configIds.add(detailId);
- }
- initIds.add(initId);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- logger.info("configIds: " + objectMapper.writeValueAsString(configIds));
- logger.info("initIds " + objectMapper.writeValueAsString(initIds));
- if (!configIds.isEmpty() && !initIds.isEmpty()) {
- //更新明细表数据
- StringBuilder updateSql = new StringBuilder();
- updateSql.append("update T_HR_STaxCalConfigDetail config set ").append("\n");
- for (String key : taxItemConfigMap.keySet()) {
- updateSql.append("config.").append(taxItemConfigMap.get(key))
- .append(" = init.").append(taxItemConfigMap.get(key)).append(",").append("\n");
- }
- updateSql.deleteCharAt(updateSql.lastIndexOf(","));
- updateSql.append("from( select * from T_HR_STaxCalInitDetail where fid in( ");
- updateSql.append(AtsUtil.convertSetToString(initIds)).append(")) init").append("\n");
- updateSql.append("where config.fpersonId = init.fpersonId").append("\n");
- updateSql.append(" and config.fCmpCalTableId = init.fCmpCalTableId").append("\n");
- updateSql.append(" and config.fIncomeItemId = init.fIncomeItemId").append("\n");
- updateSql.append(" and config.FPERIODBEGIN = init.FPERIODBEGIN").append("\n");
- updateSql.append(" and config.FPERIODEND = init.FPERIODEND").append("\n");
- updateSql.append(" and config.fstate = '10'").append("\n");
- updateSql.append(" and config.fid in(").append(AtsUtil.convertSetToString(configIds)).append(")").append("\n");
- logger.info("更新明细表sql: " + updateSql);
- DbUtil.execute(ctx, updateSql.toString());
- }
- }
- /**
- * 获取证件map
- *
- * @return
- */
- // private static Map<String, String> getCardTypeEnumMap() {
- // Map<String, String> cardTypeEnumMap = new HashMap<>();
- // List<Map<String, String>> enumList = CardTypeEnum.getEnumList();
- // for (int i = 0; i < enumList.size(); i++) {
- // CardTypeEnum cardTypeEnum = (CardTypeEnum) enumList.get(i);
- // String value = cardTypeEnum.getValue();
- // String alias = cardTypeEnum.getAlias();
- // cardTypeEnumMap.put(alias, value);
- // }
- // return cardTypeEnumMap;
- // }
- /**
- * 获取所得项目
- *
- * @param ctx
- * @return
- * @throws BOSException
- */
- private Map<String, String> getIncomeItemMap(Context ctx) throws BOSException {
- Map<String, String> incomeItemMap = new HashMap<>();
- try {
- TaxIncomeItemCollection taxIncomeItemCollection = TaxIncomeItemFactory.getLocalInstance(ctx).getTaxIncomeItemCollection("where state = 1");
- for (int i = 0; i < taxIncomeItemCollection.size(); i++) {
- TaxIncomeItemInfo taxIncomeItemInfo = taxIncomeItemCollection.get(i);
- String taxIncomeItemId = taxIncomeItemInfo.getId().toString();
- String name = taxIncomeItemInfo.getName();
- incomeItemMap.put(name, taxIncomeItemId);
- }
- return incomeItemMap;
- } catch (BOSException e) {
- e.printStackTrace();
- throw new BOSException("获取所得项目数据报错: " + e.getMessage());
- }
- }
- /**
- * 获取报送人员信息
- *
- * @param ctx
- * @throws BOSException
- */
- private void getTaxPersonRecordMap(Context ctx) throws BOSException {
- if (taxPersonRecordMap == null) {
- taxPersonRecordMap = new HashMap<>();
- }
- TaxPersonRecordCollection taxPersonRecordCollection = TaxPersonRecordFactory
- .getLocalInstance(ctx).getTaxPersonRecordCollection();
- for (int i = 0; i < taxPersonRecordCollection.size(); i++) {
- TaxPersonRecordInfo taxPersonRecordInfo = taxPersonRecordCollection.get(i);
- String personId = taxPersonRecordInfo.getPerson().getId().toString();
- String cardTypeName = taxPersonRecordInfo.getCardType().getAlias();
- String cardNumber = taxPersonRecordInfo.getCardNumber();
- taxPersonRecordMap.put(cardNumber + cardTypeName, personId);
- }
- }
- /**
- * 获取个税项目
- *
- * @param ctx
- * @return
- * @throws BOSException
- */
- private void getTaxItemMap(Context ctx) throws BOSException {
- if (taxItemInitMap == null) {
- taxItemInitMap = new HashMap<>();
- }
- if (taxItemConfigMap == null) {
- taxItemConfigMap = new HashMap<>();
- }
- //获取所有个税项目
- Set initSet = new HashSet();
- initSet.add("jmse");//减免税额
- initSet.add("qzd");//减除费用
- initSet.add("ynssde");//应纳税所得额
- initSet.add("sl");//税率
- initSet.add("sskcs");//速算扣除数
- initSet.add("bqybtse");//应补退税额
- initSet.add("bqljsre");//累计收入额
- initSet.add("bqljmssr");///累计免税收入额
- initSet.add("zxkchj");//累计专项扣除额
- initSet.add("zxfjkchj");//累计专项(附加)扣除额
- initSet.add("qtckhj");//累计其他扣除额
- initSet.add("ljjmse");//累计减免税额
- initSet.add("jcfy");//累计减除费用额
- initSet.add("ljynssde");//累计应纳税所得额
- initSet.add("ljynse");//累计应纳税额
- initSet.add("ljyingkjse");//累计应扣缴税额
- initSet.add("znjyzc");//累计子女教育支出
- initSet.add("jxjyzc");//累计继续教育支出
- initSet.add("ljxljxjyzc_ex");//累计学历继续教育支出
- initSet.add("ljfxljxjyzc_ex");//累计非学历继续教育支出
- initSet.add("zfzjzc");//累计住房租金支出
- initSet.add("zfdklxzc");//累计房屋贷款支出
- initSet.add("sylrzc");//累计赡养老人支出
- initSet.add("ljzykcdjze");//累计准予扣除的捐赠额
- initSet.add("grylj"); //累计个人养老金
- initSet.add("zykcjze");//准予扣除的捐赠额
- initSet.add("ykjse");//本月已累计扣除税额
- initSet.add("yxkcsf");//允许扣除的税费
- initSet.add("zycb");//展业成本
- initSet.add("qzd");//月减除费用
- //最终拆分明细表个税项目
- Set configSet = new HashSet();
- configSet.add("sre");//本期收入
- configSet.add("mssd // 本期免税收入");
- configSet.add("jbylaobxf");// 基本养老保险费
- configSet.add("jbylbxf");// 基本医疗保险费
- configSet.add("sybxf");// 失业保险费
- configSet.add("zfgjj");// 住房公积金
- configSet.add("znjyzc");// 累计子女教育
- configSet.add("jxjyzc");// 累计继续教育
- configSet.add("zfdklxzc");// 累计住房贷款利息");
- configSet.add("zfzjzc");// 累计住房租金");
- configSet.add("nj");// 企业(职业)年金");
- configSet.add("syjkbx");// 商业健康保险");
- configSet.add("syylbx");// 税延养老保险");
- configSet.add("qt");// 其他");
- configSet.add("zykcjze");// 准予扣除的捐赠额");
- configSet.add("jmse");// 减免税额");
- configSet.add("yxkcsf");// 允许扣除的税费");
- configSet.add("ljsre");// 上期累计收入");
- configSet.add("bqljsre");// 本期累计收入");
- configSet.add("ljmssd");// 上期累计免税收入");
- configSet.add("bqljmssr");// 本期累计免税收入");
- configSet.add("qzd");// 减除费用");
- configSet.add("jcfy");// 累计减除费用");
- configSet.add("fy");// 本期费用");
- configSet.add("zxkchj");// 累计专项扣除");
- configSet.add("zxfjkchj");// 累计专项附加扣除合计");
- configSet.add("qtckhj");// 累计其他扣除");
- configSet.add("ljzykcdjze");// 累计准予扣除的捐赠
- configSet.add("ljynssde");// 累计应纳税所得额
- configSet.add("sl");// 税率
- configSet.add("sskcs");// 速算扣除数
- configSet.add("ljynse");// 累计应纳税额
- configSet.add("ljjmse");// 累计减免税额
- configSet.add("ljyingkjse");// 累计应扣缴税额
- configSet.add("ykjse");// 累计已预缴税额
- configSet.add("ybtse");// 累计应补(退)税额
- configSet.add("ycxbc");// 一次性补偿
- configSet.add("zycb");// 展业成本
- configSet.add("bz");// 备注
- configSet.add("ccyz");// 财产原值
- configSet.add("jsbl");// 减按计税比例
- configSet.add("ynssde");// 应纳税所得额
- configSet.add("bqybtse");// 本期应补(退)税额
- configSet.add("sylrzc");// 累计赡养老人
- configSet.add("yyezhfzc");// 累计婴幼儿照护费用
- configSet.add("grylj");// 累计个人养老金
- configSet.add("ljfxljxjyzc_ex");// 累计非学历继续教育支出
- configSet.add("ljxljxjyzc_ex");// 累计学历继续教育支出
- configSet.add("znjyzc_ex");// 子女教育支出
- configSet.add("sylrzc_ex");// 赡养老人支出
- configSet.add("zfdklxzc_ex");// 住房贷款利息支出
- configSet.add("zfzjzc_ex");// 住房租金支出
- configSet.add("jxjyzc_ex");// 继续教育支出
- configSet.add("fxljxjyzc_ex");// 非学历继续教育支出
- configSet.add("yyezhzc_ex");// 婴幼儿照护支出
- try {
- TaxItemCollection itemColl = TaxItemFactory.getLocalInstance(ctx)
- .getTaxItemCollection("where state = 1");
- for (int i = 0; i < itemColl.size(); ++i) {
- TaxItemInfo info = itemColl.get(i);
- String number = info.getNumber();
- if (initSet.contains(number)) {
- taxItemInitMap.put(number, "T" + info.getFieldSn());
- }
- if (configSet.contains(number)) {
- taxItemConfigMap.put(number, "T" + info.getFieldSn());
- }
- }
- } catch (BOSException var5) {
- var5.printStackTrace();
- throw new BOSException("获取个税项目报错: " + var5.getMessage());
- }
- }
- }
|