| | |
| | | private GenInvoiceInfoVo genInvoiceInfoVo(GenInvoiceInfoDTO genInvoiceInfoDTO, Contract contract, SysDept b) { |
| | | GenInvoiceInfoVo vo = new GenInvoiceInfoVo(); |
| | | BusinessCustomer a = businessCustomerMapper.selectById(contract.getPartyAId()); |
| | | vo.setPartyA(a.getRegisterName()); |
| | | vo.setPartyA(a.getCompanyName()); |
| | | vo.setPartyAOrgCode(a.getCreditCode()); |
| | | vo.setPartyAOpenBank(a.getBankName()); |
| | | vo.setPartyABankAccount(a.getBankAccount()); |
| | |
| | | if (!StrUtil.equals(contract.getContractCategory(),"water_house")) { |
| | | //更新合同出库单状态 |
| | | genInvoiceInfoDTO.getOutBoundInvoiceList().stream().forEach(contractOutBoundInvoiceVo -> { |
| | | ContractOutBound bound = contractOutBoundMapper.selectById(contractOutBoundInvoiceVo.getContractOutBoundId()); |
| | | bound.setInvoiceStatus("1"); |
| | | bound.setInvoiceNum(bound.getInvoiceNum().add(contractOutBoundInvoiceVo.getInvoiceNum())); |
| | | contractOutBoundMapper.updateById(bound); |
| | | ContractOutBound contractOutBound = contractOutBoundMapper.selectById(contractOutBoundInvoiceVo.getContractOutBoundId()); |
| | | contractOutBound.setInvoiceStatus("1"); |
| | | if (contractOutBoundInvoiceVo.getInvoiceNum().compareTo(contractOutBound.getOutBoundNum().subtract(contractOutBound.getInvoiceNum()))<=0) { |
| | | contractOutBound.setInvoiceNum(contractOutBound.getInvoiceNum().subtract(contractOutBoundInvoiceVo.getInvoiceNum())); |
| | | } |
| | | contractOutBoundMapper.updateById(contractOutBound); |
| | | }); |
| | | }else { |
| | | //更新合同房租 水电 费开票状态 |
| | |
| | | data.put("billDate",DateUtil.format(contractInvoice.getInvoiceTime(),DatePattern.NORM_DATETIME_FORMAT)); |
| | | data.put("objectType","1"); |
| | | data.put("exchangeRate","1"); |
| | | data.put("exchangeRate",DateUtil.now()); |
| | | data.put("exchangeRateDate",DateUtil.now()); |
| | | data.put("_status","Insert"); |
| | | GenInvoiceInfoVo vo = BeanUtil.copyProperties(JSONObject.parseObject(contractInvoice.getInvoicePreview()), GenInvoiceInfoVo.class); |
| | | JSONArray bodyItem = new JSONArray(); |
| | | for (InvoiceItemVo invoiceItemVo : vo.getInvoiceItemList()) { |
| | | JSONObject item = new JSONObject(); |
| | | |
| | | JSONObject freeCh = new JSONObject(); |
| | | freeCh.put("JT32",""); |
| | | item.put("freeChId",freeCh); |
| | | |
| | | item.put("invoiceNo",contractInvoice.getInvoiceNo()); |
| | | item.put("materialCode",invoiceItemVo.getErpCode()); |
| | | item.put("taxRate", invoiceItemVo.getTaxRate()); |
| | | item.put("oriTaxAmount", invoiceItemVo.getPriceTax()); |
| | | item.put("oriTaxExcludedAmount", invoiceItemVo.getPriceNoTax()); |
| | | item.put("oriTaxIncludedAmount", invoiceItemVo.getUnitPrice().multiply(invoiceItemVo.getQuantity())); |
| | | item.put("_status","Insert"); |
| | | |
| | |
| | | if (!StrUtil.equals(contract.getContractCategory(),"water_house")) { |
| | | //合同状态 |
| | | if (StrUtil.equals(contract.getBillingStatus(), "2")) { |
| | | if (ObjUtil.isNull(contract.getBillingAmout())) { |
| | | contract.setBillingAmout(vo.getTotalPrice()); |
| | | if (contract.getBillingAmout().compareTo(contract.getAmount()) == 0) { |
| | | contract.setBillingStatus("3"); |
| | | } |
| | | if (contract.getBillingAmout().compareTo(contract.getAmount()) < 0) { |
| | | contract.setBillingStatus("1"); |
| | | } |
| | | contractMapper.updateById(contract); |
| | | } else { |
| | | contract.setBillingAmout(vo.getTotalPrice().add(contract.getBillingAmout())); |
| | | if (contract.getBillingAmout().compareTo(contract.getAmount()) == 0) { |
| | | contract.setBillingStatus("3"); |
| | |
| | | if (contract.getBillingAmout().compareTo(contract.getAmount()) < 0) { |
| | | contract.setBillingStatus("1"); |
| | | } |
| | | contractMapper.updateById(contract); |
| | | //防止重复审开票审核通过后 开票金额超出合同金额 |
| | | if (contract.getBillingAmout().compareTo(contract.getAmount())>0){ |
| | | contract.setBillingAmout(contract.getAmount()); |
| | | } |
| | | } else { |
| | | if (ObjUtil.isNull(contract.getBillingAmout())) { |
| | | contract.setBillingAmout(vo.getTotalPrice()); |
| | | contractMapper.updateById(contract); |
| | | } else { |
| | | contract.setBillingAmout(vo.getTotalPrice().add(contract.getBillingAmout())); |
| | | contractMapper.updateById(contract); |
| | | } |
| | | } |
| | | }else { |
| | | //判断 循环是否完成 |
| | |
| | | contract.setBillingStatus("2"); |
| | | } |
| | | } |
| | | if (ObjUtil.isNull(contract.getBillingAmout())) { |
| | | contract.setBillingAmout(vo.getTotalPrice()); |
| | | } else { |
| | | contract.setBillingAmout(vo.getTotalPrice().add(contract.getBillingAmout())); |
| | | //防止重复审开票审核通过后 开票金额超出合同金额 |
| | | if (contract.getBillingAmout().compareTo(contract.getAmount())>0){ |
| | | contract.setBillingAmout(contract.getAmount()); |
| | | } |
| | | contractMapper.updateById(contract); |
| | | } |
| | |
| | | } |
| | | } |
| | | contract.setBillingAmout(contract.getBillingAmout().subtract(invoice.getInvoiceTotalPriceTax())); |
| | | //防止重复审开票审核通过后 开票金额为负 |
| | | if (contract.getBillingAmout().compareTo(new BigDecimal("0"))<0){ |
| | | contract.setBillingAmout(new BigDecimal("0")); |
| | | } |
| | | //更新合同开票状态 前提出库完成 |
| | | contract.setBillingStatus("2"); |
| | | contractMapper.updateById(contract); |
| | |
| | | if (ArrayUtil.isNotEmpty(outBoundInvoiceVoList.toArray())) { |
| | | outBoundInvoiceVoList.stream().forEach(contractOutBoundInvoiceVo -> { |
| | | ContractOutBound contractOutBound = contractOutBoundMapper.selectById(contractOutBoundInvoiceVo.getContractOutBoundId()); |
| | | if (contractOutBoundInvoiceVo.getInvoiceNum().compareTo(contractOutBound.getOutBoundNum().subtract(contractOutBound.getInvoiceNum()))<=0) { |
| | | contractOutBound.setInvoiceNum(contractOutBound.getInvoiceNum().subtract(contractOutBoundInvoiceVo.getInvoiceNum())); |
| | | contractOutBoundMapper.updateById(contractOutBound); |
| | | } |
| | | }); |
| | | } |
| | | }else { |
| | |
| | | if (ArrayUtil.isNotEmpty(outBoundInvoiceVoList.toArray())) { |
| | | outBoundInvoiceVoList.stream().forEach(contractOutBoundInvoiceVo -> { |
| | | ContractOutBound contractOutBound = contractOutBoundMapper.selectById(contractOutBoundInvoiceVo.getContractOutBoundId()); |
| | | if (contractOutBoundInvoiceVo.getInvoiceNum().compareTo(contractOutBound.getOutBoundNum().subtract(contractOutBound.getInvoiceNum()))<=0) { |
| | | contractOutBound.setInvoiceNum(contractOutBound.getInvoiceNum().subtract(contractOutBoundInvoiceVo.getInvoiceNum())); |
| | | contractOutBoundMapper.updateById(contractOutBound); |
| | | } |
| | | }); |
| | | } |
| | | }else { |