|
@@ -30,6 +30,7 @@ import org.slf4j.LoggerFactory;
|
|
|
|
|
|
import java.io.Serializable;
|
|
import java.io.Serializable;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
+import java.math.RoundingMode;
|
|
import java.text.ParseException;
|
|
import java.text.ParseException;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@@ -179,13 +180,20 @@ public class ContractbillApiPlugin implements Serializable {
|
|
|
|
|
|
|
|
|
|
JSONArray fukuanplanAry = (JSONArray) billData.get("fukuanplan");
|
|
JSONArray fukuanplanAry = (JSONArray) billData.get("fukuanplan");
|
|
|
|
+ if(fukuanplanAry.size() > 1) {
|
|
|
|
+ result.setMessage("付款计划只能传一条记录");
|
|
|
|
+ result.setStatus(false);
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
String entityNumber = "er_contractbill";
|
|
String entityNumber = "er_contractbill";
|
|
QFilter qFilter = new QFilter("contractcode", QCP.equals,fcontractcode);
|
|
QFilter qFilter = new QFilter("contractcode", QCP.equals,fcontractcode);
|
|
DynamicObject dynamicObject = null;
|
|
DynamicObject dynamicObject = null;
|
|
|
|
+ boolean isnew = true;
|
|
if(QueryServiceHelper.exists(entityNumber,new QFilter[]{qFilter})){
|
|
if(QueryServiceHelper.exists(entityNumber,new QFilter[]{qFilter})){
|
|
|
|
|
|
|
|
+ isnew = false;
|
|
dynamicObject = BusinessDataServiceHelper.loadSingle(entityNumber,new QFilter[]{qFilter});
|
|
dynamicObject = BusinessDataServiceHelper.loadSingle(entityNumber,new QFilter[]{qFilter});
|
|
String contractcodenewhistory = dynamicObject.getString("nckd_contractcodenew");
|
|
String contractcodenewhistory = dynamicObject.getString("nckd_contractcodenew");
|
|
if (!StringUtils.isEmpty(nckd_contractcodenew)) {
|
|
if (!StringUtils.isEmpty(nckd_contractcodenew)) {
|
|
@@ -355,8 +363,13 @@ public class ContractbillApiPlugin implements Serializable {
|
|
|
|
|
|
|
|
|
|
DynamicObjectCollection plannewColl = dynamicObject.getDynamicObjectCollection("expenseentryentity");
|
|
DynamicObjectCollection plannewColl = dynamicObject.getDynamicObjectCollection("expenseentryentity");
|
|
- plannewColl.clear();
|
|
+
|
|
- BigDecimal hetongjinetotalfist = new BigDecimal(0);
|
|
+ BigDecimal hetongjinetotalfist = new BigDecimal(0);
|
|
|
|
+ BigDecimal hetongjinetotalfistBen = new BigDecimal(0);
|
|
|
|
+ BigDecimal yifutotal = new BigDecimal(0);
|
|
|
|
+ BigDecimal yifutotalBen = new BigDecimal(0);
|
|
|
|
+ BigDecimal yibaoxiaototal = new BigDecimal(0);
|
|
|
|
+ BigDecimal yibaoxiaototalBen = new BigDecimal(0);
|
|
for (Object item : fukuanplanAry) {
|
|
for (Object item : fukuanplanAry) {
|
|
JSONObject jsb = (JSONObject)item;
|
|
JSONObject jsb = (JSONObject)item;
|
|
String fpayterms = jsb.getString("payterms");
|
|
String fpayterms = jsb.getString("payterms");
|
|
@@ -371,8 +384,51 @@ public class ContractbillApiPlugin implements Serializable {
|
|
result.setStatus(false);
|
|
result.setStatus(false);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
+ BigDecimal fexpapplyamountBen =fexpapplyamount.multiply(huilv).setScale(2, RoundingMode.HALF_UP);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ DynamicObject newEntry3 = null;
|
|
|
|
+ if (isnew) {
|
|
|
|
+
|
|
|
|
+ newEntry3 = new DynamicObject(plannewColl.getDynamicObjectType());
|
|
|
|
+ newEntry3.set("reimbursedamount",0);
|
|
|
|
+ newEntry3.set("reimbursedcurramount",0);
|
|
|
|
+ newEntry3.set("oriexppayedamount",0);
|
|
|
|
+ newEntry3.set("exppayedamount",0);
|
|
|
|
+ newEntry3.set("oriexpnotpayamount",fexpapplyamount);
|
|
|
|
+ newEntry3.set("expnotpayamount",fexpapplyamountBen);
|
|
|
|
+ newEntry3.set("canloanamount",fexpapplyamount);
|
|
|
|
+ newEntry3.set("canloancurramount",fexpapplyamountBen);
|
|
|
|
+ newEntry3.set("orgiexpebalanceamount",fexpapplyamount);
|
|
|
|
+ newEntry3.set("expebalanceamount",fexpapplyamountBen);
|
|
|
|
+ } else {
|
|
|
|
+
|
|
|
|
+ newEntry3 = plannewColl.get(0);
|
|
|
|
+
|
|
|
|
+ newEntry3.set("oriexpnotpayamount",fexpapplyamount.subtract(newEntry3.getBigDecimal("oriexppayedamount")));
|
|
|
|
+ newEntry3.set("expnotpayamount",fexpapplyamountBen.subtract(newEntry3.getBigDecimal("exppayedamount")));
|
|
|
|
+
|
|
|
|
+ newEntry3.set("canloanamount",fexpapplyamount.subtract(newEntry3.getBigDecimal("oriexppayedamount")));
|
|
|
|
+ newEntry3.set("canloancurramount",fexpapplyamountBen.subtract(newEntry3.getBigDecimal("exppayedamount")));
|
|
|
|
+
|
|
|
|
+ newEntry3.set("orgiexpebalanceamount",fexpapplyamount.subtract(newEntry3.getBigDecimal("reimbursedamount")));
|
|
|
|
+ newEntry3.set("expebalanceamount",fexpapplyamountBen.subtract(newEntry3.getBigDecimal("reimbursedcurramount")));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ yifutotal = yifutotal.add(newEntry3.getBigDecimal("oriexppayedamount"));
|
|
|
|
+ yifutotalBen = yifutotalBen.add(newEntry3.getBigDecimal("exppayedamount"));
|
|
|
|
+ yibaoxiaototal = yibaoxiaototal.add(newEntry3.getBigDecimal("reimbursedamount"));
|
|
|
|
+ yibaoxiaototalBen = yibaoxiaototalBen.add(newEntry3.getBigDecimal("reimbursedcurramount"));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ newEntry3.set("orientryamount",fexpapplyamount);
|
|
|
|
+ newEntry3.set("expenseamount",fexpapplyamount);
|
|
|
|
+ newEntry3.set("currexpenseamount",fexpapplyamountBen);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ hetongjinetotalfist = hetongjinetotalfist.add(fexpapplyamount);
|
|
|
|
+ hetongjinetotalfistBen = hetongjinetotalfistBen.add(fexpapplyamountBen);
|
|
|
|
|
|
- DynamicObject newEntry3 = new DynamicObject(plannewColl.getDynamicObjectType());
|
|
|
|
DynamicObject fukuantype = BusinessDataServiceHelper.loadSingle("cas_paymentbilltype","id,name",new QFilter[]{new QFilter("number",QCP.equals,"201")});
|
|
DynamicObject fukuantype = BusinessDataServiceHelper.loadSingle("cas_paymentbilltype","id,name",new QFilter[]{new QFilter("number",QCP.equals,"201")});
|
|
newEntry3.set("paymenttypeid",fukuantype);
|
|
newEntry3.set("paymenttypeid",fukuantype);
|
|
newEntry3.set("payterms",fpayterms);
|
|
newEntry3.set("payterms",fpayterms);
|
|
@@ -383,14 +439,11 @@ public class ContractbillApiPlugin implements Serializable {
|
|
}
|
|
}
|
|
newEntry3.set("entrycostdept",company);
|
|
newEntry3.set("entrycostdept",company);
|
|
newEntry3.set("entrycostcompany",company);
|
|
newEntry3.set("entrycostcompany",company);
|
|
|
|
+ newEntry3.set("exchangerate",huilv);
|
|
|
|
|
|
DynamicObject feiyongproject = BusinessDataServiceHelper.loadSingle("er_expenseitemedit","id,name",new QFilter[]{new QFilter("number",QCP.equals,"FYXM99.01")});
|
|
DynamicObject feiyongproject = BusinessDataServiceHelper.loadSingle("er_expenseitemedit","id,name",new QFilter[]{new QFilter("number",QCP.equals,"FYXM99.01")});
|
|
newEntry3.set("expenseitem",feiyongproject);
|
|
newEntry3.set("expenseitem",feiyongproject);
|
|
- newEntry3.set("expenseamount",fexpapplyamount);
|
|
|
|
- newEntry3.set("orientryamount",fexpapplyamount);
|
|
|
|
- hetongjinetotalfist = hetongjinetotalfist.add(fexpapplyamount);
|
|
|
|
|
|
|
|
- newEntry3.set("exchangerate",huilv);
|
|
|
|
|
|
|
|
String std_project = jsb.getString("projectid");
|
|
String std_project = jsb.getString("projectid");
|
|
DynamicObject project = BusinessDataServiceHelper.loadSingle("bd_project","id,name",new QFilter[]{new QFilter("number",QCP.equals,std_project)});
|
|
DynamicObject project = BusinessDataServiceHelper.loadSingle("bd_project","id,name",new QFilter[]{new QFilter("number",QCP.equals,std_project)});
|
|
@@ -398,10 +451,12 @@ public class ContractbillApiPlugin implements Serializable {
|
|
|
|
|
|
newEntry3.set("entrycurrency",bizhong);
|
|
newEntry3.set("entrycurrency",bizhong);
|
|
|
|
|
|
- plannewColl.add(newEntry3);
|
|
+ if (isnew) {
|
|
|
|
+ plannewColl.add(newEntry3);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
+
|
|
if (hetongjinetotalfist.compareTo(BigDecimal.ZERO) == 0) {
|
|
if (hetongjinetotalfist.compareTo(BigDecimal.ZERO) == 0) {
|
|
dynamicObject.set("frameworkcontract",true);
|
|
dynamicObject.set("frameworkcontract",true);
|
|
dynamicObject.set("contractamount", 0);
|
|
dynamicObject.set("contractamount", 0);
|
|
@@ -411,15 +466,47 @@ public class ContractbillApiPlugin implements Serializable {
|
|
plannewColl.clear();
|
|
plannewColl.clear();
|
|
} else {
|
|
} else {
|
|
dynamicObject.set("frameworkcontract",false);
|
|
dynamicObject.set("frameworkcontract",false);
|
|
- dynamicObject.set("contractamount", hetongjinetotalfist);
|
|
+ dynamicObject.set("contractamount", hetongjinetotalfist);
|
|
- dynamicObject.set("oriapplyamount", hetongjinetotalfist);
|
|
+ dynamicObject.set("oriapplyamount", hetongjinetotalfist);
|
|
- dynamicObject.set("originalamount", hetongjinetotalfist);
|
|
+ dynamicObject.set("originalamount", hetongjinetotalfist);
|
|
- dynamicObject.set("orinotpayamount", hetongjinetotalfist);
|
|
+ dynamicObject.set("oriavailableamount", hetongjinetotalfist);
|
|
|
|
+ dynamicObject.set("availableamount", hetongjinetotalfistBen);
|
|
|
|
+ if (isnew) {
|
|
|
|
+
|
|
|
|
+ dynamicObject.set("oripayedamount", 0);
|
|
|
|
+ dynamicObject.set("payedamount", 0);
|
|
|
|
+ dynamicObject.set("oriusedamount", 0);
|
|
|
|
+ dynamicObject.set("usedamount", 0);
|
|
|
|
+ dynamicObject.set("orinotpayamount", hetongjinetotalfist);
|
|
|
|
+ dynamicObject.set("notpayamount",hetongjinetotalfistBen );
|
|
|
|
+ dynamicObject.set("oricanloanamount", hetongjinetotalfist);
|
|
|
|
+ dynamicObject.set("billcanloanamount", hetongjinetotalfistBen);
|
|
|
|
+ dynamicObject.set("oribalanceamount", hetongjinetotalfist);
|
|
|
|
+ dynamicObject.set("balanceamount", hetongjinetotalfistBen);
|
|
|
|
+ } else {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ BigDecimal oripayedamount = dynamicObject.getBigDecimal("oripayedamount");
|
|
|
|
+ BigDecimal payedamount = dynamicObject.getBigDecimal("payedamount");
|
|
|
|
+
|
|
|
|
+ BigDecimal oriusedamount = dynamicObject.getBigDecimal("oriusedamount");
|
|
|
|
+ BigDecimal usedamount = dynamicObject.getBigDecimal("usedamount");
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ dynamicObject.set("orinotpayamount", hetongjinetotalfist.subtract(oripayedamount));
|
|
|
|
+ dynamicObject.set("notpayamount", hetongjinetotalfistBen.subtract(payedamount));
|
|
|
|
+
|
|
|
|
+ dynamicObject.set("oricanloanamount", hetongjinetotalfist.subtract(oripayedamount));
|
|
|
|
+ dynamicObject.set("billcanloanamount", hetongjinetotalfistBen.subtract(payedamount));
|
|
|
|
+
|
|
|
|
+ dynamicObject.set("oribalanceamount", hetongjinetotalfist.subtract(oriusedamount));
|
|
|
|
+ dynamicObject.set("balanceamount", hetongjinetotalfist.subtract(usedamount));
|
|
|
|
+ }
|
|
|
|
|
|
dynamicObject.set("expenseentryentity", plannewColl);
|
|
dynamicObject.set("expenseentryentity", plannewColl);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
+
|
|
OperationResult opResult = SaveServiceHelper.saveOperate(entityNumber, new DynamicObject[]{dynamicObject}, OperateOption.create());
|
|
OperationResult opResult = SaveServiceHelper.saveOperate(entityNumber, new DynamicObject[]{dynamicObject}, OperateOption.create());
|
|
|
|
|
|
if (!opResult.isSuccess()) {
|
|
if (!opResult.isSuccess()) {
|
|
@@ -432,7 +519,7 @@ public class ContractbillApiPlugin implements Serializable {
|
|
|
|
|
|
|
|
|
|
List<Map<String, Object>> atts = AttachmentServiceHelper.getAttachments(entityNumber, dynamicObject.getPkValue(),"attachmentpanel");
|
|
List<Map<String, Object>> atts = AttachmentServiceHelper.getAttachments(entityNumber, dynamicObject.getPkValue(),"attachmentpanel");
|
|
- if (atts.size() > 0) {
|
|
+ if (!atts.isEmpty()) {
|
|
Iterator<Map<String, Object>> iterator = atts.iterator();
|
|
Iterator<Map<String, Object>> iterator = atts.iterator();
|
|
|
|
|
|
while (iterator.hasNext()) {
|
|
while (iterator.hasNext()) {
|