wanwei 8 сар өмнө
parent
commit
c49f1863e6

+ 67 - 0
src/main/java/fi/er/opplugin/FinapbillBeforeF7SelectSample.java

@@ -2,6 +2,7 @@ package fi.er.opplugin;
 
 import com.alibaba.druid.util.StringUtils;
 import com.alibaba.fastjson.JSONObject;
+import com.grapecity.documents.excel.B;
 import kd.bos.dataentity.entity.DynamicObject;
 import kd.bos.dataentity.entity.DynamicObjectCollection;
 import kd.bos.dataentity.serialization.SerializationUtils;
@@ -15,8 +16,10 @@ import kd.bos.list.ListShowParameter;
 import kd.bos.orm.query.QCP;
 import kd.bos.orm.query.QFilter;
 import kd.bos.servicehelper.BusinessDataServiceHelper;
+import scala.Int;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.EventObject;
@@ -205,6 +208,70 @@ public class FinapbillBeforeF7SelectSample extends AbstractFormPlugin implements
             this.getModel().setValue("asset_costdept", orgInfo, e.getChangeSet()[0].getRowIndex());
             //刷新资产信息分录
             this.getView().updateView("assetentry");
+        } else if (StringUtils.equals("expenseamount", fieldKey) || StringUtils.equals("nckd_amountfield3", fieldKey)) {
+            ChangeData changeData = e.getChangeSet()[0];
+            BigDecimal expenseamount = (BigDecimal) changeData.getNewValue();
+            this.getModel().setValue("nckd_amountfield3", expenseamount);//含税单价
+
+            //含税金额 = 含税单价*数量
+            BigDecimal asset_quantity = (BigDecimal) this.getModel().getValue("asset_quantity");
+            BigDecimal assetexpenseamount = expenseamount.multiply(asset_quantity);
+            this.getModel().setValue("assetexpenseamount", assetexpenseamount);
+
+            //不含税单价 = 含税单价/(1+税率)
+            BigDecimal assettaxrate = (BigDecimal) this.getModel().getValue("assettaxrate");
+            assettaxrate = assettaxrate.divide(new BigDecimal(100), 2, RoundingMode.HALF_UP);
+            BigDecimal rate = assettaxrate.add(BigDecimal.ONE);
+            BigDecimal assetpricewithouttax = expenseamount.divide(rate, 2 , RoundingMode.HALF_UP);
+            this.getModel().setValue("assetpricewithouttax", assetpricewithouttax);
+
+            //不含税金额 = 不含税单价*数量
+            BigDecimal assetorientryamount = assetpricewithouttax.multiply(asset_quantity);
+            this.getModel().setValue("assetorientryamount", assetorientryamount);
+
+            //税额 = 含税金额-不含税金额
+            BigDecimal assettaxamount = assetexpenseamount.subtract(assetorientryamount);
+            this.getModel().setValue("assettaxamount", assettaxamount);
+        } else if (StringUtils.equals("taxrate", fieldKey) || StringUtils.equals("assettaxrate", fieldKey)) {
+            ChangeData changeData = e.getChangeSet()[0];
+            BigDecimal assettaxrate = (BigDecimal) changeData.getNewValue();
+            this.getModel().setValue("assettaxrate", assettaxrate);//税率
+
+            //含税金额 = 含税单价 * 数量
+            BigDecimal nckd_amountfield3 = (BigDecimal) this.getModel().getValue("nckd_amountfield3");
+            BigDecimal asset_quantity = (BigDecimal) this.getModel().getValue("asset_quantity");
+            BigDecimal assetexpenseamount = nckd_amountfield3.multiply(asset_quantity);
+            this.getModel().setValue("assetexpenseamount", assetexpenseamount);
+
+            //不含税单价 = 含税单价/(1+税率)
+            assettaxrate = assettaxrate.divide(new BigDecimal(100), 2, RoundingMode.HALF_UP);
+            BigDecimal rate = assettaxrate.add(BigDecimal.ONE);
+            BigDecimal assetpricewithouttax = nckd_amountfield3.divide(rate, 2 , RoundingMode.HALF_UP);
+            this.getModel().setValue("assetpricewithouttax", assetpricewithouttax);
+
+            //不含税金额 = 不含税单价*数量
+            BigDecimal assetorientryamount = assetpricewithouttax.multiply(asset_quantity);
+            this.getModel().setValue("assetorientryamount", assetorientryamount);
+
+            //税额 = 含税金额-不含税金额
+            BigDecimal assettaxamount = assetexpenseamount.subtract(assetorientryamount);
+            this.getModel().setValue("assettaxamount", assettaxamount);
+        }
+    }
+
+    @Override
+    public void afterCreateNewData(EventObject e) {
+        //报账类型
+        String reimbursetype = (String) this.getModel().getValue("reimbursetype");
+        if("asset".equals(reimbursetype)){
+            //获取费用明细分录
+            DynamicObjectCollection assetentry = this.getModel().getEntryEntity("expenseentryentity");
+            //查询费用明细
+            QFilter filter = new QFilter("name", QCP.equals,"资产报账");
+            DynamicObject[] dynamicObjects = BusinessDataServiceHelper.load("er_expenseitemedit","id",new QFilter[] {filter});
+            DynamicObject info = BusinessDataServiceHelper.loadSingle(dynamicObjects[0].getPkValue(), dynamicObjects[0].getDynamicObjectType().getName());
+            this.getModel().setValue("expenseitem", info, 0);
+            int rowIndex = this.getModel().createNewEntryRow("assetentry");
         }
     }