|
@@ -15,10 +15,8 @@ import kd.bos.orm.query.QFilter;
|
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
import java.math.RoundingMode;
|
|
import java.math.RoundingMode;
|
|
-import java.util.ArrayList;
|
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.EventObject;
|
|
import java.util.EventObject;
|
|
-import java.util.List;
|
|
|
|
|
|
|
|
public class FinapbillBeforeF7SelectSample extends AbstractFormPlugin implements BeforeF7SelectListener {
|
|
public class FinapbillBeforeF7SelectSample extends AbstractFormPlugin implements BeforeF7SelectListener {
|
|
private static String nckd_apfinapbill = "nckd_apfinapbill"; //应付挂账单字段
|
|
private static String nckd_apfinapbill = "nckd_apfinapbill"; //应付挂账单字段
|
|
@@ -120,22 +118,44 @@ public class FinapbillBeforeF7SelectSample extends AbstractFormPlugin implements
|
|
Date bookdate = gzInfo.getDate("bookdate");
|
|
Date bookdate = gzInfo.getDate("bookdate");
|
|
String remark = gzInfo.getString("remark");
|
|
String remark = gzInfo.getString("remark");
|
|
BigDecimal pricetaxtotal = gzInfo.getBigDecimal("pricetaxtotal");
|
|
BigDecimal pricetaxtotal = gzInfo.getBigDecimal("pricetaxtotal");
|
|
|
|
+ BigDecimal expeapproveamount = BigDecimal.ZERO;//核定金额
|
|
|
|
+ BigDecimal orireceiveamount = BigDecimal.ZERO;//收款金额
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //费用明细分录
|
|
|
|
+ DynamicObjectCollection expenseentryentity = this.getModel().getEntryEntity("expenseentryentity");
|
|
|
|
+ for (DynamicObject object : expenseentryentity) {
|
|
|
|
+ expeapproveamount = expeapproveamount.add(object.getBigDecimal("expeapproveamount"));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //收款信息分录
|
|
|
|
+ DynamicObjectCollection accountentry = this.getModel().getEntryEntity("accountentry");
|
|
|
|
+ for (DynamicObject object : accountentry) {
|
|
|
|
+ orireceiveamount = orireceiveamount.add(object.getBigDecimal("orireceiveamount"));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //冲销金额
|
|
|
|
+ BigDecimal nckd_accloanamount = expeapproveamount.subtract(orireceiveamount);
|
|
|
|
+ //差额
|
|
|
|
+ BigDecimal nckd_sub_amount = pricetaxtotal.subtract(nckd_accloanamount);
|
|
//给冲预付借款赋值
|
|
//给冲预付借款赋值
|
|
- int rowIndex = this.getModel().createNewEntryRow("writeoffmoney");
|
|
|
|
-
|
|
|
|
- this.getModel().setValue("loanbillnov1",billno,rowIndex);
|
|
|
|
- this.getModel().setValue("sourceentrycostdept",org,rowIndex);
|
|
|
|
- this.getModel().setValue("sourceentrycostcompany",org,rowIndex);
|
|
|
|
- this.getModel().setValue("sourceexpenseitem",expenseitem,rowIndex);
|
|
|
|
- this.getModel().setValue("srcentrywlunit",receivingsupplierid,rowIndex);
|
|
|
|
- this.getModel().setValue("loanapplydatev1",bookdate,rowIndex);
|
|
|
|
- this.getModel().setValue("loandescriptionv1",remark,rowIndex);
|
|
|
|
- this.getModel().setValue("loanamount",pricetaxtotal,rowIndex);
|
|
|
|
- this.getModel().setValue("accloanamount",pricetaxtotal,rowIndex);
|
|
|
|
- this.getModel().setValue("currloanamount",pricetaxtotal,rowIndex);
|
|
|
|
- this.getModel().setValue("curraccloanamount",pricetaxtotal,rowIndex);
|
|
|
|
|
|
+ this.getModel().deleteEntryData("nckd_ap_finapbill_detail");
|
|
|
|
+ int rowIndex = this.getModel().createNewEntryRow("nckd_ap_finapbill_detail");
|
|
|
|
+
|
|
|
|
+ this.getModel().setValue("nckd_loanbillnov1",billno,rowIndex);
|
|
|
|
+ this.getModel().setValue("nckd_sourceentrycostdept",org,rowIndex);
|
|
|
|
+ this.getModel().setValue("nckd_sourceentrycostcompa",org,rowIndex);
|
|
|
|
+ this.getModel().setValue("nckd_sourceexpenseitem",expenseitem,rowIndex);
|
|
|
|
+// this.getModel().setValue("nckd_srcentrywlunit",receivingsupplierid,rowIndex);
|
|
|
|
+ this.getModel().setValue("nckd_loanapplydatev1",bookdate,rowIndex);
|
|
|
|
+ this.getModel().setValue("nckd_loandescriptionv1",remark,rowIndex);
|
|
|
|
+ this.getModel().setValue("nckd_loanamount",pricetaxtotal,rowIndex);
|
|
|
|
+ this.getModel().setValue("nckd_currloanamount",pricetaxtotal,rowIndex);
|
|
|
|
+ this.getModel().setValue("nckd_accloanamount",nckd_accloanamount,rowIndex);
|
|
|
|
+ this.getModel().setValue("nckd_curraccloanamount",nckd_accloanamount,rowIndex);
|
|
|
|
+ this.getModel().setValue("nckd_sub_amount",nckd_sub_amount,rowIndex);
|
|
//刷新冲预付借款分录
|
|
//刷新冲预付借款分录
|
|
- this.getView().updateView("writeoffmoney");
|
|
|
|
|
|
+ this.getView().updateView("nckd_ap_finapbill_detail");
|
|
}
|
|
}
|
|
}//资产组织变更
|
|
}//资产组织变更
|
|
else if (StringUtils.equals("assetorg", fieldKey)) {
|
|
else if (StringUtils.equals("assetorg", fieldKey)) {
|
|
@@ -174,29 +194,32 @@ public class FinapbillBeforeF7SelectSample extends AbstractFormPlugin implements
|
|
} else if (StringUtils.equals("expenseamount", fieldKey) || StringUtils.equals("nckd_amountfield3", fieldKey)) {
|
|
} else if (StringUtils.equals("expenseamount", fieldKey) || StringUtils.equals("nckd_amountfield3", fieldKey)) {
|
|
String reimbursetype = (String) this.getModel().getValue("reimbursetype");
|
|
String reimbursetype = (String) this.getModel().getValue("reimbursetype");
|
|
if("asset".equals(reimbursetype)) {
|
|
if("asset".equals(reimbursetype)) {
|
|
|
|
+ if (this.getModel().getEntryEntity("assetentry").size() == 0) {
|
|
|
|
+ int rowIndex = this.getModel().createNewEntryRow("assetentry");
|
|
|
|
+ }
|
|
ChangeData changeData = e.getChangeSet()[0];
|
|
ChangeData changeData = e.getChangeSet()[0];
|
|
BigDecimal expenseamount = (BigDecimal) changeData.getNewValue();
|
|
BigDecimal expenseamount = (BigDecimal) changeData.getNewValue();
|
|
- this.getModel().setValue("nckd_amountfield3", expenseamount);//含税单价
|
|
|
|
|
|
+ this.getModel().setValue("nckd_amountfield3", expenseamount, 0);//含税单价
|
|
|
|
|
|
//含税金额 = 含税单价*数量
|
|
//含税金额 = 含税单价*数量
|
|
BigDecimal asset_quantity = (BigDecimal) this.getModel().getValue("asset_quantity");
|
|
BigDecimal asset_quantity = (BigDecimal) this.getModel().getValue("asset_quantity");
|
|
BigDecimal assetexpenseamount = expenseamount.multiply(asset_quantity);
|
|
BigDecimal assetexpenseamount = expenseamount.multiply(asset_quantity);
|
|
- this.getModel().setValue("assetexpenseamount", assetexpenseamount);
|
|
|
|
|
|
+ this.getModel().setValue("assetexpenseamount", assetexpenseamount, 0);
|
|
|
|
|
|
//不含税单价 = 含税单价/(1+税率)
|
|
//不含税单价 = 含税单价/(1+税率)
|
|
BigDecimal assettaxrate = (BigDecimal) this.getModel().getValue("assettaxrate");
|
|
BigDecimal assettaxrate = (BigDecimal) this.getModel().getValue("assettaxrate");
|
|
assettaxrate = assettaxrate.divide(new BigDecimal(100), 2, RoundingMode.HALF_UP);
|
|
assettaxrate = assettaxrate.divide(new BigDecimal(100), 2, RoundingMode.HALF_UP);
|
|
BigDecimal rate = assettaxrate.add(BigDecimal.ONE);
|
|
BigDecimal rate = assettaxrate.add(BigDecimal.ONE);
|
|
BigDecimal assetpricewithouttax = expenseamount.divide(rate, 2 , RoundingMode.HALF_UP);
|
|
BigDecimal assetpricewithouttax = expenseamount.divide(rate, 2 , RoundingMode.HALF_UP);
|
|
- this.getModel().setValue("assetpricewithouttax", assetpricewithouttax);
|
|
|
|
|
|
+ this.getModel().setValue("assetpricewithouttax", assetpricewithouttax, 0);
|
|
|
|
|
|
//不含税金额 = 不含税单价*数量
|
|
//不含税金额 = 不含税单价*数量
|
|
BigDecimal assetorientryamount = assetpricewithouttax.multiply(asset_quantity);
|
|
BigDecimal assetorientryamount = assetpricewithouttax.multiply(asset_quantity);
|
|
- this.getModel().setValue("assetorientryamount", assetorientryamount);
|
|
|
|
|
|
+ this.getModel().setValue("assetorientryamount", assetorientryamount, 0);
|
|
|
|
|
|
//税额 = 含税金额-不含税金额
|
|
//税额 = 含税金额-不含税金额
|
|
BigDecimal assettaxamount = assetexpenseamount.subtract(assetorientryamount);
|
|
BigDecimal assettaxamount = assetexpenseamount.subtract(assetorientryamount);
|
|
- this.getModel().setValue("assettaxamount", assettaxamount);
|
|
|
|
|
|
+ this.getModel().setValue("assettaxamount", assettaxamount, 0);
|
|
}
|
|
}
|
|
} else if (StringUtils.equals("taxrate", fieldKey) || StringUtils.equals("assettaxrate", fieldKey)) {
|
|
} else if (StringUtils.equals("taxrate", fieldKey) || StringUtils.equals("assettaxrate", fieldKey)) {
|
|
ChangeData changeData = e.getChangeSet()[0];
|
|
ChangeData changeData = e.getChangeSet()[0];
|
|
@@ -222,6 +245,38 @@ public class FinapbillBeforeF7SelectSample extends AbstractFormPlugin implements
|
|
//税额 = 含税金额-不含税金额
|
|
//税额 = 含税金额-不含税金额
|
|
BigDecimal assettaxamount = assetexpenseamount.subtract(assetorientryamount);
|
|
BigDecimal assettaxamount = assetexpenseamount.subtract(assetorientryamount);
|
|
this.getModel().setValue("assettaxamount", assettaxamount);
|
|
this.getModel().setValue("assettaxamount", assettaxamount);
|
|
|
|
+ } else if (StringUtils.equals("expeapproveamount", fieldKey) || StringUtils.equals("orireceiveamount", fieldKey)) {
|
|
|
|
+ DynamicObjectCollection nckd_ap_finapbill_detail = this.getModel().getEntryEntity("nckd_ap_finapbill_detail");
|
|
|
|
+ if (nckd_ap_finapbill_detail.size() > 0) {
|
|
|
|
+ BigDecimal expeapproveamount = BigDecimal.ZERO;//核定金额
|
|
|
|
+ BigDecimal orireceiveamount = BigDecimal.ZERO;//收款金额
|
|
|
|
+ //费用明细分录
|
|
|
|
+ DynamicObjectCollection expenseentryentity = this.getModel().getEntryEntity("expenseentryentity");
|
|
|
|
+ for (DynamicObject object : expenseentryentity) {
|
|
|
|
+ expeapproveamount = expeapproveamount.add(object.getBigDecimal("expeapproveamount"));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //收款信息分录
|
|
|
|
+ DynamicObjectCollection accountentry = this.getModel().getEntryEntity("accountentry");
|
|
|
|
+ for (DynamicObject object : accountentry) {
|
|
|
|
+ orireceiveamount = orireceiveamount.add(object.getBigDecimal("orireceiveamount"));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //冲销金额
|
|
|
|
+ BigDecimal nckd_accloanamount = expeapproveamount.subtract(orireceiveamount);
|
|
|
|
+ //借款余额
|
|
|
|
+ BigDecimal nckd_loanamount = nckd_ap_finapbill_detail.get(0).getBigDecimal("nckd_loanamount");
|
|
|
|
+ //差额
|
|
|
|
+ BigDecimal nckd_sub_amount = nckd_loanamount.subtract(nckd_accloanamount);
|
|
|
|
+
|
|
|
|
+ this.getModel().setValue("nckd_loanamount",nckd_loanamount,0);
|
|
|
|
+ this.getModel().setValue("nckd_currloanamount",nckd_loanamount,0);
|
|
|
|
+ this.getModel().setValue("nckd_accloanamount",nckd_accloanamount,0);
|
|
|
|
+ this.getModel().setValue("nckd_curraccloanamount",nckd_accloanamount,0);
|
|
|
|
+ this.getModel().setValue("nckd_sub_amount",nckd_sub_amount,0);
|
|
|
|
+ //刷新冲预付借款分录
|
|
|
|
+ this.getView().updateView("nckd_ap_finapbill_detail");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|