Commit 47381568 by 13420

采购收票bug处理

parent dcc48924
...@@ -254,7 +254,7 @@ public class ServiceHGCW012 extends ServiceBase { ...@@ -254,7 +254,7 @@ public class ServiceHGCW012 extends ServiceBase {
mainId = queryRows.get(0).get("mainId").toString(); mainId = queryRows.get(0).get("mainId").toString();
} }
//获取相应的数据 //获取相应的数据
List<HGCW013> hgcw013List = HGCWTools.HgCw013.mapToList(resultRows, NumberUtils.toLong(mainId)); List<HGCW013> hgcw013List = HGCWTools.HgCw013.mapToeList(resultRows, NumberUtils.toLong(mainId));
DecimalFormat decimalFormat = new DecimalFormat("#.000"); DecimalFormat decimalFormat = new DecimalFormat("#.000");
if (CollectionUtils.isNotEmpty(hgcw013List)) { if (CollectionUtils.isNotEmpty(hgcw013List)) {
if (StringUtils.isEmpty(mainId)) { if (StringUtils.isEmpty(mainId)) {
...@@ -273,8 +273,8 @@ public class ServiceHGCW012 extends ServiceBase { ...@@ -273,8 +273,8 @@ public class ServiceHGCW012 extends ServiceBase {
settlementNumber.append(hgcw013.getSettlementNumber()).append(","); settlementNumber.append(hgcw013.getSettlementNumber()).append(",");
} }
for (Map m : resultRows) { for (Map m : resultRows) {
String c = m.get("settlementNumber").toString(); String c = m.get("receiveNo").toString();
BigDecimal remainingAmount = new BigDecimal(m.get("thisAmount").toString()); BigDecimal remainingAmount = new BigDecimal(m.get("thisSettlementAmount").toString());
rowMap.put(c, remainingAmount); rowMap.put(c, remainingAmount);
totalContractPriceIncluding = totalContractPriceIncluding.add(remainingAmount); totalContractPriceIncluding = totalContractPriceIncluding.add(remainingAmount);
} }
...@@ -283,7 +283,6 @@ public class ServiceHGCW012 extends ServiceBase { ...@@ -283,7 +283,6 @@ public class ServiceHGCW012 extends ServiceBase {
hgcw012.setTaxPoints(hgcw013List.get(0).getTaxPoints()); hgcw012.setTaxPoints(hgcw013List.get(0).getTaxPoints());
hgcw012.setThisSettlementTax(hgcw013List.get(0).getThisSettlementTax()); hgcw012.setThisSettlementTax(hgcw013List.get(0).getThisSettlementTax());
hgcw012.setThisSettlementAmount(hgcw013List.get(0).getThisSettlementAmount()); hgcw012.setThisSettlementAmount(hgcw013List.get(0).getThisSettlementAmount());
hgcw012.setBillNumber(hgcw013List.get(0).getBillNumber());
hgcw012.setSettlementNumber(settlementNumber.toString().substring(0, settlementNumber.length() - 1)); hgcw012.setSettlementNumber(settlementNumber.toString().substring(0, settlementNumber.length() - 1));
hgcw012.setRemainingAmount(new BigDecimal(decimalFormat.format(totalContractPriceIncluding))); hgcw012.setRemainingAmount(new BigDecimal(decimalFormat.format(totalContractPriceIncluding)));
this.add(hgcw012); this.add(hgcw012);
...@@ -292,17 +291,14 @@ public class ServiceHGCW012 extends ServiceBase { ...@@ -292,17 +291,14 @@ public class ServiceHGCW012 extends ServiceBase {
for (HGCW013 hgcw013 : hgcw013List) { for (HGCW013 hgcw013 : hgcw013List) {
hgcw013.setMainId(hgcw012.getId()); hgcw013.setMainId(hgcw012.getId());
hgcw013.setId(null); hgcw013.setId(null);
// 反写金额
HGCWTools.HgCw008.deductionAmount(hgcw013.getSettlementNumber(),rowMap.get(hgcw013.getSettlementNumber()));
DaoUtils.insert(HGCW013.INSERT, hgcw013);
} }
} else { } else {
HGCW012 hgcw012 = HGCWTools.HgCw012.getId(mainId); HGCW012 hgcw012 = HGCWTools.HgCw012.getId(mainId);
Map<String, BigDecimal> rowMap = new HashMap<>(); Map<String, BigDecimal> rowMap = new HashMap<>();
for (Map m : resultRows) { for (Map m : resultRows) {
String c = m.get("settlementNumber").toString(); String c = m.get("receiveNo").toString();
BigDecimal remainingAmount = new BigDecimal(m.get("thisAmount").toString()); BigDecimal remainingAmount = new BigDecimal(m.get("thisSettlementAmount").toString());
rowMap.put(c, remainingAmount); rowMap.put(c, remainingAmount);
} }
// 生成明细表 // 生成明细表
...@@ -323,7 +319,6 @@ public class ServiceHGCW012 extends ServiceBase { ...@@ -323,7 +319,6 @@ public class ServiceHGCW012 extends ServiceBase {
hgcw012.setTaxPoints(hgcw013List.get(0).getTaxPoints()); hgcw012.setTaxPoints(hgcw013List.get(0).getTaxPoints());
hgcw012.setThisSettlementTax(hgcw013List.get(0).getThisSettlementTax()); hgcw012.setThisSettlementTax(hgcw013List.get(0).getThisSettlementTax());
hgcw012.setThisSettlementAmount(hgcw013List.get(0).getThisSettlementAmount()); hgcw012.setThisSettlementAmount(hgcw013List.get(0).getThisSettlementAmount());
hgcw012.setBillNumber(hgcw013List.get(0).getBillNumber());
hgcw012.setSettlementNumber(settlementNumber.toString().substring(0, settlementNumber.length() - 1)); hgcw012.setSettlementNumber(settlementNumber.toString().substring(0, settlementNumber.length() - 1));
this.modify(hgcw012); this.modify(hgcw012);
...@@ -346,7 +341,7 @@ public class ServiceHGCW012 extends ServiceBase { ...@@ -346,7 +341,7 @@ public class ServiceHGCW012 extends ServiceBase {
mainId = queryRows.get(0).get("mainId").toString(); mainId = queryRows.get(0).get("mainId").toString();
} }
//获取相应的数据 //获取相应的数据
List<HGCW013> hgcw013List = HGCWTools.HgCw013.mapToList(resultRows, NumberUtils.toLong(mainId)); List<HGCW013> hgcw013List = HGCWTools.HgCw013.mapTofList(resultRows, NumberUtils.toLong(mainId));
DecimalFormat decimalFormat = new DecimalFormat("#.000"); DecimalFormat decimalFormat = new DecimalFormat("#.000");
if (CollectionUtils.isNotEmpty(hgcw013List)) { if (CollectionUtils.isNotEmpty(hgcw013List)) {
if (StringUtils.isEmpty(mainId)) { if (StringUtils.isEmpty(mainId)) {
...@@ -365,7 +360,7 @@ public class ServiceHGCW012 extends ServiceBase { ...@@ -365,7 +360,7 @@ public class ServiceHGCW012 extends ServiceBase {
settlementNumber.append(hgcw013.getSettlementNumber()).append(","); settlementNumber.append(hgcw013.getSettlementNumber()).append(",");
} }
for (Map m : resultRows) { for (Map m : resultRows) {
String c = m.get("settlementNumber").toString(); String c = m.get("contractNumber").toString();
BigDecimal remainingAmount = new BigDecimal(m.get("thisAmount").toString()); BigDecimal remainingAmount = new BigDecimal(m.get("thisAmount").toString());
rowMap.put(c, remainingAmount); rowMap.put(c, remainingAmount);
totalContractPriceIncluding = totalContractPriceIncluding.add(remainingAmount); totalContractPriceIncluding = totalContractPriceIncluding.add(remainingAmount);
...@@ -390,7 +385,7 @@ public class ServiceHGCW012 extends ServiceBase { ...@@ -390,7 +385,7 @@ public class ServiceHGCW012 extends ServiceBase {
Map<String, BigDecimal> rowMap = new HashMap<>(); Map<String, BigDecimal> rowMap = new HashMap<>();
for (Map m : resultRows) { for (Map m : resultRows) {
String c = m.get("settlementNumber").toString(); String c = m.get("contractNumber").toString();
BigDecimal remainingAmount = new BigDecimal(m.get("thisAmount").toString()); BigDecimal remainingAmount = new BigDecimal(m.get("thisAmount").toString());
rowMap.put(c, remainingAmount); rowMap.put(c, remainingAmount);
} }
......
...@@ -508,7 +508,31 @@ public class HGCWTools { ...@@ -508,7 +508,31 @@ public class HGCWTools {
}); });
return results.get(0); return results.get(0);
} }
public static List<HGCW013> mapTofList(List<Map> rows, Long mainId) {
List<HGCW013> HGCW013List = new ArrayList<>();
if (CollectionUtils.isNotEmpty(rows)) {
rows.forEach(row -> {
HGCW013 HGCW013 = new HGCW013();
HGCW013.fromMap(row);
String settlementNumber = row.get("contractNumber").toString();
String remainingAmount = row.get("thisAmount").toString();
BigDecimal taxPoints = new BigDecimal(row.get("taxPoints").toString()); // 假设这是以整数形式给出的税率,比如17表示17%
BigDecimal thisAmount = new BigDecimal(row.get("thisAmount").toString());
BigDecimal taxRateAsDecimal = taxPoints.divide(new BigDecimal("100")).add(new BigDecimal("1")); // 将税率转换为小数形式
BigDecimal thisSettlementAmount = thisAmount.divide(taxRateAsDecimal, 2, RoundingMode.HALF_UP);
BigDecimal thisSettlementTax = thisAmount.subtract(thisSettlementAmount); // 计算税额
HGCW013.setTotalContractPriceIncluding(new BigDecimal(remainingAmount));
HGCW013.setSettlementNumber(settlementNumber);
HGCW013.setThisSettlementTax(thisSettlementTax.toString());
HGCW013.setThisSettlementAmount(thisSettlementAmount.toString());
if (mainId != null) {
HGCW013.setMainId(mainId);
}
HGCW013List.add(HGCW013);
});
}
return HGCW013List;
}
public static List<HGCW013> mapToList(List<Map> rows, Long mainId) { public static List<HGCW013> mapToList(List<Map> rows, Long mainId) {
List<HGCW013> HGCW013List = new ArrayList<>(); List<HGCW013> HGCW013List = new ArrayList<>();
if (CollectionUtils.isNotEmpty(rows)) { if (CollectionUtils.isNotEmpty(rows)) {
...@@ -535,6 +559,34 @@ public class HGCWTools { ...@@ -535,6 +559,34 @@ public class HGCWTools {
return HGCW013List; return HGCW013List;
} }
public static List<HGCW013> mapToeList(List<Map> rows, Long mainId) {
List<HGCW013> HGCW013List = new ArrayList<>();
if (CollectionUtils.isNotEmpty(rows)) {
rows.forEach(row -> {
HGCW013 HGCW013 = new HGCW013();
HGCW013.fromMap(row);
String settlementNumber = row.get("receiveNo").toString();
String partA = row.get("supName").toString();
String remainingAmount = row.get("thisSettlementAmount").toString();
BigDecimal taxPoints = new BigDecimal("13"); // 假设这是以整数形式给出的税率,比如17表示17%
BigDecimal thisAmount = new BigDecimal(row.get("thisSettlementAmount").toString());
BigDecimal taxRateAsDecimal = taxPoints.divide(new BigDecimal("100")).add(new BigDecimal("1")); // 将税率转换为小数形式
BigDecimal thisSettlementAmount = thisAmount.divide(taxRateAsDecimal, 2, RoundingMode.HALF_UP);
BigDecimal thisSettlementTax = thisAmount.subtract(thisSettlementAmount); // 计算税额
HGCW013.setPartyA(partA);
HGCW013.setTaxPoints(new Integer(String.valueOf(taxPoints)));
HGCW013.setTotalContractPriceIncluding(new BigDecimal(remainingAmount));
HGCW013.setSettlementNumber(settlementNumber);
HGCW013.setThisSettlementTax(thisSettlementTax.toString());
HGCW013.setThisSettlementAmount(thisSettlementAmount.toString());
if (mainId != null) {
HGCW013.setMainId(mainId);
}
HGCW013List.add(HGCW013);
});
}
return HGCW013List;
}
public static List<HGCW013> getMainId(Long mainId) { public static List<HGCW013> getMainId(Long mainId) {
AssertUtils.isNull(mainId, "主表ID不能为空!"); AssertUtils.isNull(mainId, "主表ID不能为空!");
List<HGCW013> results = DaoBase.getInstance().query(HGCW013.QUERY,new HashMap<String,Object>(){ List<HGCW013> results = DaoBase.getInstance().query(HGCW013.QUERY,new HashMap<String,Object>(){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment