Browse Source

发票添加部分收款功能

user5 2 years ago
parent
commit
007be55dde

+ 6 - 0
src/main/java/com/jeeplus/modules/workinvoice/dao/WorkInvoiceDao.java

@@ -66,6 +66,12 @@ public interface WorkInvoiceDao extends CrudDao<WorkInvoice> {
 	void receiptMoney(WorkInvoice workInvoice);
 
 	/**
+	 * 财务部分收款操作
+	 * @param workInvoice
+	 */
+	void updateInvoiceReceipt(WorkInvoice workInvoice);
+
+	/**
 	 * 撤回财务确认收款操作
 	 * @param workInvoice
 	 */

+ 27 - 0
src/main/java/com/jeeplus/modules/workinvoice/entity/WorkInvoice.java

@@ -103,6 +103,9 @@ public class WorkInvoice extends ActEntity<WorkInvoice> {
 	private String newDrawerName;    	//开票人名称
 	private String actualDrawerId;    		//实际开票人id
 	private String actualDrawerName;    	//实际开票人名称
+	private String proceedsMoney;    	//收款总收入
+	private String noProceedsMoney;    	//剩余应收款费用
+	private Integer workReceiptCount;    	//收款数据量
 	@Override
 	@ExcelField(title="经办人", fieldType=User.class, value="createBy.name", align=2, sort=7)
 	public User getCreateBy() {
@@ -717,4 +720,28 @@ public class WorkInvoice extends ActEntity<WorkInvoice> {
 	public void setActualDrawerName(String actualDrawerName) {
 		this.actualDrawerName = actualDrawerName;
 	}
+
+	public String getProceedsMoney() {
+		return proceedsMoney;
+	}
+
+	public void setProceedsMoney(String proceedsMoney) {
+		this.proceedsMoney = proceedsMoney;
+	}
+
+	public String getNoProceedsMoney() {
+		return noProceedsMoney;
+	}
+
+	public void setNoProceedsMoney(String noProceedsMoney) {
+		this.noProceedsMoney = noProceedsMoney;
+	}
+
+	public Integer getWorkReceiptCount() {
+		return workReceiptCount;
+	}
+
+	public void setWorkReceiptCount(Integer workReceiptCount) {
+		this.workReceiptCount = workReceiptCount;
+	}
 }

+ 15 - 1
src/main/java/com/jeeplus/modules/workinvoice/service/WorkInvoiceAllService.java

@@ -219,7 +219,8 @@ public class WorkInvoiceAllService extends CrudService<WorkInvoiceDao, WorkInvoi
 		page.setCount(count);
 		page.setCountFlag(false);
 		workInvoice.setPage(page);
-		page.setList(dao.findListNew(workInvoice));
+		List<WorkInvoice> list = dao.findListNew(workInvoice);
+		page.setList(list);
 		return page;
 
 	}
@@ -504,6 +505,19 @@ public class WorkInvoiceAllService extends CrudService<WorkInvoiceDao, WorkInvoi
 					workInvoiceReceiptDao.delete(receiptInfo);
 				}
 			}
