From cd11bc80579a629e8ab6f9ee9e1cd982f4396408 Mon Sep 17 00:00:00 2001
From: shiyunteng <shiyunteng@example.com>
Date: 星期三, 12 八月 2026 10:02:07 +0800
Subject: [PATCH] feat:银行流水绑定合同问题 出库单据查看 历史当前逾期新增删除去掉 完成开票隐藏开票按钮  出库业务单据文件类型

---
 platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ContractInvoiceServiceImpl.java |   79 ++++++++++++++++++++-------------------
 1 files changed, 40 insertions(+), 39 deletions(-)

diff --git a/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ContractInvoiceServiceImpl.java b/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ContractInvoiceServiceImpl.java
index 9d07ded..d2bb434 100644
--- a/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ContractInvoiceServiceImpl.java
+++ b/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ContractInvoiceServiceImpl.java
@@ -141,7 +141,7 @@
 	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());
@@ -322,10 +322,12 @@
 		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 {
 			//鏇存柊鍚堝悓鎴跨 姘寸數 璐瑰紑绁ㄧ姸鎬�
@@ -616,16 +618,22 @@
 		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");
 
@@ -701,33 +709,18 @@
 			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);
+					contract.setBillingAmout(vo.getTotalPrice().add(contract.getBillingAmout()));
+					if (contract.getBillingAmout().compareTo(contract.getAmount()) == 0) {
+						contract.setBillingStatus("3");
 					}
-				} else {
-					if (ObjUtil.isNull(contract.getBillingAmout())) {
-						contract.setBillingAmout(vo.getTotalPrice());
-						contractMapper.updateById(contract);
-					} else {
-						contract.setBillingAmout(vo.getTotalPrice().add(contract.getBillingAmout()));
-						contractMapper.updateById(contract);
+					if (contract.getBillingAmout().compareTo(contract.getAmount()) < 0) {
+						contract.setBillingStatus("1");
 					}
+					//闃叉閲嶅瀹″紑绁ㄥ鏍搁�氳繃鍚� 寮�绁ㄩ噾棰濊秴鍑哄悎鍚岄噾棰�
+					if (contract.getBillingAmout().compareTo(contract.getAmount())>0){
+						contract.setBillingAmout(contract.getAmount());
+					}
+					contractMapper.updateById(contract);
 				}
 			}else {
 				//鍒ゆ柇 寰幆鏄惁瀹屾垚
@@ -756,10 +749,10 @@
 						contract.setBillingStatus("2");
 					}
 				}
-				if (ObjUtil.isNull(contract.getBillingAmout())) {
-					contract.setBillingAmout(vo.getTotalPrice());
-				} else {
-					contract.setBillingAmout(vo.getTotalPrice().add(contract.getBillingAmout()));
+				contract.setBillingAmout(vo.getTotalPrice().add(contract.getBillingAmout()));
+				//闃叉閲嶅瀹″紑绁ㄥ鏍搁�氳繃鍚� 寮�绁ㄩ噾棰濊秴鍑哄悎鍚岄噾棰�
+				if (contract.getBillingAmout().compareTo(contract.getAmount())>0){
+					contract.setBillingAmout(contract.getAmount());
 				}
 				contractMapper.updateById(contract);
 			}
@@ -796,6 +789,10 @@
 				}
 			}
 			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);
@@ -807,8 +804,10 @@
 				if (ArrayUtil.isNotEmpty(outBoundInvoiceVoList.toArray())) {
 					outBoundInvoiceVoList.stream().forEach(contractOutBoundInvoiceVo -> {
 						ContractOutBound contractOutBound = contractOutBoundMapper.selectById(contractOutBoundInvoiceVo.getContractOutBoundId());
-						contractOutBound.setInvoiceNum(contractOutBound.getInvoiceNum().subtract(contractOutBoundInvoiceVo.getInvoiceNum()));
-						contractOutBoundMapper.updateById(contractOutBound);
+						if (contractOutBoundInvoiceVo.getInvoiceNum().compareTo(contractOutBound.getOutBoundNum().subtract(contractOutBound.getInvoiceNum()))<=0) {
+							contractOutBound.setInvoiceNum(contractOutBound.getInvoiceNum().subtract(contractOutBoundInvoiceVo.getInvoiceNum()));
+							contractOutBoundMapper.updateById(contractOutBound);
+						}
 					});
 				}
 			}else {
@@ -841,8 +840,10 @@
 				if (ArrayUtil.isNotEmpty(outBoundInvoiceVoList.toArray())) {
 					outBoundInvoiceVoList.stream().forEach(contractOutBoundInvoiceVo -> {
 						ContractOutBound contractOutBound = contractOutBoundMapper.selectById(contractOutBoundInvoiceVo.getContractOutBoundId());
-						contractOutBound.setInvoiceNum(contractOutBound.getInvoiceNum().subtract(contractOutBoundInvoiceVo.getInvoiceNum()));
-						contractOutBoundMapper.updateById(contractOutBound);
+						if (contractOutBoundInvoiceVo.getInvoiceNum().compareTo(contractOutBound.getOutBoundNum().subtract(contractOutBound.getInvoiceNum()))<=0) {
+							contractOutBound.setInvoiceNum(contractOutBound.getInvoiceNum().subtract(contractOutBoundInvoiceVo.getInvoiceNum()));
+							contractOutBoundMapper.updateById(contractOutBound);
+						}
 					});
 				}
 			}else {

--
Gitblit v1.9.1