|
|
@@ -278,14 +278,30 @@ public class stockbillitems extends Controller {
|
|
|
}
|
|
|
|
|
|
dbConnect.runSqlUpdate(sqlList);
|
|
|
+
|
|
|
+
|
|
|
Rows rowsdetail = dbConnect.runSqlQuery("select amount,qty from st_stockbill_items where st_stockbillid=" + st_stockbillid);
|
|
|
- Rows stockbillrows= dbConnect.runSqlQuery("select paydiscountamount from st_stockbill where st_stockbillid=" + st_stockbillid);
|
|
|
- if(stockbillrows.isNotEmpty()){
|
|
|
- if(stockbillrows.get(0).getBigDecimal("paydiscountamount").compareTo(rowsdetail.sum("amount"))>0){
|
|
|
- dbConnect.runSqlUpdate("update st_stockbill set paydiscountamount="+rowsdetail.sum("amount")+",payamount=0 where st_stockbillid="+st_stockbillid);
|
|
|
+ Rows stockbillrows= dbConnect.runSqlQuery("select t1.sys_enterpriseid,t1.paydiscountamount,t2.depname from st_stockbill t1 left join sys_department t2 on t1.departmentid=t2.departmentid where t1.st_stockbillid=" + st_stockbillid);
|
|
|
+ Rows accountbalancerows = dbConnect.runSqlQuery("select * from sa_accountbalance t1 inner join sa_accountclass t2 on t1.sa_accountclassid=t2.sa_accountclassid and t1.siteid=t2.siteid where t2.accountname='现金账户' and t1.sys_enterpriseid=" + stockbillrows.get(0).getLong("sys_enterpriseid"));
|
|
|
+ String depname= stockbillrows.get(0).getString("depname");
|
|
|
+ BigDecimal payamount=rowsdetail.sum("amount");
|
|
|
+ if(depname.equals("售后部")){
|
|
|
+ if(accountbalancerows.isNotEmpty()){
|
|
|
+ if(accountbalancerows.get(0).getBigDecimal("discountamount").compareTo(BigDecimal.ZERO)>0){
|
|
|
+ if(accountbalancerows.get(0).getBigDecimal("discountamount").compareTo(payamount)>0){
|
|
|
+ dbConnect.runSqlUpdate("update st_stockbill set payamount=0,paydiscountamount="+payamount+" where st_stockbillid="+st_stockbillid);
|
|
|
+ }else{
|
|
|
+ dbConnect.runSqlUpdate("update st_stockbill set payamount="+payamount.subtract(accountbalancerows.get(0).getBigDecimal("discountamount"))+",paydiscountamount="+accountbalancerows.get(0).getBigDecimal("discountamount")+" where st_stockbillid="+st_stockbillid);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ dbConnect.runSqlUpdate("update st_stockbill set payamount="+payamount+",paydiscountamount=0 where st_stockbillid="+st_stockbillid);
|
|
|
+ }
|
|
|
+
|
|
|
}else{
|
|
|
- dbConnect.runSqlUpdate("update st_stockbill set payamount="+rowsdetail.sum("amount")+"-paydiscountamount where st_stockbillid="+st_stockbillid);
|
|
|
+ dbConnect.runSqlUpdate("update st_stockbill set payamount="+payamount+",paydiscountamount=0 where st_stockbillid="+st_stockbillid);
|
|
|
}
|
|
|
+ }else{
|
|
|
+ dbConnect.runSqlUpdate("update st_stockbill set payamount="+payamount+",paydiscountamount=0 where st_stockbillid="+st_stockbillid);
|
|
|
}
|
|
|
return querStcokbillItemsList();
|
|
|
}
|
|
|
@@ -378,14 +394,27 @@ public class stockbillitems extends Controller {
|
|
|
updateRowNo(st_stockbillid);
|
|
|
|
|
|
Rows rowsdetail = dbConnect.runSqlQuery("select amount,qty from st_stockbill_items where st_stockbillid=" + st_stockbillid);
|
|
|
- Rows stockbillrows= dbConnect.runSqlQuery("select paydiscountamount from st_stockbill where st_stockbillid=" + st_stockbillid);
|
|
|
+ Rows stockbillrows= dbConnect.runSqlQuery("select t1.sys_enterpriseid,t1.paydiscountamount,t2.depname from st_stockbill t1 left join sys_department t2 on t1.departmentid=t2.departmentid where t1.st_stockbillid=" + st_stockbillid);
|
|
|
+ Rows accountbalancerows = dbConnect.runSqlQuery("select * from sa_accountbalance t1 inner join sa_accountclass t2 on t1.sa_accountclassid=t2.sa_accountclassid and t1.siteid=t2.siteid where t2.accountname='现金账户' and t1.sys_enterpriseid=" + stockbillrows.get(0).getLong("sys_enterpriseid"));
|
|
|
+ String depname= stockbillrows.get(0).getString("depname");
|
|
|
+ BigDecimal payamount=rowsdetail.sum("amount");
|
|
|
+ if(depname.equals("售后部")){
|
|
|
+ if(accountbalancerows.isNotEmpty()){
|
|
|
+ if(accountbalancerows.get(0).getBigDecimal("discountamount").compareTo(BigDecimal.ZERO)>0){
|
|
|
+ if(accountbalancerows.get(0).getBigDecimal("discountamount").compareTo(payamount)>0){
|
|
|
+ dbConnect.runSqlUpdate("update st_stockbill set payamount=0,paydiscountamount="+payamount+" where st_stockbillid="+st_stockbillid);
|
|
|
+ }else{
|
|
|
+ dbConnect.runSqlUpdate("update st_stockbill set payamount="+payamount.subtract(accountbalancerows.get(0).getBigDecimal("discountamount"))+",paydiscountamount="+accountbalancerows.get(0).getBigDecimal("discountamount")+" where st_stockbillid="+st_stockbillid);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ dbConnect.runSqlUpdate("update st_stockbill set payamount="+payamount+",paydiscountamount=0 where st_stockbillid="+st_stockbillid);
|
|
|
+ }
|
|
|
|
|
|
- if(stockbillrows.isNotEmpty()){
|
|
|
- if(stockbillrows.get(0).getBigDecimal("paydiscountamount").compareTo(rowsdetail.sum("amount"))>0){
|
|
|
- dbConnect.runSqlUpdate("update st_stockbill set paydiscountamount="+rowsdetail.sum("amount")+",payamount=0 where st_stockbillid="+st_stockbillid);
|
|
|
}else{
|
|
|
- dbConnect.runSqlUpdate("update st_stockbill set payamount="+rowsdetail.sum("amount")+"-paydiscountamount where st_stockbillid="+st_stockbillid);
|
|
|
+ dbConnect.runSqlUpdate("update st_stockbill set payamount="+payamount+",paydiscountamount=0 where st_stockbillid="+st_stockbillid);
|
|
|
}
|
|
|
+ }else{
|
|
|
+ dbConnect.runSqlUpdate("update st_stockbill set payamount="+payamount+",paydiscountamount=0 where st_stockbillid="+st_stockbillid);
|
|
|
}
|
|
|
|
|
|
return batchDeleteErr.getReturnObject().toString();
|