+
+			//查询收款信息
+			WorkInvoiceReceipt erceipt = new WorkInvoiceReceipt();
+			erceipt.setInvoiceId(workInvoice.getId());
+			List<WorkInvoiceReceipt> receiptList = workInvoiceReceiptDao.findList(erceipt);
+			if(null != receiptList && receiptList.size()>0){
+				workInvoice.setReceiptMoney("2");
+				workInvoiceDao.updateInvoiceReceipt(workInvoice);
+			}else{
+				workInvoice.setReceiptMoney("0");
+				workInvoiceDao.updateInvoiceReceipt(workInvoice);
+			}
+
 		}
 	}
 	/**

+ 29 - 0
src/main/java/com/jeeplus/modules/workinvoice/web/WorkInvoiceAllController.java

@@ -40,6 +40,7 @@ import com.jeeplus.modules.workclientinfo.service.WorkClientInfoService;
 import com.jeeplus.modules.workcontractinfo.entity.WorkContractInfo;
 import com.jeeplus.modules.workcontractinfo.service.WorkContractInfoService;
 import com.jeeplus.modules.workinvoice.entity.WorkInvoice;
+import com.jeeplus.modules.workinvoice.entity.WorkInvoiceReceipt;
 import com.jeeplus.modules.workinvoice.service.WorkInvoiceAllService;
 import com.jeeplus.modules.workinvoice.service.WorkInvoiceService;
 import com.jeeplus.modules.workinvoicealter.entity.WorkInvoiceAlter;
@@ -67,6 +68,7 @@ import javax.servlet.http.HttpServletResponse;
 import javax.validation.ConstraintViolationException;
 import java.io.UnsupportedEncodingException;
 import java.lang.reflect.InvocationTargetException;
+import java.math.BigDecimal;
 import java.net.URLDecoder;
 import java.util.*;
 
@@ -354,6 +356,24 @@ public class WorkInvoiceAllController extends BaseController {
 			//workInvoice.setInvoiceNumber( (int)((Math.random()*9+1)*100000));
 			workInvoice.setInvoiceDate(new Date());
 		}
+
+		if(null != workInvoice.getWorkReceiptList() && workInvoice.getWorkReceiptList().size()>0){
+			BigDecimal moneyAll = new BigDecimal(0);
+			for (WorkInvoiceReceipt info: workInvoice.getWorkReceiptList()) {
+				if(null != info.getMoney()){
+					moneyAll = moneyAll.add(new BigDecimal(info.getMoney()));
+				}
+			}
+			workInvoice.setProceedsMoney(moneyAll.toString());
+
+			if(null != workInvoice.getMoney() && null != moneyAll){
+				BigDecimal money = new BigDecimal(workInvoice.getMoney());
+				BigDecimal noProceedsMoney = money.subtract(moneyAll);
+				workInvoice.setNoProceedsMoney(noProceedsMoney.toString());
+			}
+
+		}
+
 		model.addAttribute("workInvoice", workInvoice);
 		return "modules/workinvoice/" + view;
 	}
@@ -362,6 +382,15 @@ public class WorkInvoiceAllController extends BaseController {
 	 */
 	@RequestMapping(value = "receiptForm")
 	public String receiptForm(WorkInvoice workInvoice, Model model) {
+		if(null != workInvoice.getWorkReceiptList() && workInvoice.getWorkReceiptList().size()>0){
+			BigDecimal moneyAll = new BigDecimal(0);
+			for (WorkInvoiceReceipt info: workInvoice.getWorkReceiptList()) {
+				if(null != info.getMoney()){
+					moneyAll = moneyAll.add(new BigDecimal(info.getMoney()));
+				}
+			}
+			workInvoice.setProceedsMoney(moneyAll.toString());
+		}
 		model.addAttribute("workInvoice", workInvoice);
 		return "modules/workinvoice/workInvoiceAllReceiptForm";
 	}

+ 9 - 3
src/main/resources/mappings/modules/workinvoice/WorkInvoiceDao.xml

@@ -60,7 +60,7 @@
 		prd.number as "project.reportData.number",
 		p.area_name as "project.county",
 		a.receipt_money_date as "receiptMoneyDate",
-		(case when a.receipt_money = '0' then '否' when a.receipt_money = '1' then '是' else '否' end) as receiptMoney,
+		(case when a.receipt_money = '0' then '否' when a.receipt_money = '1' then '是' when a.receipt_money = '2' then '部分收款' else '否' end) as receiptMoney,
 		a.cancellation_remark as "cancellationRemark",
 		a.account_checking_user_id as "accountCheckingUserId",
 		a.area_id as "area.id",
@@ -127,7 +127,7 @@
 		a.billing_content as "billingContent",
 		p.area_name as "project.county",
 		a.receipt_money_date as "receiptMoneyDate",
