Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
a120667f44
|
@ -48,19 +48,26 @@ public class DailyReimbursSubOp extends AbstractOperationServicePlugIn {
|
|||
for (DynamicObject accountEntry : accountEntryCollection) {
|
||||
String payerType = accountEntry.getString("payertype");//收款人类型
|
||||
if (payerType.equals("er_payeer")) {
|
||||
DynamicObject payer = accountEntry.getDynamicObject("payer");//收款人(个人
|
||||
if (payer != null && applier != null) {
|
||||
String applierNumber = applier.getString("number");//申请人编号
|
||||
DynamicObject payer1 = payer.getDynamicObject("payer");//收款人(个人-收款人
|
||||
if (payer1 == null) {
|
||||
return;
|
||||
}
|
||||
String payer1Number = payer1.getString("number");//收款人编号
|
||||
if (!applierNumber.equals(payer1Number) && "".equals(zcgj_invoiceremark)) {
|
||||
//申请人和收款人不一致
|
||||
String payerName = accountEntry.getString("payername");//收款人名称
|
||||
if (!"".equals(payerName) && applier != null){
|
||||
String applierName = applier.getString("name");//申请人名称
|
||||
if (!applierName.equals(payerName) && "".equals(zcgj_invoiceremark)) {
|
||||
this.addFatalErrorMessage(extendedDataEntity, "收款人与申请人不一致!请填写特殊说明!");
|
||||
}
|
||||
}
|
||||
// DynamicObject payer = accountEntry.getDynamicObject("payer");//收款人(个人
|
||||
// this.addFatalErrorMessage(extendedDataEntity, "收款人与申请人不一致!请填写特殊说明!");
|
||||
// if (payer != null && applier != null) {
|
||||
// String applierName = applier.getString("name");//申请人编号
|
||||
// DynamicObject payer1 = payer.getDynamicObject("payer");//收款人(个人-收款人
|
||||
// if (payer1 == null) {
|
||||
// return;
|
||||
// }
|
||||
// String payer1Number = payer1.getString("number");//收款人编号
|
||||
// if (!applierName.equals(payer1Number) && "".equals(zcgj_invoiceremark)) {
|
||||
// //申请人和收款人不一致
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,169 @@
|
|||
package zcgj.zcdev.zcdev.fs.plugin.operate;
|
||||
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.entity.ExtendedDataEntity;
|
||||
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
||||
import kd.bos.entity.plugin.AddValidatorsEventArgs;
|
||||
import kd.bos.entity.plugin.PreparePropertysEventArgs;
|
||||
import kd.bos.entity.validate.AbstractValidator;
|
||||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 1:校验逻辑:开票日期与当前日期的对比校验 → 使用单据:费用报销单、差旅报销单、对公报销单提交操作;
|
||||
* 2:校验逻辑:冲预付时预付单支付日期与开票日期和当前日期的对比校验 → 使用单据:对公报销单提交操作。
|
||||
*/
|
||||
public class InvoiceDateValidatorSubOp extends AbstractOperationServicePlugIn {
|
||||
@Override
|
||||
public void onPreparePropertys(PreparePropertysEventArgs e) {
|
||||
super.onPreparePropertys(e);
|
||||
e.getFieldKeys().add("costcompany");//费用承担公司
|
||||
e.getFieldKeys().add("zcgj_invoiceremark");//特殊说明
|
||||
e.getFieldKeys().add("invoiceentry");//发票信息分录
|
||||
e.getFieldKeys().add("invoicedate");//开票日期
|
||||
e.getFieldKeys().add("writeoffmoney");//冲预付/借款分录
|
||||
e.getFieldKeys().add("srcbilltype");//来源单据类型
|
||||
e.getFieldKeys().add("loanbillnov1");//冲预付编码
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAddValidators(AddValidatorsEventArgs e) {
|
||||
super.onAddValidators(e);
|
||||
e.getValidators().add(new ValidatorExt());
|
||||
}
|
||||
|
||||
class ValidatorExt extends AbstractValidator {
|
||||
@Override
|
||||
public void validate() {
|
||||
ExtendedDataEntity[] extendedDataEntities = this.getDataEntities();
|
||||
for (ExtendedDataEntity extendedDataEntity : extendedDataEntities) {
|
||||
DynamicObject dataEntity = extendedDataEntity.getDataEntity();
|
||||
DynamicObject costCompany = dataEntity.getDynamicObject("costcompany");//费用承担公司
|
||||
if (costCompany != null) {
|
||||
Long companyId = costCompany.getLong("id");
|
||||
if (OrgCheckUtils.isKS(companyId)) {
|
||||
//仅针对矿山下组织下的逻辑
|
||||
String dataEntityTypeName = dataEntity.getDataEntityType().getName();
|
||||
String invoiceRemark = dataEntity.getString("zcgj_invoiceremark");//特殊说明
|
||||
DynamicObjectCollection invoiceEntryCollection = dataEntity.getDynamicObjectCollection("invoiceentry");//发票信息分录
|
||||
if (invoiceEntryCollection.size() > 0) {
|
||||
//存在发票分录时才进行下列校验
|
||||
for (int i = 0; i < invoiceEntryCollection.size(); i++) {
|
||||
DynamicObject invoiceEntry = invoiceEntryCollection.get(i);
|
||||
int i1 = i + 1;
|
||||
Date currentDate = new Date();//当前日期
|
||||
// Date currentDate = invoiceEntry.getDate("zcgj_invoicedate");//当前日期
|
||||
Date invoiceDate = invoiceEntry.getDate("invoicedate");//开票日期
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
try {
|
||||
Date currentDateFormat = sdf.parse(sdf.format(currentDate));//当前日期
|
||||
Date invoiceDateFormat = sdf.parse(sdf.format(invoiceDate));//开票日期
|
||||
|
||||
// 校验1: 开票日期不能大于当前日期
|
||||
if (invoiceDate.after(currentDateFormat)) {
|
||||
this.addFatalErrorMessage(extendedDataEntity, "发票信息第" + i1 + "行:开票日期大于当前日期!");
|
||||
return;
|
||||
}
|
||||
|
||||
// 校验2: 当前日期减去开票日期不能大于30天
|
||||
long diffInMillies = Math.abs(currentDateFormat.getTime() - invoiceDateFormat.getTime());
|
||||
long diffInDays = TimeUnit.DAYS.convert(diffInMillies, TimeUnit.MILLISECONDS);
|
||||
|
||||
// 校验3:如果发票是去年12月开具,且当前是今年1月31日前,则视为合规
|
||||
boolean isSpecialCase = false;
|
||||
java.util.Calendar currentCal = java.util.Calendar.getInstance();
|
||||
currentCal.setTime(currentDate);
|
||||
int currentYear = currentCal.get(java.util.Calendar.YEAR);//当前年份
|
||||
int currentMonth = currentCal.get(java.util.Calendar.MONTH);//当前月份
|
||||
int currentDay = currentCal.get(java.util.Calendar.DAY_OF_MONTH);//当前日期
|
||||
java.util.Calendar invoiceCal = java.util.Calendar.getInstance();
|
||||
invoiceCal.setTime(invoiceDate);
|
||||
int invoiceYear = invoiceCal.get(java.util.Calendar.YEAR);//发票年份
|
||||
int invoiceMonth = invoiceCal.get(java.util.Calendar.MONTH);//发票月份
|
||||
// 判断是否为特殊情况:发票为去年12月,当前为今年1月且日期<=31日的视为合理
|
||||
if (currentYear - invoiceYear == 1 &&
|
||||
invoiceMonth == java.util.Calendar.DECEMBER &&
|
||||
currentMonth == java.util.Calendar.JANUARY &&
|
||||
currentDay <= 31) {
|
||||
isSpecialCase = true;
|
||||
}
|
||||
|
||||
// 最终校验:当前日期减去开票日期不能大于30天且不是特殊情况且特殊说明为空时,则视为不合规
|
||||
if (diffInDays > 30 && !isSpecialCase && "".equals(invoiceRemark)) {
|
||||
this.addFatalErrorMessage(extendedDataEntity, "发票信息第" + i1 + "行:发票开具日期至当前报销日的间隔时间,不得超过一个月(30天)。必须填写特殊说明才能提交!");
|
||||
return;
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
return;
|
||||
}
|
||||
// 对公报销单冲预付单独校验逻辑
|
||||
if (dataEntityTypeName.equals("er_publicreimbursebill")) {
|
||||
// 对公报销单
|
||||
DynamicObjectCollection writeOffMoneyCollection = dataEntity.getDynamicObjectCollection("writeoffmoney");//冲预付/借款分录
|
||||
if (writeOffMoneyCollection.size() > 0) {
|
||||
for (int j = 0; j < writeOffMoneyCollection.size(); j++) {
|
||||
int j1 = j + 1;
|
||||
DynamicObject writeOffMoney = writeOffMoneyCollection.get(j);
|
||||
String srcBillType = writeOffMoney.getString("srcbilltype");//冲预付分录-源单据类型
|
||||
if (srcBillType.equals("er_prepaybill")) {
|
||||
//冲预付
|
||||
String loanBillNov1 = writeOffMoney.getString("loanbillnov1");//冲预付分录-单据编码
|
||||
QFilter[] qFilter = new QFilter[]{new QFilter("billno", QCP.equals, loanBillNov1)};
|
||||
DynamicObject er_prepayBill = BusinessDataServiceHelper.loadSingle("er_prepaybill",
|
||||
"id,head_paydate", qFilter);//预付单
|
||||
Date head_payDate = er_prepayBill.getDate("head_paydate");//预付单-付款日期
|
||||
if (head_payDate != null) {
|
||||
try {
|
||||
Date currentDateFormat = sdf.parse(sdf.format(currentDate));//当前日期
|
||||
Date invoiceDateFormat = sdf.parse(sdf.format(invoiceDate));//开票日期
|
||||
Date headPayDateFormat = sdf.parse(sdf.format(head_payDate));//预付单付款日期
|
||||
|
||||
// 校验1:付款日期不能大于当前日期或者开票日期
|
||||
if (headPayDateFormat.after(currentDateFormat)) {
|
||||
this.addFatalErrorMessage(extendedDataEntity, "发票信息第" + i1 + "行与冲预付/借款分录第" + j1 + "行:预付单付款日期不能大于当前日期!");
|
||||
return;
|
||||
}
|
||||
if (headPayDateFormat.after(invoiceDateFormat)) {
|
||||
this.addFatalErrorMessage(extendedDataEntity, "发票信息第" + i1 + "行与冲预付/借款分录第" + j1 + "行:预付单付款日期不能大于发票开票日期!");
|
||||
return;
|
||||
}
|
||||
|
||||
// 校验2: 发票开具时间减去预付单的付款日期,必须小于等于15天
|
||||
long diffInvoiceToPayMillis = Math.abs(invoiceDateFormat.getTime() - headPayDateFormat.getTime());
|
||||
long diffInvoiceToPayDays = TimeUnit.DAYS.convert(diffInvoiceToPayMillis, TimeUnit.MILLISECONDS);
|
||||
if (diffInvoiceToPayDays > 15 && "".equals(invoiceRemark)) {
|
||||
this.addFatalErrorMessage(extendedDataEntity, "发票信息第" + i1 + "行与冲预付/借款分录第" + j1 + "行:发票开具日期至预付单的支付时间的间隔,不得超过15天。必须填写特殊说明才能提交");
|
||||
return;
|
||||
}
|
||||
|
||||
// 校验3: 当前时间减去预付单的付款日期,必须小于等于30天
|
||||
long diffCurrentToPayMillis = Math.abs(currentDateFormat.getTime() - headPayDateFormat.getTime());
|
||||
long diffCurrentToPayDays = TimeUnit.DAYS.convert(diffCurrentToPayMillis, TimeUnit.MILLISECONDS);
|
||||
if (diffCurrentToPayDays > 30 && "".equals(invoiceRemark)) {
|
||||
this.addFatalErrorMessage(extendedDataEntity, "发票信息第" + i1 + "行与冲预付/借款分录第" + j1 + "行:预付款支付日期至当前报销日的间隔时间,不得超过30天。必须填写特殊说明才能提交");
|
||||
return;
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue