|
@@ -8,16 +8,16 @@ import com.actionsoft.bpms.util.DBSql;
|
|
|
import com.actionsoft.bpms.util.TypeUtil;
|
|
import com.actionsoft.bpms.util.TypeUtil;
|
|
|
import com.actionsoft.sdk.local.SDK;
|
|
import com.actionsoft.sdk.local.SDK;
|
|
|
import com.actionsoft.sdk.local.api.Logger;
|
|
import com.actionsoft.sdk.local.api.Logger;
|
|
|
|
|
+import com.awspaas.user.apps.donenow_ctt.cttConstant;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.joda.time.LocalDate;
|
|
import org.joda.time.LocalDate;
|
|
|
import org.joda.time.format.DateTimeFormat;
|
|
import org.joda.time.format.DateTimeFormat;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
|
+import java.sql.SQLException;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
|
-import java.util.ArrayList;
|
|
|
|
|
-import java.util.List;
|
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -321,19 +321,32 @@ public class InvoiceService {
|
|
|
* @param dealStatus
|
|
* @param dealStatus
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
- public boolean invoiceUpdate(UserContext uc, String invoiceIds, String dealStatus) {
|
|
|
|
|
|
|
+ public boolean invoiceUpdate(UserContext uc, String invoiceIds, String dealStatus) throws SQLException {
|
|
|
for (String invoiceId : invoiceIds.split(",")) {
|
|
for (String invoiceId : invoiceIds.split(",")) {
|
|
|
BO invoice = SDK.getBOAPI().get("BO_EU_DNCTT_INVOICE", invoiceId);
|
|
BO invoice = SDK.getBOAPI().get("BO_EU_DNCTT_INVOICE", invoiceId);
|
|
|
List<BO> invoiceDetails = SDK.getBOAPI().query("BO_EU_DNCTT_INVOICE_DETAIL").bindId(invoice.getBindId()).addQuery("INVOICE_ID =", invoiceId).orderBy("ACCOUNT_ID").orderBy("BILL_ACCOUNT_ID").list();
|
|
List<BO> invoiceDetails = SDK.getBOAPI().query("BO_EU_DNCTT_INVOICE_DETAIL").bindId(invoice.getBindId()).addQuery("INVOICE_ID =", invoiceId).orderBy("ACCOUNT_ID").orderBy("BILL_ACCOUNT_ID").list();
|
|
|
|
|
|
|
|
- boolean isDelete = true;
|
|
|
|
|
|
|
+ Map<String, HashSet<String>> TypeDedIds = new HashMap<>();
|
|
|
|
|
+
|
|
|
int lineNo = 1;
|
|
int lineNo = 1;
|
|
|
for (BO invoiceDetail : invoiceDetails) {
|
|
for (BO invoiceDetail : invoiceDetails) {
|
|
|
|
|
+
|
|
|
String accountDeductionId = invoiceDetail.getString("ACCOUNT_DEDUCTION_ID");
|
|
String accountDeductionId = invoiceDetail.getString("ACCOUNT_DEDUCTION_ID");
|
|
|
|
|
+ if (StringUtils.isBlank(accountDeductionId))
|
|
|
|
|
+ continue;
|
|
|
BO accountDeduction = SDK.getBOAPI().get("BO_EU_DNCRM_ACCOUNT_DEDUCTION", accountDeductionId);
|
|
BO accountDeduction = SDK.getBOAPI().get("BO_EU_DNCRM_ACCOUNT_DEDUCTION", accountDeductionId);
|
|
|
|
|
+ if (accountDeduction == null)
|
|
|
|
|
+ continue;
|
|
|
|
|
+
|
|
|
|
|
+ String typeId = accountDeduction.getString("TYPE_ID");
|
|
|
|
|
+ if (TypeDedIds.containsKey(typeId)) {
|
|
|
|
|
+ TypeDedIds.get(typeId).add(accountDeductionId);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ TypeDedIds.put(typeId, new HashSet<String>());
|
|
|
|
|
+ TypeDedIds.get(typeId).add(accountDeductionId);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
if (dealStatus.equals("生成发票")) {
|
|
if (dealStatus.equals("生成发票")) {
|
|
|
- isDelete = false;
|
|
|
|
|
if (StringUtils.isBlank(accountDeduction.getString("INVOICE_ID"))) {
|
|
if (StringUtils.isBlank(accountDeduction.getString("INVOICE_ID"))) {
|
|
|
accountDeduction.set("INVOICE_ID", invoice.getId());
|
|
accountDeduction.set("INVOICE_ID", invoice.getId());
|
|
|
accountDeduction.set("INVOICE_LINE_ITEM_NO", lineNo);
|
|
accountDeduction.set("INVOICE_LINE_ITEM_NO", lineNo);
|
|
@@ -344,9 +357,8 @@ public class InvoiceService {
|
|
|
lineNo++;
|
|
lineNo++;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- } else if (dealStatus.equals("作废发票")) {
|
|
|
|
|
|
|
+ } else if (dealStatus.contains("作废发票")) {
|
|
|
if (StringUtils.isNotBlank(accountDeduction.getString("INVOICE_ID"))) {
|
|
if (StringUtils.isNotBlank(accountDeduction.getString("INVOICE_ID"))) {
|
|
|
- isDelete = false;
|
|
|
|
|
accountDeduction.set("INVOICE_ID", null);
|
|
accountDeduction.set("INVOICE_ID", null);
|
|
|
accountDeduction.set("INVOICE_LINE_ITEM_NO", 0);
|
|
accountDeduction.set("INVOICE_LINE_ITEM_NO", 0);
|
|
|
|
|
|
|
@@ -358,7 +370,7 @@ public class InvoiceService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (isDelete) {
|
|
|
|
|
|
|
+ if (dealStatus.contains("作废发票")) {
|
|
|
SDK.getProcessAPI().deleteById(invoice.getBindId(), uc.getUID());
|
|
SDK.getProcessAPI().deleteById(invoice.getBindId(), uc.getUID());
|
|
|
SDK.getBOAPI().remove("BO_EU_DNCTT_INVOICE", invoiceId);
|
|
SDK.getBOAPI().remove("BO_EU_DNCTT_INVOICE", invoiceId);
|
|
|
SDK.getBOAPI().removeByBindId("BO_EU_DNCTT_INVOICE_DETAIL", invoice.getBindId());
|
|
SDK.getBOAPI().removeByBindId("BO_EU_DNCTT_INVOICE_DETAIL", invoice.getBindId());
|
|
@@ -379,16 +391,52 @@ public class InvoiceService {
|
|
|
SDK.getBOAPI().update("BO_EU_DNCTT_INVOICE", invoice);
|
|
SDK.getBOAPI().update("BO_EU_DNCTT_INVOICE", invoice);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (isDelete || dealStatus.equals("作废发票")) {
|
|
|
|
|
|
|
+ if (dealStatus.contains("作废发票")) {
|
|
|
List<BO> deductions = SDK.getBOAPI().query("BO_EU_DNCRM_ACCOUNT_DEDUCTION").addQuery("INVOICE_ID =", invoiceId).list();
|
|
List<BO> deductions = SDK.getBOAPI().query("BO_EU_DNCRM_ACCOUNT_DEDUCTION").addQuery("INVOICE_ID =", invoiceId).list();
|
|
|
for (BO deduction : deductions) {
|
|
for (BO deduction : deductions) {
|
|
|
|
|
+
|
|
|
|
|
+ String typeId = deduction.getString("TYPE_ID");
|
|
|
|
|
+
|
|
|
|
|
+ if (TypeDedIds.containsKey(typeId) == false) {
|
|
|
|
|
+ TypeDedIds.put(typeId, new HashSet<String>());
|
|
|
|
|
+ }
|
|
|
|
|
+ TypeDedIds.get(typeId).add(deduction.getId());
|
|
|
|
|
+
|
|
|
deduction.set("INVOICE_ID", null);
|
|
deduction.set("INVOICE_ID", null);
|
|
|
deduction.set("INVOICE_LINE_ITEM_NO", 0);
|
|
deduction.set("INVOICE_LINE_ITEM_NO", 0);
|
|
|
dn.recordFormChanges.record(uc, deduction, "作废发票");
|
|
dn.recordFormChanges.record(uc, deduction, "作废发票");
|
|
|
SDK.getBOAPI().update("BO_EU_DNCRM_ACCOUNT_DEDUCTION", deduction);
|
|
SDK.getBOAPI().update("BO_EU_DNCRM_ACCOUNT_DEDUCTION", deduction);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ DBSql.update("UPDATE BO_EU_DNCRM_ACCOUNT_DEDUCTION SET INVOICE_ID=null,INVOICE_LINE_ITEM_NO=0 WHERE INVOICE_ID=?", new Object[]{invoiceId});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- DBSql.update("UPDATE BO_EU_DNCRM_ACCOUNT_DEDUCTION SET INVOICE_ID=null,INVOICE_LINE_ITEM_NO=0 WHERE INVOICE_ID=?", new Object[]{invoiceId});
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (dealStatus.contains("取消审批") && TypeDedIds.isEmpty() == false) {
|
|
|
|
|
+ for (String typeId : TypeDedIds.keySet()) {
|
|
|
|
|
+ String ids = StringUtils.join(TypeDedIds.get(typeId), ",");
|
|
|
|
|
+ //定期服务
|
|
|
|
|
+ if (typeId.equals(String.valueOf(cttConstant.ACCOUNT_DEDUCTION_TYPE_SERVICE)) || typeId.equals(String.valueOf(cttConstant.ACCOUNT_DEDUCTION_TYPE_INITIAL_COST))) {
|
|
|
|
|
+ //撤销定期服务 初始费用
|
|
|
|
|
+ String result = contractService.getInstance().revokeRecurringServices(uc, ids);
|
|
|
|
|
+ } else if (typeId.equals(String.valueOf(cttConstant.ACCOUNT_DEDUCTION_TYPE_CHARGE))) {
|
|
|
|
|
+ //撤销合同成本成功
|
|
|
|
|
+ String result = contractService.getInstance().revokeCost(uc, ids);
|
|
|
|
|
+ } else if (typeId.equals(String.valueOf(cttConstant.ACCOUNT_DEDUCTION_TYPE_MILESTONES))) {
|
|
|
|
|
+ //撤销合同里程碑成功
|
|
|
|
|
+ String result = contractService.getInstance().revokeMilestones(uc, ids);
|
|
|
|
|
+ } else if (typeId.equals(String.valueOf(cttConstant.ACCOUNT_DEDUCTION_TYPE_EXPENSES))) {
|
|
|
|
|
+ //撤销合同费用成功
|
|
|
|
|
+ String result = contractService.getInstance().revokeExpense(uc, ids);
|
|
|
|
|
+ } else if (typeId.equals(String.valueOf(cttConstant.ACCOUNT_DEDUCTION_TYPE_LABOUR))) {
|
|
|
|
|
+ //撤销合同人工成功
|
|
|
|
|
+ String result = contractService.getInstance().revokeLabor(uc, ids);
|
|
|
|
|
+ } else if (typeId.equals(String.valueOf(cttConstant.ACCOUNT_DEDUCTION_TYPE_COMMISSION))) {
|
|
|
|
|
+ //撤销合同佣金成功
|
|
|
|
|
+ String result = contractService.getInstance().revokeCommission(uc, ids);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
return true;
|
|
return true;
|