-		(case when a.receipt_money = '0' then '否' when a.receipt_money = '1' then '是' else '否' end) as receiptMoney,
+		(case when a.receipt_money = '0' then '否' when a.receipt_money = '1' then '是' when a.receipt_money = '2' then '部分收款' else '否' end) as receiptMoney,
 		a.cancellation_remark as "cancellationRemark",
 		a.account_checking_user_id as "accountCheckingUserId",
 		a.area_id as "area.id",
@@ -214,7 +214,7 @@
 		prd.number as "projectReportDataNumber",
 		p.area_name as "projectCounty",
 		a.receipt_money_date as "receiptMoneyDate",
-		(case when a.receipt_money = '0' then '否' when a.receipt_money = '1' then '是' else '否' end) as receiptMoney,
+		(case when a.receipt_money = '0' then '否' when a.receipt_money = '1' then '是' when a.receipt_money = '2' then '部分收款' else '否' end) as receiptMoney,
 		a.cancellation_remark as "cancellationRemark",
 		a.account_checking_user_id as "accountCheckingUserId",
 		a.area_id as "areaId",
@@ -1648,6 +1648,12 @@
 		WHERE id = #{id}
 	</update>
 
+	<update id="updateInvoiceReceipt">
+		UPDATE work_invoice SET
+			receipt_money = #{receiptMoney}
+		WHERE id = #{id}
+	</update>
+
 	<update id="cancelReceiptMoney">
 		UPDATE work_invoice SET
 			update_by = #{updateBy.id},

+ 10 - 2
src/main/webapp/webpage/modules/workinvoice/workInvoiceAllList.jsp

@@ -539,6 +539,7 @@
 								<select id="receiptMoney" name="receiptMoney" class="form-control simple-select">
 									<option value=""></option>
 									<option value="0" <c:if test="${workInvoiceShow.receiptMoney=='0'}">selected</c:if>>否</option>
+									<option value="2" <c:if test="${workInvoiceShow.receiptMoney=='2'}">selected</c:if>>部分收款</option>
 									<option value="1" <c:if test="${workInvoiceShow.receiptMoney=='1'}">selected</c:if>>是</option>
 								</select>
 							</div>
@@ -680,7 +681,14 @@
 
 				,{field:'invoiceDate',align:'center', sort:true,title: '开票日期',  width:90}
 				,{field:'receiptMoneyDate',align:'center', sort:true,title: '收款日期',  width:90}
-				,{field:'receiptMoney',align:'center', title: '是否收款',  width:80}
+				,{field:'receiptMoney',align:'center', title: '是否收款',  width:80,templet:function(d){
+						if("部分收款" === d.receiptMoney || "是" === d.receiptMoney)
+							var xml = "<a class=\"status-label status-label-signed\" title=\""+ d.invoiceNum +"\"href=\"javascript:void(0);\" onclick=\"openDialogListView('查看发票管理', '${ctx}/workinvoiceAll/workInvoiceAll/form?id=" + d.id + "&tabId=1','"+ d.id +"','95%', '95%')\">" + d.receiptMoney + "</a>";
+
+						else
+							var xml = "<span style=\"cursor:default;\" class=\"status-label status-label-" + d.receiptMoney + "\" >" + d.receiptMoney + "</span>";
+						return xml;
+					}}
 				,{field:'cancellation',align:'center', title: '是否作废',  width:80}
                 ,{align:'center', title: '状态', fixed: 'right', width:70,templet:function(d){
                         <%--var st = getAuditState(d.status);--%>
@@ -817,7 +825,7 @@
 					<shiro:hasPermission name="workinvoice:workInvoice:receipt">
 						,"financeFlag":
 							<c:choose>
-								<c:when test="${workInvoice.invoiceState == 5 && workInvoice.receiptMoney == '否'}">"1"</c:when>
+								<c:when test="${workInvoice.invoiceState == 5 && workInvoice.receiptMoney != '是'}">"1"</c:when>
 								<c:otherwise>"0"</c:otherwise>
 						</c:choose>
 						,"moneyReceiptFlag":

+ 89 - 2
src/main/webapp/webpage/modules/workinvoice/workInvoiceAllReceiptForm.jsp

@@ -110,6 +110,23 @@
 				}
 			});
 
