|
|
@@ -255,9 +255,8 @@ public class contractApproveController {
|
|
|
return ResponseObject.newOkResponse();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
- * 工时审批
|
|
|
+ * 批量审批人工
|
|
|
* @param uc
|
|
|
* @param approveDate
|
|
|
* @param approveIds
|
|
|
@@ -272,14 +271,133 @@ public class contractApproveController {
|
|
|
}
|
|
|
sql = sql.substring(0, sql.length() - 1) + ")";
|
|
|
List<RowMap> list = DBSql.getMaps(sql, Arrays.stream(IdArr).toArray());
|
|
|
+ String ORGID = uc.getCompanyModel().getId();
|
|
|
+ LocalDate thisDate = getLocalDate(approveDate);//审批时间
|
|
|
+ for (RowMap thisWorkEntry : list) {
|
|
|
+
|
|
|
+ for (String key : thisWorkEntry.keySet()) {
|
|
|
+ thisWorkEntry.put(key.toUpperCase(), thisWorkEntry.get(key) == null ? "" : thisWorkEntry.get(key));
|
|
|
+ }
|
|
|
+
|
|
|
+ BO oldEntry = SDK.getBOAPI().get("BO_EU_DNSDK_WORK_ENTRY", thisWorkEntry.getString("ID"));
|
|
|
+ String COST_CODE_ID = oldEntry.getString("COST_CODE_ID");//获取成本代码ID
|
|
|
+
|
|
|
+ System.out.println("COST_CODE_ID:" + COST_CODE_ID);
|
|
|
+
|
|
|
+ RowMap thisTaxCate = null;//税收种类
|
|
|
+ if (StringUtils.isNotBlank(COST_CODE_ID)) {
|
|
|
+ RowMap costCode = DBSql.getMap("SELECT * FROM BO_EU_DND_COST_CODE WHERE OID=? AND ORGID=?", new Object[]{COST_CODE_ID, ORGID});
|
|
|
+ if (costCode != null && StringUtils.isNotBlank(costCode.getString("TAX_CATEGORY_ID"))) {
|
|
|
+ thisTaxCate = DBSql.getMap("SELECT * FROM BO_EU_DND_GENERAL WHERE OID=? AND ORGID=?", new Object[]{costCode.getString("TAX_CATEGORY_ID"), ORGID});
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ System.out.println("TAX_CATEGORY_ID:" + thisTaxCate.getString("OID"));
|
|
|
+
|
|
|
+ Double tax_rate = 0.0;
|
|
|
+ RowMap thisTaxRegion = null;
|
|
|
+ RowMap thisAccount = DBSql.getMap("SELECT * FROM BO_EU_DNCRM_ACCOUNT WHERE ID=?", new Object[]{thisWorkEntry.getString("ACCOUNT_ID")});
|
|
|
+ // 获取税收信息
|
|
|
+ if (thisAccount != null && StringUtils.isNotBlank(thisAccount.getString("TAX_REGION_ID"))) {
|
|
|
+ thisTaxRegion = DBSql.getMap("SELECT * FROM BO_EU_DND_GENERAL WHERE OID=? AND ORGID=?", new Object[]{thisAccount.getString("TAX_REGION_ID"), ORGID});
|
|
|
+ }
|
|
|
+
|
|
|
+ System.out.println("TAX_REGION_ID:" + thisTaxRegion.getString("OID"));
|
|
|
+
|
|
|
+ if (thisTaxCate != null && thisTaxRegion != null) {
|
|
|
+
|
|
|
+ RowMap thisTax = DBSql.getMap("SELECT * FROM BO_EU_DND_TAX_REGION_CATE WHERE TAX_REGION_ID=? AND TAX_CATEGORY_ID=? AND ORGID=?", new Object[]{thisTaxRegion.getString("OID"), thisTaxCate.getString("OID"), ORGID});
|
|
|
+ if (thisTax != null) {
|
|
|
+ tax_rate = thisTax.getDouble("TOTAL_EFFECTIVE_TAX_RATE");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ Double block_hour_multiplier = 0.0;
|
|
|
+
|
|
|
+ RowMap thisConRole = DBSql.getMap("SELECT * FROM BO_EU_DNCTT_CONTRACT_RATE WHERE CONTRACT_ID=? AND ROLE_ID=?", new Object[]{thisWorkEntry.getString("CONTRACT_ID"), thisWorkEntry.getString("ROLE_ID")});
|
|
|
+
|
|
|
+ if (thisConRole != null) {
|
|
|
+ block_hour_multiplier = thisConRole.getDouble("BLOCK_HOUR_MULTIPLIER");//乘数
|
|
|
+ } else {
|
|
|
+ RowMap thisRole = DBSql.getMap("SELECT * FROM BO_EU_DNSYS_ROLE WHERE ID=?", new Object[]{thisWorkEntry.getString("ROLE_ID")});
|
|
|
+ if (thisRole != null) {
|
|
|
+ block_hour_multiplier = thisRole.getDouble("HOURLY_FACTOR");//角色时间系数
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ BO thisDed = new BO();
|
|
|
+ thisDed.set("TYPE_ID", "1318");
|
|
|
+ thisDed.set("OBJECT_ID", thisWorkEntry.getString("ID"));
|
|
|
+ thisDed.set("POSTED_DATE", thisDate);
|
|
|
+ thisDed.set("TASK_ID", thisWorkEntry.getString("TASK_ID"));
|
|
|
+ thisDed.set("EXTENDED_PRICE", thisWorkEntry.getDouble("DOLLARS"));
|
|
|
+
|
|
|
+ thisDed.set("ACCOUNT_ID", thisWorkEntry.getString("ACCOUNT_ID"));
|
|
|
+ thisDed.set("CONTRACT_ID", thisWorkEntry.getString("CONTRACT_ID"));
|
|
|
+ thisDed.set("PURCHASE_ORDER_NO", thisWorkEntry.getString("PURCHASE_ORDER_NO"));
|
|
|
+ thisDed.set("BILL_ACCOUNT_ID", thisWorkEntry.getString("BILL_ACCOUNT_ID"));
|
|
|
+
|
|
|
+ thisDed.set("TAX_CATEGORY_NAME", thisTaxCate == null ? null : thisTaxCate.getString("NAME"));
|
|
|
+ thisDed.set("TAX_REGION_NAME", thisTaxRegion == null ? null : thisTaxRegion.getString("NAME"));
|
|
|
+
|
|
|
+ thisDed.set("EFFECTIVE_TAX_RATE", tax_rate);
|
|
|
+
|
|
|
+ thisDed.set("ROLE_ID", thisWorkEntry.getString("ROLE_ID"));
|
|
|
+ thisDed.set("QUANTITY", thisWorkEntry.get("QUANTITY"));
|
|
|
+ thisDed.set("RATE", thisWorkEntry.get("RATE"));
|
|
|
+ thisDed.set("BLOCK_HOUR_MULTIPLIER", block_hour_multiplier);
|
|
|
+ thisDed.set("EXTENDED_COST", thisWorkEntry.get("COST"));
|
|
|
+ if (thisTaxCate != null)
|
|
|
+ thisDed.set("TAX_CATEGORY_ID", thisTaxCate.getString("OID"));
|
|
|
+
|
|
|
|
|
|
+ thisDed.set("TAX_DOLLARS", thisWorkEntry.getDouble("DOLLARS") * (1 - 1 / (1 + tax_rate)));
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(thisDed.getString("BILL_ACCOUNT_ID")) && StringUtils.isNotBlank(thisDed.getString("ACCOUNT_ID")))
|
|
|
+ thisDed.set("BILL_ACCOUNT_ID", thisDed.get("ACCOUNT_ID"));
|
|
|
+
|
|
|
+ dn.recordFormChanges.record(uc, thisDed, "审批提交工时");
|
|
|
+ SDK.getBOAPI().createDataBO("BO_EU_DNCRM_ACCOUNT_DEDUCTION", thisDed, uc);
|
|
|
+
|
|
|
+
|
|
|
+ oldEntry.set("APPROVE_AND_POST_DATE", thisDate);
|
|
|
+ oldEntry.set("APPROVE_AND_POST_USER_ID", uc.getUID());
|
|
|
+ dn.recordFormChanges.record(uc, oldEntry, "审批提交工时");
|
|
|
+ SDK.getBOAPI().update("BO_EU_DNSDK_WORK_ENTRY", oldEntry);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return ResponseObject.newOkResponse();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 工时审批
|
|
|
+ * @param uc
|
|
|
+ * @param approveDate
|
|
|
+ * @param approveIds
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Mapping("com.awspaas.user.apps.donenow_ctt.approve_labor2")
|
|
|
+ public ResponseObject laborApprove2(UserContext uc, String approveDate, String approveIds) {
|
|
|
+ String[] IdArr = approveIds.split(",");
|
|
|
+ String sql = "SELECT * FROM VIEW_EU_DNV_PENDING_LABOR WHERE ID IN(";
|
|
|
+ for (int i = 0; IdArr.length > i; i++) {
|
|
|
+ sql += "?,";
|
|
|
+ }
|
|
|
+ sql = sql.substring(0, sql.length() - 1) + ")";
|
|
|
+ List<RowMap> list = DBSql.getMaps(sql, Arrays.stream(IdArr).toArray());
|
|
|
+ String ORGID = uc.getCompanyModel().getId();
|
|
|
for (RowMap rowMap : list) {
|
|
|
String COST_CODE_ID = getString(rowMap, "COST_CODE_ID");//获取成本代码ID
|
|
|
RowMap thisTaxCate = null;//税收种类
|
|
|
if (StringUtils.isNotBlank(COST_CODE_ID)) {
|
|
|
- RowMap costCode = DBSql.getMap("SELECT * FROM BO_EU_DND_COST_CODE WHERE ID=?", new Object[]{COST_CODE_ID});
|
|
|
+ RowMap costCode = DBSql.getMap("SELECT * FROM BO_EU_DND_COST_CODE WHERE OID=? AND ORGID=?", new Object[]{COST_CODE_ID, ORGID});
|
|
|
if (costCode != null && StringUtils.isNotBlank(costCode.getString("TAX_CATEGORY_ID"))) {
|
|
|
- thisTaxCate = DBSql.getMap("SELECT * FROM BO_EU_DND_GENERAL WHERE OID=?", new Object[]{costCode.getString("TAX_CATEGORY_ID")});
|
|
|
+ thisTaxCate = DBSql.getMap("SELECT * FROM BO_EU_DND_GENERAL WHERE OID=? AND ORGID=?", new Object[]{costCode.getString("TAX_CATEGORY_ID"), ORGID});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -295,36 +413,28 @@ public class contractApproveController {
|
|
|
thisAccount = thatAccount;
|
|
|
}
|
|
|
|
|
|
- RowMap thisProject = null;
|
|
|
|
|
|
RowMap thisTaxRegion = null;
|
|
|
Double tax_rate = 0.0;//税率
|
|
|
-
|
|
|
String TASK_ID = rowMap.getString("TASK_ID");
|
|
|
if (StringUtils.isNotBlank(TASK_ID)) {
|
|
|
-
|
|
|
- thisProject = DBSql.getMap("SELECT * FROM BO_EU_DNPRO_PROJECT WHERE ID IN (SELECT PROJECT_ID FROM BO_EU_DNSDK_TASK WHERE ID=?)", new Object[]{TASK_ID});
|
|
|
-
|
|
|
RowMap thatAccount = DBSql.getMap("SELECT * FROM BO_EU_DNCRM_ACCOUNT WHERE ID IN (SELECT ACCOUNT_ID FROM BO_EU_DNSDK_TASK WHERE ID=?)", new Object[]{TASK_ID});
|
|
|
if (thatAccount != null)
|
|
|
thisAccount = thatAccount;
|
|
|
}
|
|
|
|
|
|
- //该员工的费率
|
|
|
- // decimal? laborRate = sweDal.FindSignleBySql<decimal?>($"SELECT f_get_labor_rate({thisContractId},{oldEntry.cost_code_id},{oldEntry.role_id});");
|
|
|
-
|
|
|
String thisContractId = thisContract == null ? "null" : thisContract.getString("ID");
|
|
|
String ROLE_ID = rowMap.getString("ROLE_ID");
|
|
|
|
|
|
Double laborRate = 0.0;
|
|
|
//该员工的费率
|
|
|
try {
|
|
|
- laborRate = DBSql.getDouble("SELECT f_get_labor_rate(" + thisContractId + "," + COST_CODE_ID + "," + ROLE_ID + "," + uc.getCompanyModel().getId() + ") as laborRate", "laborRate");
|
|
|
+ laborRate = DBSql.getDouble("SELECT f_get_labor_rate(" + thisContractId + "," + COST_CODE_ID + "," + ROLE_ID + "," + ORGID + ") as laborRate", "laborRate");
|
|
|
} catch (Exception e) {
|
|
|
System.out.println("获取费率异常" + e.getMessage());
|
|
|
}
|
|
|
|
|
|
- String ORGID = uc.getCompanyModel().getId();
|
|
|
+
|
|
|
// 获取税收信息
|
|
|
if (thisAccount != null && StringUtils.isNotBlank(thisAccount.getString("TAX_REGION_ID"))) {
|
|
|
thisTaxRegion = DBSql.getMap("SELECT * FROM BO_EU_DND_GENERAL WHERE OID=? AND ORGID=?", new Object[]{thisAccount.getString("TAX_REGION_ID"), ORGID});
|
|
|
@@ -400,6 +510,10 @@ public class contractApproveController {
|
|
|
thisBlockDed.set("EXTENDED_PRICE", 0);
|
|
|
thisBlockDed.set("BILL_ACCOUNT_ID", thisWorkEntry.get("BILL_ACCOUNT_ID"));
|
|
|
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(thisBlockDed.getString("BILL_ACCOUNT_ID")) && StringUtils.isNotBlank(thisBlockDed.getString("ACCOUNT_ID")))
|
|
|
+ thisBlockDed.set("BILL_ACCOUNT_ID", thisBlockDed.get("ACCOUNT_ID"));
|
|
|
+
|
|
|
dn.recordFormChanges.record(uc, thisBlockDed, "审批提交工时");
|
|
|
SDK.getBOAPI().createDataBO("BO_EU_DNCRM_ACCOUNT_DEDUCTION", thisBlockDed, uc);
|
|
|
} else if (thisContract != null && thisContract.getString("TYPE_ID").equals("1203")) {
|
|
|
@@ -455,6 +569,11 @@ public class contractApproveController {
|
|
|
}
|
|
|
if (thisWorkEntry.getString("IS_BILLABLE").equals("0"))
|
|
|
thisBlockDed.set("EXTENDED_PRICE", 0);
|
|
|
+
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(thisBlockDed.getString("BILL_ACCOUNT_ID")) && StringUtils.isNotBlank(thisBlockDed.getString("ACCOUNT_ID")))
|
|
|
+ thisBlockDed.set("BILL_ACCOUNT_ID", thisBlockDed.get("ACCOUNT_ID"));
|
|
|
+
|
|
|
dn.recordFormChanges.record(uc, thisBlockDed, "审批提交工时");
|
|
|
SDK.getBOAPI().createDataBO("BO_EU_DNCRM_ACCOUNT_DEDUCTION", thisBlockDed, uc);
|
|
|
|
|
|
@@ -496,6 +615,11 @@ public class contractApproveController {
|
|
|
thisBlockDed.set("extended_price", block.get(key) - (extend - totalMoney));
|
|
|
if (thisWorkEntry.getString("IS_BILLABLE").equals("0"))
|
|
|
thisBlockDed.set("EXTENDED_PRICE", 0);
|
|
|
+
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(thisBlockDed.getString("BILL_ACCOUNT_ID")) && StringUtils.isNotBlank(thisBlockDed.getString("ACCOUNT_ID")))
|
|
|
+ thisBlockDed.set("BILL_ACCOUNT_ID", thisBlockDed.get("ACCOUNT_ID"));
|
|
|
+
|
|
|
dn.recordFormChanges.record(uc, thisBlockDed, "审批提交工时");
|
|
|
SDK.getBOAPI().createDataBO("BO_EU_DNCRM_ACCOUNT_DEDUCTION", thisBlockDed, uc);
|
|
|
break;
|
|
|
@@ -524,6 +648,11 @@ public class contractApproveController {
|
|
|
thisBlockDed.set("TAX_CATEGORY_ID", thisTaxCate.getString("ID"));
|
|
|
if (thisWorkEntry.getString("IS_BILLABLE").equals("0"))
|
|
|
thisBlockDed.set("EXTENDED_PRICE", 0);
|
|
|
+
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(thisBlockDed.getString("BILL_ACCOUNT_ID")) && StringUtils.isNotBlank(thisBlockDed.getString("ACCOUNT_ID")))
|
|
|
+ thisBlockDed.set("BILL_ACCOUNT_ID", thisBlockDed.get("ACCOUNT_ID"));
|
|
|
+
|
|
|
dn.recordFormChanges.record(uc, thisBlockDed, "审批提交工时");
|
|
|
SDK.getBOAPI().createDataBO("BO_EU_DNCRM_ACCOUNT_DEDUCTION", thisBlockDed, uc);
|
|
|
}
|
|
|
@@ -561,6 +690,9 @@ public class contractApproveController {
|
|
|
if (thisAccount.getString("IS_TAX_EXEMPT").equals("1") == false)
|
|
|
thisBlockDed.set("TAX_DOLLARS", thisWorkEntry.getDouble("HOURS_BILLED") * laborRate * (1 - 1 / (1 + tax_rate)));
|
|
|
|
|
|
+ if (StringUtils.isBlank(thisBlockDed.getString("BILL_ACCOUNT_ID")) && StringUtils.isNotBlank(thisBlockDed.getString("ACCOUNT_ID")))
|
|
|
+ thisBlockDed.set("BILL_ACCOUNT_ID", thisBlockDed.get("ACCOUNT_ID"));
|
|
|
+
|
|
|
dn.recordFormChanges.record(uc, thisBlockDed, "审批提交工时");
|
|
|
SDK.getBOAPI().createDataBO("BO_EU_DNCRM_ACCOUNT_DEDUCTION", thisBlockDed, uc);
|
|
|
|
|
|
@@ -589,7 +721,7 @@ public class contractApproveController {
|
|
|
thisDed.set("EXTENDED_PRICE", thisWorkEntry.getDouble("HOURS_BILLED") * laborRate * block_hour_multiplier);
|
|
|
thisDed.set("ACCOUNT_ID", thisAccount.getString("ID"));
|
|
|
thisDed.set("CONTRACT_ID", thisWorkEntry.getString("CONTRACT_ID"));
|
|
|
- thisDed.set("QUANTITY", thisWorkEntry.getDouble("HOURS_BILLED"));
|
|
|
+ //thisDed.set("QUANTITY", thisWorkEntry.getDouble("HOURS_BILLED"));
|
|
|
thisDed.set("PURCHASE_ORDER_NO", thisWorkEntry.getString("PURCHASE_ORDER_NO"));
|
|
|
thisDed.set("BILL_ACCOUNT_ID", thisWorkEntry.getString("BILL_ACCOUNT_ID"));
|
|
|
thisDed.set("TAX_CATEGORY_NAME", thisTaxCate == null ? null : thisTaxCate.getString("NAME"));
|
|
|
@@ -609,6 +741,9 @@ public class contractApproveController {
|
|
|
if (thisAccount.getString("IS_TAX_EXEMPT").equals("1") == false)
|
|
|
thisDed.set("TAX_DOLLARS", thisWorkEntry.getDouble("HOURS_BILLED") * laborRate * (1 - 1 / (1 + tax_rate)));
|
|
|
|
|
|
+ if (StringUtils.isBlank(thisDed.getString("BILL_ACCOUNT_ID")) && StringUtils.isNotBlank(thisDed.getString("ACCOUNT_ID")))
|
|
|
+ thisDed.set("BILL_ACCOUNT_ID", thisDed.get("ACCOUNT_ID"));
|
|
|
+
|
|
|
dn.recordFormChanges.record(uc, thisDed, "审批提交工时");
|
|
|
SDK.getBOAPI().createDataBO("BO_EU_DNCRM_ACCOUNT_DEDUCTION", thisDed, uc);
|
|
|
}
|
|
|
@@ -625,7 +760,7 @@ public class contractApproveController {
|
|
|
thisDed.set("EXTENDED_PRICE", thisWorkEntry.getDouble("HOURS_BILLED") * laborRate * block_hour_multiplier);
|
|
|
thisDed.set("ACCOUNT_ID", thisAccount == null ? null : thisAccount.getString("ID"));
|
|
|
thisDed.set("CONTRACT_ID", thisWorkEntry.getString("CONTRACT_ID"));
|
|
|
- thisDed.set("QUANTITY", thisWorkEntry.getDouble("HOURS_BILLED"));
|
|
|
+ //thisDed.set("QUANTITY", thisWorkEntry.getDouble("HOURS_BILLED"));
|
|
|
thisDed.set("PURCHASE_ORDER_NO", thisWorkEntry.getString("PURCHASE_ORDER_NO"));
|
|
|
thisDed.set("BILL_ACCOUNT_ID", thisWorkEntry.getString("BILL_ACCOUNT_ID"));
|
|
|
thisDed.set("TAX_CATEGORY_NAME", thisTaxCate == null ? null : thisTaxCate.getString("NAME"));
|
|
|
@@ -645,6 +780,9 @@ public class contractApproveController {
|
|
|
if (thisAccount.getString("IS_TAX_EXEMPT").equals("1") == false)
|
|
|
thisDed.set("TAX_DOLLARS", thisWorkEntry.getDouble("HOURS_BILLED") * laborRate * (1 - 1 / (1 + tax_rate)));
|
|
|
|
|
|
+ if (StringUtils.isBlank(thisDed.getString("BILL_ACCOUNT_ID")) && StringUtils.isNotBlank(thisDed.getString("ACCOUNT_ID")))
|
|
|
+ thisDed.set("BILL_ACCOUNT_ID", thisDed.get("ACCOUNT_ID"));
|
|
|
+
|
|
|
dn.recordFormChanges.record(uc, thisDed, "审批提交工时");
|
|
|
SDK.getBOAPI().createDataBO("BO_EU_DNCRM_ACCOUNT_DEDUCTION", thisDed, uc);
|
|
|
}
|
|
|
@@ -774,6 +912,8 @@ public class contractApproveController {
|
|
|
if (thisTaxCate != null)
|
|
|
thisDed.set("TAX_CATEGORY_ID", thisTaxCate.getString("OID"));
|
|
|
|
|
|
+ if (StringUtils.isBlank(thisDed.getString("BILL_ACCOUNT_ID")) && StringUtils.isNotBlank(thisDed.getString("ACCOUNT_ID")))
|
|
|
+ thisDed.set("BILL_ACCOUNT_ID", thisDed.get("ACCOUNT_ID"));
|
|
|
|
|
|
dn.recordFormChanges.record(uc, thisDed, "审批提交费用");
|
|
|
SDK.getBOAPI().createDataBO("BO_EU_DNCRM_ACCOUNT_DEDUCTION", thisDed, uc);
|