优化对账单接口,扣除退货单的欠款金额
This commit is contained in:
@@ -302,36 +302,44 @@ public class DepotHeadController {
|
||||
try {
|
||||
String type = "";
|
||||
String subType = "";
|
||||
String typeBack = "";
|
||||
String subTypeBack = "";
|
||||
if (("供应商").equals(supplierType)) {
|
||||
type = "入库";
|
||||
subType = "采购";
|
||||
typeBack = "出库";
|
||||
subTypeBack = "采购退货";
|
||||
} else if (("客户").equals(supplierType)) {
|
||||
type = "出库";
|
||||
subType = "销售";
|
||||
typeBack = "入库";
|
||||
subTypeBack = "销售退货";
|
||||
}
|
||||
String [] organArray = depotHeadService.getOrganArray(subType, "");
|
||||
beginTime = Tools.parseDayToTime(beginTime,BusinessConstants.DAY_FIRST_TIME);
|
||||
endTime = Tools.parseDayToTime(endTime,BusinessConstants.DAY_LAST_TIME);
|
||||
List<DepotHeadVo4StatementAccount> list = depotHeadService.getStatementAccount(beginTime, endTime, organId, organArray,
|
||||
supplierType, type, subType, (currentPage-1)*pageSize, pageSize);
|
||||
supplierType, type, subType,typeBack, subTypeBack, (currentPage-1)*pageSize, pageSize);
|
||||
int total = depotHeadService.getStatementAccountCount(beginTime, endTime, organId, organArray,
|
||||
supplierType, type, subType);
|
||||
supplierType, type, subType,typeBack, subTypeBack);
|
||||
for(DepotHeadVo4StatementAccount item: list) {
|
||||
BigDecimal preNeed = item.getBeginNeed().add(item.getPreDebtMoney()).subtract(item.getPreBackMoney());
|
||||
BigDecimal preNeed = item.getBeginNeed().add(item.getPreDebtMoney()).subtract(item.getPreReturnDebtMoney()).subtract(item.getPreBackMoney());
|
||||
item.setPreNeed(preNeed);
|
||||
BigDecimal allNeedGet = preNeed.add(item.getDebtMoney()).subtract(item.getBackMoney());
|
||||
BigDecimal realDebtMoney = item.getDebtMoney().subtract(item.getReturnDebtMoney());
|
||||
item.setDebtMoney(realDebtMoney);
|
||||
BigDecimal allNeedGet = preNeed.add(realDebtMoney).subtract(item.getBackMoney());
|
||||
item.setAllNeed(allNeedGet);
|
||||
}
|
||||
map.put("rows", list);
|
||||
map.put("total", total);
|
||||
List<DepotHeadVo4StatementAccount> totalPayList = depotHeadService.getStatementAccountTotalPay(beginTime, endTime, organId, organArray, supplierType, type, subType);
|
||||
List<DepotHeadVo4StatementAccount> totalPayList = depotHeadService.getStatementAccountTotalPay(beginTime, endTime, organId, organArray, supplierType, type, subType, typeBack, subTypeBack);
|
||||
if(totalPayList.size()>0) {
|
||||
DepotHeadVo4StatementAccount totalPayItem = totalPayList.get(0);
|
||||
BigDecimal firstMoney = BigDecimal.ZERO;
|
||||
BigDecimal lastMoney = BigDecimal.ZERO;
|
||||
if(totalPayItem!=null) {
|
||||
firstMoney = totalPayItem.getBeginNeed().add(totalPayItem.getPreDebtMoney()).subtract(totalPayItem.getPreBackMoney());
|
||||
lastMoney = firstMoney.add(totalPayItem.getDebtMoney()).subtract(totalPayItem.getBackMoney());
|
||||
firstMoney = totalPayItem.getBeginNeed().add(totalPayItem.getPreDebtMoney()).subtract(totalPayItem.getPreReturnDebtMoney()).subtract(totalPayItem.getPreBackMoney());
|
||||
lastMoney = firstMoney.add(totalPayItem.getDebtMoney()).subtract(totalPayItem.getReturnDebtMoney()).subtract(totalPayItem.getBackMoney());
|
||||
}
|
||||
map.put("firstMoney", firstMoney); //期初
|
||||
map.put("lastMoney", lastMoney); //期末
|
||||
|
||||
@@ -146,6 +146,8 @@ public interface DepotHeadMapperEx {
|
||||
@Param("supplierType") String supplierType,
|
||||
@Param("type") String type,
|
||||
@Param("subType") String subType,
|
||||
@Param("typeBack") String typeBack,
|
||||
@Param("subTypeBack") String subTypeBack,
|
||||
@Param("offset") Integer offset,
|
||||
@Param("rows") Integer rows);
|
||||
|
||||
@@ -156,7 +158,9 @@ public interface DepotHeadMapperEx {
|
||||
@Param("organArray") String[] organArray,
|
||||
@Param("supplierType") String supplierType,
|
||||
@Param("type") String type,
|
||||
@Param("subType") String subType);
|
||||
@Param("subType") String subType,
|
||||
@Param("typeBack") String typeBack,
|
||||
@Param("subTypeBack") String subTypeBack);
|
||||
|
||||
List<DepotHeadVo4StatementAccount> getStatementAccountTotalPay(
|
||||
@Param("beginTime") String beginTime,
|
||||
@@ -165,7 +169,9 @@ public interface DepotHeadMapperEx {
|
||||
@Param("organArray") String[] organArray,
|
||||
@Param("supplierType") String supplierType,
|
||||
@Param("type") String type,
|
||||
@Param("subType") String subType);
|
||||
@Param("subType") String subType,
|
||||
@Param("typeBack") String typeBack,
|
||||
@Param("subTypeBack") String subTypeBack);
|
||||
|
||||
BigDecimal findAllMoney(
|
||||
@Param("supplierId") Integer supplierId,
|
||||
|
||||
@@ -17,18 +17,50 @@ public class DepotHeadVo4StatementAccount {
|
||||
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 起始期初金额
|
||||
*/
|
||||
private BigDecimal beginNeed;
|
||||
|
||||
/**
|
||||
* 上期欠款金额
|
||||
*/
|
||||
private BigDecimal preDebtMoney;
|
||||
|
||||
/**
|
||||
* 上期退货的欠款金额
|
||||
*/
|
||||
private BigDecimal preReturnDebtMoney;
|
||||
|
||||
|
||||
/**
|
||||
* 上期收付款
|
||||
*/
|
||||
private BigDecimal preBackMoney;
|
||||
|
||||
/**
|
||||
* 期初应收
|
||||
*/
|
||||
private BigDecimal preNeed;
|
||||
|
||||
/**
|
||||
* 本期欠款
|
||||
*/
|
||||
private BigDecimal debtMoney;
|
||||
|
||||
/**
|
||||
* 本期退货的欠款金额
|
||||
*/
|
||||
private BigDecimal returnDebtMoney;
|
||||
|
||||
/**
|
||||
* 本期收款
|
||||
*/
|
||||
private BigDecimal backMoney;
|
||||
|
||||
/**
|
||||
* 期末应收
|
||||
*/
|
||||
private BigDecimal allNeed;
|
||||
|
||||
public Long getId() {
|
||||
@@ -95,6 +127,14 @@ public class DepotHeadVo4StatementAccount {
|
||||
this.preDebtMoney = preDebtMoney;
|
||||
}
|
||||
|
||||
public BigDecimal getPreReturnDebtMoney() {
|
||||
return preReturnDebtMoney;
|
||||
}
|
||||
|
||||
public void setPreReturnDebtMoney(BigDecimal preReturnDebtMoney) {
|
||||
this.preReturnDebtMoney = preReturnDebtMoney;
|
||||
}
|
||||
|
||||
public BigDecimal getPreBackMoney() {
|
||||
return preBackMoney;
|
||||
}
|
||||
@@ -119,6 +159,14 @@ public class DepotHeadVo4StatementAccount {
|
||||
this.debtMoney = debtMoney;
|
||||
}
|
||||
|
||||
public BigDecimal getReturnDebtMoney() {
|
||||
return returnDebtMoney;
|
||||
}
|
||||
|
||||
public void setReturnDebtMoney(BigDecimal returnDebtMoney) {
|
||||
this.returnDebtMoney = returnDebtMoney;
|
||||
}
|
||||
|
||||
public BigDecimal getBackMoney() {
|
||||
return backMoney;
|
||||
}
|
||||
|
||||
@@ -603,10 +603,10 @@ public class DepotHeadService {
|
||||
}
|
||||
|
||||
public List<DepotHeadVo4StatementAccount> getStatementAccount(String beginTime, String endTime, Integer organId, String [] organArray,
|
||||
String supplierType, String type, String subType, Integer offset, Integer rows) {
|
||||
String supplierType, String type, String subType, String typeBack, String subTypeBack, Integer offset, Integer rows) {
|
||||
List<DepotHeadVo4StatementAccount> list = null;
|
||||
try{
|
||||
list = depotHeadMapperEx.getStatementAccount(beginTime, endTime, organId, organArray, supplierType, type, subType, offset, rows);
|
||||
list = depotHeadMapperEx.getStatementAccount(beginTime, endTime, organId, organArray, supplierType, type, subType,typeBack, subTypeBack, offset, rows);
|
||||
} catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
@@ -614,10 +614,10 @@ public class DepotHeadService {
|
||||
}
|
||||
|
||||
public int getStatementAccountCount(String beginTime, String endTime, Integer organId,
|
||||
String [] organArray, String supplierType, String type, String subType) {
|
||||
String [] organArray, String supplierType, String type, String subType, String typeBack, String subTypeBack) {
|
||||
int result = 0;
|
||||
try{
|
||||
result = depotHeadMapperEx.getStatementAccountCount(beginTime, endTime, organId, organArray, supplierType, type, subType);
|
||||
result = depotHeadMapperEx.getStatementAccountCount(beginTime, endTime, organId, organArray, supplierType, type, subType,typeBack, subTypeBack);
|
||||
} catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
@@ -626,10 +626,10 @@ public class DepotHeadService {
|
||||
|
||||
public List<DepotHeadVo4StatementAccount> getStatementAccountTotalPay(String beginTime, String endTime, Integer organId,
|
||||
String [] organArray, String supplierType,
|
||||
String type, String subType) {
|
||||
String type, String subType, String typeBack, String subTypeBack) {
|
||||
List<DepotHeadVo4StatementAccount> list = null;
|
||||
try{
|
||||
list = depotHeadMapperEx.getStatementAccountTotalPay(beginTime, endTime, organId, organArray, supplierType, type, subType);
|
||||
list = depotHeadMapperEx.getStatementAccountTotalPay(beginTime, endTime, organId, organArray, supplierType, type, subType,typeBack, subTypeBack);
|
||||
} catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user