+			//方法一使用id选择器进行计算。
+			//获取输入的数字
+			//自动计算出结果并填充在相应的输入框中
+			var proceedsMoney = '${workInvoice.proceedsMoney}'
+			if(null == proceedsMoney || undefined == proceedsMoney || '' == proceedsMoney){
+				proceedsMoney = "0.00"
+			}
+			$("#proceedsMoneys").val(parseFloat(proceedsMoney).toFixed(2));
+
+			// 计算剩余应收款金额
+			// 获取开票金额
+			var money = '${workInvoice.money}'
+			var noProceedsMoneys = (parseFloat(money) - parseFloat(proceedsMoney)).toFixed(2);
+
+			$("#noProceedsMoneys").val(noProceedsMoneys);
+
+
 			laydate.render({
 				elem: '#receiptDate', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎,因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
 				event: 'focus', //响应事件。如果没有传入event,则按照默认的click
@@ -189,6 +206,51 @@
 			}
 
 		}
+
+		function isNumber(val){
+			if(val === "" || val ==null){
+				return false;
+			}
+			var regPos = /^\d+(\.\d+)?$/; //非负浮点数
+			var regNeg = /^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$/; //负浮点数
+			if(regPos.test(val) || regNeg.test(val)){
+				return true;
+			}else{
+				return false;
+			}
+		}
+
+		function getProceedsMoneys(value){
+
+			var proceedsMoneys = "0.00";
+			//方法一使用id选择器进行计算。
+			//获取输入的数字
+			//自动计算出结果并填充在相应的输入框中
+			var size = $("#workReceiptList tr").length;
+			for (var i = 0;i<size;i++){
+				var workReceiptMoney = $("#workReceiptList"+i+"_money").val();
+				var delFlag = $("#workReceiptList"+i+"_delFlag").val();
+				if (workReceiptMoney!=undefined && isNumber(workReceiptMoney) && delFlag==0){
+					if(proceedsMoneys==""){
+						proceedsMoneys = parseFloat(workReceiptMoney).toFixed(2);
+					}else {
+						proceedsMoneys = (parseFloat(proceedsMoneys) + parseFloat(workReceiptMoney)).toFixed(2);
+					}
+				}
+			}
+			$("#proceedsMoneys").val(proceedsMoneys);
+
+			// 计算剩余应收款金额
+			// 获取开票金额
+			var money = '${workInvoice.money}'
+			console.log(parseFloat(money))
+			console.log(parseFloat(proceedsMoneys))
+			console.log(parseFloat(money) - parseFloat(proceedsMoneys))
+			var noProceedsMoneys = (parseFloat(money) - parseFloat(proceedsMoneys)).toFixed(2);
+
+			$("#noProceedsMoneys").val(noProceedsMoneys);
+
+		}
 	</script>
 </head>
 <body >
@@ -540,10 +602,11 @@
 						   onclick="addRow('#workReceiptList', workClientBankRowIdx, workClientBankTpl);workClientBankRowIdx = workClientBankRowIdx + 1;"
 						   title="新增"><i class="fa fa-plus"></i> 新增</a>
 					</div>
-					<table id="receiptTable" class="table table-bordered table-condensed details">
+					<table id="receiptTable" class="table table-bordered table-condensed details" style="margin-bottom: 0px">
 						<thead>
 						<tr>
 							<th><span class="require-item">*</span>汇款单位</th>
+
 							<th><span class="require-item">*</span>汇款金额</th>
 							<th width="160px"><span class="require-item">*</span>汇款时间</th>
 							<th width="100px">操作</th>
@@ -552,6 +615,30 @@
 						<tbody id="workReceiptList">
 						</tbody>
 					</table>
