优化收付款相关接口,支持退款单修改退款金额
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
package com.jsh.erp.service.supplier;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.jsh.erp.constants.BusinessConstants;
|
||||
import com.jsh.erp.constants.ExceptionConstants;
|
||||
import com.jsh.erp.datasource.entities.*;
|
||||
import com.jsh.erp.datasource.mappers.*;
|
||||
import com.jsh.erp.datasource.vo.DepotHeadVo4StatementAccount;
|
||||
import com.jsh.erp.exception.BusinessRunTimeException;
|
||||
import com.jsh.erp.exception.JshException;
|
||||
import com.jsh.erp.service.accountHead.AccountHeadService;
|
||||
@@ -17,6 +17,7 @@ import com.jsh.erp.service.userBusiness.UserBusinessService;
|
||||
import com.jsh.erp.utils.BaseResponseInfo;
|
||||
import com.jsh.erp.utils.ExcelUtils;
|
||||
import com.jsh.erp.utils.StringUtil;
|
||||
import com.jsh.erp.utils.Tools;
|
||||
import jxl.Sheet;
|
||||
import jxl.Workbook;
|
||||
import org.slf4j.Logger;
|
||||
@@ -33,7 +34,6 @@ import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
import static com.jsh.erp.utils.Tools.getNow3;
|
||||
|
||||
@Service
|
||||
public class SupplierService {
|
||||
@@ -104,24 +104,45 @@ public class SupplierService {
|
||||
List<Supplier> list = supplierMapperEx.selectByConditionSupplier(supplier, type, phonenum, telephone, offset, rows);
|
||||
for(Supplier s : list) {
|
||||
Integer supplierId = s.getId().intValue();
|
||||
String endTime = getNow3();
|
||||
String supType = s.getType();
|
||||
String beginTime = Tools.getYearBegin();
|
||||
String endTime = Tools.getCenternTime(new Date());
|
||||
BigDecimal sum = BigDecimal.ZERO;
|
||||
BigDecimal beginNeedGet = s.getBeginNeedGet();
|
||||
if(beginNeedGet==null) {
|
||||
beginNeedGet = BigDecimal.ZERO;
|
||||
String supplierType = type;
|
||||
String inOutType = "";
|
||||
String subType = "";
|
||||
String typeBack = "";
|
||||
String subTypeBack = "";
|
||||
String billType = "";
|
||||
if (("供应商").equals(supplierType)) {
|
||||
inOutType = "入库";
|
||||
subType = "采购";
|
||||
typeBack = "出库";
|
||||
subTypeBack = "采购退货";
|
||||
billType = "付款";
|
||||
} else if (("客户").equals(supplierType)) {
|
||||
inOutType = "出库";
|
||||
subType = "销售";
|
||||
typeBack = "入库";
|
||||
subTypeBack = "销售退货";
|
||||
billType = "收款";
|
||||
}
|
||||
BigDecimal beginNeedPay = s.getBeginNeedPay();
|
||||
if(beginNeedPay==null) {
|
||||
beginNeedPay = BigDecimal.ZERO;
|
||||
List<DepotHeadVo4StatementAccount> saList = depotHeadService.getStatementAccount(beginTime, endTime, supplierId, null,
|
||||
supplierType, inOutType, subType, typeBack, subTypeBack, billType, null, null);
|
||||
if(saList.size()>0) {
|
||||
DepotHeadVo4StatementAccount item = saList.get(0);
|
||||
//期初 = 起始期初金额+上期欠款金额-上期退货的欠款金额-上期收付款
|
||||
BigDecimal preNeed = item.getBeginNeed().add(item.getPreDebtMoney()).subtract(item.getPreReturnDebtMoney()).subtract(item.getPreBackMoney());
|
||||
item.setPreNeed(preNeed);
|
||||
//实际欠款 = 本期欠款-本期退货的欠款金额
|
||||
BigDecimal realDebtMoney = item.getDebtMoney().subtract(item.getReturnDebtMoney());
|
||||
item.setDebtMoney(realDebtMoney);
|
||||
//期末 = 期初+实际欠款-本期收款
|
||||
BigDecimal allNeedGet = preNeed.add(realDebtMoney).subtract(item.getBackMoney());
|
||||
sum = sum.add(allNeedGet);
|
||||
}
|
||||
sum = sum.add(depotHeadService.findTotalPay(supplierId, endTime, supType))
|
||||
.subtract(accountHeadService.findTotalPay(supplierId, endTime, supType));
|
||||
if(("客户").equals(s.getType())) {
|
||||
sum = sum.add(beginNeedGet);
|
||||
s.setAllNeedGet(sum);
|
||||
} else if(("供应商").equals(s.getType())) {
|
||||
sum = sum.add(beginNeedPay);
|
||||
s.setAllNeedPay(sum);
|
||||
}
|
||||
resList.add(s);
|
||||
@@ -602,24 +623,46 @@ public class SupplierService {
|
||||
if (null != dataList) {
|
||||
for (Supplier s : dataList) {
|
||||
Integer supplierId = s.getId().intValue();
|
||||
String endTime = getNow3();
|
||||
String supType = s.getType();
|
||||
|
||||
String beginTime = Tools.getYearBegin();
|
||||
String endTime = Tools.getCenternTime(new Date());
|
||||
BigDecimal sum = BigDecimal.ZERO;
|
||||
BigDecimal beginNeedGet = s.getBeginNeedGet();
|
||||
if(beginNeedGet==null) {
|
||||
beginNeedGet = BigDecimal.ZERO;
|
||||
String supplierType = type;
|
||||
String inOutType = "";
|
||||
String subType = "";
|
||||
String typeBack = "";
|
||||
String subTypeBack = "";
|
||||
String billType = "";
|
||||
if (("供应商").equals(supplierType)) {
|
||||
inOutType = "入库";
|
||||
subType = "采购";
|
||||
typeBack = "出库";
|
||||
subTypeBack = "采购退货";
|
||||
billType = "付款";
|
||||
} else if (("客户").equals(supplierType)) {
|
||||
inOutType = "出库";
|
||||
subType = "销售";
|
||||
typeBack = "入库";
|
||||
subTypeBack = "销售退货";
|
||||
billType = "收款";
|
||||
}
|
||||
BigDecimal beginNeedPay = s.getBeginNeedPay();
|
||||
if(beginNeedPay==null) {
|
||||
beginNeedPay = BigDecimal.ZERO;
|
||||
List<DepotHeadVo4StatementAccount> saList = depotHeadService.getStatementAccount(beginTime, endTime, supplierId, null,
|
||||
supplierType, inOutType, subType, typeBack, subTypeBack, billType, null, null);
|
||||
if(saList.size()>0) {
|
||||
DepotHeadVo4StatementAccount item = saList.get(0);
|
||||
//期初 = 起始期初金额+上期欠款金额-上期退货的欠款金额-上期收付款
|
||||
BigDecimal preNeed = item.getBeginNeed().add(item.getPreDebtMoney()).subtract(item.getPreReturnDebtMoney()).subtract(item.getPreBackMoney());
|
||||
item.setPreNeed(preNeed);
|
||||
//实际欠款 = 本期欠款-本期退货的欠款金额
|
||||
BigDecimal realDebtMoney = item.getDebtMoney().subtract(item.getReturnDebtMoney());
|
||||
item.setDebtMoney(realDebtMoney);
|
||||
//期末 = 期初+实际欠款-本期收款
|
||||
BigDecimal allNeedGet = preNeed.add(realDebtMoney).subtract(item.getBackMoney());
|
||||
sum = sum.add(allNeedGet);
|
||||
}
|
||||
sum = sum.add(depotHeadService.findTotalPay(supplierId, endTime, supType))
|
||||
.subtract(accountHeadService.findTotalPay(supplierId, endTime, supType));
|
||||
if(("客户").equals(s.getType())) {
|
||||
sum = sum.add(beginNeedGet);
|
||||
s.setAllNeedGet(sum);
|
||||
} else if(("供应商").equals(s.getType())) {
|
||||
sum = sum.add(beginNeedPay);
|
||||
s.setAllNeedPay(sum);
|
||||
}
|
||||
String[] objs = new String[20];
|
||||
|
||||
Reference in New Issue
Block a user