自动收款;费用支付公司带动费用承担
This commit is contained in:
		
							parent
							
								
									d90d9c64a2
								
							
						
					
					
						commit
						4bb5f6f8ec
					
				| 
						 | 
					@ -0,0 +1,105 @@
 | 
				
			||||||
 | 
					package kd.fi.er.botp;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import kd.bos.dataentity.entity.DynamicObject;
 | 
				
			||||||
 | 
					import kd.bos.dataentity.entity.DynamicObjectCollection;
 | 
				
			||||||
 | 
					import kd.bos.entity.ExtendedDataEntity;
 | 
				
			||||||
 | 
					import kd.bos.entity.ExtendedDataEntitySet;
 | 
				
			||||||
 | 
					import kd.bos.entity.botp.plugin.AbstractConvertPlugIn;
 | 
				
			||||||
 | 
					import kd.bos.entity.botp.plugin.args.AfterConvertEventArgs;
 | 
				
			||||||
 | 
					import kd.bos.entity.botp.runtime.ConvertConst;
 | 
				
			||||||
 | 
					import kd.bos.orm.query.QFilter;
 | 
				
			||||||
 | 
					import kd.bos.servicehelper.BusinessDataServiceHelper;
 | 
				
			||||||
 | 
					import kd.scm.pds.common.util.TemplateUtil;
 | 
				
			||||||
 | 
					import kd.sdk.plugin.Plugin;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.math.BigDecimal;
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * 单据转换插件
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public class ConvertBillPlugln extends AbstractConvertPlugIn implements Plugin {
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void afterConvert(AfterConvertEventArgs e) {
 | 
				
			||||||
 | 
					        super.afterConvert(e);
 | 
				
			||||||
 | 
					        //采购合同
 | 
				
			||||||
 | 
					        ExtendedDataEntitySet targetExtDataEntitySet = e.getTargetExtDataEntitySet();
 | 
				
			||||||
 | 
					        ExtendedDataEntity[] entities = targetExtDataEntitySet.FindByEntityKey(getTgtMainType().getName());
 | 
				
			||||||
 | 
					        for (ExtendedDataEntity entity : entities) {
 | 
				
			||||||
 | 
					            List<DynamicObject> srcRows = (List<DynamicObject>) entity.getValue(ConvertConst.ConvExtDataKey_SourceRows);
 | 
				
			||||||
 | 
					            DynamicObject srcRow = srcRows.get(0);
 | 
				
			||||||
 | 
					            Object sourceBillPK = e.getFldProperties().get("id").getValue(srcRow);
 | 
				
			||||||
 | 
					            ////付款处理单据
 | 
				
			||||||
 | 
					            DynamicObject contract = entity.getDataEntity();
 | 
				
			||||||
 | 
					            //对公报销
 | 
				
			||||||
 | 
					            DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(sourceBillPK, getSrcMainType().getName());
 | 
				
			||||||
 | 
					            DynamicObjectCollection accountentry = dynamicObject.getDynamicObjectCollection("accountentry");
 | 
				
			||||||
 | 
					            BigDecimal orireceiveamount = accountentry.get(0).getBigDecimal("orireceiveamount"); //实付金额
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            DynamicObjectCollection writeoffmoney = dynamicObject.getDynamicObjectCollection("writeoffmoney"); //预付
 | 
				
			||||||
 | 
					            DynamicObjectCollection expenseentryentity = dynamicObject.getDynamicObjectCollection("expenseentryentity"); //预付
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            BigDecimal yuf = BigDecimal.ZERO; //预付金额
 | 
				
			||||||
 | 
					            for(int i=0;i<writeoffmoney.size();i++){
 | 
				
			||||||
 | 
					                DynamicObject enry = writeoffmoney.get(i);
 | 
				
			||||||
 | 
					                BigDecimal loanamount = enry.getBigDecimal("loanamount");
 | 
				
			||||||
 | 
					                yuf = yuf.add(loanamount);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if(yuf.compareTo(BigDecimal.ZERO) ==0){
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            BigDecimal feiy = BigDecimal.ZERO; //报销金额的合计
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            for(int i=0;i<expenseentryentity.size();i++){
 | 
				
			||||||
 | 
					                DynamicObject enry = expenseentryentity.get(i);
 | 
				
			||||||
 | 
					                BigDecimal loanamount = enry.getBigDecimal("expenseamount");
 | 
				
			||||||
 | 
					                feiy = feiy.add(loanamount);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//            BigDecimal proportion = yuf.divide(feiy, 4, 4); // 预付/报销金额 = 已付比例
 | 
				
			||||||
 | 
					//            BigDecimal supro = one.subtract(proportion); // 1-已付比例 = 未付比例
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            BigDecimal sfTatalo = BigDecimal.ZERO;
 | 
				
			||||||
 | 
					            BigDecimal zft = BigDecimal.ZERO;
 | 
				
			||||||
 | 
					            for(int i=0;i<expenseentryentity.size();i++){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                DynamicObject enry = expenseentryentity.get(i);
 | 
				
			||||||
 | 
					                BigDecimal loanamount = enry.getBigDecimal("expenseamount"); //报销金额
 | 
				
			||||||
 | 
					                BigDecimal supro = loanamount.divide(feiy,4,4);
 | 
				
			||||||
 | 
					                BigDecimal multiply = orireceiveamount.multiply(supro);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if(i==expenseentryentity.size()-1){
 | 
				
			||||||
 | 
					                    multiply =  orireceiveamount.subtract(zft);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                zft =zft.add(multiply);
 | 
				
			||||||
 | 
					                DynamicObjectCollection entry = contract.getDynamicObjectCollection("entry");
 | 
				
			||||||
 | 
					                entry.get(i).set("e_actamt",multiply); //付款单实付
 | 
				
			||||||
 | 
					                entry.get(i).set("e_payableamt",loanamount); //应付
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                entry.get(i).set("e_unsettledlocalamt", multiply);
 | 
				
			||||||
 | 
					                entry.get(i).set("e_unlockamt", multiply);
 | 
				
			||||||
 | 
					                entry.get(i).set("e_unsettledamt", multiply);
 | 
				
			||||||
 | 
					                entry.get(i).set("e_payableamt", multiply);
 | 
				
			||||||
 | 
					                entry.get(i).set("e_payablelocamt", multiply);
 | 
				
			||||||
 | 
					                entry.get(i).set("e_localamt", multiply);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                sfTatalo =  sfTatalo.add(multiply);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            DynamicObjectCollection entry = contract.getDynamicObjectCollection("entry");
 | 
				
			||||||
 | 
					//            entry.get(0).set("e_actamt",new BigDecimal(10) );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //签约单id
 | 
				
			||||||
 | 
					            Object pkValue = dynamicObject.getPkValue();
 | 
				
			||||||
 | 
					            //根据id找采购实施
 | 
				
			||||||
 | 
					            contract.set("actpayamt",sfTatalo);
 | 
				
			||||||
 | 
					            contract.set("localamt",sfTatalo);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -173,9 +173,9 @@ public class CommonCostCenterBillFormPlugin extends AbstractBillPlugIn implement
 | 
				
			||||||
                if("costcompany".equals(name)){
 | 
					                if("costcompany".equals(name)){
 | 
				
			||||||
                DynamicObject applier = (DynamicObject) this.getModel().getValue("applier");
 | 
					                DynamicObject applier = (DynamicObject) this.getModel().getValue("applier");
 | 
				
			||||||
                if (applier != null){
 | 
					                if (applier != null){
 | 
				
			||||||
                    DynamicObject bos_user = BusinessDataServiceHelper.loadSingle(applier.getPkValue(), "bos_user");
 | 
					//                    DynamicObject bos_user = BusinessDataServiceHelper.loadSingle(applier.getPkValue(), "bos_user");
 | 
				
			||||||
                    DynamicObject shkd_labororg = bos_user.getDynamicObject("shkd_labororg");
 | 
					//                    DynamicObject shkd_labororg = bos_user.getDynamicObject("shkd_labororg");
 | 
				
			||||||
                    this.getModel().setValue("paycompany",shkd_labororg);//设置支付公司为申请人员上的劳动主体
 | 
					//                    this.getModel().setValue("paycompany",shkd_labororg);//设置支付公司为申请人员上的劳动主体
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,43 @@
 | 
				
			||||||
 | 
					package shkd.fi.er.plugin.formplugin;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import kd.bos.bill.AbstractBillPlugIn;
 | 
				
			||||||
 | 
					import kd.bos.dataentity.entity.DynamicObject;
 | 
				
			||||||
 | 
					import kd.bos.entity.datamodel.events.ChangeData;
 | 
				
			||||||
 | 
					import kd.bos.entity.datamodel.events.PropertyChangedArgs;
 | 
				
			||||||
 | 
					import kd.sdk.plugin.Plugin;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.EventObject;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * 单据界面插件,费用承担公司根据支付公司做变化
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public class CommonCostCompanyPlugin extends AbstractBillPlugIn implements Plugin {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void registerListener(EventObject e) {
 | 
				
			||||||
 | 
					        super.registerListener(e);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void propertyChanged(PropertyChangedArgs e) {
 | 
				
			||||||
 | 
					        super.propertyChanged(e);
 | 
				
			||||||
 | 
					        String name = e.getProperty().getName();
 | 
				
			||||||
 | 
					        ChangeData[] changeSet = e.getChangeSet();
 | 
				
			||||||
 | 
					        ChangeData changeData = changeSet[0];
 | 
				
			||||||
 | 
					        if("paycompany".equals(name)){
 | 
				
			||||||
 | 
					            DynamicObject newValue = (DynamicObject)changeData.getNewValue();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            this.getModel().setValue("costcompany",newValue);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void afterCreateNewData(EventObject e) {
 | 
				
			||||||
 | 
					        super.afterCreateNewData(e);
 | 
				
			||||||
 | 
					        Object paycompany = this.getModel().getValue("paycompany");
 | 
				
			||||||
 | 
					        if(paycompany!=null){
 | 
				
			||||||
 | 
					            DynamicObject value = (DynamicObject)paycompany;
 | 
				
			||||||
 | 
					            this.getModel().setValue("costcompany",value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,51 @@
 | 
				
			||||||
 | 
					package shkd.fi.er.plugin.formplugin;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import kd.bos.bill.AbstractBillPlugIn;
 | 
				
			||||||
 | 
					import kd.bos.dataentity.entity.DynamicObject;
 | 
				
			||||||
 | 
					import kd.bos.dataentity.entity.DynamicObjectCollection;
 | 
				
			||||||
 | 
					import kd.bos.form.control.events.ItemClickEvent;
 | 
				
			||||||
 | 
					import kd.sdk.plugin.Plugin;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.EventObject;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * 单据界面插件
 | 
				
			||||||
 | 
					 * 收款信息生成
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public class GenerateSKClickPlugln extends AbstractBillPlugIn implements Plugin {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private final static String KEY_sku = "shkd_generatesku";
 | 
				
			||||||
 | 
					    private final static String bar_save = "bar_save";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void registerListener(EventObject e) {
 | 
				
			||||||
 | 
					        super.registerListener(e);
 | 
				
			||||||
 | 
					        this.addItemClickListeners(KEY_sku);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void itemClick(ItemClickEvent evt) {
 | 
				
			||||||
 | 
					        super.itemClick(evt);
 | 
				
			||||||
 | 
					        System.out.println();
 | 
				
			||||||
 | 
					        DynamicObjectCollection expenseentryentity = this.getModel().getEntryEntity("expenseentryentity");
 | 
				
			||||||
 | 
					        DynamicObjectCollection entryEntity = this.getModel().getEntryEntity("");
 | 
				
			||||||
 | 
					        entryEntity.clear();
 | 
				
			||||||
 | 
					        for(int i= 0;i<expenseentryentity.size();i++){
 | 
				
			||||||
 | 
					            DynamicObject fymx = expenseentryentity.get(0);
 | 
				
			||||||
 | 
					            DynamicObject shkd_entrypaycompany = fymx.getDynamicObject("shkd_entrypaycompany");
 | 
				
			||||||
 | 
					            DynamicObject std_entrycostcenter = fymx.getDynamicObject("std_entrycostcenter");
 | 
				
			||||||
 | 
					            DynamicObject dynamicObject = fymx.getDynamicObject("expenseitem");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//            DynamicObject dynamicObject = entryEntity.addNew();
 | 
				
			||||||
 | 
					//            dynamicObject.set("","");
 | 
				
			||||||
 | 
					//            dynamicObject.set("","");
 | 
				
			||||||
 | 
					//            dynamicObject.set("","");
 | 
				
			||||||
 | 
					//            dynamicObject.set("","");
 | 
				
			||||||
 | 
					//            dynamicObject.set("","");
 | 
				
			||||||
 | 
					//            dynamicObject.set("","");
 | 
				
			||||||
 | 
					//            dynamicObject.set("","");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        this.getView().updateView("");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
		Reference in New Issue