+					<table id="proceedsMoneysTable" class="table table-bordered table-condensed can-edit no-bottom-margin details">
+						<thead>
+						<tr style="border: 0px">
+							<td style="vertical-align:middle;text-align: center;"><label><font color="red">*</font>总收款费用(元):</label></td>
+							<td style="border: 0px">
+								<input htmlEscape="false" style="border: 0px; vertical-align:middle;text-align: center; font-weight: bold;" id="proceedsMoneys" name="proceedsMoneys" readonly="true" class="form-control layui-input" value="${workInvoice.proceedsMoney}"/>
+							</td>
+							<td width="160px"></td>
+							<td width="100px"></td>
+						</tr>
+						</thead>
+					</table>
+					<table id="noProceedsMoneysTable" class="table table-bordered table-condensed can-edit no-bottom-margin details">
+						<thead>
+						<tr style="border: 0px">
+							<td style="vertical-align:middle;text-align: center;"><label><font color="red">*</font>剩余应收款费用(元):</label></td>
+							<td style="border: 0px">
+								<input htmlEscape="false" style="border: 0px; vertical-align:middle;text-align: center; font-weight: bold;" id="noProceedsMoneys" name="noProceedsMoneys" readonly="true" class="form-control layui-input" value=""/>
+							</td>
+							<td width="160px"></td>
+							<td width="100px"></td>
+						</tr>
+						</thead>
+					</table>
 					<script type="text/template" id="workClientBankTpl">//<!--
                                 <tr id="workReceiptList{{idx}}">
                                     <td class="hide">
@@ -562,7 +649,7 @@
                                         <input id="workReceiptList{{idx}}_companyName" placeholder="请输入汇款单位" name="workReceiptList[{{idx}}].companyName" value="{{row.companyName}}" style="text-align: center" class="form-control judgment "/>
                                     </td>
                                     <td>
-                                        <input id="workReceiptList{{idx}}_money" name="workReceiptList[{{idx}}].money" placeholder="请输入汇款金额" value="{{row.money}}" style="text-align: center" class="form-control number judgment"/>
+                                        <input id="workReceiptList{{idx}}_money" name="workReceiptList[{{idx}}].money" placeholder="请输入汇款金额" value="{{row.money}}" onchange="getProceedsMoneys(this.value)" style="text-align: center" class="form-control number judgment"/>
                                     </td>
 
                                     <td>

+ 24 - 1
src/main/webapp/webpage/modules/workinvoice/workInvoiceView.jsp

@@ -419,7 +419,7 @@
 			<div class="form-group layui-row">
 			<div class="form-group-label"><h2>收款明细</h2></div>
 			<div class="layui-item layui-col-xs12 form-table-container">
-				<table id="receiptTable" class="table table-bordered table-condensed details">
+				<table id="receiptTable" class="table table-bordered table-condensed details" style="margin-bottom: 0px">
 					<thead>
 					<tr>
 						<th><span class="require-item">*</span>汇款单位</th>
@@ -446,6 +446,29 @@
 					</c:if>
 					</tbody>
 				</table>
+				<table id="proceedsMoneysTable" class="table table-bordered table-condensed can-edit no-bottom-margin details">
+					<thead>
+					<tr style="border: 0px">
+						<td style="vertical-align:middle;text-align: center;"><label><font color="red">*</font>总收款费用(元):</label></td>
+						<td style="border: 0px;vertical-align:middle;text-align: center;">
+								${workInvoice.proceedsMoney}
+						</td>
+						<td width="160px"></td>
+					</tr>
+					</thead>
+				</table>
+				<table id="noProceedsMoneysTable" class="table table-bordered table-condensed can-edit no-bottom-margin details">
+					<thead>
+					<tr style="border: 0px">
+						<td style="vertical-align:middle;text-align: center;"><label><font color="red">*</font>剩余应收款费用(元):</label></td>
+						<td style="border: 0px;vertical-align:middle;text-align: center;">
+								${workInvoice.noProceedsMoney}
+						</td>
+						<td width="160px"></td>
+					</tr>
+					</thead>
+				</table>
+
 			</div>
 		</div>
 			<div class="form-group layui-row page-end"></div>