package fi.cas.formplugin; import com.alibaba.fastjson.JSON; import kd.bos.bill.BillShowParameter; import kd.bos.bill.OperationStatus; import kd.bos.context.RequestContext; import kd.bos.dataentity.OperateOption; import kd.bos.dataentity.entity.DataEntityBase; import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObjectCollection; import kd.bos.dataentity.entity.LocaleString; import kd.bos.dataentity.metadata.IDataEntityProperty; import kd.bos.dataentity.metadata.clr.DataEntityPropertyCollection; import kd.bos.dataentity.resource.ResManager; import kd.bos.dataentity.serialization.SerializationUtils; import kd.bos.entity.AppMetadataCache; import kd.bos.entity.EntityMetadataCache; import kd.bos.entity.Tips; import kd.bos.entity.datamodel.*; import kd.bos.entity.datamodel.events.*; import kd.bos.entity.format.FormatFactory; import kd.bos.entity.format.FormatObject; import kd.bos.entity.format.FormatTypes; import kd.bos.entity.operate.result.OperationResult; import kd.bos.entity.param.AppParam; import kd.bos.entity.property.EntryProp; import kd.bos.exception.KDBizException; import kd.bos.form.*; import kd.bos.form.control.*; import kd.bos.form.control.events.BeforeItemClickEvent; import kd.bos.form.control.events.ClickListener; import kd.bos.form.control.events.ItemClickEvent; import kd.bos.form.control.events.RowClickEventListener; import kd.bos.form.events.*; import kd.bos.form.field.BasedataEdit; import kd.bos.form.field.ComboEdit; import kd.bos.form.field.ComboItem; import kd.bos.form.operate.AbstractOperate; import kd.bos.form.operate.FormOperate; import kd.bos.form.operate.SignOperateCallback; import kd.bos.list.ListFilterParameter; import kd.bos.list.ListShowParameter; import kd.bos.logging.Log; import kd.bos.logging.LogFactory; import kd.bos.orm.query.QFilter; import kd.bos.orm.util.CollectionUtils; import kd.bos.servicehelper.BusinessDataServiceHelper; import kd.bos.servicehelper.DispatchServiceHelper; import kd.bos.servicehelper.QueryServiceHelper; import kd.bos.servicehelper.inte.InteServiceHelper; import kd.bos.servicehelper.operation.OperationServiceHelper; import kd.bos.servicehelper.parameter.SystemParamServiceHelper; import kd.bos.servicehelper.workflow.WorkflowServiceHelper; import kd.bos.workflow.component.approvalrecord.IApprovalRecordGroup; import kd.fi.cas.business.errorcode.CasErrorCode; import kd.fi.cas.business.errorcode.PaymentErrorCode; import kd.fi.cas.business.helper.AcctBalanceHelper; import kd.fi.cas.business.helper.PayBillHepler; import kd.fi.cas.business.helper.PaymentFillPropHelper; import kd.fi.cas.business.helper.VisibleVirtualAcctHelper; import kd.fi.cas.business.opservice.impl.PaymentPayImpl; import kd.fi.cas.business.service.ViewReceiptService; import kd.fi.cas.consts.BillTypeConstants; import kd.fi.cas.enums.*; import kd.fi.cas.formplugin.PaymentBillEdit; import kd.fi.cas.formplugin.common.CasBillEdit; import kd.fi.cas.formplugin.helper.InitCheckPluginHelper; import kd.fi.cas.helper.*; import kd.fi.cas.pojo.BizBalanceModelBean; import kd.fi.cas.util.DateUtils; import kd.fi.cas.util.EmptyUtil; import kd.fi.cas.util.FormUtils; import kd.fi.cas.util.StringUtils; import java.math.BigDecimal; import java.text.Format; import java.util.*; import java.util.List; import java.util.stream.Collectors; public class ArBillEditPlugin extends CasBillEdit implements ClickListener, RowClickEventListener, SignCallbackLisenter { private String labCurrencySign; private int currencyAmtprecision; private Format currencyFormat; private static final String KEY_DIFFPAY_CALLBACK = "KEY_DIFFPAY_CALLBACK"; private static final String CONFIRM_DEL_CALLBACK = "CONFIRM_DEL_CALLBACK"; private static final String KEY_CALLBACK_CHARGEBACK = "CALLBACK_CHARGEBACK"; private static final String KEY_CLOSECALLBACK_CHARGEBACK = "CALLBACK_SELECTDRAFT"; private static Log logger = LogFactory.getLog(PaymentBillEdit.class); private Long orgId; private boolean isBeConfirmOK = false; private List settleTypes; public ArBillEditPlugin() { this.settleTypes = Arrays.asList(SettleMentTypeEnum.PROMISSORY.getValue(), SettleMentTypeEnum.CHECK.getValue(), SettleMentTypeEnum.DRAFT.getValue(), SettleMentTypeEnum.BUSINESS.getValue(), SettleMentTypeEnum.BANK.getValue()); } private void initFormat() { FormatObject fobj = InteServiceHelper.getUserFormat(RequestContext.get().getCurrUserId()); fobj.getCurrencyFormat().setCurrencySymbols(this.labCurrencySign); fobj.getCurrencyFormat().setMinimumFractionDigits(this.currencyAmtprecision); this.currencyFormat = FormatFactory.get(FormatTypes.Currency).getFormat(fobj); } public void preOpenForm(PreOpenFormEventArgs e) { BillShowParameter showParameter = (BillShowParameter)e.getSource(); Object pkId = showParameter.getPkId(); if (pkId != null && !pkId.equals(0L)) { DynamicObject info = BusinessDataServiceHelper.loadSingle(pkId, "nckd_cas_arbill", "id, billtype"); DynamicObject billtype = info.getDynamicObject("billtype"); if (billtype != null && BillTypeConstants.PAYBILL_SYN.equals(billtype.getPkValue())) { e.getFormShowParameter().setFormId("cas_paybill_synonym"); e.getFormShowParameter().setCaption(ResManager.loadKDString("同名转账", "PaymentBillEdit_24", "fi-cas-formplugin", new Object[0])); } else if (billtype != null && BillTypeConstants.PAYBILL_CASH.equals(billtype.getPkValue())) { e.getFormShowParameter().setFormId("cas_paybill_cash"); e.getFormShowParameter().setCaption(ResManager.loadKDString("现金存取", "PaymentBillEdit_25", "fi-cas-formplugin", new Object[0])); } else if (billtype != null && BillTypeConstants.PAYBILL_SPAN.equals(billtype.getPkValue())) { e.getFormShowParameter().setCaption(ResManager.loadKDString("跨主体调拨", "PaymentBillEdit_28", "fi-cas-formplugin", new Object[0])); } } else { String formId = showParameter.getFormId(); if ("cas_paybill_synonym".equals(formId)) { e.getFormShowParameter().setFormId("cas_paybill_synonym"); e.getFormShowParameter().setCaption(ResManager.loadKDString("同名转账", "PaymentBillEdit_24", "fi-cas-formplugin", new Object[0])); } else if ("cas_paybill_cash".equals(formId)) { e.getFormShowParameter().setFormId("cas_paybill_cash"); e.getFormShowParameter().setCaption(ResManager.loadKDString("现金存取", "PaymentBillEdit_25", "fi-cas-formplugin", new Object[0])); } else if ("cas_paybill_spanmainpart".equals(formId)) { e.getFormShowParameter().setFormId("cas_paybill_spanmainpart"); e.getFormShowParameter().setCaption(ResManager.loadKDString("跨主体调拨", "PaymentBillEdit_28", "fi-cas-formplugin", new Object[0])); } } } public void registerListener(EventObject e) { super.registerListener(e); this.addClickListeners(new String[]{"changepayer", "changepayee", "addpayeelb1", "addpayeelb2", "settletnumber", "applyname"}); this.initF7(); } private void initF7() { this.fillPaymentType(); this.fillCurrency(); this.fillEntrustorg(); this.setSettlementTypeFilter(); this.fillNetBankAcct(); this.expenseItem(); this.fillFundFlow(); } private void fillFundFlow() { BasedataEdit fundFlow = (BasedataEdit)this.getControl("e_fundflowitem"); fundFlow.addBeforeF7SelectListener((select) -> { ListShowParameter showParam = (ListShowParameter)select.getFormShowParameter(); Object org = this.getModel().getValue("org"); showParam.setCustomParam("org", String.valueOf(((DynamicObject)org).getPkValue())); }); } protected void expenseItem() { BasedataEdit orgCtrl = (BasedataEdit)this.getControl("e_expenseitem"); orgCtrl.addBeforeF7SelectListener((beforeF7SelectEvent) -> { ListShowParameter showParameter = (ListShowParameter)beforeF7SelectEvent.getFormShowParameter(); DynamicObject[] objects = BusinessDataServiceHelper.load("er_expenseitembill", "id,expenseitem", new QFilter[]{new QFilter("billtype.bill_number.number", "=", "nckd_cas_arbill")}); if (!EmptyUtil.isEmpty(objects)) { List ids = (List)Arrays.stream(objects).map((o) -> { return o.get("expenseitem.id"); }).collect(Collectors.toList()); QFilter qFilter = new QFilter("id", "in", ids); showParameter.getListFilterParameter().getQFilters().add(qFilter); } }); } protected String getControlBankAcctForSettleType() { return "payeracctbank"; } private boolean isAcctBankExistOnlineBankAcct() { DynamicObject payeracctbank = (DynamicObject)this.getValue("payeracctbank"); if (null != payeracctbank) { DynamicObjectCollection onlineBankAccts = payeracctbank.getDynamicObjectCollection("netbank"); return null != onlineBankAccts && onlineBankAccts.size() != 0; } else { return false; } } private void fillNetBankAcct() { BasedataEdit onlinebankacct = (BasedataEdit)this.getControl("netbankacct"); onlinebankacct.addBeforeF7SelectListener((beforeF7SelectEvent) -> { ListShowParameter showParameter = (ListShowParameter)beforeF7SelectEvent.getFormShowParameter(); DynamicObject payeracctbank = (DynamicObject)this.getValue("payeracctbank"); List ids = new ArrayList(); if (null != payeracctbank) { DynamicObjectCollection onlineBankAccts = payeracctbank.getDynamicObjectCollection("netbank"); if (null != onlineBankAccts && onlineBankAccts.size() > 0) { Iterator var6 = onlineBankAccts.iterator(); while(var6.hasNext()) { DynamicObject bankAcct = (DynamicObject)var6.next(); ids.add((Long)bankAcct.getDynamicObject("fbasedataid").getPkValue()); } } } if (ids.size() == 0) { ids.add(0L); } QFilter qFilter = new QFilter("id", "in", ids); showParameter.getListFilterParameter().getQFilters().add(qFilter); }); } private void fillEntrustorg() { BasedataEdit currencyF7 = (BasedataEdit)this.getControl("entrustorg"); currencyF7.addBeforeF7SelectListener((beforeF7SelectEvent) -> { ListShowParameter showParameter = (ListShowParameter)beforeF7SelectEvent.getFormShowParameter(); showParameter.setCustomParam("orgFuncId", "08"); }); } private void fillPaymentType() { BasedataEdit paymenttypeF7 = (BasedataEdit)this.getControl("paymenttype"); paymenttypeF7.addBeforeF7SelectListener((beforeF7SelectEvent) -> { String sourceBillType = (String)this.getModel().getValue("sourcebilltype"); ListShowParameter showParameter = (ListShowParameter)beforeF7SelectEvent.getFormShowParameter(); QFilter qFilter = new QFilter("enable", "=", "1"); Object entrance = this.getModel().getValue("entrance"); if (!CasHelper.isEmpty(this.getModel().getDataEntity().getPkValue())) { DynamicObject payemntType = (DynamicObject)this.getModel().getValue("paymenttype"); if (payemntType != null) { qFilter = qFilter.and(new QFilter("ispartpayment", "=", payemntType.getBoolean("ispartpayment") ? "1" : "0")); } else if (!PaymentTypeEnum.AP.name().equals(entrance)) { qFilter = qFilter.and(new QFilter("ispartpayment", "=", "0")); } } if (entrance != null && !"".equals(entrance)) { if (PaymentTypeEnum.AP.name().equals(entrance)) { qFilter = qFilter.and(new QFilter("ispartpayment", "=", "1")); } else { qFilter = qFilter.and(new QFilter("ispartpayment", "=", "0")); } } if ("pm_purorderbill".equals(sourceBillType) || "conm_purcontract".equals(sourceBillType)) { qFilter = qFilter.and(new QFilter("biztype", "=", "202")).and(new QFilter("ispartpayment", "=", "1")); qFilter = qFilter.and(new QFilter("ispartpayment", "=", "1")); } showParameter.getListFilterParameter().setFilter(qFilter); }); } private void fillCurrency() { BasedataEdit currencyF7 = (BasedataEdit)this.getControl("currency"); currencyF7.addBeforeF7SelectListener((beforeF7SelectEvent) -> { ListShowParameter showParameter = (ListShowParameter)beforeF7SelectEvent.getFormShowParameter(); QFilter qFilter = new QFilter("enable", "=", "1"); Boolean isDiffCur = (Boolean)this.getValue("isdiffcur"); if (!isDiffCur) { DynamicObject settleType = (DynamicObject)this.getModel().getValue("settletype"); boolean isCash = BaseDataHelper.isSettleTypeCash(settleType); DynamicObject accountCash; if (isCash) { accountCash = (DynamicObject)this.getModel().getValue("payeracctcash"); if (accountCash != null) { List currencys = AccountCashHelper.getCurrencys(Collections.singletonList((Long)accountCash.getPkValue())); qFilter = qFilter.and(new QFilter("id", "in", currencys)); } } else { accountCash = (DynamicObject)this.getModel().getValue("payeracctbank"); if (accountCash != null) { Set currencysx = AccountBankHelper.getCurrencyPks((Long)accountCash.getPkValue()); qFilter = qFilter.and(new QFilter("id", "in", currencysx)); } } } showParameter.getListFilterParameter().setFilter(qFilter); }); } public void afterCreateNewData(EventObject e) { super.afterCreateNewData(e); this.setDefaultPaymentChannelValue(); if (!"true".equals(this.getPageCache().get("isFromWebApi"))) { this.createNewModel(); } this.getView().setVisible(false, new String[]{"netbankacct"}); this.getEntryCache(); this.calculateAmt(); DynamicObject settleType = this.getDynamicObject("settletype"); if (BaseDataHelper.isSettleTypeCash(settleType)) { this.setValue("payeracctcash", AccountCashHelper.getDefaultAccountcash(this.getPk("org"), "payer")); } } private void getEntryCache() { String str_json = this.getPageCache().get("entry"); if (str_json != null) { this.getModel().deleteEntryRow("entry", 0); TableValueSetter vs = new TableValueSetter(new String[0]); vs.addField("e_expenseitem", new Object[0]).addField("e_payableamt", new Object[0]).addField("project", new Object[0]).addField("e_fundflowitem", new Object[0]).addField("e_remark", new Object[0]); Map>> maps = (Map) SerializationUtils.fromJsonString(str_json, Map.class); ArrayList> list = (ArrayList)maps.get("entry"); Iterator var5 = list.iterator(); while(var5.hasNext()) { Map map = (Map)var5.next(); vs.addRow(new Object[]{map.get("e_expenseitem"), map.get("e_payableamt"), map.get("project"), map.get("e_fundflowitem"), map.get("e_remark")}); } AbstractFormDataModel model = (AbstractFormDataModel)this.getModel(); model.batchCreateNewEntryRow("entry", vs); this.getView().updateView("entry"); } } private void setDefaultPaymentChannelValue() { List comboItems = new ArrayList(); ComboEdit paymentChannel = (ComboEdit)this.getControl("paymentchannel"); ComboItem comboItem = new ComboItem(); comboItem.setValue(PaymentChannelEnum.COUNTER.getValue()); comboItem.setCaption(new LocaleString(ResManager.loadKDString(PaymentChannelEnum.COUNTER.getName(), "PaymentBillEdit_16", "fi-cas-formplugin", new Object[0]))); comboItems.add(comboItem); paymentChannel.setComboItems(comboItems); this.getModel().setValue("paymentchannel", comboItem.getValue()); } public void beforeBindData(EventObject e) { super.beforeBindData(e); DynamicObject paymenttype = (DynamicObject)this.getModel().getValue("paymenttype"); if (null != paymenttype && !paymenttype.getBoolean("ispartpayment")) { this.getView().setVisible(false, new String[]{"settleorg"}); } this.settleOrg(false); if (this.isBotpNew()) { this.supplePayeeInfo(); } this.getModel().setDataChanged(false); } private void supplePayeeInfo() { Object sourcebilltype = this.getModel().getValue("sourcebilltype"); if (!CasHelper.isEmpty(sourcebilltype)) { Object payee = this.getModel().getValue("payee"); Object payeebanknumMo = this.getModel().getValue("payeebanknum"); Object payeebankMo = this.getModel().getValue("payeebank"); Object payeeType = this.getValue("payeetype"); if (CasHelper.isEmpty(payeebanknumMo) && CasHelper.isEmpty(payeebankMo)) { String billName = this.getModel().getDataEntityType().getName(); Map resultMap = CasPayeeOrPayerHelper.getPayeeOrPayerInfo(payee, payeeType, billName); if (resultMap.size() > 0) { Object bankaccount = resultMap.get("payeebanknum"); Object accountname = resultMap.get("accountname"); DynamicObject payeebank = (DynamicObject)resultMap.get("payeebank"); this.getModel().setValue("payeebanknum", bankaccount); this.getModel().setValue("recaccbankname", accountname); if (!CasHelper.isEmpty(payeebank)) { this.fillProvinceAndCity(payeebank); } } } else if (!CasHelper.isEmpty(payeebankMo)) { this.fillProvinceAndCity((DynamicObject)payeebankMo); } } } private void fillProvinceAndCity(DynamicObject payeeBank) { logger.info("打开单据 填充 国家、省、城市字段"); payeeBank = BusinessDataServiceHelper.loadSingle(payeeBank.getPkValue(), payeeBank.getDataEntityType().getName(), "id,name,number,country,provincetxt,citytxt,union_number"); this.getModel().setValue("payeebank", payeeBank); this.getModel().setValue("payeebankname", payeeBank.getString("name")); this.getModel().setValue("recbanknumber", payeeBank.getString("union_number")); this.getModel().setValue("reccountry", payeeBank.getDynamicObject("country")); this.getModel().setValue("recprovince", payeeBank.getString("provincetxt")); this.getModel().setValue("reccity", payeeBank.getString("citytxt")); } private void createNewModel() { this.getView().setVisible(false, new String[]{"usage"}); FormShowParameter parameter = this.getView().getFormShowParameter(); Map customParams = parameter.getCustomParams(); if (this.getModel().getValue("org") != null) { this.orgId = this.getPk("org"); } else { String appId = this.getView().getFormShowParameter().getAppId(); if (EmptyUtil.isNotEmpty(appId)) { appId = AppMetadataCache.getAppInfo(appId).getId(); } else { appId = AppMetadataCache.getAppInfo("cas").getId(); } List authorizedBankOrgId = OrgHelper.getAuthorizedBankOrgId(RequestContext.get().getCurrUserId(), appId, "nckd_cas_arbill", "47156aff000000ac"); if (!CollectionUtils.isEmpty(authorizedBankOrgId)) { this.orgId = (Long)authorizedBankOrgId.get(0); this.setValue("org", this.orgId); } else { this.orgId = null; } } this.setValueIfAbsent("bizdate", DateUtils.getCurrentDate()); if (customParams != null && customParams.containsKey("paymentType")) { String entrance = (String)customParams.get("paymentType"); this.setValue("entrance", entrance); long billTypeID = 0L; QFilter[] qFilters; if (PaymentTypeEnum.AP.name().equals(entrance)) { qFilters = new QFilter[]{new QFilter("ispartpayment", "=", "1"), new QFilter("biztype", "=", "201")}; this.setPaymentType(qFilters); billTypeID = BillTypeConstants.PAYBILL_PUR; } else if (PaymentTypeEnum.SYN.name().equals(entrance)) { qFilters = new QFilter[]{new QFilter("biztype", "=", "214")}; this.setPaymentType(qFilters); billTypeID = BillTypeConstants.PAYBILL_SYN; } else if (PaymentTypeEnum.SPAN.name().equals(entrance)) { qFilters = new QFilter[]{new QFilter("biztype", "=", "217")}; this.setPaymentType(qFilters); billTypeID = BillTypeConstants.PAYBILL_SPAN; } else if (PaymentTypeEnum.CASH.name().equals(entrance)) { qFilters = new QFilter[]{new QFilter("biztype", "=", "215")}; this.setPaymentType(qFilters); billTypeID = BillTypeConstants.PAYBILL_CASH; } else { if (PaymentTypeEnum.ER.name().equals(entrance)) { qFilters = new QFilter[]{new QFilter("biztype", "=", "211")}; this.setPaymentType(qFilters); } else if (PaymentTypeEnum.OTR.name().equals(entrance)) { qFilters = new QFilter[]{new QFilter("biztype", "=", "999")}; this.setPaymentType(qFilters); } billTypeID = BillTypeConstants.PAYBILL_OTR; } this.setValue("issingle", "1"); if (billTypeID != 0L && QueryServiceHelper.exists("bos_billtype", billTypeID)) { this.setValue("billtype", billTypeID); } } this.fillPayeeType(true); if (CasHelper.isEmpty(this.orgId)) { this.getView().setEnable(false, new String[]{"bar_save", "bar_submit", "bar_beforesubmit"}); this.getView().showErrorNotification(ResManager.loadKDString("请先选择付款人", "PaymentBillEdit_30", "fi-cas-formplugin", new Object[0])); } else if (InitCheckPluginHelper.checkInitForPlugin(this.getView(), this.getDynamicObject("org"), new String[]{"bar_save", "bar_submit", "bar_beforesubmit"})) { this.getView().setEnable(true, new String[]{"bar_save", "bar_submit", "bar_beforesubmit"}); DynamicObject baseCurrency = OrgHelper.getBaseCurrency(this.orgId); this.setValue("basecurrency", baseCurrency); this.setValue("currency", baseCurrency); this.setValue("dpcurrency", baseCurrency); this.setValue("feecurrency", baseCurrency); this.setDefaultExratetable(this.orgId); DynamicObject defaultSettleType = BaseDataHelper.getDefaultSettleType(); this.setValue("settletype", defaultSettleType); DynamicObject defaultPayAccount; if (!BaseDataHelper.isSettleTypeCash(defaultSettleType)) { defaultPayAccount = AccountBankHelper.getDefaultPayAccount(this.orgId); if (defaultPayAccount == null || (!BaseDataHelper.isSettleTypeVirtual(defaultSettleType) || !VisibleVirtualAcctHelper.checkVirtualAcct(defaultPayAccount)) && (BaseDataHelper.isSettleTypeVirtual(defaultSettleType) || VisibleVirtualAcctHelper.checkVirtualAcct(defaultPayAccount))) { this.getView().setEnable(false, new String[]{"exchangerate"}); this.clearBalanceValue(); } else { this.setValue("payeracctbank", defaultPayAccount); this.payerAcctBankF7Changed((PropertyChangedArgs)null, defaultPayAccount); this.currencyF7Changed(false); } } defaultPayAccount = BusinessDataServiceHelper.loadSingleFromCache(this.orgId, "bos_org"); this.getModel().setValue("payernumber", defaultPayAccount.getString("number")); this.getModel().setValue("uniformsocialcreditcode", defaultPayAccount.getString("uniformsocialcreditcode")); this.setPayerInfo4Lb(); this.setOpenOrg(); } } private void setPayerInfo4Lb() { DynamicObject org = (DynamicObject)this.getModel().getValue("org"); if (org != null) { this.getModel().setValue("orgv", CasHelper.getLocalValue(org, "name")); String defaultUrl = "/icons/pc/entrance/cn_fk_80_80.png"; Image orgPic = (Image)this.getControl("orgpic"); orgPic.setUrl(defaultUrl); DynamicObject payerAcctBank = (DynamicObject)this.getModel().getValue("payeracctbank"); DynamicObject payerAcctCash = (DynamicObject)this.getModel().getValue("payeracctcash"); String v_payerbanknum = ""; if (payerAcctBank != null) { v_payerbanknum = StringUtils.splitString(payerAcctBank.getString("bankaccountnumber"), 4, " "); } else if (payerAcctCash != null) { v_payerbanknum = payerAcctCash.getString("number"); } ((Label)this.getControl("payerbanknumv")).setText(v_payerbanknum); DynamicObject payerBank = (DynamicObject)this.getModel().getValue("payerbank"); String v_payerbankname = ""; if (payerBank != null) { v_payerbankname = CasHelper.getLocalValue(payerBank, "name"); } ((Label)this.getControl("payerbanknamev")).setText(v_payerbankname); boolean isCash = BaseDataHelper.isSettleTypeCash((DynamicObject)this.getModel().getValue("settletype")); this.getView().setVisible(!isCash, new String[]{"payerbanknamev", "payerbanknamelb"}); } } private void fillPayeeType(boolean setDefaultValue) { ComboEdit payeetypeCbo = (ComboEdit)this.getView().getControl("payeetype"); List comboItem = new ArrayList(); String entrance = (String)this.getModel().getValue("entrance"); if (PaymentTypeEnum.AP.name().equals(entrance)) { comboItem.add(new ComboItem(new LocaleString(AsstActTypeEnum.SUPPLIER.getName()), AsstActTypeEnum.SUPPLIER.getValue())); comboItem.add(new ComboItem(new LocaleString(AsstActTypeEnum.CUSTOMER.getName()), AsstActTypeEnum.CUSTOMER.getValue())); comboItem.add(new ComboItem(new LocaleString(AsstActTypeEnum.EMPLOYEE.getName()), AsstActTypeEnum.EMPLOYEE.getValue())); } else if (!PaymentTypeEnum.SYN.name().equals(entrance) && !PaymentTypeEnum.CASH.name().equals(entrance)) { AsstActTypeEnum[] var5 = AsstActTypeEnum.values(); int var6 = var5.length; for(int var7 = 0; var7 < var6; ++var7) { AsstActTypeEnum asstAct = var5[var7]; comboItem.add(new ComboItem(new LocaleString(asstAct.getName()), asstAct.getValue())); } } else { comboItem.add(new ComboItem(new LocaleString(AsstActTypeEnum.COMPANY.getName()), AsstActTypeEnum.COMPANY.getValue())); } payeetypeCbo.setComboItems(comboItem); if (setDefaultValue) { this.getModel().setValue("payeetype", ((ComboItem)comboItem.get(0)).getValue()); } } public void afterImportData(ImportDataEventArgs e) { super.afterImportData(e); PaymentFillPropHelper.fillProp(this.getModel().getDataEntity()); if (this.getModel().getValue("entrance") == null) { this.setEntrance(); } } public void initImportData(InitImportDataEventArgs e) { super.initImportData(e); this.getPageCache().put("isFromWebApi", "true"); } public void afterCopyData(EventObject e) { super.afterCopyData(e); DynamicObject billType = (DynamicObject)this.getValue("billtype"); if (billType != null && BillTypeConstants.PAYBILL_PUR == billType.getLong("id")) { this.getModel().setValue("entrance", PaymentTypeEnum.AP.name()); } this.fillPayeeType(false); this.setValue("sourcetype", SourceTypeEnum.CAS); DynamicObject paymentType = (DynamicObject)this.getValue("paymenttype"); if (paymentType != null && paymentType.getBoolean("ispartpayment")) { int count = this.getModel().getEntryRowCount("entry"); for(int i = 0; i < count; ++i) { this.setValue("e_unlockamt", (BigDecimal)this.getModel().getValue("e_payableamt", i), i); this.setValue("e_unsettledamt", (BigDecimal)this.getModel().getValue("e_payableamt", i), i); } this.getView().updateView("entry"); } this.showBalance(); this.setNetBankAcctVisible(); DynamicObject accountBank = this.getDynamicObject("payeracctbank"); this.setPaymentChannelValue(accountBank, Boolean.TRUE); DynamicObject crossTranType0 = (DynamicObject)this.getModel().getValue("crosstrantype"); if (crossTranType0 != null) { DynamicObject crossTransType = BusinessDataServiceHelper.loadSingle(crossTranType0.getPkValue(), "bei_crosstrantype"); DynamicObjectCollection dynamicObjectCollection = crossTransType.getDynamicObjectCollection("entry"); this.isCrossTranTypeHide(dynamicObjectCollection); } this.getModel().deleteEntryData("cas_draftinfo"); this.getModel().setValue("applyorg", (Object)null); } public void afterLoadData(EventObject e) { super.afterLoadData(e); this.showBalance(); this.setNetBankAcctVisible(); DynamicObject crossTranType0 = (DynamicObject)this.getModel().getValue("crosstrantype"); if (crossTranType0 != null) { DynamicObject crossTransType = BusinessDataServiceHelper.loadSingle(crossTranType0.getPkValue(), "bei_crosstrantype"); DynamicObjectCollection dynamicObjectCollection = crossTransType.getDynamicObjectCollection("entry"); this.isCrossTranTypeHide(dynamicObjectCollection); } } private void ctrRefundInfoVisibility() { logger.info("付款单:PaymentBillEdit.ctrRefundInfoVisibility()"); this.getView().setVisible(false, new String[]{"bar_refund_save"}); String billstatus = (String)this.getValue("billstatus"); this.getView().setVisible(BillStatusEnum.REFUND.getValue().equals(billstatus) || BillStatusEnum.RENOTE.getValue().equals(billstatus), new String[]{"e_refundamt", "e_refunddes"}); this.getView().setEnable(false, new String[]{"e_refundamt", "e_refunddes"}); } private void setNetBankAcctVisible() { String paymentchannel = (String)this.getValue("paymentchannel"); if (null != paymentchannel && this.isAcctBankExistOnlineBankAcct()) { this.getView().setVisible(true, new String[]{"netbankacct"}); } else { this.getView().setVisible(false, new String[]{"netbankacct"}); } } private void setEntrance() { DynamicObject billType = (DynamicObject)this.getModel().getValue("billtype"); if (billType != null) { Long billTypeId = billType.getLong("id"); if (BillTypeConstants.PAYBILL_PUR.equals(billTypeId)) { this.getModel().setValue("entrance", PaymentTypeEnum.AP.name()); } else if (BillTypeConstants.PAYBILL_EXP.equals(billTypeId)) { this.getModel().setValue("entrance", PaymentTypeEnum.OTR.name()); } else if (BillTypeConstants.PAYBILL_OTR.equals(billTypeId)) { this.getModel().setValue("entrance", PaymentTypeEnum.OTR.name()); } else if (BillTypeConstants.PAYBILL_SYN.equals(billTypeId)) { this.getModel().setValue("entrance", PaymentTypeEnum.SYN.name()); } else if (BillTypeConstants.PAYBILL_CASH.equals(billTypeId)) { this.getModel().setValue("entrance", PaymentTypeEnum.CASH.name()); } else if (BillTypeConstants.PAYBILL_SPAN.equals(billTypeId)) { this.getModel().setValue("entrance", PaymentTypeEnum.SPAN.name()); } } } public void customPrintDataObject(CustomPrintDataObjectArgs e) { super.customPrintDataObject(e); String entityKey = e.getDataSourceName(); if ("nckd_cas_arbill".equals(entityKey)) { List dataEntitiesv = new ArrayList(); DynamicObject dsv = this.getModel().getDataEntity(); DynamicObject basecur = (DynamicObject)this.getModel().getValue("basecurrency"); if (basecur != null) { dsv.set("basecurrency", basecur.getString("name")); } if (dsv.getString("payeetype") != null && dsv.getString("payeetype").length() > 0) { dsv.set("payeetype", AsstActTypeEnum.getName(dsv.getString("payeetype"))); } dataEntitiesv.add(dsv); e.setDataEntities(dataEntitiesv); } } public void propertyChanged(PropertyChangedArgs e) { String key = e.getProperty().getName(); ChangeData[] changeData = e.getChangeSet(); Object newValue = changeData[0].getNewValue(); Object oldValue = changeData[0].getOldValue(); int iRow = changeData[0].getRowIndex(); if (newValue != oldValue) { DynamicObject applyDo; switch (key) { case "paymenttype": this.paymentTypeChanged((DynamicObject)newValue); break; case "bizdate": this.exratedateChanged(newValue); break; case "exratetable": this.currencyF7Changed(false); this.setRecInfo("dpexratetable", newValue, Boolean.FALSE); break; case "exratedate": this.currencyF7Changed(false); this.setRecInfo("dpexratedate", newValue, Boolean.FALSE); break; case "payeetype": this.payeeTypeChanged((String)newValue, true); break; case "org": this.setOpenOrg(); this.showBalance(); break; case "payeracctbank": this.payerAcctBankF7Changed(e, newValue); this.isOnlinebankVisibility(); break; case "payeracctcash": this.payerAcctCashChanged((DynamicObject)newValue); break; case "currency": this.currencyF7Changed(true); this.setRecInfo("dpcurrency", newValue, Boolean.TRUE); this.setExratetableVisibility(); break; case "exchangerate": case "agreedquotation": case "payquotation": case "dppayquotation": this.calculateAmt(); break; case "settletype": this.settleTypeChanged(e, newValue); this.settletNumber((DynamicObject)newValue); this.isClearSettleType((DynamicObject)oldValue, (DynamicObject)newValue); if (this.isClearFeeSettleType()) { this.setValue("fee", (Object)null); } break; case "billstatus": PaymentBillPluginHelper.fillToolBar(this, this.getModel(), this.getView()); break; case "e_payableamt": this.entries_payableAmtChanged((BigDecimal)newValue, oldValue, iRow); break; case "e_discountamt": this.entries_discountAmtChanged((BigDecimal)newValue, oldValue, iRow); break; case "entrustorg": this.entrustorgChange(newValue); break; case "paymentchannel": this.paymentchannelChange(); break; case "e_refundamt": this.refundChange((BigDecimal)newValue, (BigDecimal)oldValue, iRow); break; case "crosstrantype": DynamicObject crossTranType0 = (DynamicObject)this.getModel().getValue("crosstrantype"); if (crossTranType0 != null) { applyDo = BusinessDataServiceHelper.loadSingle(crossTranType0.getPkValue(), "bei_crosstrantype"); DynamicObjectCollection dynamicObjectCollection = applyDo.getDynamicObjectCollection("entry"); this.isCrossTranTypeHide(dynamicObjectCollection); Iterator var16 = dynamicObjectCollection.iterator(); while(var16.hasNext()) { DynamicObject dyobj = (DynamicObject)var16.next(); String settleMethod = ResManager.loadKDString("清算方式", "PaymentBillEdit_27", "fi-cas-formplugin", new Object[0]); if (kd.bos.dataentity.utils.StringUtils.equals(settleMethod, dyobj.getString("fieldname")) && kd.bos.dataentity.utils.StringUtils.isNotEmpty(dyobj.getString("defaultvalue"))) { this.getModel().setValue("settlementmethod", dyobj.getString("defaultvalue")); } } } break; case "applyid": applyDo = (DynamicObject)newValue; if (applyDo != null) { String name = applyDo.getString("name"); String phone = applyDo.getString("phone"); this.getModel().beginInit(); this.getModel().setValue("applyname", name); this.getModel().endInit(); if (kd.bos.dataentity.utils.StringUtils.isNotEmpty(phone)) { this.getModel().setValue("applyphone", phone); } this.getView().updateView("applyname"); } break; case "reccountry": case "paycountry": this.setCrossPayValue(); } } } private void isCrossTranTypeHide(DynamicObjectCollection dyobj) { QFilter qFilter = new QFilter("enable", "=", '1'); DynamicObject[] crossTransType = BusinessDataServiceHelper.load("bei_crosstranfield", "id,number", new QFilter[]{qFilter}); List number = (List)dyobj.stream().map((e) -> { return e.getLong("id"); }).collect(Collectors.toList()); Arrays.stream(crossTransType).forEach((e) -> { if (!number.contains(e.getLong("id"))) { this.getView().setVisible(Boolean.FALSE, new String[]{e.getString("number")}); } }); } private void isClearSettleType(DynamicObject oldValue, DynamicObject newValue) { String settletnumber = (String)this.getModel().getValue("settletnumber"); if (EmptyUtil.isNoEmpty(settletnumber) && Objects.nonNull(oldValue) && SettleMentTypeEnum.CREDIT.getValue().equals(oldValue.getString("settlementtype")) && (Objects.nonNull(newValue) && !SettleMentTypeEnum.CREDIT.getValue().equals(newValue.getString("settlementtype")) || Objects.isNull(newValue))) { this.getModel().setValue("settletnumber", (Object)null); this.getModel().setValue("sourcebilltype", (Object)null); this.getModel().setValue("sourcebillid", (Object)null); this.getModel().setValue("sourcetype", "CAS"); this.getModel().deleteEntryData("billhead_lk"); } } private void settletNumber(DynamicObject newValue) { if (!Objects.isNull(newValue)) { Object settlementType = newValue.get("settlementtype"); DynamicObject org = (DynamicObject)this.getModel().getValue("org"); String appId; if (Objects.nonNull(org)) { appId = AppMetadataCache.getAppInfo("cdm").getId(); boolean visible = false; if (!Objects.equals(settlementType, SettleMentTypeEnum.BUSINESS.getValue()) && !Objects.equals(settlementType, SettleMentTypeEnum.BANK.getValue())) { if (Objects.equals(settlementType, SettleMentTypeEnum.PROMISSORY.getValue())) { visible = (Boolean) SystemParamServiceHelper.getAppParameter(appId, "08", (Long)org.getPkValue(), "ischeck"); } else if (Objects.equals(settlementType, SettleMentTypeEnum.CHECK.getValue())) { visible = (Boolean)SystemParamServiceHelper.getAppParameter(appId, "08", (Long)org.getPkValue(), "ispromissorynote"); } } else { visible = (Boolean)SystemParamServiceHelper.getAppParameter(appId, "08", (Long)org.getPkValue(), "isdraft"); } this.getView().setVisible(!visible, new String[]{"settletnumber"}); this.getView().setVisible(visible, new String[]{"draftbill"}); } appId = this.getString("settletnumber"); if (PayBillHepler.isCreditSettlement(newValue) && appId != null && appId.trim().length() > 0 && "cas_payapplybill".equals(this.getString("sourcebilltype"))) { this.getView().setEnable(false, new String[]{"settletype", "settletnumber"}); } } } private void refundChange(BigDecimal newValue, BigDecimal oldValue, int iRow) { IBillModel model = (IBillModel)this.getModel(); BigDecimal e_actamt = (BigDecimal)model.getValue("e_actamt", iRow); if (BigDecimal.ZERO.compareTo(newValue) != 0) { if (BigDecimal.ZERO.compareTo(newValue) > 0) { model.setValue("e_refundamt", oldValue, iRow); this.getView().showTipNotification(ResManager.loadKDString("退款金额不能为零", "PaymentBillEdit_21", "fi-cas-formplugin", new Object[0])); } else if (e_actamt.compareTo(newValue) < 0) { model.setValue("e_refundamt", oldValue, iRow); this.getView().showTipNotification(ResManager.loadKDString("退款金额不能大于付款金额", "PaymentBillEdit_20", "fi-cas-formplugin", new Object[0])); } } } private void paymentchannelChange() { if (this.isBeiBePay()) { this.setValue("fee", (Object)null); } this.isOnlinebankVisibility(); this.ctrBeInfoVisibility(); this.changePayeeValue(); } private void entrustorgChange(Object newValue) { if (null != newValue) { this.getModel().setValue("settletype", (Object)null); } else { DynamicObject defaultSettleType = BaseDataHelper.getDefaultSettleType(); this.setValue("settletype", defaultSettleType); } } private void addEntryCache() { DynamicObjectCollection entry = this.getModel().getEntryEntity("entry"); List> list = new ArrayList(); Iterator var3 = entry.iterator(); while(var3.hasNext()) { DynamicObject row = (DynamicObject)var3.next(); Map map = new HashMap(); map.put("e_expenseitem", row.get("e_expenseitem") == null ? null : ((DynamicObject)row.get("e_expenseitem")).getPkValue()); map.put("e_payableamt", row.get("e_payableamt")); map.put("project", row.get("project") == null ? null : row.getDynamicObject("project").getPkValue()); map.put("e_fundflowitem", row.get("e_fundflowitem") == null ? null : row.getDynamicObject("e_fundflowitem").getPkValue()); map.put("e_remark", row.get("e_remark")); list.add(map); } Map>> map = new HashMap(); map.put("entry", list); String mapJson = SerializationUtils.toJsonString(map); this.getPageCache().put("entry", mapJson); } private void paymentTypeChanged(DynamicObject paymentType) { String entrance = (String)this.getModel().getValue("entrance"); boolean isAp; if (paymentType != null && PaymentTypeEnum.OTR.name().equals(entrance)) { isAp = paymentType.getBoolean("ispartpayment"); Long billTypeID = this.getPk("billtype"); boolean isChange = false; if (isAp) { if (!BillTypeConstants.PAYBILL_EXP.equals(billTypeID)) { this.addEntryCache(); this.setValue("billtype", BusinessDataServiceHelper.loadSingleFromCache(BillTypeConstants.PAYBILL_EXP, "bos_billtype")); isChange = true; } } else if (!BillTypeConstants.PAYBILL_OTR.equals(billTypeID)) { this.addEntryCache(); this.setValue("billtype", BusinessDataServiceHelper.loadSingleFromCache(BillTypeConstants.PAYBILL_OTR, "bos_billtype")); isChange = true; } if (isChange) { this.getModel().beginInit(); this.setValue("paymenttype", paymentType); this.getModel().endInit(); this.getView().updateView("paymenttype"); Label payeebanknumvLable = (Label)this.getControl("payeebanknumv"); payeebanknumvLable.setText(""); Label recaccbanknamevLable = (Label)this.getControl("recaccbanknamev"); recaccbanknamevLable.setText(""); Label payeebanknamevLable = (Label)this.getControl("payeebanknamev"); payeebanknamevLable.setText(""); Label recbanknumbervLable = (Label)this.getControl("recbanknumberv"); recbanknumbervLable.setText(""); } } this.setEntryAmountCaption(); if (paymentType != null) { isAp = paymentType.getBoolean("ispartpayment"); this.getView().setVisible(isAp, new String[]{"settleorg"}); this.settleOrg(false); DynamicObject fundflowitem = paymentType.getDynamicObject("fundflowitem"); this.fillFundflowItem(true, fundflowitem); } } private void settleTypeChanged(PropertyChangedArgs e, Object newValue) { this.ctrBeInfoVisibility(); DynamicObject settleType = (DynamicObject)newValue; DynamicObject accountCash; if (BaseDataHelper.isSettleTypeCash(settleType)) { this.setValue("payeracctbank", (Object)null); this.setValue("payerbank", (Object)null); accountCash = this.getDynamicObject("payeracctcash"); if (accountCash == null) { this.setValue("payeracctcash", AccountCashHelper.getDefaultAccountcash(this.getPk("org"), "payer")); } this.setValue("isdiffcur", "0"); this.getView().setVisible(false, new String[]{"isdiffcur"}); } else { this.setValue("payeracctcash", (Object)null); this.getView().setVisible(true, new String[]{"isdiffcur"}); } this.setPayerInfo4Lb(); accountCash = this.getDynamicObject("payeracctbank"); this.setPaymentChannelValue(accountCash, Boolean.TRUE); this.changePayeeValue(); } private void ctrBeInfoVisibility() { boolean isBePay = this.isBePay(); this.getView().setVisible(!this.isDraft(), new String[]{"settletnumber"}); this.getView().setVisible(this.isDraft(), new String[]{"draftbill"}); this.getView().setVisible(isBePay, new String[]{"usage"}); } private boolean isDraft() { DynamicObject settleType = (DynamicObject)this.getModel().getValue("settletype"); if (settleType == null) { return false; } else { String settlementType = settleType.getString("settlementtype"); return Objects.equals(settlementType, SettleMentTypeEnum.BANK.getValue()) || Objects.equals(settlementType, SettleMentTypeEnum.BUSINESS.getValue()) || Objects.equals(settlementType, SettleMentTypeEnum.CHECK.getValue()) || Objects.equals(settlementType, SettleMentTypeEnum.PROMISSORY.getValue()); } } private void exratedateChanged(Object newValue) { if (newValue != null) { this.setValue("exratedate", newValue); this.setValue("dpexratedate", newValue); } } private void currencyF7Changed(boolean reBalance) { if (reBalance) { this.showBalance(); } this.setExchangerateEditable(); } private void entries_payableAmtChanged(BigDecimal payableAmt, Object oldValue, int iRow) { IBillModel model = (IBillModel)this.getModel(); BigDecimal discountAmt = (BigDecimal)model.getValue("e_discountamt", iRow); discountAmt = discountAmt != null ? discountAmt : BigDecimal.ZERO; if (discountAmt.abs().compareTo(payableAmt.abs()) > 0) { this.getView().showTipNotification(String.format(ResManager.loadKDString("现金折扣绝对值不允许大于应付金额绝对值!", "PaymentBillEdit_2", "fi-cas-formplugin", new Object[0]))); this.setValue("e_payableamt", oldValue, iRow); } else { this.calculateAmt(); } } private void entries_discountAmtChanged(BigDecimal discountAmt, Object oldValue, int iRow) { IBillModel model = (IBillModel)this.getModel(); BigDecimal payableAmt = (BigDecimal)model.getValue("e_payableamt", iRow); payableAmt = payableAmt != null ? payableAmt : BigDecimal.ZERO; if (discountAmt.abs().compareTo(payableAmt.abs()) > 0) { this.getView().showTipNotification(String.format(ResManager.loadKDString("现金折扣绝对值不允许大于应付金额绝对值!", "PaymentBillEdit_2", "fi-cas-formplugin", new Object[0]))); this.setValue("e_discountamt", oldValue, iRow); } else { this.calculateAmt(); } } private void calculateAmt() { DynamicObject basecurrency = this.getDynamicObject("basecurrency"); BigDecimal exchangeRate = (BigDecimal)this.getModel().getValue("exchangerate"); String quotation = this.getString("payquotation"); int round = 10; if (basecurrency != null) { round = basecurrency.getInt("amtprecision"); } int count = this.getModel().getEntryRowCount("entry"); BigDecimal sumAmt = BigDecimal.ZERO; BigDecimal sumLocalAmt = BigDecimal.ZERO; for(int i = 0; i < count; ++i) { DynamicObject rowInfo = this.getModel().getEntryRowEntity("entry", i); BigDecimal payAmount = rowInfo.getBigDecimal("e_payableamt"); if (payAmount != null) { this.setValue("e_payablelocamt", QuotationHelper.callToCurrency(payAmount, exchangeRate, quotation, round), i); } BigDecimal discountAmt = rowInfo.getBigDecimal("e_discountamt"); if (discountAmt != null) { this.setValue("e_discountlocamt", QuotationHelper.callToCurrency(discountAmt, exchangeRate, quotation, round), i); } if (payAmount != null && discountAmt != null) { BigDecimal actAmt = payAmount.subtract(discountAmt); sumAmt = sumAmt.add(actAmt); BigDecimal actLocalAmt = BigDecimal.ZERO; actLocalAmt = QuotationHelper.callToCurrency(actAmt, exchangeRate, quotation, round); sumLocalAmt = sumLocalAmt.add(actLocalAmt); this.setValue("e_actamt", actAmt, i); this.setValue("e_localamt", actLocalAmt, i); } this.setValue("e_unsettledamt", payAmount, i); if (payAmount != null) { this.setValue("e_unsettledlocalamt", QuotationHelper.callToCurrency(payAmount, exchangeRate, quotation, round), i); } this.setValue("e_unlockamt", payAmount, i); } this.setValue("actpayamt", sumAmt); this.setValue("localamt", sumLocalAmt); this.calculateDpAmt(); } private void calculateDpAmt() { DynamicObject dpcurrency = this.getDynamicObject("dpcurrency"); DynamicObject basecurrency = this.getDynamicObject("basecurrency"); DynamicObject currency = this.getDynamicObject("currency"); String dppayquotation = this.getString("dppayquotation"); String agreedquotation = this.getString("agreedquotation"); int round = 10; if (basecurrency != null) { round = basecurrency.getInt("amtprecision"); } int dppayround = 10; if (dpcurrency != null) { dppayround = dpcurrency.getInt("amtprecision"); } BigDecimal actPayAmt = this.getBigDecimal("actpayamt"); if (currency != null) { actPayAmt = actPayAmt.setScale(currency.getInt("amtprecision"), 4); } BigDecimal localAmt = this.getBigDecimal("localamt"); BigDecimal agreedRate = this.getBigDecimal("agreedrate"); if (agreedRate.compareTo(new BigDecimal(0)) != 0) { BigDecimal dpAmt = BigDecimal.ZERO; dpAmt = QuotationHelper.callToCurrency(actPayAmt, agreedRate, agreedquotation, dppayround); BigDecimal dpExchangeRate = this.getBigDecimal("dpexchangerate"); BigDecimal dpLocalAmt = BigDecimal.ZERO; dpLocalAmt = QuotationHelper.callToCurrency(dpAmt, dpExchangeRate, dppayquotation, round); this.getModel().beginInit(); this.setValue("dpamt", dpAmt); this.setValue("dplocalamt", dpLocalAmt); this.setValue("lossamt", localAmt.subtract(dpLocalAmt)); this.getModel().endInit(); this.getView().updateView("dpamt"); this.getView().updateView("dplocalamt"); this.getView().updateView("lossamt"); } } private void payeeTypeChanged(String payeeType, boolean isChanged) { if (isChanged) { this.getView().setVisible(true, new String[]{"flex_addpayee"}); this.getView().setVisible(false, new String[]{"flex_payeeinfo"}); this.clearPayeeValue(); } } private void clearPayeeValue() { Object value = null; this.setValue("payeeformid", value); this.setValue("payee", value); this.setValue("payeename", value); this.setValue("payeeaccformid", value); this.setValue("payeeacctbank", value); this.setValue("payeebanknum", value); this.setValue("payeebank", value); this.setValue("payeebankname", value); this.setValue("recaccbankname", value); this.setValue("recbanknumber", value); this.setValue("payeenumber", (Object)null); this.setValue("supplierBankId", (Object)null); } private void payerAcctBankF7Changed(PropertyChangedArgs e, Object newValue) { DynamicObject payerAcctBank = (DynamicObject)newValue; this.ctrBeInfoVisibility(); this.showBalance(); if (!FeePayerEnum.REC.getValue().equals(this.getString("feepayer"))) { this.setValue("feeactbank", payerAcctBank); } if (payerAcctBank == null) { this.setValue("payerbank", (Object)null); this.setPaymentChannelValue((DynamicObject)null, Boolean.TRUE); this.setCurrencyEditable(); } else { this.setValue("payerbank", payerAcctBank.getDynamicObject("bank")); Boolean isDiffCur = (Boolean)this.getValue("isdiffcur"); DynamicObject payCurrency = null; if (isDiffCur) { payCurrency = this.getDynamicObject("dpcurrency"); } else { payCurrency = this.getDynamicObject("currency"); } boolean containCurrency = AccountBankHelper.isAcctBankContainCurrency("bd_accountbanks", payerAcctBank.getPkValue(), payCurrency); if (!containCurrency) { Long defaultCurrencyId = (Long)payerAcctBank.get("defaultcurrency.id"); if (isDiffCur) { this.setValue("dpcurrency", defaultCurrencyId); } else if (this.isBotpCreate()) { this.setValueIfAbsent("currency", defaultCurrencyId); } else { this.setValue("currency", defaultCurrencyId); } } this.setCurrencyEditable(); this.setOpenOrg(); this.setPaymentChannelValue(payerAcctBank, Boolean.TRUE); this.setSettleTypeValue(payerAcctBank); this.settleOrg(true); } } private void setPaymentChannelValue(DynamicObject payerAcctBank, boolean isAdd) { List comboItems = new ArrayList(1); ComboEdit paymentChannel = (ComboEdit)this.getControl("paymentchannel"); DynamicObject settleType = this.getDynamicObject("settletype"); ComboItem comboItem = new ComboItem(); comboItem.setValue(PaymentChannelEnum.COUNTER.getValue()); comboItem.setCaption(new LocaleString(PaymentChannelEnum.COUNTER.getName())); ComboItem selectedItem = comboItem; comboItems.add(comboItem); DynamicObject billtype = this.getDynamicObject("billtype"); if (null != payerAcctBank && (settleType == null || !"14".equals(settleType.getString("settlementtype"))) && (billtype == null || !BillTypeConstants.PAYBILL_CASH.equals(billtype.getPkValue()))) { ComboItem item; if (payerAcctBank.getBoolean("isopenbank")) { item = new ComboItem(); item.setValue(PaymentChannelEnum.ONLINEBANK.getValue()); item.setCaption(new LocaleString(PaymentChannelEnum.ONLINEBANK.getName())); selectedItem = item; comboItems.add(item); } if (payerAcctBank.getBoolean("issetbankinterface")) { item = new ComboItem(); item.setValue(PaymentChannelEnum.BEI.getValue()); item.setCaption(new LocaleString(ResManager.loadKDString(PaymentChannelEnum.BEI.getName(), "PaymentBillEdit_18", "fi-cas-formplugin", new Object[0]))); selectedItem = item; comboItems.add(item); } String defaultPaymentChannel = ""; String defChannel; if (Objects.nonNull(settleType)) { defChannel = settleType.getString("paymentchannel"); defaultPaymentChannel = settleType.getString("defaultpaymentchannel"); if (kd.bos.dataentity.utils.StringUtils.isNotEmpty(defChannel)) { List paymentChannels = (List)Arrays.stream(defChannel.split(",")).filter(kd.bos.dataentity.utils.StringUtils::isNotEmpty).collect(Collectors.toList()); comboItems.removeIf((i) -> { return !paymentChannels.contains(i.getValue()); }); } } paymentChannel.setComboItems(comboItems); if (isAdd || this.isBotpNew() && Objects.isNull(this.getModel().getValue("paymentchannel"))) { defChannel = selectedItem.getValue(); if (settleType != null && !SettleMentTypeEnum.COLLECT.getValue().equals(settleType.getString("settlementtype"))) { defChannel = PaymentChannelEnum.COUNTER.getValue(); } if (kd.bos.dataentity.utils.StringUtils.isNotEmpty(defaultPaymentChannel)) { defChannel = defaultPaymentChannel; } String finalDefChannel = defChannel; boolean contains = comboItems.stream().anyMatch((itemx) -> { return Objects.equals(finalDefChannel, itemx.getValue()); }); if (!contains) { defChannel = null; } if ("bei".equalsIgnoreCase(defChannel)) { this.getModel().setValue("fee", (Object)null); this.getModel().setValue("singlestream", Boolean.FALSE); } this.getModel().setValue("paymentchannel", defChannel); } } else { paymentChannel.setComboItems(comboItems); if (isAdd) { this.getModel().setValue("paymentchannel", comboItem.getValue()); if ("bei".equalsIgnoreCase(comboItem.getValue())) { this.getModel().setValue("fee", (Object)null); this.getModel().setValue("singlestream", Boolean.FALSE); } } } } private void payerAcctCashChanged(DynamicObject acctCash) { if (acctCash == null) { this.setValue("currency", this.getDynamicObject("basecurrency")); this.setCurrencyEditable(); this.showBalance(); } else { Boolean isDiffCur = (Boolean)this.getValue("isdiffcur"); DynamicObject payCurrency = null; if (isDiffCur) { payCurrency = this.getDynamicObject("dpcurrency"); } else { payCurrency = this.getDynamicObject("currency"); } boolean containCurrency = AccountBankHelper.isAcctBankContainCurrency("cas_accountcash", acctCash.getPkValue(), payCurrency); if (!containCurrency) { DynamicObject defaultCurrency = acctCash.getDynamicObject("defaultcurrency"); if (isDiffCur) { this.setValue("dpcurrency", defaultCurrency); } else if (this.isBotpCreate()) { this.setValueIfAbsent("currency", defaultCurrency); } else { this.setValue("currency", defaultCurrency); } } this.setCurrencyEditable(); this.setValue("openorg", acctCash.getDynamicObject("openorg")); this.showBalance(); } } private void setCurrencyEditable() { Boolean isCurrencyEditable = Boolean.TRUE; DynamicObject settleType = this.getDynamicObject("settletype"); boolean isCash = BaseDataHelper.isSettleTypeCash(settleType); DynamicObject accountCash; if (isCash) { accountCash = this.getDynamicObject("payeracctcash"); if (accountCash != null) { isCurrencyEditable = !accountCash.getBoolean("isbycurrency"); } } else { accountCash = this.getDynamicObject("payeracctbank"); if (accountCash != null) { isCurrencyEditable = accountCash.getBoolean("ismulcurrency"); } } Boolean isDiffCur = (Boolean)this.getValue("isdiffcur"); if (isDiffCur) { this.getView().setEnable(isCurrencyEditable, new String[]{"dpcurrency"}); } else { this.getView().setEnable(isCurrencyEditable, new String[]{"currency"}); } if (this.isBotpCreate()) { this.getView().setEnable(false, new String[]{"currency"}); } } private void showBalance() { this.getView().setEnable(true, new String[]{"bar_save", "bar_submit", "bar_beforesubmit"}); if (this.getModel().getValue("org") != null) { Long orgID = this.getPk("org"); Long acctBankId = this.getPk("payeracctbank"); Long acctCashId = this.getPk("payeracctcash"); Long currencyId = this.getPk("currency"); boolean var5 = (Boolean)this.getValue("isdiffcur"); if (var5) { currencyId = this.getPk("dpcurrency"); } if (orgID != null && (acctBankId != null || acctCashId != null) && currencyId != null) { DynamicObject currency = BusinessDataServiceHelper.loadSingleFromCache(currencyId, "bd_currency"); try { BigDecimal currentBalance = BigDecimal.ZERO; if (CasHelper.isNotEmpty(acctBankId)) { DynamicObject acctBank = BusinessDataServiceHelper.loadSingle(acctBankId, "am_accountbank", "acctclassify"); if (Objects.equals(acctBank.get("acctclassify"), AcctClassifyEnum.I.getValue())) { currentBalance = getCurrBalance(acctBank); } else { String balanceType = SystemParameterFcsHelper.getParameterString(orgID, "balancevalue"); Object result = DispatchServiceHelper.invokeBizService("tmc", "fbp", "balanceModelService", "getRunningBalance", new Object[]{balanceType, acctBankId, currencyId}); BizBalanceModelBean bizBalanceModelBean = (BizBalanceModelBean)SerializationUtils.fromJsonString(SerializationUtils.toJsonString(result), BizBalanceModelBean.class); currentBalance = bizBalanceModelBean.getAmount(); } } if (CasHelper.isNotEmpty(acctCashId)) { currentBalance = AcctBalanceHelper.getAccountCashCurrBalance(orgID, acctCashId, currencyId, new Date()); ((Label)this.getControl("balancelb")).setText(ResManager.loadKDString("账面余额:", "PaymentBillEdit_4", "fi-cas-formplugin", new Object[0])); LocaleString content = new LocaleString(ResManager.loadKDString("付款账户为现金账户时,账面余额即为当前时点现金日记账账面余额。", "PaymentBillEdit_3", "fi-cas-formplugin", new Object[0])); ((Label)this.getControl("balancelb")).addTips(new Tips("text", (LocaleString)null, content, false, (List)null)); } this.labCurrencySign = currency.getString("sign"); this.currencyAmtprecision = currency.getInt("amtprecision"); this.initFormat(); ((Label)this.getControl("balancev")).setText(this.currencyFormat.format(currentBalance == null ? 0 : currentBalance)); } catch (Exception var12) { this.clearBalanceValue(); logger.error(var12); } } else { this.clearBalanceValue(); } } } private static BigDecimal getCurrBalance(DynamicObject bankAcct) { DynamicObject[] load = BusinessDataServiceHelper.load("ifm_accountbalance", "amount", (new QFilter("accountbank", "=", bankAcct.getPkValue())).toArray(), "bizdate desc", 1); return load.length > 0 ? load[0].getBigDecimal("amount") : BigDecimal.ZERO; } private void clearBalanceValue() { ((Label)this.getControl("balancelb")).setText(ResManager.loadKDString("即时余额:", "PaymentBillEdit_5", "fi-cas-formplugin", new Object[0])); LocaleString content = new LocaleString(ResManager.loadKDString("付款账户当前时点余额。付款账户即时余额取值来源有银企互联余额表、出纳/资金结算日记账;系统支持四种取值模式:(1)完全取自余额表;(2)完全取自日记账;(3)优先取余额表,再取日记账;(4)开通银企取余额表,未开通银企取日记账。具体采取何种模式请前往【系统服务云】-【配置工具】-【系统参数】-【资金云】-【资金公共服务】中查看。", "PaymentBillEdit_6", "fi-cas-formplugin", new Object[0])); ((Label)this.getControl("balancelb")).addTips(new Tips("text", (LocaleString)null, content, false, (List)null)); DynamicObject currency = this.getDynamicObject("currency"); Boolean isDiffCur = (Boolean)this.getValue("isdiffcur"); if (isDiffCur) { currency = this.getDynamicObject("dpcurrency"); } if (!CasHelper.isEmpty(currency)) { this.labCurrencySign = currency.getString("sign"); this.currencyAmtprecision = currency.getInt("amtprecision"); this.initFormat(); ((Label)this.getControl("balancev")).setText(this.currencyFormat.format(BigDecimal.ZERO)); } else { ((Label)this.getControl("balancev")).setText("¥0.00"); } } public void click(EventObject evt) { super.click(evt); this.getView().setEnable(true, 0, new String[]{"e_payableamt", "e_discountamt", "contractnumber", "e_corebillno", "e_corebillentryseq"}); Control c = (Control)evt.getSource(); switch (c.getKey().toLowerCase()) { case "changepayer": this.changePayerPage(); break; case "addpayeelb1": this.addPayee(); break; case "addpayeelb2": this.addPayee(); break; case "changepayee": this.changePayeePage(); break; case "settletnumber": this.settleNumberClick(); break; case "applyname": BasedataEdit applyF7 = (BasedataEdit)this.getControl("applyid"); applyF7.click(); } } private void settleNumberClick() { DynamicObject settleType = (DynamicObject)this.getModel().getValue("settletype"); if (EmptyUtil.isNoEmpty(settleType) && SettleMentTypeEnum.CREDIT.getValue().equals(settleType.getString("settlementtype"))) { String appId = AppMetadataCache.getAppInfo("lc").getId(); DynamicObject org = (DynamicObject)this.getModel().getValue("org"); AppParam param = new AppParam(); param.setAppId(appId); param.setOrgId(org.getLong("id")); param.setViewType("08"); String paymethod = (String)SystemParamServiceHelper.loadAppParameterFromCache(param, "paymethod"); if ("0".equals(paymethod)) { CloseCallBack closeCallBack = new CloseCallBack(this, "settletnumber"); QFilter qFilterSour = new QFilter("arrivalstatus", "=", "arrival_confirm"); qFilterSour.and("arrivalway", "!=", "protest"); qFilterSour.and(QFilter.sqlExpress("arrivalamount", ">", "flockamount")); qFilterSour.and("isinit", "=", '0'); qFilterSour.and("eassrcid", "=", ""); CasBotpHelper.doBeforeDraw(this.getView(), "lc_arrival", this.getModel().getDataEntityType().getName(), false, qFilterSour, closeCallBack); } } } private void changePayeePage() { this.opreatePayee(Boolean.FALSE); } private void addPayee() { this.opreatePayee(Boolean.TRUE); } private void opreatePayee(Boolean isAddNew) { Map paramMap = new HashMap(); if (this.isHwControl()) { paramMap.put("hw_payeesiteid", this.getValue("hw_payeesiteid")); } paramMap.put("org", this.getPk("org")); paramMap.put("asstActType", this.getString("payeetype")); paramMap.put("isBE", this.isBePay()); paramMap.put("billtype", Optional.ofNullable(this.getDynamicObject("billtype")).map(DataEntityBase::getPkValue).orElse((Object)null)); FormShowParameter parameter = new FormShowParameter(); parameter.getOpenStyle().setShowType(ShowType.Modal); parameter.setFormId("cas_addpayee"); parameter.setStatus(isAddNew ? OperationStatus.ADDNEW : OperationStatus.EDIT); parameter.getCustomParams().putAll(paramMap); parameter.setCloseCallBack(new CloseCallBack(this, "addpayee")); this.getView().showForm(parameter); } private void addPayeeValue(Map resultMap) { this.setValue("payeeformid", resultMap.get("payeeformid")); this.setValue("payee", resultMap.get("payee")); this.setValue("payeename", resultMap.get("payeename")); if (this.isHwControl()) { this.setValue("hw_payeesiteid", resultMap.get("hw_payeesiteid")); this.setValue("scorg", resultMap.get("scorg")); } this.setValue("payeenumber", resultMap.get("payeenumber")); this.setValue("payeeaccformid", resultMap.get("payeeaccformid")); this.setValue("payeeacctbank", resultMap.get("payeeacctbank")); this.setValue("payeeacctcash", resultMap.get("payeeacctcash")); this.setValue("payeebanknum", resultMap.get("payeebanknum")); this.setValue("payeebank", resultMap.get("payeebank")); this.setValue("payeebankname", resultMap.get("payeebankname")); this.setValue("recaccbankname", resultMap.get("recaccbankname")); String beBankNumber = (String)resultMap.get("recbanknumber"); this.setValue("recbanknumber", beBankNumber); this.setValue("reccountry", resultMap.get("reccountry")); this.setValue("recprovince", resultMap.get("recprovince")); this.setValue("reccity", resultMap.get("reccity")); this.setValue("recswiftcode", resultMap.get("swift_code")); this.setValue("recroutingnum", resultMap.get("routingnum")); this.setValue("recothercode", resultMap.get("other_code")); this.setValue("recbankaddress", resultMap.get("address_eng")); this.setValue("recemail", resultMap.get("payeeemail")); this.setValue("payeecurrency", resultMap.get("payeecurrency")); this.setValue("recaddress", resultMap.get("payeeaddress")); this.setValue("supplierBankId", resultMap.get("supplierBankId")); PaymentBillPluginHelper.fillProxyBeBankInfo(this.getModel(), this.getView(), true); Boolean isDiffCur = (Boolean)this.getValue("isdiffcur"); Object recCurId = resultMap.get("payeecurrency"); if (recCurId != null && ((Long)recCurId).intValue() != 0 && !this.isBotpCreate() && isDiffCur) { this.setValue("currency", resultMap.get("payeecurrency")); } if (AsstActTypeEnum.SUPPLIER.getValue().equals(this.getModel().getValue("payeetype"))) { DynamicObject new_settletype = (DynamicObject)resultMap.get("settlment"); DynamicObject old_settletype = (DynamicObject)this.getModel().getValue("settletype"); if (!CasHelper.isEquals(new_settletype, old_settletype) && new_settletype != null) { this.setValue("settletype", new_settletype); } } this.setPayeeInfo4Lb(); this.getView().setVisible(false, new String[]{"flex_addpayee"}); this.getView().setVisible(true, new String[]{"flex_payeeinfo"}); } private void changePayeeValue() { this.setPayeeInfo4Lb(); boolean addpayView = this.hasPayeeInfo(); this.getView().setVisible(!addpayView, new String[]{"flex_addpayee"}); this.getView().setVisible(addpayView, new String[]{"flex_payeeinfo"}); } private void setPayeeInfo4Lb() { String payeeformid = this.getString("payeetype"); List payeetypeList = Arrays.asList("bos_org", "bd_supplier", "bd_customer", "bos_user"); Long payeeId = Long.parseLong(this.getValue("payee") == null ? "0" : this.getValue("payee").toString()); String payeeType = this.getString("payeetype"); if (isOther(payeeType)) { this.setValue("payeenamev", this.getValue("payeename")); } else if (CasHelper.isNotEmpty(payeeformid) && payeetypeList.contains(payeeformid) && CasHelper.isNotEmpty(payeeId)) { DynamicObject payeeObj = BusinessDataServiceHelper.loadSingleFromCache(payeeId, payeeformid, "name"); this.setValue("payeenamev", CasHelper.getLocalValue(payeeObj, "name")); } Image payeePic = (Image)this.getControl("payeepic"); String defaultUrl = BaseDataHelper.getPictureUrl(payeeId, payeeformid); defaultUrl = defaultUrl == null ? "/icons/pc/entrance/cn_sk_80_80.png" : defaultUrl; payeePic.setUrl(defaultUrl); ((Label)this.getControl("payeebanknumv")).setText(StringUtils.splitString(this.getString("payeebanknum"), 4, " ")); ((Label)this.getControl("payeebanknamev")).setText(this.getString("payeebankname")); ((Label)this.getControl("recaccbanknamev")).setText(this.getString("recaccbankname")); ((Label)this.getControl("recbanknumberv")).setText(this.getString("recbanknumber")); } private void changePayerPage() { DynamicObject settleType = this.getDynamicObject("settletype"); Object sourceBillType = this.getModel().getValue("sourcebilltype"); Map payerInfo = new HashMap(); payerInfo.put("cash", BaseDataHelper.isSettleTypeCash(settleType)); payerInfo.put("virtual", BaseDataHelper.isSettleTypeVirtual(settleType)); payerInfo.put("sourceBillType", sourceBillType); FormShowParameter parameter = new FormShowParameter(); parameter.getOpenStyle().setShowType(ShowType.Modal); parameter.setFormId("cas_changepayer"); parameter.getCustomParams().putAll(payerInfo); parameter.setCloseCallBack(new CloseCallBack(this, "changepayer")); this.getView().showForm(parameter); } private void changePayerValue(Map returnMap) { boolean isChangeCur = false; IBillModel model = (IBillModel)this.getModel(); DynamicObject new_org = (DynamicObject)returnMap.get("org"); DynamicObject old_org = (DynamicObject)model.getValue("org"); DynamicObject cur = OrgHelper.getBaseCurrency((Long)new_org.getPkValue()); if (!CasHelper.isEquals(new_org, old_org)) { this.setValue("org", new_org); this.setValue("basecurrency", cur); this.setValue("draftbill", (Object)null); isChangeCur = true; } DynamicObject new_acctcash = (DynamicObject)returnMap.get("payeracctcash"); DynamicObject old_acctcash = (DynamicObject)model.getValue("payeracctcash"); if (!CasHelper.isEquals(new_acctcash, old_acctcash)) { this.setValue("payeracctcash", new_acctcash); isChangeCur = false; } DynamicObject new_acctbank = (DynamicObject)returnMap.get("payeracctbank"); DynamicObject old_acctbank = (DynamicObject)model.getValue("payeracctbank"); if (!CasHelper.isEquals(new_acctbank, old_acctbank)) { this.setValue("payeracctbank", new_acctbank); isChangeCur = false; } DynamicObject new_bank = (DynamicObject)returnMap.get("payerbank"); DynamicObject old_bank = (DynamicObject)model.getValue("payerbank"); if (!CasHelper.isEquals(new_bank, old_bank)) { this.setValue("payerbank", new_bank); } this.setPayerInfo4Lb(); this.settleOrg(true); if (isChangeCur) { this.setValue("currency", cur); } String uniformsocialcreditcode = new_org.getString("uniformsocialcreditcode"); if (kd.bos.dataentity.utils.StringUtils.isNotBlank(uniformsocialcreditcode)) { this.setValue("uniformsocialcreditcode", uniformsocialcreditcode); } String payerNumber = new_org.getString("number"); if (kd.bos.dataentity.utils.StringUtils.isNotBlank(payerNumber)) { this.setValue("payernumber", payerNumber); } this.setValue("openorg", returnMap.get("openorg")); } public void closedCallBack(ClosedCallBackEvent e) { super.closedCallBack(e); Map data; if ("changepayer".equals(e.getActionId())) { data = (Map)e.getReturnData(); if (data != null) { this.changePayerValue(data); } } else if ("addpayee".equals(e.getActionId())) { data = (Map)e.getReturnData(); if (data != null) { this.addPayeeValue(data); this.setCrossPayValue(); } } else { String confirm; if ("beforesubmit".equals(e.getActionId())) { confirm = (String)e.getReturnData(); if (confirm != null && confirm.equals("ok")) { this.getView().invokeOperation("submit"); } } else if ("beforesubmitnew".equals(e.getActionId())) { confirm = (String)e.getReturnData(); if (confirm != null && confirm.equals("ok")) { this.getView().invokeOperation("submitandnew"); } } else { OperateOption option; if (kd.bos.dataentity.utils.StringUtils.equals(e.getActionId(), "KEY_DIFFPAY_CALLBACK")) { data = (Map)e.getReturnData(); if (data != null) { option = OperateOption.create(); Iterator var4 = data.entrySet().iterator(); while(var4.hasNext()) { Map.Entry entry = (Map.Entry)var4.next(); if (entry.getValue() != null) { option.setVariableValue((String)entry.getKey(), entry.getValue().toString()); } } option.setVariableValue("payConfirm", "1"); this.getView().invokeOperation("pay", option); } } else if (kd.bos.dataentity.utils.StringUtils.equals(e.getActionId(), "CALLBACK_SELECTDRAFT")) { Object draftIdList = e.getReturnData(); if (draftIdList != null) { option = OperateOption.create(); option.setVariableValue("draftids", JSON.toJSONString(draftIdList)); this.getView().invokeOperation("pay", option); } } else if (kd.bos.dataentity.utils.StringUtils.equals(e.getActionId(), "settletnumber")) { ListSelectedRowCollection rows = (ListSelectedRowCollection)e.getReturnData(); if (EmptyUtil.isNoEmpty(rows)) { this.getModel().deleteEntryData("entry"); CasBotpHelper.doDraw(this.getView(), "lc_arrival", this.getModel().getDataEntityType().getName(), rows); } } } } PaymentBillPluginHelper.isSchePayEditable(this, this.getModel()); DynamicObject org = this.getDynamicObject("org"); InitCheckPluginHelper.checkInitForPlugin(this.getView(), org, new String[]{"bar_save", "bar_submit"}); } public void beforeItemClick(BeforeItemClickEvent evt) { String opKey = evt.getOperationKey(); if ("delete".equals(opKey)) { if ("cas_recbill".equals(this.getString("sourcebilltype"))) { evt.setCancel(true); String billno = this.getString("billno"); this.getView().showConfirm(String.format(ResManager.loadKDString("%s付款单由内部收付协同业务自动生成,是否确认删除?", "PaymentBillEdit_23", "fi-cas-formplugin", new Object[0]), billno), MessageBoxOptions.YesNo, ConfirmTypes.Default, new ConfirmCallBackListener("CONFIRM_DEL_CALLBACK", this)); } } else if ("pay".equals(opKey)) { DynamicObject dataEntity = this.getModel().getDataEntity(); long orgDynId = dataEntity.getDynamicObject("org").getLong("id"); boolean selectDraftFlag = SystemParameterHelper.getParameterBoolean(orgDynId, "cs122"); String settleTypeKey = DraftHelper.getKey(dataEntity.get("settletype")); logger.info("selectDraftFlag is:" + selectDraftFlag + ",key:" + settleTypeKey); boolean isdraft = SystemParameterHelper.getCdmParameterBoolean(orgDynId, "isdraft"); boolean ischeck = SystemParameterHelper.getCdmParameterBoolean(orgDynId, "ischeck"); boolean ispromissorynote = SystemParameterHelper.getCdmParameterBoolean(orgDynId, "ispromissorynote"); if (!CasHelper.isEmpty(settleTypeKey)) { String typeName; switch (settleTypeKey) { case "isdraft": if (isdraft && !selectDraftFlag) { typeName = ResManager.loadKDString("汇票", "DraftHelper_4", "fi-cas-common", new Object[0]); this.cancelAndWarn(evt, dataEntity, typeName); } break; case "ischeck": if (ischeck && !selectDraftFlag) { typeName = ResManager.loadKDString("支票", "DraftHelper_5", "fi-cas-common", new Object[0]); this.cancelAndWarn(evt, dataEntity, typeName); } break; case "ispromissorynote": if (ispromissorynote && !selectDraftFlag) { typeName = ResManager.loadKDString("本票", "DraftHelper_6", "fi-cas-common", new Object[0]); this.cancelAndWarn(evt, dataEntity, typeName); } } } } if ("commitbe".equals(opKey)) { OperateOption op = OperateOption.create(); op.setVariableValue("ishasright", "true"); OperationResult operationResult = OperationServiceHelper.executeOperate("beforecommitbe", "nckd_cas_arbill", new Object[]{this.getModel().getDataEntity().getPkValue()}, op); if (!operationResult.isSuccess() && operationResult.isNeedSign()) { SignOperateCallback signOperate = new SignOperateCallback(this.getView(), this, op, ClientCallback.SignClientType.Secondry, "signbeforecommitbe"); OperationResult ops = signOperate.sign(operationResult); evt.setCancel(true); if (!ops.isSuccess()) { logger.info(" beforecommitbe sign error "); if (ops.isShowMessage() && EmptyUtil.isNoEmpty(ops.getMessage())) { this.getView().showTipNotification(ops.getMessage()); } } } } } private void cancelAndWarn(BeforeItemClickEvent evt, DynamicObject dataEntity, String typeName) { String msg = String.format(ResManager.loadKDString("%1$s :结算方式类别为%2$s的付款单不支持确认付款", "DraftHelper_7_1", "fi-cas-common", new Object[0]), dataEntity.getString("billno"), typeName); evt.setCancel(true); this.getView().showTipNotification(msg); } public void itemClick(ItemClickEvent evt) { super.itemClick(evt); String key = evt.getItemKey().toLowerCase(); if ("bar_beforesubmit".equals(key)) { this.getView().invokeOperation("beforesubmit"); } else if ("bar_cancelpay".equals(key)) { this.cancelPay(); } else if ("viewsettle".equals(key)) { this.viewSettle(); } else if ("bar_save".equals(key)) { this.getView().updateView("feeactbank"); this.getView().updateView("feecurrency"); } } public void afterDeleteRow(AfterDeleteRowEventArgs e) { super.afterDeleteRow(e); this.calculateAmt(); } public void afterBindData(EventObject e) { super.afterBindData(e); DynamicObject org = this.getDynamicObject("org"); InitCheckPluginHelper.checkInitForPlugin(this.getView(), org, new String[]{"bar_save", "bar_submit"}); DynamicObject paymentBill = this.getModel().getDataEntity(); Map customParams = this.getView().getFormShowParameter().getCustomParams(); Object showConer = customParams.get("showConer"); List workflowlist = WorkflowServiceHelper.getAllApprovalRecord(paymentBill.getPkValue().toString()); if (CollectionUtils.isEmpty(workflowlist) || CasHelper.isEmpty(showConer)) { SplitContainer control = (SplitContainer)this.getControl("splitcontainerap"); control.hidePanel(SplitDirection.right, true); control.setCollapse("splitpanelap1", true); } Long orgId = this.getPk("org"); DynamicObject cur; DynamicObject payeracctbank; if (this.isBotpNew()) { if (orgId == null) { this.getView().setEnable(false, new String[]{"bar_save", "bar_submit", "bar_beforesubmit"}); this.getView().showErrorNotification(ResManager.loadKDString("请在上游单据维护付款组织来源再推付款单。", "PaymentBillEdit_7", "fi-cas-formplugin", new Object[0])); return; } cur = OrgHelper.getBaseCurrency(orgId); if (cur == null) { this.getView().setEnable(false, new String[]{"bar_save", "bar_submit", "bar_beforesubmit"}); this.getView().setVisible(false, new String[]{"bar_refund_save", "bar_submitandnew", "bar_del", "bar_audit", "bar_unaudit", "bar_pay", "bar_cancelpay", "bar_commitbe", "genvoucher", "deletevoucher", "copyentryrow"}); this.getView().getFormShowParameter().setStatus(OperationStatus.VIEW); this.getView().showErrorNotification(SystemStatusCtrolHelper.notFinishInitSetMsg(CasHelper.getLocalValue(this.getDynamicObject("org"), "name"))); return; } this.setValueIfAbsent("basecurrency", cur); payeracctbank = this.getDynamicObject("payeracctbank"); if (payeracctbank != null) { this.setValueIfAbsent("payerbank", payeracctbank.getDynamicObject("bank")); this.setValueIfAbsent("openorg", payeracctbank.getDynamicObject("openorg")); } this.setNetBankAcctVisible(); DynamicObject paymentType = paymentBill.getDynamicObject("paymenttype"); if (paymentType != null) { paymentType = BusinessDataServiceHelper.loadSingleFromCache(paymentType.getPkValue(), "cas_paymentbilltype", "id,fundflowitem"); this.fillFundflowItem(false, paymentType.getDynamicObject("fundflowitem")); } } if (null == this.getDynamicObject("exratetable")) { this.setDefaultExratetable(orgId); } PaymentBillPluginHelper.fillToolBar(this, this.getModel(), this.getView()); this.setPayerInfo4Lb(); this.changePayeeValue(); this.setEntryAmountCaption(); this.ctrChangeLableVisible(); this.setCurrencyEditable(); this.ctrBeInfoVisibility(); this.setExchangerateEditable(); this.ctrRefundInfoVisibility(); cur = this.getDynamicObject("payeracctbank"); this.setPaymentChannelValue(cur, Boolean.FALSE); this.setDiffCurInfo(); this.setCountryValue(); this.setCrossPayValue(); this.isDiffCurVisibility(); this.isOnlinebankVisibility(); this.setPayerAndPayeeInfo(orgId); this.getModel().setDataChanged(false); payeracctbank = (DynamicObject)this.getModel().getValue("settletype"); if (Objects.nonNull(payeracctbank)) { this.settletNumber(payeracctbank); } else { this.getView().setVisible(Boolean.FALSE, new String[]{"draftbill"}); } this.showBalance(); } private void setPayerAndPayeeInfo(Long orgId) { if (!CasHelper.isEmpty(orgId)) { DynamicObject org = BusinessDataServiceHelper.loadSingleFromCache(orgId, "bos_org"); this.getModel().setValue("payernumber", org.getString("number")); this.getModel().setValue("uniformsocialcreditcode", org.getString("uniformsocialcreditcode")); Long payeeId = Long.valueOf(this.getModel().getValue("payee").toString()); String type = this.getModel().getValue("payeetype").toString(); String number = this.getModel().getValue("payeenumber").toString(); if (!number.isEmpty() || !AsstActTypeEnum.SUPPLIER.getValue().equals(type) && !AsstActTypeEnum.CUSTOMER.getValue().equals(type)) { if (number.isEmpty() && (AsstActTypeEnum.EMPLOYEE.getValue().equals(type) || AsstActTypeEnum.COMPANY.getValue().equals(type))) { number = this.getUserOrOrgNumber(payeeId, type); } } else { number = this.getPayeeOrPayerInfoNumber(payeeId, type, this.getModel().getDataEntityType().getName()); } this.getModel().setValue("payeenumber", number); if (!this.getModel().getDataEntity().getString("billstatus").equals(BillStatusEnum.SAVE.getValue())) { this.getView().setEnable(false, new String[]{"priority"}); } } } protected void setExchangerateEditable() { DynamicObject srcCurrency = this.getDynamicObject("currency"); DynamicObject destCurrency = this.getDynamicObject("basecurrency"); if (srcCurrency != null && destCurrency != null) { if (srcCurrency.getLong("id") == destCurrency.getLong("id")) { this.getView().setEnable(false, new String[]{"exchangerate"}); } } } private void setDefaultExratetable(Long orgId) { Long exchangeRateTableId = 0L; try { exchangeRateTableId = SystemStatusCtrolHelper.getExrateTable(orgId).getLong("id"); } catch (Exception var4) { } this.getModel().setValue("exratetable", exchangeRateTableId); } private void setEntryAmountCaption() { DynamicObject billType = (DynamicObject)this.getModel().getValue("billtype"); if (billType != null) { EntryGrid entryCtr = (EntryGrid)this.getControl("entry"); if (BillTypeConstants.PAYBILL_OTR.equals(billType.getPkValue())) { entryCtr.setColumnProperty("e_payableamt", "header", new LocaleString(ResManager.loadKDString("实付金额", "PaymentBillEdit_8", "fi-cas-formplugin", new Object[0]))); entryCtr.setColumnProperty("e_payablelocamt", "header", new LocaleString(ResManager.loadKDString("实付折本币", "PaymentBillEdit_9", "fi-cas-formplugin", new Object[0]))); } else { entryCtr.setColumnProperty("e_payableamt", "header", new LocaleString(ResManager.loadKDString("应付金额", "PaymentBillEdit_10", "fi-cas-formplugin", new Object[0]))); entryCtr.setColumnProperty("e_payablelocamt", "header", new LocaleString(ResManager.loadKDString("应付折本币", "PaymentBillEdit_11", "fi-cas-formplugin", new Object[0]))); } } } private void ctrChangeLableVisible() { Object sourceBillType = this.getModel().getValue("sourcebilltype"); if (!"cas_recbill".equals(sourceBillType) && !"bei_transdetail_cas".equals(sourceBillType) && BillStatusEnum.SAVE.getValue().equals(this.getModel().getValue("billstatus"))) { if (!(Boolean)this.getModel().getValue("issupplecontract")) { this.getView().setVisible(true, new String[]{"changepayer", "changepayee"}); } } else { this.getView().setVisible(false, new String[]{"changepayer", "changepayee"}); } } private boolean isBePay() { DynamicObject payerAcctBank = this.getDynamicObject("payeracctbank"); if (payerAcctBank != null && PayBillCrossHelper.isIfmBankAcc(payerAcctBank)) { return true; } else { return payerAcctBank != null && (Boolean)payerAcctBank.get("issetbankinterface") && "bei".equalsIgnoreCase(this.getString("paymentchannel")); } } private boolean isBeiBePay() { DynamicObject payerAcctBank = this.getDynamicObject("payeracctbank"); return payerAcctBank != null && (Boolean)payerAcctBank.get("issetbankinterface") && "bei".equalsIgnoreCase(this.getString("paymentchannel")); } public void beforeDoOperation(BeforeDoOperationEventArgs args) { super.beforeDoOperation(args); AbstractOperate op = (AbstractOperate)args.getSource(); String operateKey = op.getOperateKey(); DynamicObject payerAcctBank = this.getDynamicObject("payeracctbank"); DynamicObject accountBank; if ("trackdown".equals(operateKey)) { accountBank = this.getDynamicObject("settletype"); if (accountBank != null) { String settlementtype = accountBank.getString("settlementtype"); if (EmptyUtil.isNoEmpty(settlementtype) && this.settleTypes.contains(settlementtype)) { op.getOption().setVariableValue("botp_track_edit_status", "true"); } } } else if ((!"save".equals(operateKey) || (Boolean)this.getModel().getValue("issupplecontract")) && !"submit".equals(operateKey) && !"submitandnew".equals(operateKey) && !"beforesubmit".equals(operateKey) && !"beforesubmitnew".equals(operateKey)) { DynamicObject orgData; if ("refundsave".equals(operateKey)) { Long rebillid = (Long)this.getView().getFormShowParameter().getCustomParam("rebillid"); orgData = BusinessDataServiceHelper.loadSingle(rebillid, "cas_recbill"); BigDecimal actrecamt = orgData.getBigDecimal("actrecamt"); DynamicObjectCollection payEntrys = this.getModel().getEntryEntity("entry"); BigDecimal refundamtTotal = (BigDecimal)payEntrys.stream().map((o) -> { return o.getBigDecimal("e_refundamt"); }).reduce(BigDecimal.ZERO, BigDecimal::add); if (actrecamt.compareTo(refundamtTotal) != 0) { throw new KDBizException(ResManager.loadKDString("退款金额合计与收款单金额不相等", "PaymentBillEdit_19", "fi-cas-formplugin", new Object[0])); } FormOperate operate = (FormOperate)args.getSource(); operate.getOption().setVariableValue("rebillid", SerializationUtils.toJsonString(this.getView().getFormShowParameter().getCustomParam("rebillid"))); operate.getOption().setVariableValue("billtype", "nckd_cas_arbill"); } else if ("recbook".equals(operateKey)) { accountBank = this.getDynamicObject("payeracctbank"); if (null != accountBank && AccountBankHelper.isClosed(accountBank.getLong("id"))) { throw new KDBizException(String.format(ResManager.loadKDString("账户%s当前状态为已销户,暂无法进行业务处理。", "PaymentErrorCode_47", "fi-cas-business", new Object[0]), accountBank.getString("number"))); } if (payerAcctBank != null && PayBillCrossHelper.isIfmBankAcc(payerAcctBank)) { throw new KDBizException(ResManager.loadKDString("内部账户请选择内部结算付款。", "PaymentErrorCode_48", "fi-cas-business", new Object[0])); } if (PaymentBillPluginHelper.checkPayeeTypeFreeze(Collections.singletonList(this.getModel().getDataEntity()))) { throw new KDBizException((new PaymentErrorCode()).CANOTDOTHISOP_WHENSUPPLIERFREEZE().getMessage()); } } else if ("endorse".equals(operateKey)) { if (payerAcctBank != null && PayBillCrossHelper.isIfmBankAcc(payerAcctBank)) { throw new KDBizException(ResManager.loadKDString("内部账户请选择内部结算付款。", "PaymentErrorCode_48", "fi-cas-business", new Object[0])); } if (PaymentBillPluginHelper.checkPayeeTypeFreeze(Collections.singletonList(this.getModel().getDataEntity()))) { throw new KDBizException((new PaymentErrorCode()).CANOTDOTHISOP_WHENSUPPLIERFREEZE().getMessage()); } } else if ("pay".equals(operateKey)) { String draftIds = op.getOption().getVariableValue("draftids", ""); if (kd.bos.dataentity.utils.StringUtils.isEmpty(draftIds)) { orgData = (DynamicObject)this.getValue("org"); Long pkValue = (Long)orgData.getPkValue(); boolean selectDraftFlag = SystemParameterHelper.getParameterBoolean(pkValue, "cs122"); DynamicObject data = this.getModel().getDataEntity(true); if (selectDraftFlag && PaymentBillPluginHelper.needSelectedDraft(data)) { FormShowParameter showParameter = new FormShowParameter(); showParameter.setAppId("cas"); showParameter.setFormId("cas_payment_selectdraft"); showParameter.setCustomParam("payBillId", data.getPkValue()); showParameter.getOpenStyle().setShowType(ShowType.Modal); showParameter.setCloseCallBack(new CloseCallBack(this, "CALLBACK_SELECTDRAFT")); this.getView().showForm(showParameter); args.setCancel(true); } else if (!DraftHelper.isAllPayDrafBill((DynamicObjectCollection)this.getModel().getValue("draftbill")) && !(Boolean)this.getModel().getValue("feepay")) { String payConfirm = op.getOption().getVariableValue("payConfirm", ""); if (kd.bos.dataentity.utils.StringUtils.isEmpty(payConfirm)) { this.pay(args); } } } } } else if (!this.isBeConfirmOK) { this.storeFields(); } if ("submit".equals(operateKey)) { FormUtils.deleteEmptyRows(this.getModel(), new String[]{"e_payableamt"}); } if (Arrays.asList("unaudit", "chargeback", "invalid", "delete", "pay").contains(operateKey) && PayBillHepler.getViewSettle(this.getModel().getDataEntity()).size() > 0) { this.getView().showErrorNotification(String.format(ResManager.loadKDString("%s已存在结算记录,导致操作失败。如需继续执行操作,请先反结算。", "PaymentBillList_36", "fi-cas-formplugin", new Object[0]), "")); args.setCancel(true); } } public void confirmCallBack(MessageBoxClosedEvent messageBoxClosedEvent) { super.confirmCallBack(messageBoxClosedEvent); String id = messageBoxClosedEvent.getCallBackId(); MessageBoxResult res = messageBoxClosedEvent.getResult(); if (id.equals("CONFIRM_CANCELPAY_CALLBACK") && MessageBoxResult.Yes.equals(res)) { String billno = (String)this.getModel().getValue("billno"); DynamicObject payObj = BusinessDataServiceHelper.loadSingle("nckd_cas_arbill", "id,billno", new QFilter[]{new QFilter("billno", "=", billno)}); if (!this.cancelPayCheckSettle(payObj)) { this.getView().invokeOperation("cancelpay"); } } if (id.equals("CONFIRM_CANCELPAY_SETTLE_CALLBACK") && MessageBoxResult.Yes.equals(res)) { this.getView().invokeOperation("cancelpay"); } if (id.equals("CONFIRM_DEL_CALLBACK")) { OperateOption option = OperateOption.create(); if (MessageBoxResult.Yes.equals(res)) { option.setVariableValue("delrecpay", "1"); this.getView().invokeOperation("delete", option); } } } private void storeFields() { IBillModel model = (IBillModel)this.getModel(); String entrance = (String)model.getValue("entrance"); if (PaymentTypeEnum.OTR.name().equals(entrance)) { DynamicObject paymentType = (DynamicObject)model.getValue("paymenttype"); if (paymentType != null && !paymentType.getBoolean("ispartpayment")) { int count = model.getEntryRowCount("entry"); for(int i = 0; i < count; ++i) { this.setValue("e_discountamt", (Object)null, i); this.setValue("e_discountlocamt", (Object)null, i); this.setValue("e_corebilltype", (Object)null, i); this.setValue("e_corebillno", (Object)null, i); this.setValue("e_corebillentryseq", (Object)null, i); this.setValue("e_lockamt", (Object)null, i); this.setValue("e_unlockamt", (Object)null, i); this.setValue("e_settledamt", (Object)null, i); this.setValue("e_unsettledamt", (Object)null, i); } } } else if (PaymentTypeEnum.SYN.name().equals(entrance) || PaymentTypeEnum.CASH.name().equals(entrance) || PaymentTypeEnum.SPAN.name().equals(entrance)) { int count = model.getEntryRowCount("entry"); if (count < 1) { this.getView().updateView("entry"); this.getView().invokeOperation("newentry"); } this.setValue("e_payableamt", this.getBigDecimal("actpayamt"), 0); this.setValue("e_fundflowitem", this.getValue("fundflowitem"), 0); } } public void afterDoOperation(AfterDoOperationEventArgs arg) { super.afterDoOperation(arg); AbstractOperate op = (AbstractOperate)arg.getSource(); OperationResult operationResult = arg.getOperationResult(); String key = op.getOperateKey(); if ("copyentryrow".equals(key)) { EntryGrid entry = (EntryGrid)this.getControl("entry"); if (entry.getSelectRows().length == 0) { this.getView().showTipNotification(ResManager.loadKDString("请选中一行再进行操作", "PaymentBillEdit_12", "fi-cas-formplugin", new Object[0])); return; } this.calculateAmt(); } else if (!"beforesubmit".equals(key) && !"beforesubmitnew".equals(key)) { if ("newentry".equals(key)) { this.settleOrg(false); } else { IFormView view; if ("refundsave".equals(key) && arg.getOperationResult().isSuccess()) { view = this.getView().getParentView(); view.close(); this.getView().sendFormAction(view); return; } if ("delete".equals(key) && arg.getOperationResult().isSuccess()) { view = this.getView(); view.close(); this.getView().sendFormAction(view); } else if (("unsubmit".equals(key) || "unaudit".equals(key)) && arg.getOperationResult().isSuccess()) { this.getView().setStatus(OperationStatus.EDIT); } else { String reason; if (!"pay".equals(key) && !"cancelpay".equals(key)) { if ("receipt".equals(key) && arg.getOperationResult().isSuccess()) { this.viewReceipt(); } else if ("chargebacknoreason".equals(key)) { reason = ResManager.loadKDString("自动退单", "PaymentBillList_37", "fi-cas-formplugin", new Object[0]); List successPkIds = operationResult.getSuccessPkIds(); Map data = new HashMap(16); data.put("billid", successPkIds); data.put("reason", reason); data.put("operateKey", "chargeback"); PayBillListPlugnHelper.closeCallBack("CALLBACK_CHARGEBACK", this.getView(), data); } } else { reason = arg.getOperationResult().getMessage(); if (!arg.getOperationResult().isSuccess() && !(new CasErrorCode()).VOUCHER_NOT_CHECK().getMessage().equals(reason)) { this.getModel().setValue("billstatus", "pay".equals(key) ? BillStatusEnum.AUDIT.getValue() : BillStatusEnum.PAY.getValue()); } if ("pay".equals(key) && (Boolean)this.getValue("isdiffcur")) { this.getView().updateView("dpamt"); this.getView().updateView("agreedrate"); this.getView().updateView("dplocalamt"); this.getView().updateView("lossamt"); this.getView().updateView("billstatus"); this.getView().updateView("exchangerate"); this.getView().updateView("dpexchangerate"); this.getView().updateView("localamt"); this.getView().updateView("paydate"); this.getView().updateView("feeactbank"); this.getView().updateView("feecurrency"); this.getView().updateView("singlestream"); this.getView().updateView("fee"); for(int i = 0; i < this.getModel().getEntryRowCount("entry"); ++i) { this.getView().updateView("e_payablelocamt", i); this.getView().updateView("e_discountlocamt", i); this.getView().updateView("e_localamt", i); } } this.getView().updateView("draftbill"); if (arg.getOperationResult().isSuccess()) { this.getView().invokeOperation("refresh", OperateOption.create()); } } } } } else if ("beforesubmit".equals(key)) { IDataModel model = this.getModel(); if (!CasHelper.isEmpty(model.getValue("entrustorg"))) { model.setValue("payeracctbank", (Object)null); model.setValue("payerbank", (Object)null); ((Label)this.getControl("payerbanknumv")).setText(""); ((Label)this.getControl("payerbanknamev")).setText(""); model.setValue("settletype", (Object)null); } if (arg.getOperationResult().isSuccess()) { DynamicObject company = (DynamicObject)model.getValue("org"); boolean isNotCheckBeBankNumb = SystemParameterHelper.getParameterBoolean(company.getLong("id"), "cs125"); if (this.isBeiBePay() && CasHelper.isEmpty(this.getString("recbanknumber")) && !isNotCheckBeBankNumb && this.isCrossTranType()) { this.getView().showTipNotification(ResManager.loadKDString(String.format("单号%s的付款单支付渠道为银企互联,收款行行号不能为空,请补充。", this.getModel().getValue("billno")), "PaymentBillEdit_29", "fi-cas-formplugin", new Object[0])); return; } List pks = arg.getOperationResult().getSuccessPkIds(); if (!EmptyUtil.isEmpty(pks)) { this.getView().invokeOperation("submit"); } } } if (Arrays.asList("save", "submit").contains(key) && arg.getOperationResult().isSuccess()) { this.getView().updateView("entrustorg"); this.getView().updateView("totalpayamt"); for(int i = 0; i < this.getModel().getEntryRowCount("entry"); ++i) { this.getView().updateView("e_lockAmt", i); this.getView().updateView("e_unlockAmt", i); } } if ("unaudit".equals(key)) { this.getView().invokeOperation("refresh", OperateOption.create()); } PaymentBillPluginHelper.fillToolBar(this, this.getModel(), this.getView()); this.ctrChangeLableVisible(); PaymentBillPluginHelper.isSchePayEditable(this, this.getModel()); } private boolean isCrossTranType() { boolean type = (Boolean)this.getValue("iscrosspay"); DynamicObject dentify = (DynamicObject)this.getValue("paymentidentify"); return !type || null == dentify || !"0".equals(dentify.getString("type")); } public void beforeClosed(BeforeClosedEvent e) { super.beforeClosed(e); try { BillShowParameter billShowParameter = (BillShowParameter)this.getView().getFormShowParameter(); String billStatus = (String)this.getModel().getValue("billstatus"); if (!BillStatusEnum.SAVE.getValue().equals(billStatus) || billShowParameter.getStatus() == OperationStatus.VIEW) { e.setCheckDataChange(false); } } catch (Exception var4) { } } private void cancelPay() { String billno = (String)this.getModel().getValue("billno"); DynamicObject payObj = BusinessDataServiceHelper.loadSingle("nckd_cas_arbill", "id,billno,isvoucher,billstatus,org", new QFilter[]{new QFilter("billno", "=", billno)}); String billstatus = payObj.getString("billstatus"); if (!billstatus.equals("D")) { this.getView().invokeOperation("cancelpay"); } else { Object org = this.getModel().getValue("org"); if (org != null) { int CS116 = SystemParameterHelper.getParameterInteger(((DynamicObject)org).getLong("id"), "cs116"); Boolean isv = payObj.getBoolean("isvoucher"); if (3 == CS116 && isv) { this.getView().showConfirm(String.format(ResManager.loadKDString("(%s)单据已经生成凭证,是否继续取消付款?", "PaymentBillEdit_15", "fi-cas-formplugin", new Object[0]), billno), MessageBoxOptions.YesNo, ConfirmTypes.Default, new ConfirmCallBackListener("CONFIRM_CANCELPAY_CALLBACK", this)); } else if (!this.cancelPayCheckSettle(payObj)) { this.getView().invokeOperation("cancelpay"); } } } } protected String recPayAccount() { return "payeracctbank"; } private void settleOrg(boolean isOrg) { if (!this.isLockSettleOrg()) { DynamicObject paymenttype = (DynamicObject)this.getModel().getValue("paymenttype"); if (null != paymenttype && paymenttype.getBoolean("ispartpayment")) { Object openOrg = this.getModel().getValue("openorg"); if (openOrg != null) { DynamicObject accountOrg = (DynamicObject)openOrg; for(int i = 0; i < this.getModel().getEntryRowCount("entry"); ++i) { if (isOrg || CasHelper.isEmpty(this.getModel().getValue("settleorg", i))) { this.setValue("settleorg", accountOrg.getPkValue(), i); } } } } } } private boolean isHwControl() { return this.getPageCache().getAll().containsKey("isHwControl"); } private void setRecInfo(String key, Object value, Boolean isCheckDiff) { if (isCheckDiff) { Boolean isDiffCur = (Boolean)this.getModel().getValue("isdiffcur"); if (!isDiffCur) { this.getModel().setValue(key, value); } } else { this.getModel().setValue(key, value); } } private void setDiffCurInfo() { Boolean isDiffCur = (Boolean)this.getModel().getValue("isdiffcur"); if (!isDiffCur) { this.setValueIfAbsent("dpcurrency", this.getModel().getValue("currency")); this.setValueIfAbsent("dpamt", this.getModel().getValue("actpayamt")); if (!FeePayerEnum.REC.getValue().equals(this.getString("feepayer"))) { this.setValueIfAbsent("feeactbank", this.getModel().getValue("payeracctbank")); this.setValueIfAbsent("feecurrency", this.getModel().getValue("currency")); } } } private void setExratetableVisibility() { Long currencyId = this.getPk("currency"); Long dpCurrencyId = this.getPk("dpcurrency"); Long basecurrencyId = this.getPk("basecurrency"); if ((currencyId == null || currencyId.equals(basecurrencyId)) && (dpCurrencyId == null || dpCurrencyId.equals(basecurrencyId))) { this.getView().setVisible(false, new String[]{"exratetable"}); this.getView().setVisible(false, new String[]{"exratedate"}); } else { this.getView().setVisible(true, new String[]{"exratetable"}); this.getView().setVisible(true, new String[]{"exratedate"}); } } private void setSettleTypeValue(DynamicObject payerAcctBank) { if (payerAcctBank != null) { DynamicObjectCollection settlementypes = payerAcctBank.getDynamicObjectCollection("settlementtype"); if (settlementypes != null && settlementypes.size() > 0) { Set idSet = new HashSet(); Iterator var4 = settlementypes.iterator(); DynamicObject settletype; while(var4.hasNext()) { settletype = (DynamicObject)var4.next(); idSet.add(((DynamicObject)settletype.get("fbasedataid")).getLong("id")); } DynamicObject settleType = this.getDynamicObject("settletype"); if (idSet.size() == 1) { settletype = BusinessDataServiceHelper.loadSingleFromCache(idSet.iterator().next(), "bd_settlementtype", "id,settlementtype"); if (!BaseDataHelper.isSettleTypeCash(settletype)) { this.setValue("settletype", idSet.iterator().next()); } } else if (settleType != null && !idSet.contains((Long)settleType.getPkValue())) { this.setValue("settletype", (Object)null); } } } } private void setCrossPayValue() { this.getView().setEnable(true, new String[]{"iscrosspay"}); DynamicObject payCountry = this.getDynamicObject("paycountry"); DynamicObject recCountry = this.getDynamicObject("reccountry"); if ((payCountry == null || CountryHelper.isChina(payCountry)) && (recCountry == null || CountryHelper.isChina(recCountry))) { this.setValue("iscrosspay", Boolean.FALSE); } else { this.setValue("iscrosspay", Boolean.TRUE); } } private void isDiffCurVisibility() { DynamicObject settleType = this.getDynamicObject("settletype"); if (CasHelper.isNotEmpty(settleType) && BaseDataHelper.isSettleTypeCash(settleType)) { this.setValue("isdiffcur", "0"); this.getView().setVisible(false, new String[]{"isdiffcur"}); } else { this.getView().setVisible(true, new String[]{"isdiffcur"}); } } private void setCountryValue() { DynamicObject payerBank = this.getDynamicObject("payerbank"); if (payerBank != null) { this.setValueIfAbsent("paycountry", payerBank.getDynamicObject("country")); this.setCrossPayValue(); } } private void pay(BeforeDoOperationEventArgs evt) { long orgId = (Long)this.getDynamicObject("org").getPkValue(); Set cs1046 = SystemParameterHelper.getParameterComboxs(orgId, "cs1046"); DynamicObject payBill = this.getModel().getDataEntity(); (new PaymentPayImpl()).validate(payBill); if (PaymentBillPluginHelper.isShowPayConfirm(payBill, cs1046)) { FormShowParameter para = new FormShowParameter(); para.setFormId("cas_paybill_diffpay"); para.setCloseCallBack(new CloseCallBack(this, "KEY_DIFFPAY_CALLBACK")); para.getOpenStyle().setShowType(ShowType.Modal); DataEntityPropertyCollection properties = EntityMetadataCache.getDataEntityType("cas_paybill_diffpay").getProperties(); Map customParams = new HashMap(properties.size()); Iterator var9 = properties.iterator(); while(var9.hasNext()) { IDataEntityProperty property = (IDataEntityProperty)var9.next(); String propName = property.getName(); if (this.getModel().getProperty(propName) != null) { Object value = this.getValue(propName); if (value instanceof DynamicObject) { customParams.put(propName, ((DynamicObject)value).getPkValue()); } else { customParams.put(propName, value); } } } para.setCustomParams(customParams); para.setCustomParam("payamount", payBill.getBigDecimal("actpayamt")); para.setCustomParam("payamt", payBill.getBigDecimal("dpamt")); para.setCustomParam("matchFlag", payBill.getString("matchflag")); para.setCustomParam("sourcebilltype", payBill.getString("sourcebilltype")); para.setCustomParam("payBillId", payBill.getString("id")); this.getView().showForm(para); evt.setCancel(true); } } private void setPaymentType(QFilter[] qFilters) { DynamicObject paymentType = BusinessDataServiceHelper.loadSingleFromCache("cas_paymentbilltype", "id,fundflowitem", qFilters); if (paymentType != null) { this.setValue("paymenttype", paymentType.getLong("id")); DynamicObject fundflowitem = paymentType.getDynamicObject("fundflowitem"); this.fillFundflowItem(true, fundflowitem); } else { this.setValue("paymenttype", (Object)null); } } private void viewReceipt() { Long billId = (Long)this.getModel().getDataEntity().getPkValue(); if (billId == 0L) { this.getView().showTipNotification(ResManager.loadKDString("暂无对应的电子回单记录!", "ViewReceiptService_0", "fi-cas-business", new Object[0])); } else { ViewReceiptService viewService = new ViewReceiptService(); viewService.viewReceipt(this.getView(), "nckd_cas_arbill", billId); } } private void viewSettle() { Long billId = (Long)this.getModel().getDataEntity().getPkValue(); if (billId == 0L) { this.getView().showTipNotification(ResManager.loadKDString("暂无结算记录。", "PaymentBillList_5", "fi-cas-formplugin", new Object[0])); } else { List mainSettleIds = SettleRecordQueryHelperForCas.getSettleIdsByMain("ap_settlerecord", "nckd_cas_arbill", new Object[]{billId}); List asstSettleIds = SettleRecordQueryHelperForCas.getSettleIdsByAsst("ap_settlerecord", "nckd_cas_arbill", new Object[]{billId}); Set settleRecordIds = new HashSet(); settleRecordIds.addAll(mainSettleIds); settleRecordIds.addAll(asstSettleIds); if (settleRecordIds.size() > 0) { ListShowParameter parameter = new ListShowParameter(); parameter.setBillFormId("ap_settlerecord"); parameter.getOpenStyle().setShowType(ShowType.MainNewTabPage); ListFilterParameter param = new ListFilterParameter(); param.setFilter(new QFilter("id", "in", settleRecordIds)); parameter.setListFilterParameter(param); parameter.setCustomParam("checkKey", true); this.getView().showForm(parameter); } else { this.getView().showTipNotification(ResManager.loadKDString("暂无结算记录。", "PaymentBillList_5", "fi-cas-formplugin", new Object[0])); } } } public void afterAddRow(AfterAddRowEventArgs e) { super.afterAddRow(e); EntryProp entryProp = e.getEntryProp(); String entryName = entryProp.getName(); if ("entry".equals(entryName)) { RowDataEntity[] rows = e.getRowDataEntities(); if (rows.length > 0) { RowDataEntity[] var5 = rows; int var6 = rows.length; for(int var7 = 0; var7 < var6; ++var7) { RowDataEntity row = var5[var7]; this.getModel().setValue("e_sourcebillid", this.getValue("sourcebillid"), row.getRowIndex()); this.getModel().setValue("e_sourcebillentryid", this.getValue("sourceentryid"), row.getRowIndex()); } } } } private void isOnlinebankVisibility() { String paymentchannel = (String)this.getValue("paymentchannel"); if (paymentchannel != null && this.isAcctBankExistOnlineBankAcct()) { this.getView().setVisible(true, new String[]{"netbankacct"}); } else { this.getView().setVisible(false, new String[]{"netbankacct"}); } } private Boolean cancelPayCheckSettle(DynamicObject payObj) { Boolean result = Boolean.FALSE; boolean exists = SettleRecordQueryHelperForCas.isExistsSettlesByMain("ap_settlerecord", "nckd_cas_arbill", new Object[]{payObj.getPkValue()}, (QFilter)null); boolean exists2 = SettleRecordQueryHelperForCas.isExistsSettlesByAsst("ap_settlerecord", "nckd_cas_arbill", new Object[]{payObj.getPkValue()}, (QFilter)null); if (exists || exists2) { StringBuilder settleSb = new StringBuilder(); String billno = payObj.getString("billno"); settleSb.append(String.format(ResManager.loadKDString("(%s)单据已经完成结算", "PaymentBillList_28", "fi-cas-formplugin", new Object[0]), billno)); this.getView().showConfirm(settleSb.append(ResManager.loadKDString(",如果继续操作将会自动反结算对应的结算记录,是否继续?", "PaymentBillList_29", "fi-cas-formplugin", new Object[0])).toString(), MessageBoxOptions.YesNo, ConfirmTypes.Default, new ConfirmCallBackListener("CONFIRM_CANCELPAY_SETTLE_CALLBACK", this)); result = Boolean.TRUE; } return result; } public String getPayeeOrPayerInfoNumber(Object payeeOrPayer, Object payeeOrPayerType, String billName) { String payeenumber = ""; String entityNameTemp = ""; String addressPropName = ""; if (isSupplier(payeeOrPayerType)) { entityNameTemp = AsstActTypeEnum.SUPPLIER.getValue(); addressPropName = "supplieraddress"; } if (isCustomer(payeeOrPayerType)) { entityNameTemp = AsstActTypeEnum.CUSTOMER.getValue(); addressPropName = "customeraddress"; } if (!CasHelper.isEmpty(entityNameTemp) && !CasHelper.isEmpty(payeeOrPayer)) { DynamicObject supplierCustDO = BusinessDataServiceHelper.loadSingleFromCache(payeeOrPayer, entityNameTemp, "number,entry_bank.isdefault_bank,entry_bank.bankaccount,entry_bank.bank,entry_bank.accountname,entry_address." + addressPropName); if (!CasHelper.isEmpty(supplierCustDO)) { payeenumber = supplierCustDO.getString("number"); } } return payeenumber; } public String getUserOrOrgNumber(Object id, Object type) { String entityNameTemp = ""; String payeenumber = ""; if (isUser(type)) { entityNameTemp = AsstActTypeEnum.EMPLOYEE.getValue(); } if (isOrg(type)) { entityNameTemp = AsstActTypeEnum.COMPANY.getValue(); } if (!CasHelper.isEmpty(entityNameTemp) && !CasHelper.isEmpty(id)) { DynamicObject userOrgDO = BusinessDataServiceHelper.loadSingleFromCache(id, entityNameTemp, "number"); if (!CasHelper.isEmpty(userOrgDO)) { payeenumber = userOrgDO.getString("number"); } } return payeenumber; } private void fillFundflowItem(boolean isCover, DynamicObject defaultFundsItem) { if (defaultFundsItem != null) { for(int i = 0; i < this.getModel().getEntryRowCount("entry"); ++i) { if (isCover) { this.setValue("e_fundflowitem", defaultFundsItem.getPkValue(), i); } else { this.setValueIfAbsent("e_fundflowitem", defaultFundsItem.getPkValue(), i); } } } } private static boolean isSupplier(Object payeeType) { return isAimType(AsstActTypeEnum.SUPPLIER, payeeType); } private static boolean isCustomer(Object payeeType) { return isAimType(AsstActTypeEnum.CUSTOMER, payeeType); } private static boolean isUser(Object payeeType) { return isAimType(AsstActTypeEnum.EMPLOYEE, payeeType); } private static boolean isOrg(Object payeeType) { return isAimType(AsstActTypeEnum.COMPANY, payeeType); } private static boolean isOther(Object payeeType) { return isAimType(AsstActTypeEnum.OTHER, payeeType); } private static boolean isAimType(AsstActTypeEnum asstactType, Object payeeType) { return asstactType.getValue().equals(payeeType); } private boolean isLockSettleOrg() { String sourceBillType = this.getString("sourcebilltype"); return "ap_finapbill".equals(sourceBillType) || "ar_finarbill".equals(sourceBillType) || "ap_payapply".equals(sourceBillType) || "pm_purorderbill".equals(sourceBillType); } private boolean isClearFeeSettleType() { DynamicObject settleType = (DynamicObject)this.getModel().getValue("settletype"); if (settleType == null) { return true; } else { String settlementType = settleType.getString("settlementtype"); return Objects.equals(settlementType, SettleMentTypeEnum.BANK.getValue()) || Objects.equals(settlementType, SettleMentTypeEnum.BUSINESS.getValue()) || Objects.equals(settlementType, SettleMentTypeEnum.CHECK.getValue()); } } private boolean hasPayeeInfo() { String payeeformid = this.getString("payeetype"); Long payeeId = Long.parseLong(this.getValue("payee") == null ? "0" : this.getValue("payee").toString()); String payeeType = this.getString("payeetype"); if (isOther(payeeType)) { return kd.bos.dataentity.utils.StringUtils.isNotBlank(this.getValue("payeename")); } else { return CasHelper.isNotEmpty(payeeformid) && CasHelper.isNotEmpty(payeeId); } } public void signCallback(SignCallbackEvent evt) { if (evt.getCallbackId().equals("signbeforecommitbe")) { ClientMethodResult ret = evt.getResult(); if (ret.getSuccess()) { OperateOption operateOption = OperateOption.create(); operateOption.setVariableValue("ishasright", "true"); operateOption.setVariableValue("signCallbackFlag", "true"); operateOption.setVariableValue("signFirstSave", "false"); operateOption.setVariableValue("signResult", SerializationUtils.toJsonString(evt.getResult().getResult())); operateOption.setVariableValue("clearResult", evt.getClearText()); OperationResult operationResult = this.getView().invokeOperation("beforecommitbe", operateOption); if (operationResult.isSuccess()) { this.getView().invokeOperation("commitbe"); } else { logger.info(" signcallback fail "); if (EmptyUtil.isNoEmpty(operationResult.getMessage())) { evt.getView().showTipNotification(operationResult.getMessage()); } } } else { logger.info(" signbeforecommitbe SignCallbackEvent fail "); } } } }