|
|
@@ -138,7 +138,7 @@ public class XSCK extends BasicBill {
|
|
|
String order_paymentnode = Parameter.getString(siteid, "order_paymentnode");
|
|
|
if (rb == 1) {
|
|
|
if (order_paymentnode.equals("3")) {
|
|
|
- CashbillEntity entity = getCashbillEntity(billRow.getString("billdate"),billRow.getBigDecimal("payamount"), billRow.getBigDecimal("paydiscountamount"), st_stockbillid, "销售出库单审核", billno, "由销售出库单" + billno + "审核时生成", "货款");
|
|
|
+ CashbillEntity entity = getCashbillEntity(billRow.getString("billdate"), billRow.getBigDecimal("payamount"), billRow.getBigDecimal("paydiscountamount"), st_stockbillid, "销售出库单审核", billno, "由销售出库单" + billno + "审核时生成", "货款");
|
|
|
JSONObject createCashbillPay = Accountbalance.createCashbillPay(dbConnect, userInfo, sys_enterpriseid, accountbalancerows.get(0).getLong("sa_accountclassid"), entity, true);
|
|
|
if (!(billRow.getBigDecimal("payamount").compareTo(BigDecimal.ZERO) == 0 && billRow.getBigDecimal("paydiscountamount").compareTo(BigDecimal.ZERO) == 0)) {
|
|
|
sqlList.addAll(createCashbillPay.getJSONArray("sqlList").toJavaList(String.class));
|
|
|
@@ -146,7 +146,7 @@ public class XSCK extends BasicBill {
|
|
|
}
|
|
|
Rows rowsDispatchDetailGroup = dbConnect.runSqlQuery("select sum(t1.qty) qty,t1.sa_orderitemsid,t1.siteid from st_stockbill_items t1 where t1.sa_orderitemsid>0 and t1.st_stockbillid=" + st_stockbillid + " group by t1.sa_orderitemsid,t1.siteid");
|
|
|
for (Row row : rowsDispatchDetailGroup) {
|
|
|
- sqlList.add("update sa_orderitems set undeliqty=undeliqty-" + row.getDouble("qty") + ",deliedqty=ifnull(deliedqty,0)+" + row.getDouble("qty") + ",offstatus=if(billingstatus='保内收费','待核销','不可核销'),offdate=CURRENT_TIME where sa_orderitemsid=" + row.getLong("sa_orderitemsid"));
|
|
|
+ sqlList.add("update sa_orderitems set undeliqty=ifnull(undeliqty,0)-" + row.getDouble("qty") + ",deliedqty=ifnull(deliedqty,0)+" + row.getDouble("qty") + ",offstatus=if(billingstatus='保内收费','待核销','不可核销'),offdate=CURRENT_TIME where sa_orderitemsid=" + row.getLong("sa_orderitemsid"));
|
|
|
sqlList.add("update sa_orderitems set tobeoffqty=case when tobeoffqty+" + row.getDouble("qty") + ">canoffqty then canoffqty else tobeoffqty+" + row.getDouble("qty") + " end where canoffqty>0 and sa_orderitemsid=" + row.getLong("sa_orderitemsid"));
|
|
|
|
|
|
}
|
|
|
@@ -195,7 +195,7 @@ public class XSCK extends BasicBill {
|
|
|
}
|
|
|
} else {
|
|
|
if (order_paymentnode.equals("3")) {
|
|
|
- CashbillEntity entity = getCashbillEntity(billRow.getString("billdate"),billRow.getBigDecimal("payamount").negate(), billRow.getBigDecimal("paydiscountamount").negate(), st_stockbillid, "销售出库单审核", billno, "由销售出库单" + billno + "审核时生成", "货款");
|
|
|
+ CashbillEntity entity = getCashbillEntity(billRow.getString("billdate"), billRow.getBigDecimal("payamount").negate(), billRow.getBigDecimal("paydiscountamount").negate(), st_stockbillid, "销售出库单审核", billno, "由销售出库单" + billno + "审核时生成", "货款");
|
|
|
JSONObject createCashbillPay = Accountbalance.createCashbillPay(dbConnect, userInfo, sys_enterpriseid, accountbalancerows.get(0).getLong("sa_accountclassid"), entity, true);
|
|
|
if (!(billRow.getBigDecimal("payamount").compareTo(BigDecimal.ZERO) == 0 && billRow.getBigDecimal("paydiscountamount").compareTo(BigDecimal.ZERO) == 0)) {
|
|
|
sqlList.addAll(createCashbillPay.getJSONArray("sqlList").toJavaList(String.class));
|
|
|
@@ -203,11 +203,9 @@ public class XSCK extends BasicBill {
|
|
|
|
|
|
}
|
|
|
if (!billRow.getString("sourceobject").equals("tpartreimbursement")) {
|
|
|
- Rows rowsOrderDetail = dbConnect.runSqlQuery("select t1.undeliqty,t1.deliedqty,t1.qty,t1.sa_orderitemsid from sa_orderitems t1 where t1.sa_orderitemsid in (select sa_orderitemsid from st_stockbill_items where sa_orderitemsid>0 and st_stockbillid=" + st_stockbillid + ")");
|
|
|
- RowsMap rowsMap = rowsOrderDetail.toRowsMap("sa_orderitemsid");
|
|
|
Rows rowsDispatchDetailGroup = dbConnect.runSqlQuery("select sum(t1.qty) qty,t1.sa_orderitemsid,t1.siteid from st_stockbill_items t1 where t1.sa_orderitemsid>0 and t1.st_stockbillid=" + st_stockbillid + " group by t1.sa_orderitemsid,t1.siteid");
|
|
|
for (Row row : rowsDispatchDetailGroup) {
|
|
|
- sqlList.add("update sa_orderitems set undeliqty=" + rowsMap.get(row.getLong("sa_orderitemsid")).get(0).getBigDecimal("undeliqty").add(row.getBigDecimal("qty")) + ",deliedqty=" + (rowsMap.get(row.getLong("sa_orderitemsid")).get(0).getBigDecimal("deliedqty").subtract(row.getBigDecimal("qty"))) + " where sa_orderitemsid=" + row.getLong("sa_orderitemsid"));
|
|
|
+ sqlList.add("update sa_orderitems set undeliqty=ifnull(undeliqty,0)+" + row.getDouble("qty") + ",deliedqty=ifnull(deliedqty,0)-" + row.getDouble("qty") + " where sa_orderitemsid=" + row.getLong("sa_orderitemsid"));
|
|
|
|
|
|
sqlList.add("update sa_orderitems set tobeoffqty=case when tobeoffqty-" + row.getDouble("qty") + ">0 then tobeoffqty-" + row.getDouble("qty") + " else 0 end where canoffqty>0 and sa_orderitemsid=" + row.getLong("sa_orderitemsid"));
|
|
|
}
|
|
|
@@ -260,17 +258,15 @@ public class XSCK extends BasicBill {
|
|
|
if (rb == 1) {
|
|
|
if (order_paymentnode.equals("3")) {
|
|
|
Rows cashbillRows = dbConnect.runSqlQuery("select amount,discountamount from sa_cashbill where ownerid=" + st_stockbillid + " and ownertable='st_stockbill' and type=0 and class='货款'");
|
|
|
- CashbillEntity entity = getCashbillEntity(billRow.getString("billdate"),cashbillRows.sum("amount").negate(), cashbillRows.sum("discountamount").negate(), st_stockbillid, "销售出库单反审核", billno, "由销售出库单" + billno + "反审核时生成", "货款");
|
|
|
+ CashbillEntity entity = getCashbillEntity(billRow.getString("billdate"), cashbillRows.sum("amount").negate(), cashbillRows.sum("discountamount").negate(), st_stockbillid, "销售出库单反审核", billno, "由销售出库单" + billno + "反审核时生成", "货款");
|
|
|
JSONObject createCashbillPay = Accountbalance.createCashbillPay(dbConnect, userInfo, sys_enterpriseid, accountbalancerows.get(0).getLong("sa_accountclassid"), entity, true);
|
|
|
if (!(cashbillRows.sum("amount").negate().compareTo(BigDecimal.ZERO) == 0 && cashbillRows.sum("discountamount").negate().compareTo(BigDecimal.ZERO) == 0)) {
|
|
|
sqlList.addAll(createCashbillPay.getJSONArray("sqlList").toJavaList(String.class));
|
|
|
}
|
|
|
}
|
|
|
- Rows rowsOrderDetail = dbConnect.runSqlQuery("select t1.undeliqty,t1.deliedqty,t1.qty,t1.sa_orderitemsid from sa_orderitems t1 where t1.sa_orderitemsid in (select sa_orderitemsid from st_stockbill_items where sa_orderitemsid>0 and st_stockbillid=" + st_stockbillid + ")");
|
|
|
- RowsMap rowsMap = rowsOrderDetail.toRowsMap("sa_orderitemsid");
|
|
|
Rows rowsDispatchDetailGroup = dbConnect.runSqlQuery("select sum(t1.qty) qty,t1.sa_orderitemsid,t1.siteid from st_stockbill_items t1 where t1.sa_orderitemsid>0 and t1.st_stockbillid=" + st_stockbillid + " group by t1.sa_orderitemsid,t1.siteid");
|
|
|
for (Row row : rowsDispatchDetailGroup) {
|
|
|
- sqlList.add("update sa_orderitems set undeliqty=" + rowsMap.get(row.getLong("sa_orderitemsid")).get(0).getBigDecimal("undeliqty").add(row.getBigDecimal("qty")) + ",deliedqty=" + (rowsMap.get(row.getLong("sa_orderitemsid")).get(0).getBigDecimal("deliedqty").subtract(row.getBigDecimal("qty"))) + " where sa_orderitemsid=" + row.getLong("sa_orderitemsid"));
|
|
|
+ sqlList.add("update sa_orderitems set undeliqty=ifnull(undeliqty,0)+" + row.getDouble("qty") + ",deliedqty=ifnull(deliedqty,0)-" + row.getDouble("qty") + " where sa_orderitemsid=" + row.getLong("sa_orderitemsid"));
|
|
|
|
|
|
sqlList.add("update sa_orderitems set tobeoffqty=case when tobeoffqty-" + row.getDouble("qty") + ">0 then tobeoffqty-" + row.getDouble("qty") + " else 0 end where canoffqty>0 and sa_orderitemsid=" + row.getLong("sa_orderitemsid"));
|
|
|
}
|
|
|
@@ -291,7 +287,7 @@ public class XSCK extends BasicBill {
|
|
|
} else {
|
|
|
if (order_paymentnode.equals("3")) {
|
|
|
Rows cashbillRows = dbConnect.runSqlQuery("select amount,discountamount from sa_cashbill where ownerid=" + st_stockbillid + " and ownertable='st_stockbill' and type=0 and class='货款'");
|
|
|
- CashbillEntity entity = getCashbillEntity(billRow.getString("billdate"),cashbillRows.sum("amount").negate(), cashbillRows.sum("discountamount").negate(), st_stockbillid, "销售出库单反审核", billno, "由销售出库单" + billno + "反审核时生成", "货款");
|
|
|
+ CashbillEntity entity = getCashbillEntity(billRow.getString("billdate"), cashbillRows.sum("amount").negate(), cashbillRows.sum("discountamount").negate(), st_stockbillid, "销售出库单反审核", billno, "由销售出库单" + billno + "反审核时生成", "货款");
|
|
|
JSONObject createCashbillPay = Accountbalance.createCashbillPay(dbConnect, userInfo, sys_enterpriseid, accountbalancerows.get(0).getLong("sa_accountclassid"), entity, true);
|
|
|
if (!(cashbillRows.sum("amount").negate().compareTo(BigDecimal.ZERO) == 0 && cashbillRows.sum("discountamount").negate().compareTo(BigDecimal.ZERO) == 0)) {
|
|
|
sqlList.addAll(createCashbillPay.getJSONArray("sqlList").toJavaList(String.class));
|
|
|
@@ -395,7 +391,7 @@ public class XSCK extends BasicBill {
|
|
|
custamount = custamount.add(row.getBigDecimal("custamount").multiply(row.getBigDecimal("qty")));
|
|
|
}
|
|
|
|
|
|
- CashbillEntity entity_custamount = getCashbillEntity(billRow.getString("billdate"),custamount, BigDecimal.ZERO, st_stockbillid, "销售出库单审核", billno, "由销售出库单" + billno + "审核时生成", "客户档案资料费");
|
|
|
+ CashbillEntity entity_custamount = getCashbillEntity(billRow.getString("billdate"), custamount, BigDecimal.ZERO, st_stockbillid, "销售出库单审核", billno, "由销售出库单" + billno + "审核时生成", "客户档案资料费");
|
|
|
JSONObject createCashbillPay_custamount = Accountbalance.createCashbillPay(dbConnect, userInfo, sys_enterpriseid, accountbalancerows.get(0).getLong("sa_accountclassid"), entity_custamount, true);
|
|
|
if (custamount.compareTo(BigDecimal.ZERO) != 0) {
|
|
|
sqlList.addAll(createCashbillPay_custamount.getJSONArray("sqlList").toJavaList(String.class));
|
|
|
@@ -409,7 +405,7 @@ public class XSCK extends BasicBill {
|
|
|
for (Row row : itemRows) {
|
|
|
custamount = custamount.add(row.getBigDecimal("custamount").multiply(row.getBigDecimal("qty")));
|
|
|
}
|
|
|
- CashbillEntity entity_custamount = getCashbillEntity(billRow.getString("billdate"),custamount.negate(), BigDecimal.ZERO, st_stockbillid, "销售出库单审核", billno, "由销售出库单" + billno + "审核时生成", "客户档案资料费");
|
|
|
+ CashbillEntity entity_custamount = getCashbillEntity(billRow.getString("billdate"), custamount.negate(), BigDecimal.ZERO, st_stockbillid, "销售出库单审核", billno, "由销售出库单" + billno + "审核时生成", "客户档案资料费");
|
|
|
JSONObject createCashbillPay_custamount = Accountbalance.createCashbillPay(dbConnect, userInfo, sys_enterpriseid, accountbalancerows.get(0).getLong("sa_accountclassid"), entity_custamount, true);
|
|
|
if (custamount.negate().compareTo(BigDecimal.ZERO) != 0) {
|
|
|
sqlList.addAll(createCashbillPay_custamount.getJSONArray("sqlList").toJavaList(String.class));
|
|
|
@@ -422,7 +418,7 @@ public class XSCK extends BasicBill {
|
|
|
if (rb == 1) {
|
|
|
if (order_paymentnode.equals("3")) {
|
|
|
Rows cashbillRows_custamount = dbConnect.runSqlQuery("select amount,discountamount from sa_cashbill where ownerid=" + st_stockbillid + " and ownertable='st_stockbill' and type=0 and class='客户档案资料费'");
|
|
|
- CashbillEntity entity_custamount = getCashbillEntity(billRow.getString("billdate"),cashbillRows_custamount.sum("amount").negate(), cashbillRows_custamount.sum("discountamount").negate(), st_stockbillid, "销售出库单反审核", billno, "由销售出库单" + billno + "反审核时生成", "客户档案资料费");
|
|
|
+ CashbillEntity entity_custamount = getCashbillEntity(billRow.getString("billdate"), cashbillRows_custamount.sum("amount").negate(), cashbillRows_custamount.sum("discountamount").negate(), st_stockbillid, "销售出库单反审核", billno, "由销售出库单" + billno + "反审核时生成", "客户档案资料费");
|
|
|
JSONObject createCashbillPay_custamount = Accountbalance.createCashbillPay(dbConnect, userInfo, sys_enterpriseid, accountbalancerows.get(0).getLong("sa_accountclassid"), entity_custamount, true);
|
|
|
if (cashbillRows_custamount.sum("amount").negate().compareTo(BigDecimal.ZERO) != 0) {
|
|
|
sqlList.addAll(createCashbillPay_custamount.getJSONArray("sqlList").toJavaList(String.class));
|
|
|
@@ -431,7 +427,7 @@ public class XSCK extends BasicBill {
|
|
|
} else {
|
|
|
if (order_paymentnode.equals("3")) {
|
|
|
Rows cashbillRows_custamount = dbConnect.runSqlQuery("select amount,discountamount from sa_cashbill where ownerid=" + st_stockbillid + " and ownertable='st_stockbill' and type=0 and class='客户档案资料费'");
|
|
|
- CashbillEntity entity_custamount = getCashbillEntity(billRow.getString("billdate"),cashbillRows_custamount.sum("amount").negate(), cashbillRows_custamount.sum("discountamount").negate(), st_stockbillid, "销售出库单审核", billno, "由销售出库单" + billno + "审核时生成", "客户档案资料费");
|
|
|
+ CashbillEntity entity_custamount = getCashbillEntity(billRow.getString("billdate"), cashbillRows_custamount.sum("amount").negate(), cashbillRows_custamount.sum("discountamount").negate(), st_stockbillid, "销售出库单审核", billno, "由销售出库单" + billno + "审核时生成", "客户档案资料费");
|
|
|
JSONObject createCashbillPay_custamount = Accountbalance.createCashbillPay(dbConnect, userInfo, sys_enterpriseid, accountbalancerows.get(0).getLong("sa_accountclassid"), entity_custamount, true);
|
|
|
if (cashbillRows_custamount.sum("amount").negate().compareTo(BigDecimal.ZERO) != 0) {
|
|
|
sqlList.addAll(createCashbillPay_custamount.getJSONArray("sqlList").toJavaList(String.class));
|