| | |
| | | @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(smjhw); |
| | | if (("" + SecurityUtils.getUser().getCompId()).equals(smj)||("" + 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()); |
| | |
| | | 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(smjhw); |
| | | if (("" + SecurityUtils.getUser().getCompId()).equals(smj) || ("" + 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 (StrUtil.isBlank(genInvoiceInfoDTO.getVehicleNo())) { |
| | | return R.failed("机动车开票请输入车架号"); |
| | | return R.failed("机动车销售发票请输入车架号"); |
| | | } |
| | | BigDecimal invoiceNumSum = genInvoiceInfoDTO.getOutBoundInvoiceList().stream().map(item -> item.getInvoiceNum()).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | if (invoiceNumSum.compareTo(new BigDecimal("1")) > 0) { |
| | | return R.failed("机动车开票只能1次开1辆"); |
| | | return R.failed("机动车销售发票只能1次开1辆"); |
| | | } |
| | | JSONObject request = genQueryVinParam(genInvoiceInfoDTO.getVehicleNo(), b); |
| | | R r1 = requestQueryVehicleNo(request); |
| | |
| | | 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(smjhw); |
| | | if (("" + SecurityUtils.getUser().getCompId()).equals(smj) ||("" + 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); |
| | |
| | | Product product = new Product(); |
| | | List<String> smjList = new ArrayList<>(); |
| | | smjList.add(smj); |
| | | smjList.add(smjsc); |
| | | smjList.add(smjzt); |
| | | if (("" + SecurityUtils.getUser().getCompId()).equals(smj) || ("" + SecurityUtils.getUser().getCompId()).equals(smjsc) || |
| | | ("" + SecurityUtils.getUser().getCompId()).equals(smjzt)) { |
| | | smjList.add(smjhw); |
| | | if (("" + SecurityUtils.getUser().getCompId()).equals(smj) || ("" + SecurityUtils.getUser().getCompId()).equals(smjhw)) { |
| | | product = productMapper.selectOne(Wrappers.<Product>lambdaQuery().eq(Product::getErpCode, contractOutBound.getSubjectMatterCode()) |
| | | .in(Product::getCompId, smjList).last("limit 1")); |
| | | } else { |
| | |
| | | .forEach(invoiceItemVo -> { |
| | | // for (InvoiceItemVo invoiceItemVo:invoiceItemVoList) { |
| | | BigDecimal itemPrice = invoiceItemVo.getUnitPrice().multiply(invoiceItemVo.getQuantity()); |
| | | BigDecimal itemPriceTax = itemPrice.divide(new BigDecimal("100").add(invoiceItemVo.getTaxRate()), 2, RoundingMode.HALF_UP).multiply(invoiceItemVo.getTaxRate()); |
| | | BigDecimal itemPriceTax = itemPrice.divide(new BigDecimal("1").add(invoiceItemVo.getTaxRate().divide(new BigDecimal("100"))), 10, RoundingMode.HALF_UP).multiply(invoiceItemVo.getTaxRate().divide(new BigDecimal("100"))).setScale(2,RoundingMode.HALF_UP); |
| | | invoiceItemVo.setPriceTax(itemPriceTax); |
| | | invoiceItemVo.setPriceNoTax(itemPrice.subtract(itemPriceTax)); |
| | | invoiceItemVo.setPriceAndTax(itemPrice); |
| | |
| | | |
| | | log.info("机动车合格证查询接口入参:{},", request.toJSONString()); |
| | | String result = HttpUtil.post(bwUrl + "method=baiwang.output.invoice.queryVinDetail&version=1.0&request_id=" + requestId, request.toJSONString()); |
| | | // String result = "{\"success\":true,\"requestId\":\"5c2bc8a3-1399-4ff0-a039-92688c6740e0\",\"model\":[{\"engineNo\":\"5210F866\",\"vehicleName\":\"轿车\",\"vehicleSourceCode\":\"\",\"passengersLimited\":\"\",\"originPlace\":\"\",\"vehicleManufactureDate\":\"\",\"vehicleIdForAccountingUuid\":\"\",\"brandModel\":\"北京牌/BJJBJJ7201TN\",\"certificateInvoiceFlag\":\"\\\"certificateInvoiceFlag\\\": \\\"Y\\\"\",\"importCertificateNo\":\"HWJC22411181133\",\"certificateNo\":\"WZHGZBH22411181133\",\"paymentVoucherNo\":\"\",\"certificateStatusCode\":\"\\\"certificateStatusCode\\\": \\\"0\\\"\",\"vehicleNo\":\"CLSBDH22406190234\",\"invoiceUnavailableReasonCode\":\"\",\"manufacturingEnterprise\":\"佛山简捷陶瓷材料科技有限公司\",\"invoiceUnavailableReasonDesc\":\"\",\"tonnage\":0,\"inspectionListNo\":\"\",\"vehicleType\":\"\"}]}"; |
| | | log.info("机动车合格证查询接口回参:{},", result); |
| | | saveBwRequestRecord("baiwang.output.invoice.queryVinDetail", requestId, request.toJSONString(), result); |
| | | JSONObject resultObj = JSONObject.parseObject(result); |
| | |
| | | |
| | | private R requestQueryVehicleNo(JSONObject request) { |
| | | String requestId = IdUtil.fastUUID(); |
| | | |
| | | log.info("查询税局车架号码入参:{},", request.toJSONString()); |
| | | String result = HttpUtil.post(bwUrl + "method=baiwang.output.einvoice.queryvinlist&version=1.0&request_id=" + requestId, request.toJSONString()); |
| | | // String result = "{\"success\":true,\"requestId\":\"5c2bc8a3-1399-4ff0-a039-92688c6740e0\",\"model\":[{\"vehicleNo\":\"\",\"isNotOpenInvReason\":\"\",\"isOpenInvoice\":true}]}"; |
| | | log.info("查询税局车架号码回参:{},", result); |
| | | saveBwRequestRecord("baiwang.output.einvoice.queryvinlist", requestId, request.toJSONString(), result); |
| | | JSONObject resultObj = JSONObject.parseObject(result); |
| | |
| | | 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()); |
| | |
| | | vo.setPartyBBankAccount(b.getOrgBankAccount()); |
| | | vo.setInvoiceType(a.getInvoiceType()); |
| | | vo.setRemarks(genInvoiceInfoDTO.getRemarks()); |
| | | if (StrUtil.isNotBlank(b.getOrgContact())) { |
| | | vo.setContact(b.getOrgContact()); |
| | | } |
| | | if (StrUtil.isNotBlank(b.getOrgAddress())) { |
| | | vo.setAddress(b.getOrgAddress()); |
| | | } |
| | | vo.setOutBoundInvoiceList(genInvoiceInfoDTO.getOutBoundInvoiceList()); |
| | | if (StrUtil.isNotBlank(genInvoiceInfoDTO.getInvoiceType())) { |
| | | vo.setInvoiceVehicleType(genInvoiceInfoDTO.getInvoiceType()); |
| | |
| | | if (StrUtil.isNotBlank(genInvoiceInfoDTO.getVehicleData())) { |
| | | vo.setVehicleData(genInvoiceInfoDTO.getVehicleData()); |
| | | } |
| | | if (StrUtil.isNotBlank(genInvoiceInfoDTO.getSwjg())) { |
| | | vo.setSwjg(genInvoiceInfoDTO.getSwjg()); |
| | | } |
| | | 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()); |
| | |
| | | Product product = new Product(); |
| | | List<String> smjList = new ArrayList<>(); |
| | | smjList.add(smj); |
| | | smjList.add(smjsc); |
| | | smjList.add(smjzt); |
| | | if (("" + SecurityUtils.getUser().getCompId()).equals(smj) || ("" + SecurityUtils.getUser().getCompId()).equals(smjsc) || |
| | | ("" + SecurityUtils.getUser().getCompId()).equals(smjzt)) { |
| | | smjList.add(smjhw); |
| | | if (("" + SecurityUtils.getUser().getCompId()).equals(smj) || ("" + SecurityUtils.getUser().getCompId()).equals(smjhw)) { |
| | | product = productMapper.selectOne(Wrappers.<Product>lambdaQuery().eq(Product::getErpCode, contractOutBound.getSubjectMatterCode()) |
| | | .in(Product::getCompId, smjList).last("limit 1")); |
| | | } else { |
| | |
| | | .forEach(invoiceItemVo -> { |
| | | // for (InvoiceItemVo invoiceItemVo:invoiceItemVoList) { |
| | | BigDecimal itemPrice = invoiceItemVo.getUnitPrice().multiply(invoiceItemVo.getQuantity()); |
| | | BigDecimal itemPriceTax = itemPrice.divide(new BigDecimal("100").add(invoiceItemVo.getTaxRate()), 2, RoundingMode.HALF_UP).multiply(invoiceItemVo.getTaxRate()); |
| | | BigDecimal itemPriceTax = itemPrice.divide(new BigDecimal("1").add(invoiceItemVo.getTaxRate().divide(new BigDecimal("100"))), 10, RoundingMode.HALF_UP).multiply(invoiceItemVo.getTaxRate().divide(new BigDecimal("100"))).setScale(2,RoundingMode.HALF_UP); |
| | | invoiceItemVo.setPriceTax(itemPriceTax); |
| | | invoiceItemVo.setPriceNoTax(itemPrice.subtract(itemPriceTax)); |
| | | invoiceItemVo.setPriceAndTax(itemPrice); |
| | |
| | | Product product = new Product(); |
| | | List<String> smjList = new ArrayList<>(); |
| | | smjList.add(smj); |
| | | smjList.add(smjsc); |
| | | smjList.add(smjzt); |
| | | if (("" + SecurityUtils.getUser().getCompId()).equals(smj) || ("" + SecurityUtils.getUser().getCompId()).equals(smjsc) || |
| | | ("" + SecurityUtils.getUser().getCompId()).equals(smjzt)) { |
| | | smjList.add(smjhw); |
| | | if (("" + SecurityUtils.getUser().getCompId()).equals(smj) ||("" + SecurityUtils.getUser().getCompId()).equals(smjhw)) { |
| | | product = productMapper.selectOne(Wrappers.<Product>lambdaQuery().eq(Product::getErpCode, contractOutBound.getSubjectMatterCode()) |
| | | .in(Product::getCompId, smjList).last("limit 1")); |
| | | } else { |
| | |
| | | .forEach(invoiceItemVo -> { |
| | | // for (InvoiceItemVo invoiceItemVo:invoiceItemVoList) { |
| | | BigDecimal itemPrice = invoiceItemVo.getUnitPrice().multiply(invoiceItemVo.getQuantity()); |
| | | BigDecimal itemPriceTax = itemPrice.divide(new BigDecimal("100").add(invoiceItemVo.getTaxRate()), 2, RoundingMode.HALF_UP).multiply(invoiceItemVo.getTaxRate()); |
| | | BigDecimal itemPriceTax = itemPrice.divide(new BigDecimal("1").add(invoiceItemVo.getTaxRate().divide(new BigDecimal("100"))), 10, RoundingMode.HALF_UP).multiply(invoiceItemVo.getTaxRate().divide(new BigDecimal("100"))).setScale(2,RoundingMode.HALF_UP); |
| | | invoiceItemVo.setPriceTax(itemPriceTax); |
| | | invoiceItemVo.setPriceNoTax(itemPrice.subtract(itemPriceTax)); |
| | | invoiceItemVo.setPriceAndTax(itemPrice); |
| | |
| | | mergeVo.setMaterialInternalName(schedule.getSubjectMatterName()); |
| | | mergeVo.setPriceAndTax(schedule.getPlannedAmount()); |
| | | mergeVo.setQuantity(schedule.getInvoiceNum()); |
| | | Product product = productMapper.selectOne(Wrappers.<Product>lambdaQuery().eq(Product::getErpCode, schedule.getSubjectMatterCode()) |
| | | .eq(Product::getCompId, SecurityUtils.getUser().getCompId()).last("limit 1")); |
| | | List<String> smjList = new ArrayList<>(); |
| | | smjList.add(smj); |
| | | smjList.add(smjhw); |
| | | Product product = null; |
| | | if (("" + SecurityUtils.getUser().getCompId()).equals(smj) ||("" + SecurityUtils.getUser().getCompId()).equals(smjhw)) { |
| | | product = productMapper.selectOne(Wrappers.<Product>lambdaQuery().eq(Product::getErpCode, schedule.getSubjectMatterCode()) |
| | | .in(Product::getCompId, smjList).last("limit 1")); |
| | | } else { |
| | | product = productMapper.selectOne(Wrappers.<Product>lambdaQuery().eq(Product::getErpCode, schedule.getSubjectMatterCode()) |
| | | .eq(Product::getCompId, SecurityUtils.getUser().getCompId()).last("limit 1")); |
| | | } |
| | | if (ObjUtil.isNotNull(product)) { |
| | | mergeVo.setTaxClass(product.getTaxClass()); |
| | | mergeVo.setSpecification(product.getProductType()); |
| | | mergeVo.setTaxRate(new BigDecimal(product.getTaxRate())); |
| | | mergeVo.setTaxCode(product.getTaxCode()); |
| | | } |
| | | |
| | | ContractSubjectMatter subjectMatter = subjectMatterMapper.selectOne(Wrappers.<ContractSubjectMatter>lambdaQuery() |
| | | .eq(ContractSubjectMatter::getMaterialCode, schedule.getSubjectMatterCode()) |
| | | .eq(ContractSubjectMatter::getContractId, contract.getId()).last("limit 1")); |
| | |
| | | .forEach(invoiceItemVo -> { |
| | | // for (InvoiceItemVo invoiceItemVo:invoiceItemVoList) { |
| | | BigDecimal itemPrice = invoiceItemVo.getPriceAndTax(); |
| | | BigDecimal itemPriceTax = itemPrice.divide(new BigDecimal("100").add(invoiceItemVo.getTaxRate()), 2, RoundingMode.HALF_UP).multiply(invoiceItemVo.getTaxRate()); |
| | | BigDecimal itemPriceTax = itemPrice.divide(new BigDecimal("1").add(invoiceItemVo.getTaxRate().divide(new BigDecimal("100"))), 10, RoundingMode.HALF_UP).multiply(invoiceItemVo.getTaxRate().divide(new BigDecimal("100"))).setScale(2,RoundingMode.HALF_UP); |
| | | invoiceItemVo.setPriceTax(itemPriceTax); |
| | | invoiceItemVo.setPriceNoTax(itemPrice.subtract(itemPriceTax)); |
| | | |
| | |
| | | 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()); |
| | |
| | | mergeVo.setMaterialCode(subjectMatter.getMaterialCode()); |
| | | mergeVo.setMaterialInternalName(subjectMatter.getMaterialName()); |
| | | mergeVo.setQuantity(contractOutBoundInvoiceVo.getInvoiceNum()); |
| | | Product product = productMapper.selectOne(Wrappers.<Product>lambdaQuery().eq(Product::getErpCode, subjectMatter.getMaterialCode()) |
| | | .eq(Product::getCompId, SecurityUtils.getUser().getCompId()).last("limit 1")); |
| | | List<String> smjList = new ArrayList<>(); |
| | | smjList.add(smj); |
| | | smjList.add(smjhw); |
| | | Product product = null; |
| | | if (("" + SecurityUtils.getUser().getCompId()).equals(smj) ||("" + SecurityUtils.getUser().getCompId()).equals(smjhw)) { |
| | | product = productMapper.selectOne(Wrappers.<Product>lambdaQuery().eq(Product::getErpCode, subjectMatter.getMaterialCode()) |
| | | .in(Product::getCompId, smjList).last("limit 1")); |
| | | } else { |
| | | product = productMapper.selectOne(Wrappers.<Product>lambdaQuery().eq(Product::getErpCode, subjectMatter.getMaterialCode()) |
| | | .eq(Product::getCompId, SecurityUtils.getUser().getCompId()).last("limit 1")); |
| | | } |
| | | if (ObjUtil.isNotNull(product)) { |
| | | mergeVo.setTaxClass(product.getTaxClass()); |
| | | mergeVo.setSpecification(product.getProductType()); |
| | |
| | | invoiceItemVoList.stream().filter(invoiceItem -> invoiceItem.getUnitPrice().compareTo(new BigDecimal("0")) > 0).forEach(invoiceItemVo -> { |
| | | // for (InvoiceItemVo invoiceItemVo:invoiceItemVoList) { |
| | | BigDecimal itemPrice = invoiceItemVo.getUnitPrice().multiply(invoiceItemVo.getQuantity()); |
| | | BigDecimal itemPriceTax = itemPrice.divide(new BigDecimal("100").add(invoiceItemVo.getTaxRate()), 2, RoundingMode.HALF_UP).multiply(invoiceItemVo.getTaxRate()); |
| | | BigDecimal itemPriceTax = itemPrice.divide(new BigDecimal("1").add(invoiceItemVo.getTaxRate().divide(new BigDecimal("100"))), 10, RoundingMode.HALF_UP).multiply(invoiceItemVo.getTaxRate().divide(new BigDecimal("100"))).setScale(2,RoundingMode.HALF_UP); |
| | | invoiceItemVo.setPriceTax(itemPriceTax); |
| | | invoiceItemVo.setPriceNoTax(itemPrice.subtract(itemPriceTax)); |
| | | invoiceItemVo.setPriceAndTax(itemPrice); |
| | |
| | | } |
| | | 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"); |
| | |
| | | jsonObject.put("redInvoiceLabel", "01"); |
| | | jsonObject.put("invoiceSource", "2"); |
| | | jsonObject.put("originalInvoiceNo", blueInvoice.getInvoiceNo()); |
| | | jsonObject.put("autoIssueSwitch", "Y"); |
| | | GenInvoiceInfoVo vo = BeanUtil.copyProperties(JSONObject.parseObject(redInvoice.getInvoicePreview()), GenInvoiceInfoVo.class); |
| | | JSONArray invoiceDetailsList = new JSONArray(); |
| | | Integer lineNo = 1; |
| | |
| | | // 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); |
| | |
| | | } |
| | | BusinessCustomer customer = businessCustomerMapper.selectById(contract.getPartyAId()); |
| | | if (ObjUtil.isNull(customer) || StrUtil.isEmpty(customer.getBipCode())) { |
| | | log.error("查询合同信息异常"); |
| | | log.error("查询客户信息异常"); |
| | | return; |
| | | } |
| | | R<SysDept> r = remoteDeptService.getById(contract.getPartyBId()); |
| | |
| | | return; |
| | | } |
| | | SysDept comp = r.getData(); |
| | | R<SysDept> rDept = remoteDeptService.getById(SecurityUtils.getUser().getDeptId()); |
| | | if (!r.isOk()) { |
| | | log.error("查询单位信息异常"); |
| | | return; |
| | | } |
| | | SysDept dept = rDept.getData(); |
| | | // R<SysDept> rDept = remoteDeptService.getById(SecurityUtils.getUser().getDeptId()); |
| | | // if (!r.isOk()) { |
| | | // log.error("查询单位信息异常"); |
| | | // return; |
| | | // } |
| | | // SysDept dept = rDept.getData(); |
| | | //蓝票 |
| | | if (StrUtil.equals(contractInvoice.getInvoiceCategory(), "1")) { |
| | | |
| | | JSONObject params = genBlueReceiveParams(contractInvoice, contract, customer, comp, dept); |
| | | JSONObject params = genBlueReceiveParams(contractInvoice, contract, customer, comp); |
| | | String finalAccessToken = accessToken; |
| | | |
| | | log.info("应收发票集成入参:{}", params.toJSONString()); |
| | |
| | | } |
| | | |
| | | private JSONObject genBlueReceiveParams(ContractInvoice contractInvoice, Contract contract, BusinessCustomer customer |
| | | , SysDept comp, SysDept dept) { |
| | | , SysDept comp) { |
| | | GenInvoiceInfoVo vo = BeanUtil.copyProperties(JSONObject.parseObject(contractInvoice.getInvoicePreview()), GenInvoiceInfoVo.class); |
| | | JSONObject jsonObject = new JSONObject(); |
| | | JSONObject data = new JSONObject(); |
| | | if (contractInvoice.getInvoiceCategory().equals("1")) { |
| | |
| | | data.put("exchangeRate", "1");//汇率 |
| | | data.put("exchangeRateDate", DateUtil.now());//汇率时间 |
| | | data.put("objectType", "1");//往来对象类型(枚举值 1:客户; 2:员工;3:资金业务对象) |
| | | data.put("deptCode", dept.getOrgCode());//部门编码 SS2 |
| | | data.put("staffCode", SecurityUtils.getUser().getNickname());//业务员编码 |
| | | data.put("deptCode", vo.getBipVo().getBm());//部门编码 SS2 |
| | | data.put("staffCode", vo.getBipVo().getYwy());//业务员编码 |
| | | data.put("customerCode", customer.getBipCode());//客户编码 |
| | | data.put("financeOrgCode", comp.getBipCode());//开票组织编码 |
| | | data.put("orgCode", comp.getBipCode());//业务组织编码 |
| | | data.put("bustypeCode", "ZBYXGLXT");//交易类型编码 暂估默认ZGYSFP,销售默认ZBYXGLXT |
| | | data.put("bustypeCode", "ZBYXGLXT");//交易类型编码 暂估默认ZGYSFP,销售默认ZBYXGLXT ar_invoice 应收发票 |
| | | data.put("contractNo", contract.getContractNo()); |
| | | data.put("oriCurrencyCode", "CNY");//币种 |
| | | |
| | | data.put("_status", "Insert"); |
| | | GenInvoiceInfoVo vo = BeanUtil.copyProperties(JSONObject.parseObject(contractInvoice.getInvoicePreview()), GenInvoiceInfoVo.class); |
| | | |
| | | JSONArray bodyItem = new JSONArray(); |
| | | for (InvoiceItemVo invoiceItemVo : vo.getBipVo().getItemList()) { |
| | | JSONObject item = new JSONObject(); |
| | |
| | | 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); |
| | |
| | | contract.setBillingStatus("3"); |
| | | } |
| | | if (contract.getPaidAmount().compareTo(contract.getAmount().subtract(contract.getDropAmount())) >= 0 && |
| | | contract.getBillingAmout().compareTo(contract.getAmount()) == 0) { |
| | | contract.getBillingAmout().compareTo(contract.getAmount()) == 0&& |
| | | StrUtil.isBlank(contract.getNextScheduleName())) { |
| | | contract.setContractStatus(3); |
| | | } |
| | | if (contract.getBillingAmout().compareTo(contract.getAmount()) < 0) { |
| | |
| | | contract.setBillingStatus("3"); |
| | | } |
| | | if (contract.getBillingAmout().compareTo(contract.getAmount()) == 0 && |
| | | contract.getPaidAmount().compareTo(contract.getAmount().subtract(contract.getDropAmount())) >= 0) { |
| | | contract.getPaidAmount().compareTo(contract.getAmount().subtract(contract.getDropAmount())) >= 0&& |
| | | StrUtil.isBlank(contract.getNextScheduleName())) { |
| | | contract.setBillingStatus("3"); |
| | | contract.setContractStatus(3); |
| | | } |
| | |
| | | }); |
| | | } |
| | | } |
| | | }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"); |
| | |
| | | } |
| | | SysDept comp = r.getData(); |
| | | |
| | | R<SysDept> rDept = remoteDeptService.getById(SecurityUtils.getUser().getDeptId()); |
| | | if (!r.isOk()) { |
| | | log.error("查询部门信息异常"); |
| | | return R.failed("查询部门信息异常"); |
| | | } |
| | | SysDept dept = rDept.getData(); |
| | | // R<SysDept> rDept = remoteDeptService.getById(SecurityUtils.getUser().getDeptId()); |
| | | // if (!r.isOk()) { |
| | | // log.error("查询部门信息异常"); |
| | | // return R.failed("查询部门信息异常"); |
| | | // } |
| | | // SysDept dept = rDept.getData(); |
| | | |
| | | //蓝票 |
| | | if (StrUtil.equals(contractInvoice.getInvoiceCategory(), "1")) { |
| | | JSONObject params = genBlueReceiveParams(contractInvoice, contract, customer, comp, dept); |
| | | JSONObject params = genBlueReceiveParams(contractInvoice, contract, customer, comp); |
| | | String finalAccessToken = accessToken; |
| | | |
| | | log.info("应收发票集成入参:{}", params.toJSONString()); |
| | |
| | | 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(); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public R selectZbByKey(String dictKey) { |
| | | List<BipDict> bipDictList = bipDictMapper.selectList(Wrappers.<BipDict>lambdaQuery().eq(BipDict::getDictKey, dictKey) |
| | | .eq(BipDict::getCompId,SecurityUtils.getUser().getCompId())); |
| | | if (CollUtil.isNotEmpty(bipDictList)) { |
| | | // 权限内部门 |
| | | List<TreeNode<Long>> collect = bipDictList.stream() |
| | | .map(dict -> { |
| | | TreeNode<Long> treeNode = new TreeNode<>(); |
| | | treeNode.setId(dict.getId()); |
| | | treeNode.setParentId(dict.getParentId()); |
| | | treeNode.setName(dict.getDictName()); |
| | | treeNode.setWeight(dict.getDictCode()); |
| | | return treeNode; |
| | | }) |
| | | .collect(Collectors.toList()); |
| | | |
| | | return R.ok(TreeUtil.build(collect, 0L)); |
| | | } |
| | | return R.failed("字典获取失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R saveAndPush(ContractInvoiceUpateDTO upateDTO) { |
| | | ContractInvoice invoice = baseMapper.selectById(upateDTO.getId()); |
| | | invoice.setInvoicePreview(upateDTO.getInvoicePreview()); |
| | |
| | | return bipPushPdf(invoice.getId()); |
| | | } |
| | | |
| | | @Override |
| | | public R updBwParamById(UpdBwParamDTO dto) { |
| | | ContractInvoice invoice = baseMapper.selectById(dto.getId()); |
| | | if (ObjUtil.isNull(invoice)){ |
| | | return R.failed("发票信息异常"); |
| | | } |
| | | invoice.setBwRequestParam(dto.getBwRequestParam()); |
| | | baseMapper.updateById(invoice); |
| | | return R.ok(); |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | File file = new File("d://tmp//" + IdUtil.fastUUID() + ".pdf"); |
| | | HttpUtil.downloadFile("http://fp.baiwang.com/format/d?d=BB99645F8ED2AE7D2055E7D29330D366B7CAE92C278C6BB84D222610CEC2118D", file); |