付款申请(项目资金)中应付字段赋值和分录中的供应商赋值
This commit is contained in:
		
							parent
							
								
									a17f3d53e3
								
							
						
					
					
						commit
						2fbf5d1172
					
				| 
						 | 
				
			
			@ -3,10 +3,20 @@ package zcgj.zcdev.zcdev.pr.plugin.form;
 | 
			
		|||
import kd.bos.bill.AbstractBillPlugIn;
 | 
			
		||||
import kd.bos.dataentity.entity.DynamicObject;
 | 
			
		||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
 | 
			
		||||
import kd.bos.entity.datamodel.RowDataEntity;
 | 
			
		||||
import kd.bos.entity.datamodel.events.AfterAddRowEventArgs;
 | 
			
		||||
import kd.bos.entity.datamodel.events.ChangeData;
 | 
			
		||||
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
 | 
			
		||||
import kd.bos.orm.query.QCP;
 | 
			
		||||
import kd.bos.orm.query.QFilter;
 | 
			
		||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
 | 
			
		||||
 | 
			
		||||
//  付款申请(项目资金)供应商赋值收款银行和收款账号
 | 
			
		||||
import java.math.BigDecimal;
 | 
			
		||||
 | 
			
		||||
//  付款申请(项目资金)
 | 
			
		||||
//  1:供应商赋值收款银行和收款账号
 | 
			
		||||
//  2:关联业务单据(取用入库单)中的供应商赋值给分录中的供应商
 | 
			
		||||
//  3:入库单-含税总运费+材料含税总金额赋值给付款申请单中应付字段
 | 
			
		||||
public class PaymentApplySupplierPlugin extends AbstractBillPlugIn {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
| 
						 | 
				
			
			@ -32,6 +42,69 @@ public class PaymentApplySupplierPlugin extends AbstractBillPlugIn {
 | 
			
		|||
                this.getModel().setValue("zcgj_payerbank", null, rowIndex);//开户银行
 | 
			
		||||
                this.getModel().setValue("zcgj_payeraccountname", null, rowIndex);//银行账号
 | 
			
		||||
            }
 | 
			
		||||
        } else if (propName.equals("zcgj_materialinb")) {
 | 
			
		||||
            //关联业务单据(取用入库单)
 | 
			
		||||
            DynamicObjectCollection itementry = this.getModel().getDataEntity(true).getDynamicObjectCollection("itementry");//非合同付款信息分录
 | 
			
		||||
            ChangeData[] changeSet = e.getChangeSet();
 | 
			
		||||
            ChangeData changeData = changeSet[0];
 | 
			
		||||
            DynamicObject zcgj_supplier1 = (DynamicObject) changeData.getNewValue();//新值
 | 
			
		||||
            if (zcgj_supplier1 == null) {
 | 
			
		||||
                if (itementry.getRowCount() > 0) {
 | 
			
		||||
                    for (int i = 0; i < itementry.size(); i++) {
 | 
			
		||||
                        this.getModel().setValue("zcgj_supplier1", null, i);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            String billno = zcgj_supplier1.getString("billno");
 | 
			
		||||
            QFilter f1 = new QFilter("billno", QCP.equals, billno);
 | 
			
		||||
            DynamicObject ecma_materialinbill = BusinessDataServiceHelper.loadSingle("ecma_materialinbill", new QFilter[]{f1});//入库单
 | 
			
		||||
            if (ecma_materialinbill == null) {
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            DynamicObject supplier = ecma_materialinbill.getDynamicObject("supplier");//入库单-供应商
 | 
			
		||||
            if (itementry.getRowCount() > 0 && supplier != null) {
 | 
			
		||||
                for (int i = 0; i < itementry.size(); i++) {
 | 
			
		||||
                    this.getModel().setValue("zcgj_supplier1", supplier, i);
 | 
			
		||||
                }
 | 
			
		||||
            } else if (itementry.getRowCount() > 0 && supplier == null) {
 | 
			
		||||
                for (int i = 0; i < itementry.size(); i++) {
 | 
			
		||||
                    this.getModel().setValue("zcgj_supplier1", null, i);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            BigDecimal matoftaxamount = ecma_materialinbill.getBigDecimal("matoftaxamount");//入库单-材料含税总金额
 | 
			
		||||
            BigDecimal transoftaxamount = ecma_materialinbill.getBigDecimal("transoftaxamount");//入库单-含税总运费
 | 
			
		||||
            this.getModel().setValue("totalshouldpay", matoftaxamount.add(transoftaxamount));//应付金额
 | 
			
		||||
//            this.getModel().batchCreateNewEntryRow("itementry", 1);//新增行分录
 | 
			
		||||
//            for (int i = 0; i < itementry.size(); i++) {
 | 
			
		||||
//                this.getModel().setValue("zcgj_supplier1", supplier, i);
 | 
			
		||||
//            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void afterAddRow(AfterAddRowEventArgs e) {
 | 
			
		||||
        super.afterAddRow(e);
 | 
			
		||||
        String entryName = e.getEntryProp().getName();//新增行单据体名
 | 
			
		||||
        if ("itementry".equals(entryName)) {
 | 
			
		||||
            DynamicObject zcgj_supplier1 = (DynamicObject) this.getModel().getValue("zcgj_materialinb");//关联业务单据(取用入库单)
 | 
			
		||||
            if (zcgj_supplier1 == null) {
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            String billno = zcgj_supplier1.getString("billno");
 | 
			
		||||
            QFilter f1 = new QFilter("billno", QCP.equals, billno);
 | 
			
		||||
            DynamicObject ecma_materialinbill = BusinessDataServiceHelper.loadSingle("ecma_materialinbill", new QFilter[]{f1});//入库单
 | 
			
		||||
            if (ecma_materialinbill == null) {
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            DynamicObject supplier = ecma_materialinbill.getDynamicObject("supplier");//入库单-供应商
 | 
			
		||||
            if (supplier == null) {
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            RowDataEntity[] rowDataEntities = e.getRowDataEntities();
 | 
			
		||||
            for (RowDataEntity rowDataEntity : rowDataEntities) {
 | 
			
		||||
                int rowIndex = rowDataEntity.getRowIndex();
 | 
			
		||||
                this.getModel().setValue("zcgj_supplier1", supplier, rowIndex);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue