|
@@ -1,6 +1,7 @@
|
|
package fi.er.formPlugin;
|
|
package fi.er.formPlugin;
|
|
|
|
|
|
import com.alibaba.druid.util.StringUtils;
|
|
import com.alibaba.druid.util.StringUtils;
|
|
|
|
+import kd.bos.dataentity.entity.DynamicObjectCollection;
|
|
import kd.bos.entity.datamodel.events.ChangeData;
|
|
import kd.bos.entity.datamodel.events.ChangeData;
|
|
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
|
|
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
|
|
import kd.bos.form.plugin.AbstractFormPlugin;
|
|
import kd.bos.form.plugin.AbstractFormPlugin;
|
|
@@ -15,10 +16,17 @@ public class TripreimbursePlugin extends AbstractFormPlugin {
|
|
String fieldKey = e.getProperty().getName();
|
|
String fieldKey = e.getProperty().getName();
|
|
if (StringUtils.equals("nckd_amountfield1", fieldKey)) {
|
|
if (StringUtils.equals("nckd_amountfield1", fieldKey)) {
|
|
ChangeData changeData = e.getChangeSet()[0];
|
|
ChangeData changeData = e.getChangeSet()[0];
|
|
- BigDecimal nckd_checkboxfield1 = (BigDecimal) changeData.getNewValue();
|
|
|
|
- BigDecimal orientryamount = (BigDecimal) this.getModel().getValue("orientryamount");
|
|
|
|
- orientryamount = orientryamount.add(nckd_checkboxfield1);
|
|
|
|
- this.getModel().setValue("orientryamount", orientryamount);
|
|
|
|
|
|
+ BigDecimal newAmount = (BigDecimal) changeData.getNewValue();
|
|
|
|
+ BigDecimal oldAmount = (BigDecimal) changeData.getOldValue();
|
|
|
|
+ BigDecimal amount = newAmount.subtract(oldAmount);
|
|
|
|
+ DynamicObjectCollection entryentity = this.getModel().getEntryEntity("entryentity");
|
|
|
|
+ for (int i = 0; i < entryentity.size(); i++) {
|
|
|
|
+ if (entryentity.get(i).getDynamicObject("expenseitem").getString("number").equals("009")) {
|
|
|
|
+ BigDecimal orientryamount = (BigDecimal) this.getModel().getValue("orientryamount", i);
|
|
|
|
+ orientryamount = orientryamount.add(amount);
|
|
|
|
+ this.getModel().setValue("orientryamount", orientryamount, i);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}else if (StringUtils.equals("nckd_daterangefield_enddate", fieldKey)) {
|
|
}else if (StringUtils.equals("nckd_daterangefield_enddate", fieldKey)) {
|
|
ChangeData changeData = e.getChangeSet()[0];
|
|
ChangeData changeData = e.getChangeSet()[0];
|
|
Date nckd_daterangefield_enddate = (Date) changeData.getNewValue();
|
|
Date nckd_daterangefield_enddate = (Date) changeData.getNewValue();
|
|
@@ -41,8 +49,41 @@ public class TripreimbursePlugin extends AbstractFormPlugin {
|
|
long extraHours = hoursDifference - 5;
|
|
long extraHours = hoursDifference - 5;
|
|
totalSubsidy += additionalSubsidy * extraHours;
|
|
totalSubsidy += additionalSubsidy * extraHours;
|
|
}
|
|
}
|
|
- BigDecimal nckd_amountfield2 = BigDecimal.valueOf(totalSubsidy);
|
|
|
|
- this.getModel().setValue("nckd_amountfield2", nckd_amountfield2);
|
|
|
|
|
|
+ BigDecimal newAmount = BigDecimal.valueOf(totalSubsidy);
|
|
|
|
+ BigDecimal oldAmount = (BigDecimal) this.getModel().getValue("nckd_amountfield2") == null ? BigDecimal.ZERO : (BigDecimal) this.getModel().getValue("nckd_amountfield2");
|
|
|
|
+ BigDecimal amount = newAmount.subtract(oldAmount);
|
|
|
|
+ DynamicObjectCollection entryentity = this.getModel().getEntryEntity("entryentity");
|
|
|
|
+ for (int i = 0; i < entryentity.size(); i++) {
|
|
|
|
+ if (entryentity.get(i).getDynamicObject("expenseitem").getString("number").equals("009")) {
|
|
|
|
+ BigDecimal orientryamount = (BigDecimal) this.getModel().getValue("orientryamount", i);
|
|
|
|
+ orientryamount = orientryamount.add(amount);
|
|
|
|
+ this.getModel().setValue("orientryamount", orientryamount, i);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ this.getModel().setValue("nckd_amountfield2", newAmount);
|
|
|
|
+ }
|
|
|
|
+ }else if (StringUtils.equals("nckd_checkboxfield1", fieldKey)) {
|
|
|
|
+ ChangeData changeData = e.getChangeSet()[0];
|
|
|
|
+ boolean nckd_checkboxfield1 = (boolean) changeData.getNewValue();
|
|
|
|
+ if (!nckd_checkboxfield1) {
|
|
|
|
+ this.getModel().setValue("nckd_amountfield1", BigDecimal.ZERO);
|
|
|
|
+ }
|
|
|
|
+ }else if (StringUtils.equals("nckd_checkboxfield2", fieldKey)) {
|
|
|
|
+ ChangeData changeData = e.getChangeSet()[0];
|
|
|
|
+ boolean nckd_checkboxfield2 = (boolean) changeData.getNewValue();
|
|
|
|
+ if (!nckd_checkboxfield2) {
|
|
|
|
+ BigDecimal nckd_amountfield2 = (BigDecimal) this.getModel().getValue("nckd_amountfield2");
|
|
|
|
+ DynamicObjectCollection entryentity = this.getModel().getEntryEntity("entryentity");
|
|
|
|
+ for (int i = 0; i < entryentity.size(); i++) {
|
|
|
|
+ if (entryentity.get(i).getDynamicObject("expenseitem").getString("number").equals("009")) {
|
|
|
|
+ BigDecimal orientryamount = (BigDecimal) this.getModel().getValue("orientryamount", i);
|
|
|
|
+ orientryamount = orientryamount.subtract(nckd_amountfield2);
|
|
|
|
+ this.getModel().setValue("orientryamount", orientryamount, i);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ this.getModel().setValue("nckd_amountfield2", BigDecimal.ZERO);
|
|
|
|
+ this.getModel().setValue("nckd_daterangefield_startdate", null);
|
|
|
|
+ this.getModel().setValue("nckd_daterangefield_enddate", null);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|