| | |
| | | @Value("${dept.smjsc}") |
| | | private String smjsc; |
| | | |
| | | @Value("${dept.smjhw}") |
| | | private String smjhw; |
| | | |
| | | @Value("${dept.tfgs}") |
| | | private String tfgs; |
| | | |
| | |
| | | if (ObjUtil.isNotNull(subjectMatter)) { |
| | | advanceAmount = advanceAmount.add(contractOutBoundInvoiceVo.getInvoiceNum().multiply(subjectMatter.getUnitPrice())); |
| | | } |
| | | List<String> smjList = new ArrayList<>(); |
| | | smjList.add(smj); |
| | | smjList.add(smjsc); |
| | | smjList.add(smjzt); |
| | | smjList.add(smjhw); |
| | | if (("" + SecurityUtils.getUser().getCompId()).equals(smj) || ("" + SecurityUtils.getUser().getCompId()).equals(smjsc) || |
| | | ("" + SecurityUtils.getUser().getCompId()).equals(smjzt) || |
| | | ("" + SecurityUtils.getUser().getCompId()).equals(smjhw)) { |
| | | Product product = productMapper.selectOne(Wrappers.<Product>lambdaQuery().eq(Product::getErpCode, subjectMatter.getMaterialCode()) |
| | | .in(Product::getCompId, smjList).last("limit 1")); |
| | | if (ObjUtil.isNull(product) || StrUtil.isBlank(product.getTaxClass()) || StrUtil.isBlank(product.getTaxCode())) { |
| | | return R.failed("请在产品信息中补充税收分类信息"); |
| | | } |
| | | } else { |
| | | Product product = productMapper.selectOne(Wrappers.<Product>lambdaQuery().eq(Product::getErpCode, subjectMatter.getMaterialCode()) |
| | | .eq(Product::getCompId, SecurityUtils.getUser().getCompId()).last("limit 1")); |
| | | if (ObjUtil.isNull(product) || StrUtil.isBlank(product.getTaxClass()) || StrUtil.isBlank(product.getTaxCode())) { |
| | | return R.failed("请在产品信息中补充税收分类信息"); |
| | | } |
| | | } |
| | | } |
| | | log.info("advanceAmount:{}", advanceAmount); |
| | | log.info("schedule.getPlannedAmount:{}", schedule.getPlannedAmount()); |
| | |
| | | BusinessCustomer customer = businessCustomerMapper.selectById(contract.getPartyAId()); |
| | | if (ObjUtil.isNull(customer)) { |
| | | return R.failed("获取购方单位异常"); |
| | | } |
| | | for (ContractOutBoundInvoiceVo contractOutBoundInvoiceVo : genInvoiceInfoDTO.getOutBoundInvoiceList()) { |
| | | ContractOutBound contractOutBound = contractOutBoundMapper.selectById(contractOutBoundInvoiceVo.getContractOutBoundId()); |
| | | List<String> smjList = new ArrayList<>(); |
| | | smjList.add(smj); |
| | | smjList.add(smjsc); |
| | | smjList.add(smjzt); |
| | | smjList.add(smjhw); |
| | | if (("" + SecurityUtils.getUser().getCompId()).equals(smj) || ("" + SecurityUtils.getUser().getCompId()).equals(smjsc) || |
| | | ("" + SecurityUtils.getUser().getCompId()).equals(smjzt)|| |
| | | ("" + SecurityUtils.getUser().getCompId()).equals(smjhw)) { |
| | | Product product = productMapper.selectOne(Wrappers.<Product>lambdaQuery().eq(Product::getErpCode, contractOutBound.getSubjectMatterCode()) |
| | | .in(Product::getCompId, smjList).last("limit 1")); |
| | | if (ObjUtil.isNull(product) || StrUtil.isBlank(product.getTaxClass()) || StrUtil.isBlank(product.getTaxCode())) { |
| | | return R.failed("请在产品信息中补充税收分类信息"); |
| | | } |
| | | } else { |
| | | Product product = productMapper.selectOne(Wrappers.<Product>lambdaQuery().eq(Product::getErpCode, contractOutBound.getSubjectMatterCode()) |
| | | .eq(Product::getCompId, SecurityUtils.getUser().getCompId()).last("limit 1")); |
| | | if (ObjUtil.isNull(product) || StrUtil.isBlank(product.getTaxClass()) || StrUtil.isBlank(product.getTaxCode())) { |
| | | return R.failed("请在产品信息中补充税收分类信息"); |
| | | } |
| | | } |
| | | |
| | | } |
| | | //机动车开票 |
| | | if (StrUtil.equals(genInvoiceInfoDTO.getInvoiceType(), "4")) { |
| | |
| | | if (ObjUtil.isNull(customer)) { |
| | | return R.failed("获取购方单位异常"); |
| | | } |
| | | for (ContractOutBoundInvoiceVo contractOutBoundInvoiceVo : mergeInvoiceDTO.getOutBoundInvoiceList()) { |
| | | ContractOutBound contractOutBound = contractOutBoundMapper.selectById(contractOutBoundInvoiceVo.getContractOutBoundId()); |
| | | List<String> smjList = new ArrayList<>(); |
| | | smjList.add(smj); |
| | | smjList.add(smjsc); |
| | | smjList.add(smjzt); |
| | | smjList.add(smjhw); |
| | | if (("" + SecurityUtils.getUser().getCompId()).equals(smj) || ("" + SecurityUtils.getUser().getCompId()).equals(smjsc) || |
| | | ("" + SecurityUtils.getUser().getCompId()).equals(smjzt) || |
| | | ("" + SecurityUtils.getUser().getCompId()).equals(smjhw)) { |
| | | Product product = productMapper.selectOne(Wrappers.<Product>lambdaQuery().eq(Product::getErpCode, contractOutBound.getSubjectMatterCode()) |
| | | .in(Product::getCompId, smjList).last("limit 1")); |
| | | if (ObjUtil.isNull(product) || StrUtil.isBlank(product.getTaxClass()) || StrUtil.isBlank(product.getTaxCode())) { |
| | | return R.failed("请在产品信息中补充税收分类信息"); |
| | | } |
| | | } else { |
| | | Product product = productMapper.selectOne(Wrappers.<Product>lambdaQuery().eq(Product::getErpCode, contractOutBound.getSubjectMatterCode()) |
| | | .eq(Product::getCompId, SecurityUtils.getUser().getCompId()).last("limit 1")); |
| | | if (ObjUtil.isNull(product) || StrUtil.isBlank(product.getTaxClass()) || StrUtil.isBlank(product.getTaxCode())) { |
| | | return R.failed("请在产品信息中补充税收分类信息"); |
| | | } |
| | | } |
| | | |
| | | } |
| | | GenInvoiceInfoVo vo = genMergeInvoiceVo(mergeInvoiceDTO, customer, b); |
| | | vo = transBipVo(vo, b, customer); |
| | | return R.ok(vo); |
| | |
| | | smjList.add(smj); |
| | | smjList.add(smjsc); |
| | | smjList.add(smjzt); |
| | | smjList.add(smjhw); |
| | | if (("" + SecurityUtils.getUser().getCompId()).equals(smj) || ("" + SecurityUtils.getUser().getCompId()).equals(smjsc) || |
| | | ("" + SecurityUtils.getUser().getCompId()).equals(smjzt)) { |
| | | ("" + SecurityUtils.getUser().getCompId()).equals(smjzt) || |
| | | ("" + SecurityUtils.getUser().getCompId()).equals(smjhw)) { |
| | | product = productMapper.selectOne(Wrappers.<Product>lambdaQuery().eq(Product::getErpCode, contractOutBound.getSubjectMatterCode()) |
| | | .in(Product::getCompId, smjList).last("limit 1")); |
| | | } else { |
| | |
| | | GenInvoiceInfoVo vo = new GenInvoiceInfoVo(); |
| | | BusinessCustomer a = businessCustomerMapper.selectById(contract.getPartyAId()); |
| | | vo.setContractId(contract.getId()); |
| | | vo.setPartyA(a.getCompanyName()); |
| | | vo.setPartyAOrgCode(a.getCreditCode()); |
| | | vo.setPartyA(genInvoiceInfoDTO.getPartyA()); |
| | | vo.setPartyAOrgCode(genInvoiceInfoDTO.getPartyAOrgCode()); |
| | | vo.setPartyAOpenBank(a.getBankName()); |
| | | vo.setPartyABankAccount(a.getBankAccount()); |
| | | vo.setPartyB(b.getOrgName()); |
| | |
| | | List<InvoiceItemVo> invoiceItemVoList = new ArrayList<>(); |
| | | List<String> erpCode = new ArrayList<>(); |
| | | List<ContractOutBoundMergeVo> mergeOutBounds = new ArrayList<>(); |
| | | if (genInvoiceInfoDTO.getInvoiceType().equals("3")){ |
| | | if (genInvoiceInfoDTO.getInvoiceType().equals("3")) { |
| | | String[] vehiclenNoList = genInvoiceInfoDTO.getVehicleNo().split(","); |
| | | for (int i = 0; i < vehiclenNoList.length; i++) { |
| | | ContractOutBound contractOutBound = contractOutBoundMapper.selectById(genInvoiceInfoDTO.getOutBoundInvoiceList().get(0).getContractOutBoundId()); |
| | |
| | | smjList.add(smj); |
| | | smjList.add(smjsc); |
| | | smjList.add(smjzt); |
| | | smjList.add(smjhw); |
| | | if (("" + SecurityUtils.getUser().getCompId()).equals(smj) || ("" + SecurityUtils.getUser().getCompId()).equals(smjsc) || |
| | | ("" + SecurityUtils.getUser().getCompId()).equals(smjzt)) { |
| | | ("" + SecurityUtils.getUser().getCompId()).equals(smjzt)|| |
| | | ("" + SecurityUtils.getUser().getCompId()).equals(smjhw)) { |
| | | product = productMapper.selectOne(Wrappers.<Product>lambdaQuery().eq(Product::getErpCode, contractOutBound.getSubjectMatterCode()) |
| | | .in(Product::getCompId, smjList).last("limit 1")); |
| | | } else { |
| | |
| | | smjList.add(smj); |
| | | smjList.add(smjsc); |
| | | smjList.add(smjzt); |
| | | smjList.add(smjhw); |
| | | if (("" + SecurityUtils.getUser().getCompId()).equals(smj) || ("" + SecurityUtils.getUser().getCompId()).equals(smjsc) || |
| | | ("" + SecurityUtils.getUser().getCompId()).equals(smjzt)) { |
| | | ("" + SecurityUtils.getUser().getCompId()).equals(smjzt)|| |
| | | ("" + SecurityUtils.getUser().getCompId()).equals(smjhw)) { |
| | | product = productMapper.selectOne(Wrappers.<Product>lambdaQuery().eq(Product::getErpCode, contractOutBound.getSubjectMatterCode()) |
| | | .in(Product::getCompId, smjList).last("limit 1")); |
| | | } else { |
| | |
| | | BusinessCustomer a = businessCustomerMapper.selectById(contract.getPartyAId()); |
| | | vo.setContractId(contract.getId()); |
| | | vo.setAdvanceInvoice("111"); |
| | | vo.setPartyA(a.getCompanyName()); |
| | | vo.setPartyAOrgCode(a.getCreditCode()); |
| | | vo.setPartyA(genInvoiceInfoDTO.getPartyA()); |
| | | vo.setPartyAOrgCode(genInvoiceInfoDTO.getPartyAOrgCode()); |
| | | vo.setPartyAOpenBank(a.getBankName()); |
| | | vo.setPartyABankAccount(a.getBankAccount()); |
| | | vo.setPartyB(b.getOrgName()); |
| | |
| | | } |
| | | GenInvoiceInfoVo vo = BeanUtil.copyProperties(toInvoiceDTO, GenInvoiceInfoVo.class); |
| | | //发票保存 |
| | | ContractInvoice invoice = saveContractInvoice(vo, contract, toInvoiceDTO.getOutBoundInvoiceList(), DateUtil.current() + "", "1",null); |
| | | ContractInvoice invoice = saveContractInvoice(vo, contract, toInvoiceDTO.getOutBoundInvoiceList(), DateUtil.current() + "", "1", null); |
| | | //启动流程 |
| | | ProcessInstanceParamDto dto = new ProcessInstanceParamDto(); |
| | | Map<String, Object> map = BeanUtil.beanToMap(invoice); |
| | |
| | | } |
| | | GenInvoiceInfoVo vo = BeanUtil.copyProperties(toInvoiceDTO, GenInvoiceInfoVo.class); |
| | | //发票保存 |
| | | ContractInvoice invoice = saveContractInvoice(vo, contract, toInvoiceDTO.getOutBoundInvoiceList(), DateUtil.current() + "", "0",null); |
| | | ContractInvoice invoice = saveContractInvoice(vo, contract, toInvoiceDTO.getOutBoundInvoiceList(), DateUtil.current() + "", "0", null); |
| | | //启动流程 |
| | | ProcessInstanceParamDto dto = new ProcessInstanceParamDto(); |
| | | Map<String, Object> map = BeanUtil.beanToMap(invoice); |
| | |
| | | List<ContractInvoice> invoiceList = baseMapper.selectList(Wrappers.<ContractInvoice>lambdaQuery() |
| | | .eq(ContractInvoice::getContractId, contractId) |
| | | .or() |
| | | .like(ContractInvoice::getContractIds,contractId) |
| | | .like(ContractInvoice::getContractIds, contractId) |
| | | .orderByDesc(ContractInvoice::getCreateTime)); |
| | | return R.ok(invoiceList); |
| | | } |
| | |
| | | blueInvoice.setRedReversal("2"); |
| | | baseMapper.updateById(blueInvoice); |
| | | ContractInvoice invoice = new ContractInvoice(); |
| | | if (!blueInvoice.getIsMerge()){ |
| | | if (!blueInvoice.getIsMerge()) { |
| | | invoice.setContractId(blueInvoice.getContractId()); |
| | | } |
| | | if (blueInvoice.getIsMerge()){ |
| | | if (blueInvoice.getIsMerge()) { |
| | | invoice.setContractIds(blueInvoice.getContractIds()); |
| | | invoice.setIsMerge(true); |
| | | } |
| | |
| | | ProcessInstanceParamDto dto = new ProcessInstanceParamDto(); |
| | | Map<String, Object> map = BeanUtil.beanToMap(invoice); |
| | | dto.setParamMap(map); |
| | | if (!blueInvoice.getIsMerge()){ |
| | | if (!blueInvoice.getIsMerge()) { |
| | | Contract contract = contractMapper.selectById(blueInvoice.getContractId()); |
| | | if (StrUtil.equals(contract.getContractCategory(), "water_house")) { |
| | | map.put("contractCategory", "water_house"); |
| | |
| | | // invoiceDetail.put("goodsPrice", invoiceItemVo.getUnitPrice()); |
| | | invoiceDetail.put("goodsTotalPrice", invoiceItemVo.getPriceNoTax()); |
| | | invoiceDetail.put("goodsTotalTax", invoiceItemVo.getPriceTax()); |
| | | if (StrUtil.isNotBlank(vo.getInvoiceVehicleType())&&(vo.getInvoiceVehicleType().equals("3") || vo.getInvoiceVehicleType().equals("4"))) { |
| | | if (StrUtil.isNotBlank(vo.getInvoiceVehicleType()) && (vo.getInvoiceVehicleType().equals("3") || vo.getInvoiceVehicleType().equals("4"))) { |
| | | invoiceDetail.put("goodsSpecification", invoiceItemVo.getSpecification()); |
| | | } |
| | | invoiceDetailsList.add(invoiceDetail); |
| | |
| | | item.put("taxRate", invoiceItemVo.getTaxRate()); |
| | | item.put("oriTaxAmount", invoiceItemVo.getPriceTax()); |
| | | item.put("oriTaxIncludedAmount", invoiceItemVo.getPriceAndTax()); |
| | | item.put("remarks", invoiceItemVo.getZy());//摘要 |
| | | item.put("_status", "Insert"); |
| | | JSONObject freeChId = new JSONObject(); |
| | | freeChId.put("GX08", invoiceItemVo.getHsdy());//核算单元 |
| | | freeChId.put("YSYF14", "2");//款项类型 1 预收款 2 应收款 |
| | | freeChId.put("YSYF31", invoiceItemVo.getSfjs());//是否计税 |
| | | freeChId.put("JT04", invoiceItemVo.getHsjylx());//核算交易类型 0101 集团外部 01020301 三级分子公司间 01020302 三级分公司与子子公司之间 |
| | | freeChId.put("JT06", invoiceItemVo.getKxmx());//款项明细 |
| | | freeChId.put("JT32", invoiceItemVo.getZyys());//作业要素 |
| | | freeChId.put("zzbkfl", invoiceItemVo.getBkfl());//板块分类 |
| | | freeChId.put("JT12", invoiceItemVo.getCpwlfl());//产品物料分类 |
| | | |
| | | item.put("freeChId", freeChId); |
| | | bodyItem.add(item); |
| | | } |
| | |
| | | //蓝票 |
| | | if (invoice.getInvoiceCategory().equals("1")) { |
| | | // TODO 开蓝票接口机动车销售 |
| | | if (StrUtil.equals(vo.getInvoiceVehicleType(), "4")&&bwFlag) { |
| | | if (StrUtil.equals(vo.getInvoiceVehicleType(), "4") && bwFlag) { |
| | | JSONObject request = genBlueInvoiceVehicle(vo, invoice.getSerialNo(), dept); |
| | | String requestId = IdUtil.fastUUID(); |
| | | invoice.setBwRequestId(requestId); |
| | |
| | | } |
| | | |
| | | // TODO 开蓝票接口机动车专用 |
| | | if (StrUtil.equals(vo.getInvoiceVehicleType(), "3")&&bwFlag) { |
| | | if (StrUtil.equals(vo.getInvoiceVehicleType(), "3") && bwFlag) { |
| | | JSONObject request = genBlueInvoiceVehiclePre(vo, invoice.getSerialNo(), dept); |
| | | String requestId = IdUtil.fastUUID(); |
| | | invoice.setBwRequestId(requestId); |
| | |
| | | } |
| | | |
| | | // TODO 开蓝票接口 非机动车 |
| | | if (!StrUtil.equals(vo.getInvoiceVehicleType(), "3") && !StrUtil.equals(vo.getInvoiceVehicleType(), "4")&&bwFlag) { |
| | | if (!StrUtil.equals(vo.getInvoiceVehicleType(), "3") && !StrUtil.equals(vo.getInvoiceVehicleType(), "4") && bwFlag) { |
| | | JSONObject request = genBlueInvoice(vo, invoice.getSerialNo(), dept); |
| | | String requestId = IdUtil.fastUUID(); |
| | | invoice.setBwRequestId(requestId); |
| | |
| | | }); |
| | | } |
| | | } |
| | | }else { |
| | | } else { |
| | | blueInvoice.setRedReversal("1"); |
| | | baseMapper.updateById(blueInvoice); |
| | | //合并开票 |
| | |
| | | for (ContractOutBoundInvoiceVo outBoundInvoiceVo : vo.getOutBoundInvoiceList()) { |
| | | BigDecimal contractBillAmount = new BigDecimal("0"); |
| | | if (CollUtil.isNotEmpty(vo.getOutBoundInvoiceList())) { |
| | | ContractOutBound contractOutBound = contractOutBoundMapper.selectById(outBoundInvoiceVo.getContractOutBoundId()); |
| | | if (ObjUtil.isNotNull(contractOutBound) && contractOutBound.getContractId().equals(contract.getId())) { |
| | | ContractSubjectMatter subjectMatter = subjectMatterMapper.selectOne(Wrappers.<ContractSubjectMatter>lambdaQuery() |
| | | .eq(ContractSubjectMatter::getMaterialCode, contractOutBound.getSubjectMatterCode()) |
| | | .eq(StrUtil.isNotBlank(contractOutBound.getLineNo()), ContractSubjectMatter::getLineNo, contractOutBound.getLineNo()) |
| | | .eq(ContractSubjectMatter::getContractId, contract.getId()).last("limit 1")); |
| | | if (ObjUtil.isNotNull(subjectMatter) && ObjUtil.isNotNull(subjectMatter.getUnitPrice())) { |
| | | contractBillAmount = contractBillAmount.add(outBoundInvoiceVo.getInvoiceNum().multiply(subjectMatter.getUnitPrice())); |
| | | } |
| | | contractOutBound.setInvoiceNum(contractOutBound.getInvoiceNum().subtract(outBoundInvoiceVo.getInvoiceNum())); |
| | | contractOutBoundMapper.updateById(contractOutBound); |
| | | ContractOutBound contractOutBound = contractOutBoundMapper.selectById(outBoundInvoiceVo.getContractOutBoundId()); |
| | | if (ObjUtil.isNotNull(contractOutBound) && contractOutBound.getContractId().equals(contract.getId())) { |
| | | ContractSubjectMatter subjectMatter = subjectMatterMapper.selectOne(Wrappers.<ContractSubjectMatter>lambdaQuery() |
| | | .eq(ContractSubjectMatter::getMaterialCode, contractOutBound.getSubjectMatterCode()) |
| | | .eq(StrUtil.isNotBlank(contractOutBound.getLineNo()), ContractSubjectMatter::getLineNo, contractOutBound.getLineNo()) |
| | | .eq(ContractSubjectMatter::getContractId, contract.getId()).last("limit 1")); |
| | | if (ObjUtil.isNotNull(subjectMatter) && ObjUtil.isNotNull(subjectMatter.getUnitPrice())) { |
| | | contractBillAmount = contractBillAmount.add(outBoundInvoiceVo.getInvoiceNum().multiply(subjectMatter.getUnitPrice())); |
| | | } |
| | | contractOutBound.setInvoiceNum(contractOutBound.getInvoiceNum().subtract(outBoundInvoiceVo.getInvoiceNum())); |
| | | contractOutBoundMapper.updateById(contractOutBound); |
| | | } |
| | | } |
| | | //更新合同开票状态 前提出库完成 |
| | | contract.setBillingStatus("2"); |
| | |
| | | baseMapper.updateById(contractInvoice); |
| | | return R.ok(); |
| | | } |
| | | return R.failed(resultJson, "应收发票集成失败"); |
| | | return R.failed(result); |
| | | } |
| | | //红票 |
| | | if (StrUtil.equals(contractInvoice.getInvoiceCategory(), "2")) { |
| | |
| | | baseMapper.updateById(contractInvoice); |
| | | return R.ok(); |
| | | } |
| | | return R.failed(resultJson, "应收发票删除失败"); |
| | | return R.failed(result); |
| | | } |
| | | return R.ok(); |
| | | } |