费用报销单、对公报销单费用明细是否抵抗校验发票插件
This commit is contained in:
parent
a6f400bdcd
commit
97eb7e9b68
|
@ -0,0 +1,74 @@
|
||||||
|
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.util.StringUtils;
|
||||||
|
import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 费用报销单、对公报销单费用明细是否抵抗校验发票插件
|
||||||
|
*/
|
||||||
|
public class InvoiceDeductionCheckOp extends AbstractOperationServicePlugIn {
|
||||||
|
private static final String prefix ="zcgj";
|
||||||
|
@Override
|
||||||
|
public void onPreparePropertys(PreparePropertysEventArgs e) {
|
||||||
|
super.onPreparePropertys(e);
|
||||||
|
e.getFieldKeys().add("applier");
|
||||||
|
e.getFieldKeys().add("invoiceentry");
|
||||||
|
e.getFieldKeys().add("costcompany");//费用承担公司
|
||||||
|
e.getFieldKeys().add("expenseentryentity");//费用承担公司
|
||||||
|
e.getFieldKeys().add("zcgj_invoiceremark");//特殊说明
|
||||||
|
}
|
||||||
|
|
||||||
|
@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)) {
|
||||||
|
DynamicObjectCollection expenseentryentity = dataEntity.getDynamicObjectCollection("expenseentryentity");//费用明细
|
||||||
|
boolean isCkInvoice= false;
|
||||||
|
for (DynamicObject dynamicObject : expenseentryentity) {
|
||||||
|
boolean offset = dynamicObject.getBoolean("offset");
|
||||||
|
if(offset){
|
||||||
|
isCkInvoice = offset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(isCkInvoice){
|
||||||
|
String zcgjInvoiceremark = dataEntity.getString("zcgj_invoiceremark");
|
||||||
|
DynamicObjectCollection invoiceentry = dataEntity.getDynamicObjectCollection("invoiceentry");
|
||||||
|
if( (invoiceentry == null || invoiceentry.isEmpty()) && StringUtils.isEmpty(zcgjInvoiceremark) ){
|
||||||
|
String message = String.format("费用可抵扣,必须上传发票 或 填写特殊说明 才能提交");
|
||||||
|
this.addFatalErrorMessage(extendedDataEntity, message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue