ArBillEditPlugin.java 131 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642
  1. package fi.cas.formplugin;
  2. import com.alibaba.fastjson.JSON;
  3. import kd.bos.bill.BillShowParameter;
  4. import kd.bos.bill.OperationStatus;
  5. import kd.bos.context.RequestContext;
  6. import kd.bos.dataentity.OperateOption;
  7. import kd.bos.dataentity.entity.DataEntityBase;
  8. import kd.bos.dataentity.entity.DynamicObject;
  9. import kd.bos.dataentity.entity.DynamicObjectCollection;
  10. import kd.bos.dataentity.entity.LocaleString;
  11. import kd.bos.dataentity.metadata.IDataEntityProperty;
  12. import kd.bos.dataentity.metadata.clr.DataEntityPropertyCollection;
  13. import kd.bos.dataentity.resource.ResManager;
  14. import kd.bos.dataentity.serialization.SerializationUtils;
  15. import kd.bos.entity.AppMetadataCache;
  16. import kd.bos.entity.EntityMetadataCache;
  17. import kd.bos.entity.Tips;
  18. import kd.bos.entity.datamodel.*;
  19. import kd.bos.entity.datamodel.events.*;
  20. import kd.bos.entity.format.FormatFactory;
  21. import kd.bos.entity.format.FormatObject;
  22. import kd.bos.entity.format.FormatTypes;
  23. import kd.bos.entity.operate.result.OperationResult;
  24. import kd.bos.entity.param.AppParam;
  25. import kd.bos.entity.property.EntryProp;
  26. import kd.bos.exception.KDBizException;
  27. import kd.bos.form.*;
  28. import kd.bos.form.control.*;
  29. import kd.bos.form.control.events.BeforeItemClickEvent;
  30. import kd.bos.form.control.events.ClickListener;
  31. import kd.bos.form.control.events.ItemClickEvent;
  32. import kd.bos.form.control.events.RowClickEventListener;
  33. import kd.bos.form.events.*;
  34. import kd.bos.form.field.BasedataEdit;
  35. import kd.bos.form.field.ComboEdit;
  36. import kd.bos.form.field.ComboItem;
  37. import kd.bos.form.operate.AbstractOperate;
  38. import kd.bos.form.operate.FormOperate;
  39. import kd.bos.form.operate.SignOperateCallback;
  40. import kd.bos.list.ListFilterParameter;
  41. import kd.bos.list.ListShowParameter;
  42. import kd.bos.logging.Log;
  43. import kd.bos.logging.LogFactory;
  44. import kd.bos.orm.query.QFilter;
  45. import kd.bos.orm.util.CollectionUtils;
  46. import kd.bos.servicehelper.BusinessDataServiceHelper;
  47. import kd.bos.servicehelper.DispatchServiceHelper;
  48. import kd.bos.servicehelper.QueryServiceHelper;
  49. import kd.bos.servicehelper.inte.InteServiceHelper;
  50. import kd.bos.servicehelper.operation.OperationServiceHelper;
  51. import kd.bos.servicehelper.parameter.SystemParamServiceHelper;
  52. import kd.bos.servicehelper.workflow.WorkflowServiceHelper;
  53. import kd.bos.workflow.component.approvalrecord.IApprovalRecordGroup;
  54. import kd.fi.cas.business.errorcode.CasErrorCode;
  55. import kd.fi.cas.business.errorcode.PaymentErrorCode;
  56. import kd.fi.cas.business.helper.AcctBalanceHelper;
  57. import kd.fi.cas.business.helper.PayBillHepler;
  58. import kd.fi.cas.business.helper.PaymentFillPropHelper;
  59. import kd.fi.cas.business.helper.VisibleVirtualAcctHelper;
  60. import kd.fi.cas.business.opservice.impl.PaymentPayImpl;
  61. import kd.fi.cas.business.service.ViewReceiptService;
  62. import kd.fi.cas.consts.BillTypeConstants;
  63. import kd.fi.cas.enums.*;
  64. import kd.fi.cas.formplugin.PaymentBillEdit;
  65. import kd.fi.cas.formplugin.common.CasBillEdit;
  66. import kd.fi.cas.formplugin.helper.InitCheckPluginHelper;
  67. import kd.fi.cas.helper.*;
  68. import kd.fi.cas.pojo.BizBalanceModelBean;
  69. import kd.fi.cas.util.DateUtils;
  70. import kd.fi.cas.util.EmptyUtil;
  71. import kd.fi.cas.util.FormUtils;
  72. import kd.fi.cas.util.StringUtils;
  73. import java.math.BigDecimal;
  74. import java.text.Format;
  75. import java.util.*;
  76. import java.util.List;
  77. import java.util.stream.Collectors;
  78. public class ArBillEditPlugin extends CasBillEdit implements ClickListener, RowClickEventListener, SignCallbackLisenter {
  79. private String labCurrencySign;
  80. private int currencyAmtprecision;
  81. private Format currencyFormat;
  82. private static final String KEY_DIFFPAY_CALLBACK = "KEY_DIFFPAY_CALLBACK";
  83. private static final String CONFIRM_DEL_CALLBACK = "CONFIRM_DEL_CALLBACK";
  84. private static final String KEY_CALLBACK_CHARGEBACK = "CALLBACK_CHARGEBACK";
  85. private static final String KEY_CLOSECALLBACK_CHARGEBACK = "CALLBACK_SELECTDRAFT";
  86. private static Log logger = LogFactory.getLog(PaymentBillEdit.class);
  87. private Long orgId;
  88. private boolean isBeConfirmOK = false;
  89. private List<String> settleTypes;
  90. public ArBillEditPlugin() {
  91. this.settleTypes = Arrays.asList(SettleMentTypeEnum.PROMISSORY.getValue(), SettleMentTypeEnum.CHECK.getValue(), SettleMentTypeEnum.DRAFT.getValue(), SettleMentTypeEnum.BUSINESS.getValue(), SettleMentTypeEnum.BANK.getValue());
  92. }
  93. private void initFormat() {
  94. FormatObject fobj = InteServiceHelper.getUserFormat(RequestContext.get().getCurrUserId());
  95. fobj.getCurrencyFormat().setCurrencySymbols(this.labCurrencySign);
  96. fobj.getCurrencyFormat().setMinimumFractionDigits(this.currencyAmtprecision);
  97. this.currencyFormat = FormatFactory.get(FormatTypes.Currency).getFormat(fobj);
  98. }
  99. public void preOpenForm(PreOpenFormEventArgs e) {
  100. BillShowParameter showParameter = (BillShowParameter)e.getSource();
  101. Object pkId = showParameter.getPkId();
  102. if (pkId != null && !pkId.equals(0L)) {
  103. DynamicObject info = BusinessDataServiceHelper.loadSingle(pkId, "nckd_cas_arbill", "id, billtype");
  104. DynamicObject billtype = info.getDynamicObject("billtype");
  105. if (billtype != null && BillTypeConstants.PAYBILL_SYN.equals(billtype.getPkValue())) {
  106. e.getFormShowParameter().setFormId("cas_paybill_synonym");
  107. e.getFormShowParameter().setCaption(ResManager.loadKDString("同名转账", "PaymentBillEdit_24", "fi-cas-formplugin", new Object[0]));
  108. } else if (billtype != null && BillTypeConstants.PAYBILL_CASH.equals(billtype.getPkValue())) {
  109. e.getFormShowParameter().setFormId("cas_paybill_cash");
  110. e.getFormShowParameter().setCaption(ResManager.loadKDString("现金存取", "PaymentBillEdit_25", "fi-cas-formplugin", new Object[0]));
  111. } else if (billtype != null && BillTypeConstants.PAYBILL_SPAN.equals(billtype.getPkValue())) {
  112. e.getFormShowParameter().setCaption(ResManager.loadKDString("跨主体调拨", "PaymentBillEdit_28", "fi-cas-formplugin", new Object[0]));
  113. }
  114. } else {
  115. String formId = showParameter.getFormId();
  116. if ("cas_paybill_synonym".equals(formId)) {
  117. e.getFormShowParameter().setFormId("cas_paybill_synonym");
  118. e.getFormShowParameter().setCaption(ResManager.loadKDString("同名转账", "PaymentBillEdit_24", "fi-cas-formplugin", new Object[0]));
  119. } else if ("cas_paybill_cash".equals(formId)) {
  120. e.getFormShowParameter().setFormId("cas_paybill_cash");
  121. e.getFormShowParameter().setCaption(ResManager.loadKDString("现金存取", "PaymentBillEdit_25", "fi-cas-formplugin", new Object[0]));
  122. } else if ("cas_paybill_spanmainpart".equals(formId)) {
  123. e.getFormShowParameter().setFormId("cas_paybill_spanmainpart");
  124. e.getFormShowParameter().setCaption(ResManager.loadKDString("跨主体调拨", "PaymentBillEdit_28", "fi-cas-formplugin", new Object[0]));
  125. }
  126. }
  127. }
  128. public void registerListener(EventObject e) {
  129. super.registerListener(e);
  130. this.addClickListeners(new String[]{"changepayer", "changepayee", "addpayeelb1", "addpayeelb2", "settletnumber", "applyname"});
  131. this.initF7();
  132. }
  133. private void initF7() {
  134. this.fillPaymentType();
  135. this.fillCurrency();
  136. this.fillEntrustorg();
  137. this.setSettlementTypeFilter();
  138. this.fillNetBankAcct();
  139. this.expenseItem();
  140. this.fillFundFlow();
  141. }
  142. private void fillFundFlow() {
  143. BasedataEdit fundFlow = (BasedataEdit)this.getControl("e_fundflowitem");
  144. fundFlow.addBeforeF7SelectListener((select) -> {
  145. ListShowParameter showParam = (ListShowParameter)select.getFormShowParameter();
  146. Object org = this.getModel().getValue("org");
  147. showParam.setCustomParam("org", String.valueOf(((DynamicObject)org).getPkValue()));
  148. });
  149. }
  150. protected void expenseItem() {
  151. BasedataEdit orgCtrl = (BasedataEdit)this.getControl("e_expenseitem");
  152. orgCtrl.addBeforeF7SelectListener((beforeF7SelectEvent) -> {
  153. ListShowParameter showParameter = (ListShowParameter)beforeF7SelectEvent.getFormShowParameter();
  154. DynamicObject[] objects = BusinessDataServiceHelper.load("er_expenseitembill", "id,expenseitem", new QFilter[]{new QFilter("billtype.bill_number.number", "=", "nckd_cas_arbill")});
  155. if (!EmptyUtil.isEmpty(objects)) {
  156. List<Object> ids = (List)Arrays.stream(objects).map((o) -> {
  157. return o.get("expenseitem.id");
  158. }).collect(Collectors.toList());
  159. QFilter qFilter = new QFilter("id", "in", ids);
  160. showParameter.getListFilterParameter().getQFilters().add(qFilter);
  161. }
  162. });
  163. }
  164. protected String getControlBankAcctForSettleType() {
  165. return "payeracctbank";
  166. }
  167. private boolean isAcctBankExistOnlineBankAcct() {
  168. DynamicObject payeracctbank = (DynamicObject)this.getValue("payeracctbank");
  169. if (null != payeracctbank) {
  170. DynamicObjectCollection onlineBankAccts = payeracctbank.getDynamicObjectCollection("netbank");
  171. return null != onlineBankAccts && onlineBankAccts.size() != 0;
  172. } else {
  173. return false;
  174. }
  175. }
  176. private void fillNetBankAcct() {
  177. BasedataEdit onlinebankacct = (BasedataEdit)this.getControl("netbankacct");
  178. onlinebankacct.addBeforeF7SelectListener((beforeF7SelectEvent) -> {
  179. ListShowParameter showParameter = (ListShowParameter)beforeF7SelectEvent.getFormShowParameter();
  180. DynamicObject payeracctbank = (DynamicObject)this.getValue("payeracctbank");
  181. List<Long> ids = new ArrayList();
  182. if (null != payeracctbank) {
  183. DynamicObjectCollection onlineBankAccts = payeracctbank.getDynamicObjectCollection("netbank");
  184. if (null != onlineBankAccts && onlineBankAccts.size() > 0) {
  185. Iterator var6 = onlineBankAccts.iterator();
  186. while(var6.hasNext()) {
  187. DynamicObject bankAcct = (DynamicObject)var6.next();
  188. ids.add((Long)bankAcct.getDynamicObject("fbasedataid").getPkValue());
  189. }
  190. }
  191. }
  192. if (ids.size() == 0) {
  193. ids.add(0L);
  194. }
  195. QFilter qFilter = new QFilter("id", "in", ids);
  196. showParameter.getListFilterParameter().getQFilters().add(qFilter);
  197. });
  198. }
  199. private void fillEntrustorg() {
  200. BasedataEdit currencyF7 = (BasedataEdit)this.getControl("entrustorg");
  201. currencyF7.addBeforeF7SelectListener((beforeF7SelectEvent) -> {
  202. ListShowParameter showParameter = (ListShowParameter)beforeF7SelectEvent.getFormShowParameter();
  203. showParameter.setCustomParam("orgFuncId", "08");
  204. });
  205. }
  206. private void fillPaymentType() {
  207. BasedataEdit paymenttypeF7 = (BasedataEdit)this.getControl("paymenttype");
  208. paymenttypeF7.addBeforeF7SelectListener((beforeF7SelectEvent) -> {
  209. String sourceBillType = (String)this.getModel().getValue("sourcebilltype");
  210. ListShowParameter showParameter = (ListShowParameter)beforeF7SelectEvent.getFormShowParameter();
  211. QFilter qFilter = new QFilter("enable", "=", "1");
  212. Object entrance = this.getModel().getValue("entrance");
  213. if (!CasHelper.isEmpty(this.getModel().getDataEntity().getPkValue())) {
  214. DynamicObject payemntType = (DynamicObject)this.getModel().getValue("paymenttype");
  215. if (payemntType != null) {
  216. qFilter = qFilter.and(new QFilter("ispartpayment", "=", payemntType.getBoolean("ispartpayment") ? "1" : "0"));
  217. } else if (!PaymentTypeEnum.AP.name().equals(entrance)) {
  218. qFilter = qFilter.and(new QFilter("ispartpayment", "=", "0"));
  219. }
  220. }
  221. if (entrance != null && !"".equals(entrance)) {
  222. if (PaymentTypeEnum.AP.name().equals(entrance)) {
  223. qFilter = qFilter.and(new QFilter("ispartpayment", "=", "1"));
  224. } else {
  225. qFilter = qFilter.and(new QFilter("ispartpayment", "=", "0"));
  226. }
  227. }
  228. if ("pm_purorderbill".equals(sourceBillType) || "conm_purcontract".equals(sourceBillType)) {
  229. qFilter = qFilter.and(new QFilter("biztype", "=", "202")).and(new QFilter("ispartpayment", "=", "1"));
  230. qFilter = qFilter.and(new QFilter("ispartpayment", "=", "1"));
  231. }
  232. showParameter.getListFilterParameter().setFilter(qFilter);
  233. });
  234. }
  235. private void fillCurrency() {
  236. BasedataEdit currencyF7 = (BasedataEdit)this.getControl("currency");
  237. currencyF7.addBeforeF7SelectListener((beforeF7SelectEvent) -> {
  238. ListShowParameter showParameter = (ListShowParameter)beforeF7SelectEvent.getFormShowParameter();
  239. QFilter qFilter = new QFilter("enable", "=", "1");
  240. Boolean isDiffCur = (Boolean)this.getValue("isdiffcur");
  241. if (!isDiffCur) {
  242. DynamicObject settleType = (DynamicObject)this.getModel().getValue("settletype");
  243. boolean isCash = BaseDataHelper.isSettleTypeCash(settleType);
  244. DynamicObject accountCash;
  245. if (isCash) {
  246. accountCash = (DynamicObject)this.getModel().getValue("payeracctcash");
  247. if (accountCash != null) {
  248. List<Long> currencys = AccountCashHelper.getCurrencys(Collections.singletonList((Long)accountCash.getPkValue()));
  249. qFilter = qFilter.and(new QFilter("id", "in", currencys));
  250. }
  251. } else {
  252. accountCash = (DynamicObject)this.getModel().getValue("payeracctbank");
  253. if (accountCash != null) {
  254. Set<Long> currencysx = AccountBankHelper.getCurrencyPks((Long)accountCash.getPkValue());
  255. qFilter = qFilter.and(new QFilter("id", "in", currencysx));
  256. }
  257. }
  258. }
  259. showParameter.getListFilterParameter().setFilter(qFilter);
  260. });
  261. }
  262. public void afterCreateNewData(EventObject e) {
  263. super.afterCreateNewData(e);
  264. this.setDefaultPaymentChannelValue();
  265. if (!"true".equals(this.getPageCache().get("isFromWebApi"))) {
  266. this.createNewModel();
  267. }
  268. this.getView().setVisible(false, new String[]{"netbankacct"});
  269. this.getEntryCache();
  270. this.calculateAmt();
  271. DynamicObject settleType = this.getDynamicObject("settletype");
  272. if (BaseDataHelper.isSettleTypeCash(settleType)) {
  273. this.setValue("payeracctcash", AccountCashHelper.getDefaultAccountcash(this.getPk("org"), "payer"));
  274. }
  275. }
  276. private void getEntryCache() {
  277. String str_json = this.getPageCache().get("entry");
  278. if (str_json != null) {
  279. this.getModel().deleteEntryRow("entry", 0);
  280. TableValueSetter vs = new TableValueSetter(new String[0]);
  281. 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]);
  282. Map<String, ArrayList<Map<String, String>>> maps = (Map) SerializationUtils.fromJsonString(str_json, Map.class);
  283. ArrayList<Map<String, String>> list = (ArrayList)maps.get("entry");
  284. Iterator var5 = list.iterator();
  285. while(var5.hasNext()) {
  286. Map<String, String> map = (Map)var5.next();
  287. vs.addRow(new Object[]{map.get("e_expenseitem"), map.get("e_payableamt"), map.get("project"), map.get("e_fundflowitem"), map.get("e_remark")});
  288. }
  289. AbstractFormDataModel model = (AbstractFormDataModel)this.getModel();
  290. model.batchCreateNewEntryRow("entry", vs);
  291. this.getView().updateView("entry");
  292. }
  293. }
  294. private void setDefaultPaymentChannelValue() {
  295. List<ComboItem> comboItems = new ArrayList();
  296. ComboEdit paymentChannel = (ComboEdit)this.getControl("paymentchannel");
  297. ComboItem comboItem = new ComboItem();
  298. comboItem.setValue(PaymentChannelEnum.COUNTER.getValue());
  299. comboItem.setCaption(new LocaleString(ResManager.loadKDString(PaymentChannelEnum.COUNTER.getName(), "PaymentBillEdit_16", "fi-cas-formplugin", new Object[0])));
  300. comboItems.add(comboItem);
  301. paymentChannel.setComboItems(comboItems);
  302. this.getModel().setValue("paymentchannel", comboItem.getValue());
  303. }
  304. public void beforeBindData(EventObject e) {
  305. super.beforeBindData(e);
  306. DynamicObject paymenttype = (DynamicObject)this.getModel().getValue("paymenttype");
  307. if (null != paymenttype && !paymenttype.getBoolean("ispartpayment")) {
  308. this.getView().setVisible(false, new String[]{"settleorg"});
  309. }
  310. this.settleOrg(false);
  311. if (this.isBotpNew()) {
  312. this.supplePayeeInfo();
  313. }
  314. this.getModel().setDataChanged(false);
  315. }
  316. private void supplePayeeInfo() {
  317. Object sourcebilltype = this.getModel().getValue("sourcebilltype");
  318. if (!CasHelper.isEmpty(sourcebilltype)) {
  319. Object payee = this.getModel().getValue("payee");
  320. Object payeebanknumMo = this.getModel().getValue("payeebanknum");
  321. Object payeebankMo = this.getModel().getValue("payeebank");
  322. Object payeeType = this.getValue("payeetype");
  323. if (CasHelper.isEmpty(payeebanknumMo) && CasHelper.isEmpty(payeebankMo)) {
  324. String billName = this.getModel().getDataEntityType().getName();
  325. Map<String, Object> resultMap = CasPayeeOrPayerHelper.getPayeeOrPayerInfo(payee, payeeType, billName);
  326. if (resultMap.size() > 0) {
  327. Object bankaccount = resultMap.get("payeebanknum");
  328. Object accountname = resultMap.get("accountname");
  329. DynamicObject payeebank = (DynamicObject)resultMap.get("payeebank");
  330. this.getModel().setValue("payeebanknum", bankaccount);
  331. this.getModel().setValue("recaccbankname", accountname);
  332. if (!CasHelper.isEmpty(payeebank)) {
  333. this.fillProvinceAndCity(payeebank);
  334. }
  335. }
  336. } else if (!CasHelper.isEmpty(payeebankMo)) {
  337. this.fillProvinceAndCity((DynamicObject)payeebankMo);
  338. }
  339. }
  340. }
  341. private void fillProvinceAndCity(DynamicObject payeeBank) {
  342. logger.info("打开单据 填充 国家、省、城市字段");
  343. payeeBank = BusinessDataServiceHelper.loadSingle(payeeBank.getPkValue(), payeeBank.getDataEntityType().getName(), "id,name,number,country,provincetxt,citytxt,union_number");
  344. this.getModel().setValue("payeebank", payeeBank);
  345. this.getModel().setValue("payeebankname", payeeBank.getString("name"));
  346. this.getModel().setValue("recbanknumber", payeeBank.getString("union_number"));
  347. this.getModel().setValue("reccountry", payeeBank.getDynamicObject("country"));
  348. this.getModel().setValue("recprovince", payeeBank.getString("provincetxt"));
  349. this.getModel().setValue("reccity", payeeBank.getString("citytxt"));
  350. }
  351. private void createNewModel() {
  352. this.getView().setVisible(false, new String[]{"usage"});
  353. FormShowParameter parameter = this.getView().getFormShowParameter();
  354. Map<String, Object> customParams = parameter.getCustomParams();
  355. if (this.getModel().getValue("org") != null) {
  356. this.orgId = this.getPk("org");
  357. } else {
  358. String appId = this.getView().getFormShowParameter().getAppId();
  359. if (EmptyUtil.isNotEmpty(appId)) {
  360. appId = AppMetadataCache.getAppInfo(appId).getId();
  361. } else {
  362. appId = AppMetadataCache.getAppInfo("cas").getId();
  363. }
  364. List<Long> authorizedBankOrgId = OrgHelper.getAuthorizedBankOrgId(RequestContext.get().getCurrUserId(), appId, "nckd_cas_arbill", "47156aff000000ac");
  365. if (!CollectionUtils.isEmpty(authorizedBankOrgId)) {
  366. this.orgId = (Long)authorizedBankOrgId.get(0);
  367. this.setValue("org", this.orgId);
  368. } else {
  369. this.orgId = null;
  370. }
  371. }
  372. this.setValueIfAbsent("bizdate", DateUtils.getCurrentDate());
  373. if (customParams != null && customParams.containsKey("paymentType")) {
  374. String entrance = (String)customParams.get("paymentType");
  375. this.setValue("entrance", entrance);
  376. long billTypeID = 0L;
  377. QFilter[] qFilters;
  378. if (PaymentTypeEnum.AP.name().equals(entrance)) {
  379. qFilters = new QFilter[]{new QFilter("ispartpayment", "=", "1"), new QFilter("biztype", "=", "201")};
  380. this.setPaymentType(qFilters);
  381. billTypeID = BillTypeConstants.PAYBILL_PUR;
  382. } else if (PaymentTypeEnum.SYN.name().equals(entrance)) {
  383. qFilters = new QFilter[]{new QFilter("biztype", "=", "214")};
  384. this.setPaymentType(qFilters);
  385. billTypeID = BillTypeConstants.PAYBILL_SYN;
  386. } else if (PaymentTypeEnum.SPAN.name().equals(entrance)) {
  387. qFilters = new QFilter[]{new QFilter("biztype", "=", "217")};
  388. this.setPaymentType(qFilters);
  389. billTypeID = BillTypeConstants.PAYBILL_SPAN;
  390. } else if (PaymentTypeEnum.CASH.name().equals(entrance)) {
  391. qFilters = new QFilter[]{new QFilter("biztype", "=", "215")};
  392. this.setPaymentType(qFilters);
  393. billTypeID = BillTypeConstants.PAYBILL_CASH;
  394. } else {
  395. if (PaymentTypeEnum.ER.name().equals(entrance)) {
  396. qFilters = new QFilter[]{new QFilter("biztype", "=", "211")};
  397. this.setPaymentType(qFilters);
  398. } else if (PaymentTypeEnum.OTR.name().equals(entrance)) {
  399. qFilters = new QFilter[]{new QFilter("biztype", "=", "999")};
  400. this.setPaymentType(qFilters);
  401. }
  402. billTypeID = BillTypeConstants.PAYBILL_OTR;
  403. }
  404. this.setValue("issingle", "1");
  405. if (billTypeID != 0L && QueryServiceHelper.exists("bos_billtype", billTypeID)) {
  406. this.setValue("billtype", billTypeID);
  407. }
  408. }
  409. this.fillPayeeType(true);
  410. if (CasHelper.isEmpty(this.orgId)) {
  411. this.getView().setEnable(false, new String[]{"bar_save", "bar_submit", "bar_beforesubmit"});
  412. this.getView().showErrorNotification(ResManager.loadKDString("请先选择付款人", "PaymentBillEdit_30", "fi-cas-formplugin", new Object[0]));
  413. } else if (InitCheckPluginHelper.checkInitForPlugin(this.getView(), this.getDynamicObject("org"), new String[]{"bar_save", "bar_submit", "bar_beforesubmit"})) {
  414. this.getView().setEnable(true, new String[]{"bar_save", "bar_submit", "bar_beforesubmit"});
  415. DynamicObject baseCurrency = OrgHelper.getBaseCurrency(this.orgId);
  416. this.setValue("basecurrency", baseCurrency);
  417. this.setValue("currency", baseCurrency);
  418. this.setValue("dpcurrency", baseCurrency);
  419. this.setValue("feecurrency", baseCurrency);
  420. this.setDefaultExratetable(this.orgId);
  421. DynamicObject defaultSettleType = BaseDataHelper.getDefaultSettleType();
  422. this.setValue("settletype", defaultSettleType);
  423. DynamicObject defaultPayAccount;
  424. if (!BaseDataHelper.isSettleTypeCash(defaultSettleType)) {
  425. defaultPayAccount = AccountBankHelper.getDefaultPayAccount(this.orgId);
  426. if (defaultPayAccount == null || (!BaseDataHelper.isSettleTypeVirtual(defaultSettleType) || !VisibleVirtualAcctHelper.checkVirtualAcct(defaultPayAccount)) && (BaseDataHelper.isSettleTypeVirtual(defaultSettleType) || VisibleVirtualAcctHelper.checkVirtualAcct(defaultPayAccount))) {
  427. this.getView().setEnable(false, new String[]{"exchangerate"});
  428. this.clearBalanceValue();
  429. } else {
  430. this.setValue("payeracctbank", defaultPayAccount);
  431. this.payerAcctBankF7Changed((PropertyChangedArgs)null, defaultPayAccount);
  432. this.currencyF7Changed(false);
  433. }
  434. }
  435. defaultPayAccount = BusinessDataServiceHelper.loadSingleFromCache(this.orgId, "bos_org");
  436. this.getModel().setValue("payernumber", defaultPayAccount.getString("number"));
  437. this.getModel().setValue("uniformsocialcreditcode", defaultPayAccount.getString("uniformsocialcreditcode"));
  438. this.setPayerInfo4Lb();
  439. this.setOpenOrg();
  440. }
  441. }
  442. private void setPayerInfo4Lb() {
  443. DynamicObject org = (DynamicObject)this.getModel().getValue("org");
  444. if (org != null) {
  445. this.getModel().setValue("orgv", CasHelper.getLocalValue(org, "name"));
  446. String defaultUrl = "/icons/pc/entrance/cn_fk_80_80.png";
  447. Image orgPic = (Image)this.getControl("orgpic");
  448. orgPic.setUrl(defaultUrl);
  449. DynamicObject payerAcctBank = (DynamicObject)this.getModel().getValue("payeracctbank");
  450. DynamicObject payerAcctCash = (DynamicObject)this.getModel().getValue("payeracctcash");
  451. String v_payerbanknum = "";
  452. if (payerAcctBank != null) {
  453. v_payerbanknum = StringUtils.splitString(payerAcctBank.getString("bankaccountnumber"), 4, " ");
  454. } else if (payerAcctCash != null) {
  455. v_payerbanknum = payerAcctCash.getString("number");
  456. }
  457. ((Label)this.getControl("payerbanknumv")).setText(v_payerbanknum);
  458. DynamicObject payerBank = (DynamicObject)this.getModel().getValue("payerbank");
  459. String v_payerbankname = "";
  460. if (payerBank != null) {
  461. v_payerbankname = CasHelper.getLocalValue(payerBank, "name");
  462. }
  463. ((Label)this.getControl("payerbanknamev")).setText(v_payerbankname);
  464. boolean isCash = BaseDataHelper.isSettleTypeCash((DynamicObject)this.getModel().getValue("settletype"));
  465. this.getView().setVisible(!isCash, new String[]{"payerbanknamev", "payerbanknamelb"});
  466. }
  467. }
  468. private void fillPayeeType(boolean setDefaultValue) {
  469. ComboEdit payeetypeCbo = (ComboEdit)this.getView().getControl("payeetype");
  470. List<ComboItem> comboItem = new ArrayList();
  471. String entrance = (String)this.getModel().getValue("entrance");
  472. if (PaymentTypeEnum.AP.name().equals(entrance)) {
  473. comboItem.add(new ComboItem(new LocaleString(AsstActTypeEnum.SUPPLIER.getName()), AsstActTypeEnum.SUPPLIER.getValue()));
  474. comboItem.add(new ComboItem(new LocaleString(AsstActTypeEnum.CUSTOMER.getName()), AsstActTypeEnum.CUSTOMER.getValue()));
  475. comboItem.add(new ComboItem(new LocaleString(AsstActTypeEnum.EMPLOYEE.getName()), AsstActTypeEnum.EMPLOYEE.getValue()));
  476. } else if (!PaymentTypeEnum.SYN.name().equals(entrance) && !PaymentTypeEnum.CASH.name().equals(entrance)) {
  477. AsstActTypeEnum[] var5 = AsstActTypeEnum.values();
  478. int var6 = var5.length;
  479. for(int var7 = 0; var7 < var6; ++var7) {
  480. AsstActTypeEnum asstAct = var5[var7];
  481. comboItem.add(new ComboItem(new LocaleString(asstAct.getName()), asstAct.getValue()));
  482. }
  483. } else {
  484. comboItem.add(new ComboItem(new LocaleString(AsstActTypeEnum.COMPANY.getName()), AsstActTypeEnum.COMPANY.getValue()));
  485. }
  486. payeetypeCbo.setComboItems(comboItem);
  487. if (setDefaultValue) {
  488. this.getModel().setValue("payeetype", ((ComboItem)comboItem.get(0)).getValue());
  489. }
  490. }
  491. public void afterImportData(ImportDataEventArgs e) {
  492. super.afterImportData(e);
  493. PaymentFillPropHelper.fillProp(this.getModel().getDataEntity());
  494. if (this.getModel().getValue("entrance") == null) {
  495. this.setEntrance();
  496. }
  497. }
  498. public void initImportData(InitImportDataEventArgs e) {
  499. super.initImportData(e);
  500. this.getPageCache().put("isFromWebApi", "true");
  501. }
  502. public void afterCopyData(EventObject e) {
  503. super.afterCopyData(e);
  504. DynamicObject billType = (DynamicObject)this.getValue("billtype");
  505. if (billType != null && BillTypeConstants.PAYBILL_PUR == billType.getLong("id")) {
  506. this.getModel().setValue("entrance", PaymentTypeEnum.AP.name());
  507. }
  508. this.fillPayeeType(false);
  509. this.setValue("sourcetype", SourceTypeEnum.CAS);
  510. DynamicObject paymentType = (DynamicObject)this.getValue("paymenttype");
  511. if (paymentType != null && paymentType.getBoolean("ispartpayment")) {
  512. int count = this.getModel().getEntryRowCount("entry");
  513. for(int i = 0; i < count; ++i) {
  514. this.setValue("e_unlockamt", (BigDecimal)this.getModel().getValue("e_payableamt", i), i);
  515. this.setValue("e_unsettledamt", (BigDecimal)this.getModel().getValue("e_payableamt", i), i);
  516. }
  517. this.getView().updateView("entry");
  518. }
  519. this.showBalance();
  520. this.setNetBankAcctVisible();
  521. DynamicObject accountBank = this.getDynamicObject("payeracctbank");
  522. this.setPaymentChannelValue(accountBank, Boolean.TRUE);
  523. DynamicObject crossTranType0 = (DynamicObject)this.getModel().getValue("crosstrantype");
  524. if (crossTranType0 != null) {
  525. DynamicObject crossTransType = BusinessDataServiceHelper.loadSingle(crossTranType0.getPkValue(), "bei_crosstrantype");
  526. DynamicObjectCollection dynamicObjectCollection = crossTransType.getDynamicObjectCollection("entry");
  527. this.isCrossTranTypeHide(dynamicObjectCollection);
  528. }
  529. this.getModel().deleteEntryData("cas_draftinfo");
  530. this.getModel().setValue("applyorg", (Object)null);
  531. }
  532. public void afterLoadData(EventObject e) {
  533. super.afterLoadData(e);
  534. this.showBalance();
  535. this.setNetBankAcctVisible();
  536. DynamicObject crossTranType0 = (DynamicObject)this.getModel().getValue("crosstrantype");
  537. if (crossTranType0 != null) {
  538. DynamicObject crossTransType = BusinessDataServiceHelper.loadSingle(crossTranType0.getPkValue(), "bei_crosstrantype");
  539. DynamicObjectCollection dynamicObjectCollection = crossTransType.getDynamicObjectCollection("entry");
  540. this.isCrossTranTypeHide(dynamicObjectCollection);
  541. }
  542. }
  543. private void ctrRefundInfoVisibility() {
  544. logger.info("付款单:PaymentBillEdit.ctrRefundInfoVisibility()");
  545. this.getView().setVisible(false, new String[]{"bar_refund_save"});
  546. String billstatus = (String)this.getValue("billstatus");
  547. this.getView().setVisible(BillStatusEnum.REFUND.getValue().equals(billstatus) || BillStatusEnum.RENOTE.getValue().equals(billstatus), new String[]{"e_refundamt", "e_refunddes"});
  548. this.getView().setEnable(false, new String[]{"e_refundamt", "e_refunddes"});
  549. }
  550. private void setNetBankAcctVisible() {
  551. String paymentchannel = (String)this.getValue("paymentchannel");
  552. if (null != paymentchannel && this.isAcctBankExistOnlineBankAcct()) {
  553. this.getView().setVisible(true, new String[]{"netbankacct"});
  554. } else {
  555. this.getView().setVisible(false, new String[]{"netbankacct"});
  556. }
  557. }
  558. private void setEntrance() {
  559. DynamicObject billType = (DynamicObject)this.getModel().getValue("billtype");
  560. if (billType != null) {
  561. Long billTypeId = billType.getLong("id");
  562. if (BillTypeConstants.PAYBILL_PUR.equals(billTypeId)) {
  563. this.getModel().setValue("entrance", PaymentTypeEnum.AP.name());
  564. } else if (BillTypeConstants.PAYBILL_EXP.equals(billTypeId)) {
  565. this.getModel().setValue("entrance", PaymentTypeEnum.OTR.name());
  566. } else if (BillTypeConstants.PAYBILL_OTR.equals(billTypeId)) {
  567. this.getModel().setValue("entrance", PaymentTypeEnum.OTR.name());
  568. } else if (BillTypeConstants.PAYBILL_SYN.equals(billTypeId)) {
  569. this.getModel().setValue("entrance", PaymentTypeEnum.SYN.name());
  570. } else if (BillTypeConstants.PAYBILL_CASH.equals(billTypeId)) {
  571. this.getModel().setValue("entrance", PaymentTypeEnum.CASH.name());
  572. } else if (BillTypeConstants.PAYBILL_SPAN.equals(billTypeId)) {
  573. this.getModel().setValue("entrance", PaymentTypeEnum.SPAN.name());
  574. }
  575. }
  576. }
  577. public void customPrintDataObject(CustomPrintDataObjectArgs e) {
  578. super.customPrintDataObject(e);
  579. String entityKey = e.getDataSourceName();
  580. if ("nckd_cas_arbill".equals(entityKey)) {
  581. List<DynamicObject> dataEntitiesv = new ArrayList();
  582. DynamicObject dsv = this.getModel().getDataEntity();
  583. DynamicObject basecur = (DynamicObject)this.getModel().getValue("basecurrency");
  584. if (basecur != null) {
  585. dsv.set("basecurrency", basecur.getString("name"));
  586. }
  587. if (dsv.getString("payeetype") != null && dsv.getString("payeetype").length() > 0) {
  588. dsv.set("payeetype", AsstActTypeEnum.getName(dsv.getString("payeetype")));
  589. }
  590. dataEntitiesv.add(dsv);
  591. e.setDataEntities(dataEntitiesv);
  592. }
  593. }
  594. public void propertyChanged(PropertyChangedArgs e) {
  595. String key = e.getProperty().getName();
  596. ChangeData[] changeData = e.getChangeSet();
  597. Object newValue = changeData[0].getNewValue();
  598. Object oldValue = changeData[0].getOldValue();
  599. int iRow = changeData[0].getRowIndex();
  600. if (newValue != oldValue) {
  601. DynamicObject applyDo;
  602. switch (key) {
  603. case "paymenttype":
  604. this.paymentTypeChanged((DynamicObject)newValue);
  605. break;
  606. case "bizdate":
  607. this.exratedateChanged(newValue);
  608. break;
  609. case "exratetable":
  610. this.currencyF7Changed(false);
  611. this.setRecInfo("dpexratetable", newValue, Boolean.FALSE);
  612. break;
  613. case "exratedate":
  614. this.currencyF7Changed(false);
  615. this.setRecInfo("dpexratedate", newValue, Boolean.FALSE);
  616. break;
  617. case "payeetype":
  618. this.payeeTypeChanged((String)newValue, true);
  619. break;
  620. case "org":
  621. this.setOpenOrg();
  622. this.showBalance();
  623. break;
  624. case "payeracctbank":
  625. this.payerAcctBankF7Changed(e, newValue);
  626. this.isOnlinebankVisibility();
  627. break;
  628. case "payeracctcash":
  629. this.payerAcctCashChanged((DynamicObject)newValue);
  630. break;
  631. case "currency":
  632. this.currencyF7Changed(true);
  633. this.setRecInfo("dpcurrency", newValue, Boolean.TRUE);
  634. this.setExratetableVisibility();
  635. break;
  636. case "exchangerate":
  637. case "agreedquotation":
  638. case "payquotation":
  639. case "dppayquotation":
  640. this.calculateAmt();
  641. break;
  642. case "settletype":
  643. this.settleTypeChanged(e, newValue);
  644. this.settletNumber((DynamicObject)newValue);
  645. this.isClearSettleType((DynamicObject)oldValue, (DynamicObject)newValue);
  646. if (this.isClearFeeSettleType()) {
  647. this.setValue("fee", (Object)null);
  648. }
  649. break;
  650. case "billstatus":
  651. PaymentBillPluginHelper.fillToolBar(this, this.getModel(), this.getView());
  652. break;
  653. case "e_payableamt":
  654. this.entries_payableAmtChanged((BigDecimal)newValue, oldValue, iRow);
  655. break;
  656. case "e_discountamt":
  657. this.entries_discountAmtChanged((BigDecimal)newValue, oldValue, iRow);
  658. break;
  659. case "entrustorg":
  660. this.entrustorgChange(newValue);
  661. break;
  662. case "paymentchannel":
  663. this.paymentchannelChange();
  664. break;
  665. case "e_refundamt":
  666. this.refundChange((BigDecimal)newValue, (BigDecimal)oldValue, iRow);
  667. break;
  668. case "crosstrantype":
  669. DynamicObject crossTranType0 = (DynamicObject)this.getModel().getValue("crosstrantype");
  670. if (crossTranType0 != null) {
  671. applyDo = BusinessDataServiceHelper.loadSingle(crossTranType0.getPkValue(), "bei_crosstrantype");
  672. DynamicObjectCollection dynamicObjectCollection = applyDo.getDynamicObjectCollection("entry");
  673. this.isCrossTranTypeHide(dynamicObjectCollection);
  674. Iterator var16 = dynamicObjectCollection.iterator();
  675. while(var16.hasNext()) {
  676. DynamicObject dyobj = (DynamicObject)var16.next();
  677. String settleMethod = ResManager.loadKDString("清算方式", "PaymentBillEdit_27", "fi-cas-formplugin", new Object[0]);
  678. if (kd.bos.dataentity.utils.StringUtils.equals(settleMethod, dyobj.getString("fieldname")) && kd.bos.dataentity.utils.StringUtils.isNotEmpty(dyobj.getString("defaultvalue"))) {
  679. this.getModel().setValue("settlementmethod", dyobj.getString("defaultvalue"));
  680. }
  681. }
  682. }
  683. break;
  684. case "applyid":
  685. applyDo = (DynamicObject)newValue;
  686. if (applyDo != null) {
  687. String name = applyDo.getString("name");
  688. String phone = applyDo.getString("phone");
  689. this.getModel().beginInit();
  690. this.getModel().setValue("applyname", name);
  691. this.getModel().endInit();
  692. if (kd.bos.dataentity.utils.StringUtils.isNotEmpty(phone)) {
  693. this.getModel().setValue("applyphone", phone);
  694. }
  695. this.getView().updateView("applyname");
  696. }
  697. break;
  698. case "reccountry":
  699. case "paycountry":
  700. this.setCrossPayValue();
  701. }
  702. }
  703. }
  704. private void isCrossTranTypeHide(DynamicObjectCollection dyobj) {
  705. QFilter qFilter = new QFilter("enable", "=", '1');
  706. DynamicObject[] crossTransType = BusinessDataServiceHelper.load("bei_crosstranfield", "id,number", new QFilter[]{qFilter});
  707. List<Long> number = (List)dyobj.stream().map((e) -> {
  708. return e.getLong("id");
  709. }).collect(Collectors.toList());
  710. Arrays.stream(crossTransType).forEach((e) -> {
  711. if (!number.contains(e.getLong("id"))) {
  712. this.getView().setVisible(Boolean.FALSE, new String[]{e.getString("number")});
  713. }
  714. });
  715. }
  716. private void isClearSettleType(DynamicObject oldValue, DynamicObject newValue) {
  717. String settletnumber = (String)this.getModel().getValue("settletnumber");
  718. 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))) {
  719. this.getModel().setValue("settletnumber", (Object)null);
  720. this.getModel().setValue("sourcebilltype", (Object)null);
  721. this.getModel().setValue("sourcebillid", (Object)null);
  722. this.getModel().setValue("sourcetype", "CAS");
  723. this.getModel().deleteEntryData("billhead_lk");
  724. }
  725. }
  726. private void settletNumber(DynamicObject newValue) {
  727. if (!Objects.isNull(newValue)) {
  728. Object settlementType = newValue.get("settlementtype");
  729. DynamicObject org = (DynamicObject)this.getModel().getValue("org");
  730. String appId;
  731. if (Objects.nonNull(org)) {
  732. appId = AppMetadataCache.getAppInfo("cdm").getId();
  733. boolean visible = false;
  734. if (!Objects.equals(settlementType, SettleMentTypeEnum.BUSINESS.getValue()) && !Objects.equals(settlementType, SettleMentTypeEnum.BANK.getValue())) {
  735. if (Objects.equals(settlementType, SettleMentTypeEnum.PROMISSORY.getValue())) {
  736. visible = (Boolean) SystemParamServiceHelper.getAppParameter(appId, "08", (Long)org.getPkValue(), "ischeck");
  737. } else if (Objects.equals(settlementType, SettleMentTypeEnum.CHECK.getValue())) {
  738. visible = (Boolean)SystemParamServiceHelper.getAppParameter(appId, "08", (Long)org.getPkValue(), "ispromissorynote");
  739. }
  740. } else {
  741. visible = (Boolean)SystemParamServiceHelper.getAppParameter(appId, "08", (Long)org.getPkValue(), "isdraft");
  742. }
  743. this.getView().setVisible(!visible, new String[]{"settletnumber"});
  744. this.getView().setVisible(visible, new String[]{"draftbill"});
  745. }
  746. appId = this.getString("settletnumber");
  747. if (PayBillHepler.isCreditSettlement(newValue) && appId != null && appId.trim().length() > 0 && "cas_payapplybill".equals(this.getString("sourcebilltype"))) {
  748. this.getView().setEnable(false, new String[]{"settletype", "settletnumber"});
  749. }
  750. }
  751. }
  752. private void refundChange(BigDecimal newValue, BigDecimal oldValue, int iRow) {
  753. IBillModel model = (IBillModel)this.getModel();
  754. BigDecimal e_actamt = (BigDecimal)model.getValue("e_actamt", iRow);
  755. if (BigDecimal.ZERO.compareTo(newValue) != 0) {
  756. if (BigDecimal.ZERO.compareTo(newValue) > 0) {
  757. model.setValue("e_refundamt", oldValue, iRow);
  758. this.getView().showTipNotification(ResManager.loadKDString("退款金额不能为零", "PaymentBillEdit_21", "fi-cas-formplugin", new Object[0]));
  759. } else if (e_actamt.compareTo(newValue) < 0) {
  760. model.setValue("e_refundamt", oldValue, iRow);
  761. this.getView().showTipNotification(ResManager.loadKDString("退款金额不能大于付款金额", "PaymentBillEdit_20", "fi-cas-formplugin", new Object[0]));
  762. }
  763. }
  764. }
  765. private void paymentchannelChange() {
  766. if (this.isBeiBePay()) {
  767. this.setValue("fee", (Object)null);
  768. }
  769. this.isOnlinebankVisibility();
  770. this.ctrBeInfoVisibility();
  771. this.changePayeeValue();
  772. }
  773. private void entrustorgChange(Object newValue) {
  774. if (null != newValue) {
  775. this.getModel().setValue("settletype", (Object)null);
  776. } else {
  777. DynamicObject defaultSettleType = BaseDataHelper.getDefaultSettleType();
  778. this.setValue("settletype", defaultSettleType);
  779. }
  780. }
  781. private void addEntryCache() {
  782. DynamicObjectCollection entry = this.getModel().getEntryEntity("entry");
  783. List<Map<String, Object>> list = new ArrayList();
  784. Iterator var3 = entry.iterator();
  785. while(var3.hasNext()) {
  786. DynamicObject row = (DynamicObject)var3.next();
  787. Map<String, Object> map = new HashMap();
  788. map.put("e_expenseitem", row.get("e_expenseitem") == null ? null : ((DynamicObject)row.get("e_expenseitem")).getPkValue());
  789. map.put("e_payableamt", row.get("e_payableamt"));
  790. map.put("project", row.get("project") == null ? null : row.getDynamicObject("project").getPkValue());
  791. map.put("e_fundflowitem", row.get("e_fundflowitem") == null ? null : row.getDynamicObject("e_fundflowitem").getPkValue());
  792. map.put("e_remark", row.get("e_remark"));
  793. list.add(map);
  794. }
  795. Map<String, List<Map<String, Object>>> map = new HashMap();
  796. map.put("entry", list);
  797. String mapJson = SerializationUtils.toJsonString(map);
  798. this.getPageCache().put("entry", mapJson);
  799. }
  800. private void paymentTypeChanged(DynamicObject paymentType) {
  801. String entrance = (String)this.getModel().getValue("entrance");
  802. boolean isAp;
  803. if (paymentType != null && PaymentTypeEnum.OTR.name().equals(entrance)) {
  804. isAp = paymentType.getBoolean("ispartpayment");
  805. Long billTypeID = this.getPk("billtype");
  806. boolean isChange = false;
  807. if (isAp) {
  808. if (!BillTypeConstants.PAYBILL_EXP.equals(billTypeID)) {
  809. this.addEntryCache();
  810. this.setValue("billtype", BusinessDataServiceHelper.loadSingleFromCache(BillTypeConstants.PAYBILL_EXP, "bos_billtype"));
  811. isChange = true;
  812. }
  813. } else if (!BillTypeConstants.PAYBILL_OTR.equals(billTypeID)) {
  814. this.addEntryCache();
  815. this.setValue("billtype", BusinessDataServiceHelper.loadSingleFromCache(BillTypeConstants.PAYBILL_OTR, "bos_billtype"));
  816. isChange = true;
  817. }
  818. if (isChange) {
  819. this.getModel().beginInit();
  820. this.setValue("paymenttype", paymentType);
  821. this.getModel().endInit();
  822. this.getView().updateView("paymenttype");
  823. Label payeebanknumvLable = (Label)this.getControl("payeebanknumv");
  824. payeebanknumvLable.setText("");
  825. Label recaccbanknamevLable = (Label)this.getControl("recaccbanknamev");
  826. recaccbanknamevLable.setText("");
  827. Label payeebanknamevLable = (Label)this.getControl("payeebanknamev");
  828. payeebanknamevLable.setText("");
  829. Label recbanknumbervLable = (Label)this.getControl("recbanknumberv");
  830. recbanknumbervLable.setText("");
  831. }
  832. }
  833. this.setEntryAmountCaption();
  834. if (paymentType != null) {
  835. isAp = paymentType.getBoolean("ispartpayment");
  836. this.getView().setVisible(isAp, new String[]{"settleorg"});
  837. this.settleOrg(false);
  838. DynamicObject fundflowitem = paymentType.getDynamicObject("fundflowitem");
  839. this.fillFundflowItem(true, fundflowitem);
  840. }
  841. }
  842. private void settleTypeChanged(PropertyChangedArgs e, Object newValue) {
  843. this.ctrBeInfoVisibility();
  844. DynamicObject settleType = (DynamicObject)newValue;
  845. DynamicObject accountCash;
  846. if (BaseDataHelper.isSettleTypeCash(settleType)) {
  847. this.setValue("payeracctbank", (Object)null);
  848. this.setValue("payerbank", (Object)null);
  849. accountCash = this.getDynamicObject("payeracctcash");
  850. if (accountCash == null) {
  851. this.setValue("payeracctcash", AccountCashHelper.getDefaultAccountcash(this.getPk("org"), "payer"));
  852. }
  853. this.setValue("isdiffcur", "0");
  854. this.getView().setVisible(false, new String[]{"isdiffcur"});
  855. } else {
  856. this.setValue("payeracctcash", (Object)null);
  857. this.getView().setVisible(true, new String[]{"isdiffcur"});
  858. }
  859. this.setPayerInfo4Lb();
  860. accountCash = this.getDynamicObject("payeracctbank");
  861. this.setPaymentChannelValue(accountCash, Boolean.TRUE);
  862. this.changePayeeValue();
  863. }
  864. private void ctrBeInfoVisibility() {
  865. boolean isBePay = this.isBePay();
  866. this.getView().setVisible(!this.isDraft(), new String[]{"settletnumber"});
  867. this.getView().setVisible(this.isDraft(), new String[]{"draftbill"});
  868. this.getView().setVisible(isBePay, new String[]{"usage"});
  869. }
  870. private boolean isDraft() {
  871. DynamicObject settleType = (DynamicObject)this.getModel().getValue("settletype");
  872. if (settleType == null) {
  873. return false;
  874. } else {
  875. String settlementType = settleType.getString("settlementtype");
  876. 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());
  877. }
  878. }
  879. private void exratedateChanged(Object newValue) {
  880. if (newValue != null) {
  881. this.setValue("exratedate", newValue);
  882. this.setValue("dpexratedate", newValue);
  883. }
  884. }
  885. private void currencyF7Changed(boolean reBalance) {
  886. if (reBalance) {
  887. this.showBalance();
  888. }
  889. this.setExchangerateEditable();
  890. }
  891. private void entries_payableAmtChanged(BigDecimal payableAmt, Object oldValue, int iRow) {
  892. IBillModel model = (IBillModel)this.getModel();
  893. BigDecimal discountAmt = (BigDecimal)model.getValue("e_discountamt", iRow);
  894. discountAmt = discountAmt != null ? discountAmt : BigDecimal.ZERO;
  895. if (discountAmt.abs().compareTo(payableAmt.abs()) > 0) {
  896. this.getView().showTipNotification(String.format(ResManager.loadKDString("现金折扣绝对值不允许大于应付金额绝对值!", "PaymentBillEdit_2", "fi-cas-formplugin", new Object[0])));
  897. this.setValue("e_payableamt", oldValue, iRow);
  898. } else {
  899. this.calculateAmt();
  900. }
  901. }
  902. private void entries_discountAmtChanged(BigDecimal discountAmt, Object oldValue, int iRow) {
  903. IBillModel model = (IBillModel)this.getModel();
  904. BigDecimal payableAmt = (BigDecimal)model.getValue("e_payableamt", iRow);
  905. payableAmt = payableAmt != null ? payableAmt : BigDecimal.ZERO;
  906. if (discountAmt.abs().compareTo(payableAmt.abs()) > 0) {
  907. this.getView().showTipNotification(String.format(ResManager.loadKDString("现金折扣绝对值不允许大于应付金额绝对值!", "PaymentBillEdit_2", "fi-cas-formplugin", new Object[0])));
  908. this.setValue("e_discountamt", oldValue, iRow);
  909. } else {
  910. this.calculateAmt();
  911. }
  912. }
  913. private void calculateAmt() {
  914. DynamicObject basecurrency = this.getDynamicObject("basecurrency");
  915. BigDecimal exchangeRate = (BigDecimal)this.getModel().getValue("exchangerate");
  916. String quotation = this.getString("payquotation");
  917. int round = 10;
  918. if (basecurrency != null) {
  919. round = basecurrency.getInt("amtprecision");
  920. }
  921. int count = this.getModel().getEntryRowCount("entry");
  922. BigDecimal sumAmt = BigDecimal.ZERO;
  923. BigDecimal sumLocalAmt = BigDecimal.ZERO;
  924. for(int i = 0; i < count; ++i) {
  925. DynamicObject rowInfo = this.getModel().getEntryRowEntity("entry", i);
  926. BigDecimal payAmount = rowInfo.getBigDecimal("e_payableamt");
  927. if (payAmount != null) {
  928. this.setValue("e_payablelocamt", QuotationHelper.callToCurrency(payAmount, exchangeRate, quotation, round), i);
  929. }
  930. BigDecimal discountAmt = rowInfo.getBigDecimal("e_discountamt");
  931. if (discountAmt != null) {
  932. this.setValue("e_discountlocamt", QuotationHelper.callToCurrency(discountAmt, exchangeRate, quotation, round), i);
  933. }
  934. if (payAmount != null && discountAmt != null) {
  935. BigDecimal actAmt = payAmount.subtract(discountAmt);
  936. sumAmt = sumAmt.add(actAmt);
  937. BigDecimal actLocalAmt = BigDecimal.ZERO;
  938. actLocalAmt = QuotationHelper.callToCurrency(actAmt, exchangeRate, quotation, round);
  939. sumLocalAmt = sumLocalAmt.add(actLocalAmt);
  940. this.setValue("e_actamt", actAmt, i);
  941. this.setValue("e_localamt", actLocalAmt, i);
  942. }
  943. this.setValue("e_unsettledamt", payAmount, i);
  944. if (payAmount != null) {
  945. this.setValue("e_unsettledlocalamt", QuotationHelper.callToCurrency(payAmount, exchangeRate, quotation, round), i);
  946. }
  947. this.setValue("e_unlockamt", payAmount, i);
  948. }
  949. this.setValue("actpayamt", sumAmt);
  950. this.setValue("localamt", sumLocalAmt);
  951. this.calculateDpAmt();
  952. }
  953. private void calculateDpAmt() {
  954. DynamicObject dpcurrency = this.getDynamicObject("dpcurrency");
  955. DynamicObject basecurrency = this.getDynamicObject("basecurrency");
  956. DynamicObject currency = this.getDynamicObject("currency");
  957. String dppayquotation = this.getString("dppayquotation");
  958. String agreedquotation = this.getString("agreedquotation");
  959. int round = 10;
  960. if (basecurrency != null) {
  961. round = basecurrency.getInt("amtprecision");
  962. }
  963. int dppayround = 10;
  964. if (dpcurrency != null) {
  965. dppayround = dpcurrency.getInt("amtprecision");
  966. }
  967. BigDecimal actPayAmt = this.getBigDecimal("actpayamt");
  968. if (currency != null) {
  969. actPayAmt = actPayAmt.setScale(currency.getInt("amtprecision"), 4);
  970. }
  971. BigDecimal localAmt = this.getBigDecimal("localamt");
  972. BigDecimal agreedRate = this.getBigDecimal("agreedrate");
  973. if (agreedRate.compareTo(new BigDecimal(0)) != 0) {
  974. BigDecimal dpAmt = BigDecimal.ZERO;
  975. dpAmt = QuotationHelper.callToCurrency(actPayAmt, agreedRate, agreedquotation, dppayround);
  976. BigDecimal dpExchangeRate = this.getBigDecimal("dpexchangerate");
  977. BigDecimal dpLocalAmt = BigDecimal.ZERO;
  978. dpLocalAmt = QuotationHelper.callToCurrency(dpAmt, dpExchangeRate, dppayquotation, round);
  979. this.getModel().beginInit();
  980. this.setValue("dpamt", dpAmt);
  981. this.setValue("dplocalamt", dpLocalAmt);
  982. this.setValue("lossamt", localAmt.subtract(dpLocalAmt));
  983. this.getModel().endInit();
  984. this.getView().updateView("dpamt");
  985. this.getView().updateView("dplocalamt");
  986. this.getView().updateView("lossamt");
  987. }
  988. }
  989. private void payeeTypeChanged(String payeeType, boolean isChanged) {
  990. if (isChanged) {
  991. this.getView().setVisible(true, new String[]{"flex_addpayee"});
  992. this.getView().setVisible(false, new String[]{"flex_payeeinfo"});
  993. this.clearPayeeValue();
  994. }
  995. }
  996. private void clearPayeeValue() {
  997. Object value = null;
  998. this.setValue("payeeformid", value);
  999. this.setValue("payee", value);
  1000. this.setValue("payeename", value);
  1001. this.setValue("payeeaccformid", value);
  1002. this.setValue("payeeacctbank", value);
  1003. this.setValue("payeebanknum", value);
  1004. this.setValue("payeebank", value);
  1005. this.setValue("payeebankname", value);
  1006. this.setValue("recaccbankname", value);
  1007. this.setValue("recbanknumber", value);
  1008. this.setValue("payeenumber", (Object)null);
  1009. this.setValue("supplierBankId", (Object)null);
  1010. }
  1011. private void payerAcctBankF7Changed(PropertyChangedArgs e, Object newValue) {
  1012. DynamicObject payerAcctBank = (DynamicObject)newValue;
  1013. this.ctrBeInfoVisibility();
  1014. this.showBalance();
  1015. if (!FeePayerEnum.REC.getValue().equals(this.getString("feepayer"))) {
  1016. this.setValue("feeactbank", payerAcctBank);
  1017. }
  1018. if (payerAcctBank == null) {
  1019. this.setValue("payerbank", (Object)null);
  1020. this.setPaymentChannelValue((DynamicObject)null, Boolean.TRUE);
  1021. this.setCurrencyEditable();
  1022. } else {
  1023. this.setValue("payerbank", payerAcctBank.getDynamicObject("bank"));
  1024. Boolean isDiffCur = (Boolean)this.getValue("isdiffcur");
  1025. DynamicObject payCurrency = null;
  1026. if (isDiffCur) {
  1027. payCurrency = this.getDynamicObject("dpcurrency");
  1028. } else {
  1029. payCurrency = this.getDynamicObject("currency");
  1030. }
  1031. boolean containCurrency = AccountBankHelper.isAcctBankContainCurrency("bd_accountbanks", payerAcctBank.getPkValue(), payCurrency);
  1032. if (!containCurrency) {
  1033. Long defaultCurrencyId = (Long)payerAcctBank.get("defaultcurrency.id");
  1034. if (isDiffCur) {
  1035. this.setValue("dpcurrency", defaultCurrencyId);
  1036. } else if (this.isBotpCreate()) {
  1037. this.setValueIfAbsent("currency", defaultCurrencyId);
  1038. } else {
  1039. this.setValue("currency", defaultCurrencyId);
  1040. }
  1041. }
  1042. this.setCurrencyEditable();
  1043. this.setOpenOrg();
  1044. this.setPaymentChannelValue(payerAcctBank, Boolean.TRUE);
  1045. this.setSettleTypeValue(payerAcctBank);
  1046. this.settleOrg(true);
  1047. }
  1048. }
  1049. private void setPaymentChannelValue(DynamicObject payerAcctBank, boolean isAdd) {
  1050. List<ComboItem> comboItems = new ArrayList(1);
  1051. ComboEdit paymentChannel = (ComboEdit)this.getControl("paymentchannel");
  1052. DynamicObject settleType = this.getDynamicObject("settletype");
  1053. ComboItem comboItem = new ComboItem();
  1054. comboItem.setValue(PaymentChannelEnum.COUNTER.getValue());
  1055. comboItem.setCaption(new LocaleString(PaymentChannelEnum.COUNTER.getName()));
  1056. ComboItem selectedItem = comboItem;
  1057. comboItems.add(comboItem);
  1058. DynamicObject billtype = this.getDynamicObject("billtype");
  1059. if (null != payerAcctBank && (settleType == null || !"14".equals(settleType.getString("settlementtype"))) && (billtype == null || !BillTypeConstants.PAYBILL_CASH.equals(billtype.getPkValue()))) {
  1060. ComboItem item;
  1061. if (payerAcctBank.getBoolean("isopenbank")) {
  1062. item = new ComboItem();
  1063. item.setValue(PaymentChannelEnum.ONLINEBANK.getValue());
  1064. item.setCaption(new LocaleString(PaymentChannelEnum.ONLINEBANK.getName()));
  1065. selectedItem = item;
  1066. comboItems.add(item);
  1067. }
  1068. if (payerAcctBank.getBoolean("issetbankinterface")) {
  1069. item = new ComboItem();
  1070. item.setValue(PaymentChannelEnum.BEI.getValue());
  1071. item.setCaption(new LocaleString(ResManager.loadKDString(PaymentChannelEnum.BEI.getName(), "PaymentBillEdit_18", "fi-cas-formplugin", new Object[0])));
  1072. selectedItem = item;
  1073. comboItems.add(item);
  1074. }
  1075. String defaultPaymentChannel = "";
  1076. String defChannel;
  1077. if (Objects.nonNull(settleType)) {
  1078. defChannel = settleType.getString("paymentchannel");
  1079. defaultPaymentChannel = settleType.getString("defaultpaymentchannel");
  1080. if (kd.bos.dataentity.utils.StringUtils.isNotEmpty(defChannel)) {
  1081. List<String> paymentChannels = (List)Arrays.stream(defChannel.split(",")).filter(kd.bos.dataentity.utils.StringUtils::isNotEmpty).collect(Collectors.toList());
  1082. comboItems.removeIf((i) -> {
  1083. return !paymentChannels.contains(i.getValue());
  1084. });
  1085. }
  1086. }
  1087. paymentChannel.setComboItems(comboItems);
  1088. if (isAdd || this.isBotpNew() && Objects.isNull(this.getModel().getValue("paymentchannel"))) {
  1089. defChannel = selectedItem.getValue();
  1090. if (settleType != null && !SettleMentTypeEnum.COLLECT.getValue().equals(settleType.getString("settlementtype"))) {
  1091. defChannel = PaymentChannelEnum.COUNTER.getValue();
  1092. }
  1093. if (kd.bos.dataentity.utils.StringUtils.isNotEmpty(defaultPaymentChannel)) {
  1094. defChannel = defaultPaymentChannel;
  1095. }
  1096. String finalDefChannel = defChannel;
  1097. boolean contains = comboItems.stream().anyMatch((itemx) -> {
  1098. return Objects.equals(finalDefChannel, itemx.getValue());
  1099. });
  1100. if (!contains) {
  1101. defChannel = null;
  1102. }
  1103. if ("bei".equalsIgnoreCase(defChannel)) {
  1104. this.getModel().setValue("fee", (Object)null);
  1105. this.getModel().setValue("singlestream", Boolean.FALSE);
  1106. }
  1107. this.getModel().setValue("paymentchannel", defChannel);
  1108. }
  1109. } else {
  1110. paymentChannel.setComboItems(comboItems);
  1111. if (isAdd) {
  1112. this.getModel().setValue("paymentchannel", comboItem.getValue());
  1113. if ("bei".equalsIgnoreCase(comboItem.getValue())) {
  1114. this.getModel().setValue("fee", (Object)null);
  1115. this.getModel().setValue("singlestream", Boolean.FALSE);
  1116. }
  1117. }
  1118. }
  1119. }
  1120. private void payerAcctCashChanged(DynamicObject acctCash) {
  1121. if (acctCash == null) {
  1122. this.setValue("currency", this.getDynamicObject("basecurrency"));
  1123. this.setCurrencyEditable();
  1124. this.showBalance();
  1125. } else {
  1126. Boolean isDiffCur = (Boolean)this.getValue("isdiffcur");
  1127. DynamicObject payCurrency = null;
  1128. if (isDiffCur) {
  1129. payCurrency = this.getDynamicObject("dpcurrency");
  1130. } else {
  1131. payCurrency = this.getDynamicObject("currency");
  1132. }
  1133. boolean containCurrency = AccountBankHelper.isAcctBankContainCurrency("cas_accountcash", acctCash.getPkValue(), payCurrency);
  1134. if (!containCurrency) {
  1135. DynamicObject defaultCurrency = acctCash.getDynamicObject("defaultcurrency");
  1136. if (isDiffCur) {
  1137. this.setValue("dpcurrency", defaultCurrency);
  1138. } else if (this.isBotpCreate()) {
  1139. this.setValueIfAbsent("currency", defaultCurrency);
  1140. } else {
  1141. this.setValue("currency", defaultCurrency);
  1142. }
  1143. }
  1144. this.setCurrencyEditable();
  1145. this.setValue("openorg", acctCash.getDynamicObject("openorg"));
  1146. this.showBalance();
  1147. }
  1148. }
  1149. private void setCurrencyEditable() {
  1150. Boolean isCurrencyEditable = Boolean.TRUE;
  1151. DynamicObject settleType = this.getDynamicObject("settletype");
  1152. boolean isCash = BaseDataHelper.isSettleTypeCash(settleType);
  1153. DynamicObject accountCash;
  1154. if (isCash) {
  1155. accountCash = this.getDynamicObject("payeracctcash");
  1156. if (accountCash != null) {
  1157. isCurrencyEditable = !accountCash.getBoolean("isbycurrency");
  1158. }
  1159. } else {
  1160. accountCash = this.getDynamicObject("payeracctbank");
  1161. if (accountCash != null) {
  1162. isCurrencyEditable = accountCash.getBoolean("ismulcurrency");
  1163. }
  1164. }
  1165. Boolean isDiffCur = (Boolean)this.getValue("isdiffcur");
  1166. if (isDiffCur) {
  1167. this.getView().setEnable(isCurrencyEditable, new String[]{"dpcurrency"});
  1168. } else {
  1169. this.getView().setEnable(isCurrencyEditable, new String[]{"currency"});
  1170. }
  1171. if (this.isBotpCreate()) {
  1172. this.getView().setEnable(false, new String[]{"currency"});
  1173. }
  1174. }
  1175. private void showBalance() {
  1176. this.getView().setEnable(true, new String[]{"bar_save", "bar_submit", "bar_beforesubmit"});
  1177. if (this.getModel().getValue("org") != null) {
  1178. Long orgID = this.getPk("org");
  1179. Long acctBankId = this.getPk("payeracctbank");
  1180. Long acctCashId = this.getPk("payeracctcash");
  1181. Long currencyId = this.getPk("currency");
  1182. boolean var5 = (Boolean)this.getValue("isdiffcur");
  1183. if (var5) {
  1184. currencyId = this.getPk("dpcurrency");
  1185. }
  1186. if (orgID != null && (acctBankId != null || acctCashId != null) && currencyId != null) {
  1187. DynamicObject currency = BusinessDataServiceHelper.loadSingleFromCache(currencyId, "bd_currency");
  1188. try {
  1189. BigDecimal currentBalance = BigDecimal.ZERO;
  1190. if (CasHelper.isNotEmpty(acctBankId)) {
  1191. DynamicObject acctBank = BusinessDataServiceHelper.loadSingle(acctBankId, "am_accountbank", "acctclassify");
  1192. if (Objects.equals(acctBank.get("acctclassify"), AcctClassifyEnum.I.getValue())) {
  1193. currentBalance = getCurrBalance(acctBank);
  1194. } else {
  1195. String balanceType = SystemParameterFcsHelper.getParameterString(orgID, "balancevalue");
  1196. Object result = DispatchServiceHelper.invokeBizService("tmc", "fbp", "balanceModelService", "getRunningBalance", new Object[]{balanceType, acctBankId, currencyId});
  1197. BizBalanceModelBean bizBalanceModelBean = (BizBalanceModelBean)SerializationUtils.fromJsonString(SerializationUtils.toJsonString(result), BizBalanceModelBean.class);
  1198. currentBalance = bizBalanceModelBean.getAmount();
  1199. }
  1200. }
  1201. if (CasHelper.isNotEmpty(acctCashId)) {
  1202. currentBalance = AcctBalanceHelper.getAccountCashCurrBalance(orgID, acctCashId, currencyId, new Date());
  1203. ((Label)this.getControl("balancelb")).setText(ResManager.loadKDString("账面余额:", "PaymentBillEdit_4", "fi-cas-formplugin", new Object[0]));
  1204. LocaleString content = new LocaleString(ResManager.loadKDString("付款账户为现金账户时,账面余额即为当前时点现金日记账账面余额。", "PaymentBillEdit_3", "fi-cas-formplugin", new Object[0]));
  1205. ((Label)this.getControl("balancelb")).addTips(new Tips("text", (LocaleString)null, content, false, (List)null));
  1206. }
  1207. this.labCurrencySign = currency.getString("sign");
  1208. this.currencyAmtprecision = currency.getInt("amtprecision");
  1209. this.initFormat();
  1210. ((Label)this.getControl("balancev")).setText(this.currencyFormat.format(currentBalance == null ? 0 : currentBalance));
  1211. } catch (Exception var12) {
  1212. this.clearBalanceValue();
  1213. logger.error(var12);
  1214. }
  1215. } else {
  1216. this.clearBalanceValue();
  1217. }
  1218. }
  1219. }
  1220. private static BigDecimal getCurrBalance(DynamicObject bankAcct) {
  1221. DynamicObject[] load = BusinessDataServiceHelper.load("ifm_accountbalance", "amount", (new QFilter("accountbank", "=", bankAcct.getPkValue())).toArray(), "bizdate desc", 1);
  1222. return load.length > 0 ? load[0].getBigDecimal("amount") : BigDecimal.ZERO;
  1223. }
  1224. private void clearBalanceValue() {
  1225. ((Label)this.getControl("balancelb")).setText(ResManager.loadKDString("即时余额:", "PaymentBillEdit_5", "fi-cas-formplugin", new Object[0]));
  1226. LocaleString content = new LocaleString(ResManager.loadKDString("付款账户当前时点余额。付款账户即时余额取值来源有银企互联余额表、出纳/资金结算日记账;系统支持四种取值模式:(1)完全取自余额表;(2)完全取自日记账;(3)优先取余额表,再取日记账;(4)开通银企取余额表,未开通银企取日记账。具体采取何种模式请前往【系统服务云】-【配置工具】-【系统参数】-【资金云】-【资金公共服务】中查看。", "PaymentBillEdit_6", "fi-cas-formplugin", new Object[0]));
  1227. ((Label)this.getControl("balancelb")).addTips(new Tips("text", (LocaleString)null, content, false, (List)null));
  1228. DynamicObject currency = this.getDynamicObject("currency");
  1229. Boolean isDiffCur = (Boolean)this.getValue("isdiffcur");
  1230. if (isDiffCur) {
  1231. currency = this.getDynamicObject("dpcurrency");
  1232. }
  1233. if (!CasHelper.isEmpty(currency)) {
  1234. this.labCurrencySign = currency.getString("sign");
  1235. this.currencyAmtprecision = currency.getInt("amtprecision");
  1236. this.initFormat();
  1237. ((Label)this.getControl("balancev")).setText(this.currencyFormat.format(BigDecimal.ZERO));
  1238. } else {
  1239. ((Label)this.getControl("balancev")).setText("¥0.00");
  1240. }
  1241. }
  1242. public void click(EventObject evt) {
  1243. super.click(evt);
  1244. this.getView().setEnable(true, 0, new String[]{"e_payableamt", "e_discountamt", "contractnumber", "e_corebillno", "e_corebillentryseq"});
  1245. Control c = (Control)evt.getSource();
  1246. switch (c.getKey().toLowerCase()) {
  1247. case "changepayer":
  1248. this.changePayerPage();
  1249. break;
  1250. case "addpayeelb1":
  1251. this.addPayee();
  1252. break;
  1253. case "addpayeelb2":
  1254. this.addPayee();
  1255. break;
  1256. case "changepayee":
  1257. this.changePayeePage();
  1258. break;
  1259. case "settletnumber":
  1260. this.settleNumberClick();
  1261. break;
  1262. case "applyname":
  1263. BasedataEdit applyF7 = (BasedataEdit)this.getControl("applyid");
  1264. applyF7.click();
  1265. }
  1266. }
  1267. private void settleNumberClick() {
  1268. DynamicObject settleType = (DynamicObject)this.getModel().getValue("settletype");
  1269. if (EmptyUtil.isNoEmpty(settleType) && SettleMentTypeEnum.CREDIT.getValue().equals(settleType.getString("settlementtype"))) {
  1270. String appId = AppMetadataCache.getAppInfo("lc").getId();
  1271. DynamicObject org = (DynamicObject)this.getModel().getValue("org");
  1272. AppParam param = new AppParam();
  1273. param.setAppId(appId);
  1274. param.setOrgId(org.getLong("id"));
  1275. param.setViewType("08");
  1276. String paymethod = (String)SystemParamServiceHelper.loadAppParameterFromCache(param, "paymethod");
  1277. if ("0".equals(paymethod)) {
  1278. CloseCallBack closeCallBack = new CloseCallBack(this, "settletnumber");
  1279. QFilter qFilterSour = new QFilter("arrivalstatus", "=", "arrival_confirm");
  1280. qFilterSour.and("arrivalway", "!=", "protest");
  1281. qFilterSour.and(QFilter.sqlExpress("arrivalamount", ">", "flockamount"));
  1282. qFilterSour.and("isinit", "=", '0');
  1283. qFilterSour.and("eassrcid", "=", "");
  1284. CasBotpHelper.doBeforeDraw(this.getView(), "lc_arrival", this.getModel().getDataEntityType().getName(), false, qFilterSour, closeCallBack);
  1285. }
  1286. }
  1287. }
  1288. private void changePayeePage() {
  1289. this.opreatePayee(Boolean.FALSE);
  1290. }
  1291. private void addPayee() {
  1292. this.opreatePayee(Boolean.TRUE);
  1293. }
  1294. private void opreatePayee(Boolean isAddNew) {
  1295. Map<String, Object> paramMap = new HashMap();
  1296. if (this.isHwControl()) {
  1297. paramMap.put("hw_payeesiteid", this.getValue("hw_payeesiteid"));
  1298. }
  1299. paramMap.put("org", this.getPk("org"));
  1300. paramMap.put("asstActType", this.getString("payeetype"));
  1301. paramMap.put("isBE", this.isBePay());
  1302. paramMap.put("billtype", Optional.ofNullable(this.getDynamicObject("billtype")).map(DataEntityBase::getPkValue).orElse((Object)null));
  1303. FormShowParameter parameter = new FormShowParameter();
  1304. parameter.getOpenStyle().setShowType(ShowType.Modal);
  1305. parameter.setFormId("cas_addpayee");
  1306. parameter.setStatus(isAddNew ? OperationStatus.ADDNEW : OperationStatus.EDIT);
  1307. parameter.getCustomParams().putAll(paramMap);
  1308. parameter.setCloseCallBack(new CloseCallBack(this, "addpayee"));
  1309. this.getView().showForm(parameter);
  1310. }
  1311. private void addPayeeValue(Map<String, Object> resultMap) {
  1312. this.setValue("payeeformid", resultMap.get("payeeformid"));
  1313. this.setValue("payee", resultMap.get("payee"));
  1314. this.setValue("payeename", resultMap.get("payeename"));
  1315. if (this.isHwControl()) {
  1316. this.setValue("hw_payeesiteid", resultMap.get("hw_payeesiteid"));
  1317. this.setValue("scorg", resultMap.get("scorg"));
  1318. }
  1319. this.setValue("payeenumber", resultMap.get("payeenumber"));
  1320. this.setValue("payeeaccformid", resultMap.get("payeeaccformid"));
  1321. this.setValue("payeeacctbank", resultMap.get("payeeacctbank"));
  1322. this.setValue("payeeacctcash", resultMap.get("payeeacctcash"));
  1323. this.setValue("payeebanknum", resultMap.get("payeebanknum"));
  1324. this.setValue("payeebank", resultMap.get("payeebank"));
  1325. this.setValue("payeebankname", resultMap.get("payeebankname"));
  1326. this.setValue("recaccbankname", resultMap.get("recaccbankname"));
  1327. String beBankNumber = (String)resultMap.get("recbanknumber");
  1328. this.setValue("recbanknumber", beBankNumber);
  1329. this.setValue("reccountry", resultMap.get("reccountry"));
  1330. this.setValue("recprovince", resultMap.get("recprovince"));
  1331. this.setValue("reccity", resultMap.get("reccity"));
  1332. this.setValue("recswiftcode", resultMap.get("swift_code"));
  1333. this.setValue("recroutingnum", resultMap.get("routingnum"));
  1334. this.setValue("recothercode", resultMap.get("other_code"));
  1335. this.setValue("recbankaddress", resultMap.get("address_eng"));
  1336. this.setValue("recemail", resultMap.get("payeeemail"));
  1337. this.setValue("payeecurrency", resultMap.get("payeecurrency"));
  1338. this.setValue("recaddress", resultMap.get("payeeaddress"));
  1339. this.setValue("supplierBankId", resultMap.get("supplierBankId"));
  1340. PaymentBillPluginHelper.fillProxyBeBankInfo(this.getModel(), this.getView(), true);
  1341. Boolean isDiffCur = (Boolean)this.getValue("isdiffcur");
  1342. Object recCurId = resultMap.get("payeecurrency");
  1343. if (recCurId != null && ((Long)recCurId).intValue() != 0 && !this.isBotpCreate() && isDiffCur) {
  1344. this.setValue("currency", resultMap.get("payeecurrency"));
  1345. }
  1346. if (AsstActTypeEnum.SUPPLIER.getValue().equals(this.getModel().getValue("payeetype"))) {
  1347. DynamicObject new_settletype = (DynamicObject)resultMap.get("settlment");
  1348. DynamicObject old_settletype = (DynamicObject)this.getModel().getValue("settletype");
  1349. if (!CasHelper.isEquals(new_settletype, old_settletype) && new_settletype != null) {
  1350. this.setValue("settletype", new_settletype);
  1351. }
  1352. }
  1353. this.setPayeeInfo4Lb();
  1354. this.getView().setVisible(false, new String[]{"flex_addpayee"});
  1355. this.getView().setVisible(true, new String[]{"flex_payeeinfo"});
  1356. }
  1357. private void changePayeeValue() {
  1358. this.setPayeeInfo4Lb();
  1359. boolean addpayView = this.hasPayeeInfo();
  1360. this.getView().setVisible(!addpayView, new String[]{"flex_addpayee"});
  1361. this.getView().setVisible(addpayView, new String[]{"flex_payeeinfo"});
  1362. }
  1363. private void setPayeeInfo4Lb() {
  1364. String payeeformid = this.getString("payeetype");
  1365. List<String> payeetypeList = Arrays.asList("bos_org", "bd_supplier", "bd_customer", "bos_user");
  1366. Long payeeId = Long.parseLong(this.getValue("payee") == null ? "0" : this.getValue("payee").toString());
  1367. String payeeType = this.getString("payeetype");
  1368. if (isOther(payeeType)) {
  1369. this.setValue("payeenamev", this.getValue("payeename"));
  1370. } else if (CasHelper.isNotEmpty(payeeformid) && payeetypeList.contains(payeeformid) && CasHelper.isNotEmpty(payeeId)) {
  1371. DynamicObject payeeObj = BusinessDataServiceHelper.loadSingleFromCache(payeeId, payeeformid, "name");
  1372. this.setValue("payeenamev", CasHelper.getLocalValue(payeeObj, "name"));
  1373. }
  1374. Image payeePic = (Image)this.getControl("payeepic");
  1375. String defaultUrl = BaseDataHelper.getPictureUrl(payeeId, payeeformid);
  1376. defaultUrl = defaultUrl == null ? "/icons/pc/entrance/cn_sk_80_80.png" : defaultUrl;
  1377. payeePic.setUrl(defaultUrl);
  1378. ((Label)this.getControl("payeebanknumv")).setText(StringUtils.splitString(this.getString("payeebanknum"), 4, " "));
  1379. ((Label)this.getControl("payeebanknamev")).setText(this.getString("payeebankname"));
  1380. ((Label)this.getControl("recaccbanknamev")).setText(this.getString("recaccbankname"));
  1381. ((Label)this.getControl("recbanknumberv")).setText(this.getString("recbanknumber"));
  1382. }
  1383. private void changePayerPage() {
  1384. DynamicObject settleType = this.getDynamicObject("settletype");
  1385. Object sourceBillType = this.getModel().getValue("sourcebilltype");
  1386. Map<String, Object> payerInfo = new HashMap();
  1387. payerInfo.put("cash", BaseDataHelper.isSettleTypeCash(settleType));
  1388. payerInfo.put("virtual", BaseDataHelper.isSettleTypeVirtual(settleType));
  1389. payerInfo.put("sourceBillType", sourceBillType);
  1390. FormShowParameter parameter = new FormShowParameter();
  1391. parameter.getOpenStyle().setShowType(ShowType.Modal);
  1392. parameter.setFormId("cas_changepayer");
  1393. parameter.getCustomParams().putAll(payerInfo);
  1394. parameter.setCloseCallBack(new CloseCallBack(this, "changepayer"));
  1395. this.getView().showForm(parameter);
  1396. }
  1397. private void changePayerValue(Map<String, Object> returnMap) {
  1398. boolean isChangeCur = false;
  1399. IBillModel model = (IBillModel)this.getModel();
  1400. DynamicObject new_org = (DynamicObject)returnMap.get("org");
  1401. DynamicObject old_org = (DynamicObject)model.getValue("org");
  1402. DynamicObject cur = OrgHelper.getBaseCurrency((Long)new_org.getPkValue());
  1403. if (!CasHelper.isEquals(new_org, old_org)) {
  1404. this.setValue("org", new_org);
  1405. this.setValue("basecurrency", cur);
  1406. this.setValue("draftbill", (Object)null);
  1407. isChangeCur = true;
  1408. }
  1409. DynamicObject new_acctcash = (DynamicObject)returnMap.get("payeracctcash");
  1410. DynamicObject old_acctcash = (DynamicObject)model.getValue("payeracctcash");
  1411. if (!CasHelper.isEquals(new_acctcash, old_acctcash)) {
  1412. this.setValue("payeracctcash", new_acctcash);
  1413. isChangeCur = false;
  1414. }
  1415. DynamicObject new_acctbank = (DynamicObject)returnMap.get("payeracctbank");
  1416. DynamicObject old_acctbank = (DynamicObject)model.getValue("payeracctbank");
  1417. if (!CasHelper.isEquals(new_acctbank, old_acctbank)) {
  1418. this.setValue("payeracctbank", new_acctbank);
  1419. isChangeCur = false;
  1420. }
  1421. DynamicObject new_bank = (DynamicObject)returnMap.get("payerbank");
  1422. DynamicObject old_bank = (DynamicObject)model.getValue("payerbank");
  1423. if (!CasHelper.isEquals(new_bank, old_bank)) {
  1424. this.setValue("payerbank", new_bank);
  1425. }
  1426. this.setPayerInfo4Lb();
  1427. this.settleOrg(true);
  1428. if (isChangeCur) {
  1429. this.setValue("currency", cur);
  1430. }
  1431. String uniformsocialcreditcode = new_org.getString("uniformsocialcreditcode");
  1432. if (kd.bos.dataentity.utils.StringUtils.isNotBlank(uniformsocialcreditcode)) {
  1433. this.setValue("uniformsocialcreditcode", uniformsocialcreditcode);
  1434. }
  1435. String payerNumber = new_org.getString("number");
  1436. if (kd.bos.dataentity.utils.StringUtils.isNotBlank(payerNumber)) {
  1437. this.setValue("payernumber", payerNumber);
  1438. }
  1439. this.setValue("openorg", returnMap.get("openorg"));
  1440. }
  1441. public void closedCallBack(ClosedCallBackEvent e) {
  1442. super.closedCallBack(e);
  1443. Map data;
  1444. if ("changepayer".equals(e.getActionId())) {
  1445. data = (Map)e.getReturnData();
  1446. if (data != null) {
  1447. this.changePayerValue(data);
  1448. }
  1449. } else if ("addpayee".equals(e.getActionId())) {
  1450. data = (Map)e.getReturnData();
  1451. if (data != null) {
  1452. this.addPayeeValue(data);
  1453. this.setCrossPayValue();
  1454. }
  1455. } else {
  1456. String confirm;
  1457. if ("beforesubmit".equals(e.getActionId())) {
  1458. confirm = (String)e.getReturnData();
  1459. if (confirm != null && confirm.equals("ok")) {
  1460. this.getView().invokeOperation("submit");
  1461. }
  1462. } else if ("beforesubmitnew".equals(e.getActionId())) {
  1463. confirm = (String)e.getReturnData();
  1464. if (confirm != null && confirm.equals("ok")) {
  1465. this.getView().invokeOperation("submitandnew");
  1466. }
  1467. } else {
  1468. OperateOption option;
  1469. if (kd.bos.dataentity.utils.StringUtils.equals(e.getActionId(), "KEY_DIFFPAY_CALLBACK")) {
  1470. data = (Map)e.getReturnData();
  1471. if (data != null) {
  1472. option = OperateOption.create();
  1473. Iterator var4 = data.entrySet().iterator();
  1474. while(var4.hasNext()) {
  1475. Map.Entry<String, Object> entry = (Map.Entry)var4.next();
  1476. if (entry.getValue() != null) {
  1477. option.setVariableValue((String)entry.getKey(), entry.getValue().toString());
  1478. }
  1479. }
  1480. option.setVariableValue("payConfirm", "1");
  1481. this.getView().invokeOperation("pay", option);
  1482. }
  1483. } else if (kd.bos.dataentity.utils.StringUtils.equals(e.getActionId(), "CALLBACK_SELECTDRAFT")) {
  1484. Object draftIdList = e.getReturnData();
  1485. if (draftIdList != null) {
  1486. option = OperateOption.create();
  1487. option.setVariableValue("draftids", JSON.toJSONString(draftIdList));
  1488. this.getView().invokeOperation("pay", option);
  1489. }
  1490. } else if (kd.bos.dataentity.utils.StringUtils.equals(e.getActionId(), "settletnumber")) {
  1491. ListSelectedRowCollection rows = (ListSelectedRowCollection)e.getReturnData();
  1492. if (EmptyUtil.isNoEmpty(rows)) {
  1493. this.getModel().deleteEntryData("entry");
  1494. CasBotpHelper.doDraw(this.getView(), "lc_arrival", this.getModel().getDataEntityType().getName(), rows);
  1495. }
  1496. }
  1497. }
  1498. }
  1499. PaymentBillPluginHelper.isSchePayEditable(this, this.getModel());
  1500. DynamicObject org = this.getDynamicObject("org");
  1501. InitCheckPluginHelper.checkInitForPlugin(this.getView(), org, new String[]{"bar_save", "bar_submit"});
  1502. }
  1503. public void beforeItemClick(BeforeItemClickEvent evt) {
  1504. String opKey = evt.getOperationKey();
  1505. if ("delete".equals(opKey)) {
  1506. if ("cas_recbill".equals(this.getString("sourcebilltype"))) {
  1507. evt.setCancel(true);
  1508. String billno = this.getString("billno");
  1509. 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));
  1510. }
  1511. } else if ("pay".equals(opKey)) {
  1512. DynamicObject dataEntity = this.getModel().getDataEntity();
  1513. long orgDynId = dataEntity.getDynamicObject("org").getLong("id");
  1514. boolean selectDraftFlag = SystemParameterHelper.getParameterBoolean(orgDynId, "cs122");
  1515. String settleTypeKey = DraftHelper.getKey(dataEntity.get("settletype"));
  1516. logger.info("selectDraftFlag is:" + selectDraftFlag + ",key:" + settleTypeKey);
  1517. boolean isdraft = SystemParameterHelper.getCdmParameterBoolean(orgDynId, "isdraft");
  1518. boolean ischeck = SystemParameterHelper.getCdmParameterBoolean(orgDynId, "ischeck");
  1519. boolean ispromissorynote = SystemParameterHelper.getCdmParameterBoolean(orgDynId, "ispromissorynote");
  1520. if (!CasHelper.isEmpty(settleTypeKey)) {
  1521. String typeName;
  1522. switch (settleTypeKey) {
  1523. case "isdraft":
  1524. if (isdraft && !selectDraftFlag) {
  1525. typeName = ResManager.loadKDString("汇票", "DraftHelper_4", "fi-cas-common", new Object[0]);
  1526. this.cancelAndWarn(evt, dataEntity, typeName);
  1527. }
  1528. break;
  1529. case "ischeck":
  1530. if (ischeck && !selectDraftFlag) {
  1531. typeName = ResManager.loadKDString("支票", "DraftHelper_5", "fi-cas-common", new Object[0]);
  1532. this.cancelAndWarn(evt, dataEntity, typeName);
  1533. }
  1534. break;
  1535. case "ispromissorynote":
  1536. if (ispromissorynote && !selectDraftFlag) {
  1537. typeName = ResManager.loadKDString("本票", "DraftHelper_6", "fi-cas-common", new Object[0]);
  1538. this.cancelAndWarn(evt, dataEntity, typeName);
  1539. }
  1540. }
  1541. }
  1542. }
  1543. if ("commitbe".equals(opKey)) {
  1544. OperateOption op = OperateOption.create();
  1545. op.setVariableValue("ishasright", "true");
  1546. OperationResult operationResult = OperationServiceHelper.executeOperate("beforecommitbe", "nckd_cas_arbill", new Object[]{this.getModel().getDataEntity().getPkValue()}, op);
  1547. if (!operationResult.isSuccess() && operationResult.isNeedSign()) {
  1548. SignOperateCallback signOperate = new SignOperateCallback(this.getView(), this, op, ClientCallback.SignClientType.Secondry, "signbeforecommitbe");
  1549. OperationResult ops = signOperate.sign(operationResult);
  1550. evt.setCancel(true);
  1551. if (!ops.isSuccess()) {
  1552. logger.info(" beforecommitbe sign error ");
  1553. if (ops.isShowMessage() && EmptyUtil.isNoEmpty(ops.getMessage())) {
  1554. this.getView().showTipNotification(ops.getMessage());
  1555. }
  1556. }
  1557. }
  1558. }
  1559. }
  1560. private void cancelAndWarn(BeforeItemClickEvent evt, DynamicObject dataEntity, String typeName) {
  1561. String msg = String.format(ResManager.loadKDString("%1$s :结算方式类别为%2$s的付款单不支持确认付款", "DraftHelper_7_1", "fi-cas-common", new Object[0]), dataEntity.getString("billno"), typeName);
  1562. evt.setCancel(true);
  1563. this.getView().showTipNotification(msg);
  1564. }
  1565. public void itemClick(ItemClickEvent evt) {
  1566. super.itemClick(evt);
  1567. String key = evt.getItemKey().toLowerCase();
  1568. if ("bar_beforesubmit".equals(key)) {
  1569. this.getView().invokeOperation("beforesubmit");
  1570. } else if ("bar_cancelpay".equals(key)) {
  1571. this.cancelPay();
  1572. } else if ("viewsettle".equals(key)) {
  1573. this.viewSettle();
  1574. } else if ("bar_save".equals(key)) {
  1575. this.getView().updateView("feeactbank");
  1576. this.getView().updateView("feecurrency");
  1577. }
  1578. }
  1579. public void afterDeleteRow(AfterDeleteRowEventArgs e) {
  1580. super.afterDeleteRow(e);
  1581. this.calculateAmt();
  1582. }
  1583. public void afterBindData(EventObject e) {
  1584. super.afterBindData(e);
  1585. DynamicObject org = this.getDynamicObject("org");
  1586. InitCheckPluginHelper.checkInitForPlugin(this.getView(), org, new String[]{"bar_save", "bar_submit"});
  1587. DynamicObject paymentBill = this.getModel().getDataEntity();
  1588. Map<String, Object> customParams = this.getView().getFormShowParameter().getCustomParams();
  1589. Object showConer = customParams.get("showConer");
  1590. List<IApprovalRecordGroup> workflowlist = WorkflowServiceHelper.getAllApprovalRecord(paymentBill.getPkValue().toString());
  1591. if (CollectionUtils.isEmpty(workflowlist) || CasHelper.isEmpty(showConer)) {
  1592. SplitContainer control = (SplitContainer)this.getControl("splitcontainerap");
  1593. control.hidePanel(SplitDirection.right, true);
  1594. control.setCollapse("splitpanelap1", true);
  1595. }
  1596. Long orgId = this.getPk("org");
  1597. DynamicObject cur;
  1598. DynamicObject payeracctbank;
  1599. if (this.isBotpNew()) {
  1600. if (orgId == null) {
  1601. this.getView().setEnable(false, new String[]{"bar_save", "bar_submit", "bar_beforesubmit"});
  1602. this.getView().showErrorNotification(ResManager.loadKDString("请在上游单据维护付款组织来源再推付款单。", "PaymentBillEdit_7", "fi-cas-formplugin", new Object[0]));
  1603. return;
  1604. }
  1605. cur = OrgHelper.getBaseCurrency(orgId);
  1606. if (cur == null) {
  1607. this.getView().setEnable(false, new String[]{"bar_save", "bar_submit", "bar_beforesubmit"});
  1608. 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"});
  1609. this.getView().getFormShowParameter().setStatus(OperationStatus.VIEW);
  1610. this.getView().showErrorNotification(SystemStatusCtrolHelper.notFinishInitSetMsg(CasHelper.getLocalValue(this.getDynamicObject("org"), "name")));
  1611. return;
  1612. }
  1613. this.setValueIfAbsent("basecurrency", cur);
  1614. payeracctbank = this.getDynamicObject("payeracctbank");
  1615. if (payeracctbank != null) {
  1616. this.setValueIfAbsent("payerbank", payeracctbank.getDynamicObject("bank"));
  1617. this.setValueIfAbsent("openorg", payeracctbank.getDynamicObject("openorg"));
  1618. }
  1619. this.setNetBankAcctVisible();
  1620. DynamicObject paymentType = paymentBill.getDynamicObject("paymenttype");
  1621. if (paymentType != null) {
  1622. paymentType = BusinessDataServiceHelper.loadSingleFromCache(paymentType.getPkValue(), "cas_paymentbilltype", "id,fundflowitem");
  1623. this.fillFundflowItem(false, paymentType.getDynamicObject("fundflowitem"));
  1624. }
  1625. }
  1626. if (null == this.getDynamicObject("exratetable")) {
  1627. this.setDefaultExratetable(orgId);
  1628. }
  1629. PaymentBillPluginHelper.fillToolBar(this, this.getModel(), this.getView());
  1630. this.setPayerInfo4Lb();
  1631. this.changePayeeValue();
  1632. this.setEntryAmountCaption();
  1633. this.ctrChangeLableVisible();
  1634. this.setCurrencyEditable();
  1635. this.ctrBeInfoVisibility();
  1636. this.setExchangerateEditable();
  1637. this.ctrRefundInfoVisibility();
  1638. cur = this.getDynamicObject("payeracctbank");
  1639. this.setPaymentChannelValue(cur, Boolean.FALSE);
  1640. this.setDiffCurInfo();
  1641. this.setCountryValue();
  1642. this.setCrossPayValue();
  1643. this.isDiffCurVisibility();
  1644. this.isOnlinebankVisibility();
  1645. this.setPayerAndPayeeInfo(orgId);
  1646. this.getModel().setDataChanged(false);
  1647. payeracctbank = (DynamicObject)this.getModel().getValue("settletype");
  1648. if (Objects.nonNull(payeracctbank)) {
  1649. this.settletNumber(payeracctbank);
  1650. } else {
  1651. this.getView().setVisible(Boolean.FALSE, new String[]{"draftbill"});
  1652. }
  1653. this.showBalance();
  1654. }
  1655. private void setPayerAndPayeeInfo(Long orgId) {
  1656. if (!CasHelper.isEmpty(orgId)) {
  1657. DynamicObject org = BusinessDataServiceHelper.loadSingleFromCache(orgId, "bos_org");
  1658. this.getModel().setValue("payernumber", org.getString("number"));
  1659. this.getModel().setValue("uniformsocialcreditcode", org.getString("uniformsocialcreditcode"));
  1660. Long payeeId = Long.valueOf(this.getModel().getValue("payee").toString());
  1661. String type = this.getModel().getValue("payeetype").toString();
  1662. String number = this.getModel().getValue("payeenumber").toString();
  1663. if (!number.isEmpty() || !AsstActTypeEnum.SUPPLIER.getValue().equals(type) && !AsstActTypeEnum.CUSTOMER.getValue().equals(type)) {
  1664. if (number.isEmpty() && (AsstActTypeEnum.EMPLOYEE.getValue().equals(type) || AsstActTypeEnum.COMPANY.getValue().equals(type))) {
  1665. number = this.getUserOrOrgNumber(payeeId, type);
  1666. }
  1667. } else {
  1668. number = this.getPayeeOrPayerInfoNumber(payeeId, type, this.getModel().getDataEntityType().getName());
  1669. }
  1670. this.getModel().setValue("payeenumber", number);
  1671. if (!this.getModel().getDataEntity().getString("billstatus").equals(BillStatusEnum.SAVE.getValue())) {
  1672. this.getView().setEnable(false, new String[]{"priority"});
  1673. }
  1674. }
  1675. }
  1676. protected void setExchangerateEditable() {
  1677. DynamicObject srcCurrency = this.getDynamicObject("currency");
  1678. DynamicObject destCurrency = this.getDynamicObject("basecurrency");
  1679. if (srcCurrency != null && destCurrency != null) {
  1680. if (srcCurrency.getLong("id") == destCurrency.getLong("id")) {
  1681. this.getView().setEnable(false, new String[]{"exchangerate"});
  1682. }
  1683. }
  1684. }
  1685. private void setDefaultExratetable(Long orgId) {
  1686. Long exchangeRateTableId = 0L;
  1687. try {
  1688. exchangeRateTableId = SystemStatusCtrolHelper.getExrateTable(orgId).getLong("id");
  1689. } catch (Exception var4) {
  1690. }
  1691. this.getModel().setValue("exratetable", exchangeRateTableId);
  1692. }
  1693. private void setEntryAmountCaption() {
  1694. DynamicObject billType = (DynamicObject)this.getModel().getValue("billtype");
  1695. if (billType != null) {
  1696. EntryGrid entryCtr = (EntryGrid)this.getControl("entry");
  1697. if (BillTypeConstants.PAYBILL_OTR.equals(billType.getPkValue())) {
  1698. entryCtr.setColumnProperty("e_payableamt", "header", new LocaleString(ResManager.loadKDString("实付金额", "PaymentBillEdit_8", "fi-cas-formplugin", new Object[0])));
  1699. entryCtr.setColumnProperty("e_payablelocamt", "header", new LocaleString(ResManager.loadKDString("实付折本币", "PaymentBillEdit_9", "fi-cas-formplugin", new Object[0])));
  1700. } else {
  1701. entryCtr.setColumnProperty("e_payableamt", "header", new LocaleString(ResManager.loadKDString("应付金额", "PaymentBillEdit_10", "fi-cas-formplugin", new Object[0])));
  1702. entryCtr.setColumnProperty("e_payablelocamt", "header", new LocaleString(ResManager.loadKDString("应付折本币", "PaymentBillEdit_11", "fi-cas-formplugin", new Object[0])));
  1703. }
  1704. }
  1705. }
  1706. private void ctrChangeLableVisible() {
  1707. Object sourceBillType = this.getModel().getValue("sourcebilltype");
  1708. if (!"cas_recbill".equals(sourceBillType) && !"bei_transdetail_cas".equals(sourceBillType) && BillStatusEnum.SAVE.getValue().equals(this.getModel().getValue("billstatus"))) {
  1709. if (!(Boolean)this.getModel().getValue("issupplecontract")) {
  1710. this.getView().setVisible(true, new String[]{"changepayer", "changepayee"});
  1711. }
  1712. } else {
  1713. this.getView().setVisible(false, new String[]{"changepayer", "changepayee"});
  1714. }
  1715. }
  1716. private boolean isBePay() {
  1717. DynamicObject payerAcctBank = this.getDynamicObject("payeracctbank");
  1718. if (payerAcctBank != null && PayBillCrossHelper.isIfmBankAcc(payerAcctBank)) {
  1719. return true;
  1720. } else {
  1721. return payerAcctBank != null && (Boolean)payerAcctBank.get("issetbankinterface") && "bei".equalsIgnoreCase(this.getString("paymentchannel"));
  1722. }
  1723. }
  1724. private boolean isBeiBePay() {
  1725. DynamicObject payerAcctBank = this.getDynamicObject("payeracctbank");
  1726. return payerAcctBank != null && (Boolean)payerAcctBank.get("issetbankinterface") && "bei".equalsIgnoreCase(this.getString("paymentchannel"));
  1727. }
  1728. public void beforeDoOperation(BeforeDoOperationEventArgs args) {
  1729. super.beforeDoOperation(args);
  1730. AbstractOperate op = (AbstractOperate)args.getSource();
  1731. String operateKey = op.getOperateKey();
  1732. DynamicObject payerAcctBank = this.getDynamicObject("payeracctbank");
  1733. DynamicObject accountBank;
  1734. if ("trackdown".equals(operateKey)) {
  1735. accountBank = this.getDynamicObject("settletype");
  1736. if (accountBank != null) {
  1737. String settlementtype = accountBank.getString("settlementtype");
  1738. if (EmptyUtil.isNoEmpty(settlementtype) && this.settleTypes.contains(settlementtype)) {
  1739. op.getOption().setVariableValue("botp_track_edit_status", "true");
  1740. }
  1741. }
  1742. } else if ((!"save".equals(operateKey) || (Boolean)this.getModel().getValue("issupplecontract")) && !"submit".equals(operateKey) && !"submitandnew".equals(operateKey) && !"beforesubmit".equals(operateKey) && !"beforesubmitnew".equals(operateKey)) {
  1743. DynamicObject orgData;
  1744. if ("refundsave".equals(operateKey)) {
  1745. Long rebillid = (Long)this.getView().getFormShowParameter().getCustomParam("rebillid");
  1746. orgData = BusinessDataServiceHelper.loadSingle(rebillid, "cas_recbill");
  1747. BigDecimal actrecamt = orgData.getBigDecimal("actrecamt");
  1748. DynamicObjectCollection payEntrys = this.getModel().getEntryEntity("entry");
  1749. BigDecimal refundamtTotal = (BigDecimal)payEntrys.stream().map((o) -> {
  1750. return o.getBigDecimal("e_refundamt");
  1751. }).reduce(BigDecimal.ZERO, BigDecimal::add);
  1752. if (actrecamt.compareTo(refundamtTotal) != 0) {
  1753. throw new KDBizException(ResManager.loadKDString("退款金额合计与收款单金额不相等", "PaymentBillEdit_19", "fi-cas-formplugin", new Object[0]));
  1754. }
  1755. FormOperate operate = (FormOperate)args.getSource();
  1756. operate.getOption().setVariableValue("rebillid", SerializationUtils.toJsonString(this.getView().getFormShowParameter().getCustomParam("rebillid")));
  1757. operate.getOption().setVariableValue("billtype", "nckd_cas_arbill");
  1758. } else if ("recbook".equals(operateKey)) {
  1759. accountBank = this.getDynamicObject("payeracctbank");
  1760. if (null != accountBank && AccountBankHelper.isClosed(accountBank.getLong("id"))) {
  1761. throw new KDBizException(String.format(ResManager.loadKDString("账户%s当前状态为已销户,暂无法进行业务处理。", "PaymentErrorCode_47", "fi-cas-business", new Object[0]), accountBank.getString("number")));
  1762. }
  1763. if (payerAcctBank != null && PayBillCrossHelper.isIfmBankAcc(payerAcctBank)) {
  1764. throw new KDBizException(ResManager.loadKDString("内部账户请选择内部结算付款。", "PaymentErrorCode_48", "fi-cas-business", new Object[0]));
  1765. }
  1766. if (PaymentBillPluginHelper.checkPayeeTypeFreeze(Collections.singletonList(this.getModel().getDataEntity()))) {
  1767. throw new KDBizException((new PaymentErrorCode()).CANOTDOTHISOP_WHENSUPPLIERFREEZE().getMessage());
  1768. }
  1769. } else if ("endorse".equals(operateKey)) {
  1770. if (payerAcctBank != null && PayBillCrossHelper.isIfmBankAcc(payerAcctBank)) {
  1771. throw new KDBizException(ResManager.loadKDString("内部账户请选择内部结算付款。", "PaymentErrorCode_48", "fi-cas-business", new Object[0]));
  1772. }
  1773. if (PaymentBillPluginHelper.checkPayeeTypeFreeze(Collections.singletonList(this.getModel().getDataEntity()))) {
  1774. throw new KDBizException((new PaymentErrorCode()).CANOTDOTHISOP_WHENSUPPLIERFREEZE().getMessage());
  1775. }
  1776. } else if ("pay".equals(operateKey)) {
  1777. String draftIds = op.getOption().getVariableValue("draftids", "");
  1778. if (kd.bos.dataentity.utils.StringUtils.isEmpty(draftIds)) {
  1779. orgData = (DynamicObject)this.getValue("org");
  1780. Long pkValue = (Long)orgData.getPkValue();
  1781. boolean selectDraftFlag = SystemParameterHelper.getParameterBoolean(pkValue, "cs122");
  1782. DynamicObject data = this.getModel().getDataEntity(true);
  1783. if (selectDraftFlag && PaymentBillPluginHelper.needSelectedDraft(data)) {
  1784. FormShowParameter showParameter = new FormShowParameter();
  1785. showParameter.setAppId("cas");
  1786. showParameter.setFormId("cas_payment_selectdraft");
  1787. showParameter.setCustomParam("payBillId", data.getPkValue());
  1788. showParameter.getOpenStyle().setShowType(ShowType.Modal);
  1789. showParameter.setCloseCallBack(new CloseCallBack(this, "CALLBACK_SELECTDRAFT"));
  1790. this.getView().showForm(showParameter);
  1791. args.setCancel(true);
  1792. } else if (!DraftHelper.isAllPayDrafBill((DynamicObjectCollection)this.getModel().getValue("draftbill")) && !(Boolean)this.getModel().getValue("feepay")) {
  1793. String payConfirm = op.getOption().getVariableValue("payConfirm", "");
  1794. if (kd.bos.dataentity.utils.StringUtils.isEmpty(payConfirm)) {
  1795. this.pay(args);
  1796. }
  1797. }
  1798. }
  1799. }
  1800. } else if (!this.isBeConfirmOK) {
  1801. this.storeFields();
  1802. }
  1803. if ("submit".equals(operateKey)) {
  1804. FormUtils.deleteEmptyRows(this.getModel(), new String[]{"e_payableamt"});
  1805. }
  1806. if (Arrays.asList("unaudit", "chargeback", "invalid", "delete", "pay").contains(operateKey) && PayBillHepler.getViewSettle(this.getModel().getDataEntity()).size() > 0) {
  1807. this.getView().showErrorNotification(String.format(ResManager.loadKDString("%s已存在结算记录,导致操作失败。如需继续执行操作,请先反结算。", "PaymentBillList_36", "fi-cas-formplugin", new Object[0]), ""));
  1808. args.setCancel(true);
  1809. }
  1810. }
  1811. public void confirmCallBack(MessageBoxClosedEvent messageBoxClosedEvent) {
  1812. super.confirmCallBack(messageBoxClosedEvent);
  1813. String id = messageBoxClosedEvent.getCallBackId();
  1814. MessageBoxResult res = messageBoxClosedEvent.getResult();
  1815. if (id.equals("CONFIRM_CANCELPAY_CALLBACK") && MessageBoxResult.Yes.equals(res)) {
  1816. String billno = (String)this.getModel().getValue("billno");
  1817. DynamicObject payObj = BusinessDataServiceHelper.loadSingle("nckd_cas_arbill", "id,billno", new QFilter[]{new QFilter("billno", "=", billno)});
  1818. if (!this.cancelPayCheckSettle(payObj)) {
  1819. this.getView().invokeOperation("cancelpay");
  1820. }
  1821. }
  1822. if (id.equals("CONFIRM_CANCELPAY_SETTLE_CALLBACK") && MessageBoxResult.Yes.equals(res)) {
  1823. this.getView().invokeOperation("cancelpay");
  1824. }
  1825. if (id.equals("CONFIRM_DEL_CALLBACK")) {
  1826. OperateOption option = OperateOption.create();
  1827. if (MessageBoxResult.Yes.equals(res)) {
  1828. option.setVariableValue("delrecpay", "1");
  1829. this.getView().invokeOperation("delete", option);
  1830. }
  1831. }
  1832. }
  1833. private void storeFields() {
  1834. IBillModel model = (IBillModel)this.getModel();
  1835. String entrance = (String)model.getValue("entrance");
  1836. if (PaymentTypeEnum.OTR.name().equals(entrance)) {
  1837. DynamicObject paymentType = (DynamicObject)model.getValue("paymenttype");
  1838. if (paymentType != null && !paymentType.getBoolean("ispartpayment")) {
  1839. int count = model.getEntryRowCount("entry");
  1840. for(int i = 0; i < count; ++i) {
  1841. this.setValue("e_discountamt", (Object)null, i);
  1842. this.setValue("e_discountlocamt", (Object)null, i);
  1843. this.setValue("e_corebilltype", (Object)null, i);
  1844. this.setValue("e_corebillno", (Object)null, i);
  1845. this.setValue("e_corebillentryseq", (Object)null, i);
  1846. this.setValue("e_lockamt", (Object)null, i);
  1847. this.setValue("e_unlockamt", (Object)null, i);
  1848. this.setValue("e_settledamt", (Object)null, i);
  1849. this.setValue("e_unsettledamt", (Object)null, i);
  1850. }
  1851. }
  1852. } else if (PaymentTypeEnum.SYN.name().equals(entrance) || PaymentTypeEnum.CASH.name().equals(entrance) || PaymentTypeEnum.SPAN.name().equals(entrance)) {
  1853. int count = model.getEntryRowCount("entry");
  1854. if (count < 1) {
  1855. this.getView().updateView("entry");
  1856. this.getView().invokeOperation("newentry");
  1857. }
  1858. this.setValue("e_payableamt", this.getBigDecimal("actpayamt"), 0);
  1859. this.setValue("e_fundflowitem", this.getValue("fundflowitem"), 0);
  1860. }
  1861. }
  1862. public void afterDoOperation(AfterDoOperationEventArgs arg) {
  1863. super.afterDoOperation(arg);
  1864. AbstractOperate op = (AbstractOperate)arg.getSource();
  1865. OperationResult operationResult = arg.getOperationResult();
  1866. String key = op.getOperateKey();
  1867. if ("copyentryrow".equals(key)) {
  1868. EntryGrid entry = (EntryGrid)this.getControl("entry");
  1869. if (entry.getSelectRows().length == 0) {
  1870. this.getView().showTipNotification(ResManager.loadKDString("请选中一行再进行操作", "PaymentBillEdit_12", "fi-cas-formplugin", new Object[0]));
  1871. return;
  1872. }
  1873. this.calculateAmt();
  1874. } else if (!"beforesubmit".equals(key) && !"beforesubmitnew".equals(key)) {
  1875. if ("newentry".equals(key)) {
  1876. this.settleOrg(false);
  1877. } else {
  1878. IFormView view;
  1879. if ("refundsave".equals(key) && arg.getOperationResult().isSuccess()) {
  1880. view = this.getView().getParentView();
  1881. view.close();
  1882. this.getView().sendFormAction(view);
  1883. return;
  1884. }
  1885. if ("delete".equals(key) && arg.getOperationResult().isSuccess()) {
  1886. view = this.getView();
  1887. view.close();
  1888. this.getView().sendFormAction(view);
  1889. } else if (("unsubmit".equals(key) || "unaudit".equals(key)) && arg.getOperationResult().isSuccess()) {
  1890. this.getView().setStatus(OperationStatus.EDIT);
  1891. } else {
  1892. String reason;
  1893. if (!"pay".equals(key) && !"cancelpay".equals(key)) {
  1894. if ("receipt".equals(key) && arg.getOperationResult().isSuccess()) {
  1895. this.viewReceipt();
  1896. } else if ("chargebacknoreason".equals(key)) {
  1897. reason = ResManager.loadKDString("自动退单", "PaymentBillList_37", "fi-cas-formplugin", new Object[0]);
  1898. List<Object> successPkIds = operationResult.getSuccessPkIds();
  1899. Map<String, Object> data = new HashMap(16);
  1900. data.put("billid", successPkIds);
  1901. data.put("reason", reason);
  1902. data.put("operateKey", "chargeback");
  1903. PayBillListPlugnHelper.closeCallBack("CALLBACK_CHARGEBACK", this.getView(), data);
  1904. }
  1905. } else {
  1906. reason = arg.getOperationResult().getMessage();
  1907. if (!arg.getOperationResult().isSuccess() && !(new CasErrorCode()).VOUCHER_NOT_CHECK().getMessage().equals(reason)) {
  1908. this.getModel().setValue("billstatus", "pay".equals(key) ? BillStatusEnum.AUDIT.getValue() : BillStatusEnum.PAY.getValue());
  1909. }
  1910. if ("pay".equals(key) && (Boolean)this.getValue("isdiffcur")) {
  1911. this.getView().updateView("dpamt");
  1912. this.getView().updateView("agreedrate");
  1913. this.getView().updateView("dplocalamt");
  1914. this.getView().updateView("lossamt");
  1915. this.getView().updateView("billstatus");
  1916. this.getView().updateView("exchangerate");
  1917. this.getView().updateView("dpexchangerate");
  1918. this.getView().updateView("localamt");
  1919. this.getView().updateView("paydate");
  1920. this.getView().updateView("feeactbank");
  1921. this.getView().updateView("feecurrency");
  1922. this.getView().updateView("singlestream");
  1923. this.getView().updateView("fee");
  1924. for(int i = 0; i < this.getModel().getEntryRowCount("entry"); ++i) {
  1925. this.getView().updateView("e_payablelocamt", i);
  1926. this.getView().updateView("e_discountlocamt", i);
  1927. this.getView().updateView("e_localamt", i);
  1928. }
  1929. }
  1930. this.getView().updateView("draftbill");
  1931. if (arg.getOperationResult().isSuccess()) {
  1932. this.getView().invokeOperation("refresh", OperateOption.create());
  1933. }
  1934. }
  1935. }
  1936. }
  1937. } else if ("beforesubmit".equals(key)) {
  1938. IDataModel model = this.getModel();
  1939. if (!CasHelper.isEmpty(model.getValue("entrustorg"))) {
  1940. model.setValue("payeracctbank", (Object)null);
  1941. model.setValue("payerbank", (Object)null);
  1942. ((Label)this.getControl("payerbanknumv")).setText("");
  1943. ((Label)this.getControl("payerbanknamev")).setText("");
  1944. model.setValue("settletype", (Object)null);
  1945. }
  1946. if (arg.getOperationResult().isSuccess()) {
  1947. DynamicObject company = (DynamicObject)model.getValue("org");
  1948. boolean isNotCheckBeBankNumb = SystemParameterHelper.getParameterBoolean(company.getLong("id"), "cs125");
  1949. if (this.isBeiBePay() && CasHelper.isEmpty(this.getString("recbanknumber")) && !isNotCheckBeBankNumb && this.isCrossTranType()) {
  1950. this.getView().showTipNotification(ResManager.loadKDString(String.format("单号%s的付款单支付渠道为银企互联,收款行行号不能为空,请补充。", this.getModel().getValue("billno")), "PaymentBillEdit_29", "fi-cas-formplugin", new Object[0]));
  1951. return;
  1952. }
  1953. List<Object> pks = arg.getOperationResult().getSuccessPkIds();
  1954. if (!EmptyUtil.isEmpty(pks)) {
  1955. this.getView().invokeOperation("submit");
  1956. }
  1957. }
  1958. }
  1959. if (Arrays.asList("save", "submit").contains(key) && arg.getOperationResult().isSuccess()) {
  1960. this.getView().updateView("entrustorg");
  1961. this.getView().updateView("totalpayamt");
  1962. for(int i = 0; i < this.getModel().getEntryRowCount("entry"); ++i) {
  1963. this.getView().updateView("e_lockAmt", i);
  1964. this.getView().updateView("e_unlockAmt", i);
  1965. }
  1966. }
  1967. if ("unaudit".equals(key)) {
  1968. this.getView().invokeOperation("refresh", OperateOption.create());
  1969. }
  1970. PaymentBillPluginHelper.fillToolBar(this, this.getModel(), this.getView());
  1971. this.ctrChangeLableVisible();
  1972. PaymentBillPluginHelper.isSchePayEditable(this, this.getModel());
  1973. }
  1974. private boolean isCrossTranType() {
  1975. boolean type = (Boolean)this.getValue("iscrosspay");
  1976. DynamicObject dentify = (DynamicObject)this.getValue("paymentidentify");
  1977. return !type || null == dentify || !"0".equals(dentify.getString("type"));
  1978. }
  1979. public void beforeClosed(BeforeClosedEvent e) {
  1980. super.beforeClosed(e);
  1981. try {
  1982. BillShowParameter billShowParameter = (BillShowParameter)this.getView().getFormShowParameter();
  1983. String billStatus = (String)this.getModel().getValue("billstatus");
  1984. if (!BillStatusEnum.SAVE.getValue().equals(billStatus) || billShowParameter.getStatus() == OperationStatus.VIEW) {
  1985. e.setCheckDataChange(false);
  1986. }
  1987. } catch (Exception var4) {
  1988. }
  1989. }
  1990. private void cancelPay() {
  1991. String billno = (String)this.getModel().getValue("billno");
  1992. DynamicObject payObj = BusinessDataServiceHelper.loadSingle("nckd_cas_arbill", "id,billno,isvoucher,billstatus,org", new QFilter[]{new QFilter("billno", "=", billno)});
  1993. String billstatus = payObj.getString("billstatus");
  1994. if (!billstatus.equals("D")) {
  1995. this.getView().invokeOperation("cancelpay");
  1996. } else {
  1997. Object org = this.getModel().getValue("org");
  1998. if (org != null) {
  1999. int CS116 = SystemParameterHelper.getParameterInteger(((DynamicObject)org).getLong("id"), "cs116");
  2000. Boolean isv = payObj.getBoolean("isvoucher");
  2001. if (3 == CS116 && isv) {
  2002. 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));
  2003. } else if (!this.cancelPayCheckSettle(payObj)) {
  2004. this.getView().invokeOperation("cancelpay");
  2005. }
  2006. }
  2007. }
  2008. }
  2009. protected String recPayAccount() {
  2010. return "payeracctbank";
  2011. }
  2012. private void settleOrg(boolean isOrg) {
  2013. if (!this.isLockSettleOrg()) {
  2014. DynamicObject paymenttype = (DynamicObject)this.getModel().getValue("paymenttype");
  2015. if (null != paymenttype && paymenttype.getBoolean("ispartpayment")) {
  2016. Object openOrg = this.getModel().getValue("openorg");
  2017. if (openOrg != null) {
  2018. DynamicObject accountOrg = (DynamicObject)openOrg;
  2019. for(int i = 0; i < this.getModel().getEntryRowCount("entry"); ++i) {
  2020. if (isOrg || CasHelper.isEmpty(this.getModel().getValue("settleorg", i))) {
  2021. this.setValue("settleorg", accountOrg.getPkValue(), i);
  2022. }
  2023. }
  2024. }
  2025. }
  2026. }
  2027. }
  2028. private boolean isHwControl() {
  2029. return this.getPageCache().getAll().containsKey("isHwControl");
  2030. }
  2031. private void setRecInfo(String key, Object value, Boolean isCheckDiff) {
  2032. if (isCheckDiff) {
  2033. Boolean isDiffCur = (Boolean)this.getModel().getValue("isdiffcur");
  2034. if (!isDiffCur) {
  2035. this.getModel().setValue(key, value);
  2036. }
  2037. } else {
  2038. this.getModel().setValue(key, value);
  2039. }
  2040. }
  2041. private void setDiffCurInfo() {
  2042. Boolean isDiffCur = (Boolean)this.getModel().getValue("isdiffcur");
  2043. if (!isDiffCur) {
  2044. this.setValueIfAbsent("dpcurrency", this.getModel().getValue("currency"));
  2045. this.setValueIfAbsent("dpamt", this.getModel().getValue("actpayamt"));
  2046. if (!FeePayerEnum.REC.getValue().equals(this.getString("feepayer"))) {
  2047. this.setValueIfAbsent("feeactbank", this.getModel().getValue("payeracctbank"));
  2048. this.setValueIfAbsent("feecurrency", this.getModel().getValue("currency"));
  2049. }
  2050. }
  2051. }
  2052. private void setExratetableVisibility() {
  2053. Long currencyId = this.getPk("currency");
  2054. Long dpCurrencyId = this.getPk("dpcurrency");
  2055. Long basecurrencyId = this.getPk("basecurrency");
  2056. if ((currencyId == null || currencyId.equals(basecurrencyId)) && (dpCurrencyId == null || dpCurrencyId.equals(basecurrencyId))) {
  2057. this.getView().setVisible(false, new String[]{"exratetable"});
  2058. this.getView().setVisible(false, new String[]{"exratedate"});
  2059. } else {
  2060. this.getView().setVisible(true, new String[]{"exratetable"});
  2061. this.getView().setVisible(true, new String[]{"exratedate"});
  2062. }
  2063. }
  2064. private void setSettleTypeValue(DynamicObject payerAcctBank) {
  2065. if (payerAcctBank != null) {
  2066. DynamicObjectCollection settlementypes = payerAcctBank.getDynamicObjectCollection("settlementtype");
  2067. if (settlementypes != null && settlementypes.size() > 0) {
  2068. Set<Long> idSet = new HashSet();
  2069. Iterator var4 = settlementypes.iterator();
  2070. DynamicObject settletype;
  2071. while(var4.hasNext()) {
  2072. settletype = (DynamicObject)var4.next();
  2073. idSet.add(((DynamicObject)settletype.get("fbasedataid")).getLong("id"));
  2074. }
  2075. DynamicObject settleType = this.getDynamicObject("settletype");
  2076. if (idSet.size() == 1) {
  2077. settletype = BusinessDataServiceHelper.loadSingleFromCache(idSet.iterator().next(), "bd_settlementtype", "id,settlementtype");
  2078. if (!BaseDataHelper.isSettleTypeCash(settletype)) {
  2079. this.setValue("settletype", idSet.iterator().next());
  2080. }
  2081. } else if (settleType != null && !idSet.contains((Long)settleType.getPkValue())) {
  2082. this.setValue("settletype", (Object)null);
  2083. }
  2084. }
  2085. }
  2086. }
  2087. private void setCrossPayValue() {
  2088. this.getView().setEnable(true, new String[]{"iscrosspay"});
  2089. DynamicObject payCountry = this.getDynamicObject("paycountry");
  2090. DynamicObject recCountry = this.getDynamicObject("reccountry");
  2091. if ((payCountry == null || CountryHelper.isChina(payCountry)) && (recCountry == null || CountryHelper.isChina(recCountry))) {
  2092. this.setValue("iscrosspay", Boolean.FALSE);
  2093. } else {
  2094. this.setValue("iscrosspay", Boolean.TRUE);
  2095. }
  2096. }
  2097. private void isDiffCurVisibility() {
  2098. DynamicObject settleType = this.getDynamicObject("settletype");
  2099. if (CasHelper.isNotEmpty(settleType) && BaseDataHelper.isSettleTypeCash(settleType)) {
  2100. this.setValue("isdiffcur", "0");
  2101. this.getView().setVisible(false, new String[]{"isdiffcur"});
  2102. } else {
  2103. this.getView().setVisible(true, new String[]{"isdiffcur"});
  2104. }
  2105. }
  2106. private void setCountryValue() {
  2107. DynamicObject payerBank = this.getDynamicObject("payerbank");
  2108. if (payerBank != null) {
  2109. this.setValueIfAbsent("paycountry", payerBank.getDynamicObject("country"));
  2110. this.setCrossPayValue();
  2111. }
  2112. }
  2113. private void pay(BeforeDoOperationEventArgs evt) {
  2114. long orgId = (Long)this.getDynamicObject("org").getPkValue();
  2115. Set<String> cs1046 = SystemParameterHelper.getParameterComboxs(orgId, "cs1046");
  2116. DynamicObject payBill = this.getModel().getDataEntity();
  2117. (new PaymentPayImpl()).validate(payBill);
  2118. if (PaymentBillPluginHelper.isShowPayConfirm(payBill, cs1046)) {
  2119. FormShowParameter para = new FormShowParameter();
  2120. para.setFormId("cas_paybill_diffpay");
  2121. para.setCloseCallBack(new CloseCallBack(this, "KEY_DIFFPAY_CALLBACK"));
  2122. para.getOpenStyle().setShowType(ShowType.Modal);
  2123. DataEntityPropertyCollection properties = EntityMetadataCache.getDataEntityType("cas_paybill_diffpay").getProperties();
  2124. Map<String, Object> customParams = new HashMap(properties.size());
  2125. Iterator var9 = properties.iterator();
  2126. while(var9.hasNext()) {
  2127. IDataEntityProperty property = (IDataEntityProperty)var9.next();
  2128. String propName = property.getName();
  2129. if (this.getModel().getProperty(propName) != null) {
  2130. Object value = this.getValue(propName);
  2131. if (value instanceof DynamicObject) {
  2132. customParams.put(propName, ((DynamicObject)value).getPkValue());
  2133. } else {
  2134. customParams.put(propName, value);
  2135. }
  2136. }
  2137. }
  2138. para.setCustomParams(customParams);
  2139. para.setCustomParam("payamount", payBill.getBigDecimal("actpayamt"));
  2140. para.setCustomParam("payamt", payBill.getBigDecimal("dpamt"));
  2141. para.setCustomParam("matchFlag", payBill.getString("matchflag"));
  2142. para.setCustomParam("sourcebilltype", payBill.getString("sourcebilltype"));
  2143. para.setCustomParam("payBillId", payBill.getString("id"));
  2144. this.getView().showForm(para);
  2145. evt.setCancel(true);
  2146. }
  2147. }
  2148. private void setPaymentType(QFilter[] qFilters) {
  2149. DynamicObject paymentType = BusinessDataServiceHelper.loadSingleFromCache("cas_paymentbilltype", "id,fundflowitem", qFilters);
  2150. if (paymentType != null) {
  2151. this.setValue("paymenttype", paymentType.getLong("id"));
  2152. DynamicObject fundflowitem = paymentType.getDynamicObject("fundflowitem");
  2153. this.fillFundflowItem(true, fundflowitem);
  2154. } else {
  2155. this.setValue("paymenttype", (Object)null);
  2156. }
  2157. }
  2158. private void viewReceipt() {
  2159. Long billId = (Long)this.getModel().getDataEntity().getPkValue();
  2160. if (billId == 0L) {
  2161. this.getView().showTipNotification(ResManager.loadKDString("暂无对应的电子回单记录!", "ViewReceiptService_0", "fi-cas-business", new Object[0]));
  2162. } else {
  2163. ViewReceiptService viewService = new ViewReceiptService();
  2164. viewService.viewReceipt(this.getView(), "nckd_cas_arbill", billId);
  2165. }
  2166. }
  2167. private void viewSettle() {
  2168. Long billId = (Long)this.getModel().getDataEntity().getPkValue();
  2169. if (billId == 0L) {
  2170. this.getView().showTipNotification(ResManager.loadKDString("暂无结算记录。", "PaymentBillList_5", "fi-cas-formplugin", new Object[0]));
  2171. } else {
  2172. List<Long> mainSettleIds = SettleRecordQueryHelperForCas.getSettleIdsByMain("ap_settlerecord", "nckd_cas_arbill", new Object[]{billId});
  2173. List<Long> asstSettleIds = SettleRecordQueryHelperForCas.getSettleIdsByAsst("ap_settlerecord", "nckd_cas_arbill", new Object[]{billId});
  2174. Set<Long> settleRecordIds = new HashSet();
  2175. settleRecordIds.addAll(mainSettleIds);
  2176. settleRecordIds.addAll(asstSettleIds);
  2177. if (settleRecordIds.size() > 0) {
  2178. ListShowParameter parameter = new ListShowParameter();
  2179. parameter.setBillFormId("ap_settlerecord");
  2180. parameter.getOpenStyle().setShowType(ShowType.MainNewTabPage);
  2181. ListFilterParameter param = new ListFilterParameter();
  2182. param.setFilter(new QFilter("id", "in", settleRecordIds));
  2183. parameter.setListFilterParameter(param);
  2184. parameter.setCustomParam("checkKey", true);
  2185. this.getView().showForm(parameter);
  2186. } else {
  2187. this.getView().showTipNotification(ResManager.loadKDString("暂无结算记录。", "PaymentBillList_5", "fi-cas-formplugin", new Object[0]));
  2188. }
  2189. }
  2190. }
  2191. public void afterAddRow(AfterAddRowEventArgs e) {
  2192. super.afterAddRow(e);
  2193. EntryProp entryProp = e.getEntryProp();
  2194. String entryName = entryProp.getName();
  2195. if ("entry".equals(entryName)) {
  2196. RowDataEntity[] rows = e.getRowDataEntities();
  2197. if (rows.length > 0) {
  2198. RowDataEntity[] var5 = rows;
  2199. int var6 = rows.length;
  2200. for(int var7 = 0; var7 < var6; ++var7) {
  2201. RowDataEntity row = var5[var7];
  2202. this.getModel().setValue("e_sourcebillid", this.getValue("sourcebillid"), row.getRowIndex());
  2203. this.getModel().setValue("e_sourcebillentryid", this.getValue("sourceentryid"), row.getRowIndex());
  2204. }
  2205. }
  2206. }
  2207. }
  2208. private void isOnlinebankVisibility() {
  2209. String paymentchannel = (String)this.getValue("paymentchannel");
  2210. if (paymentchannel != null && this.isAcctBankExistOnlineBankAcct()) {
  2211. this.getView().setVisible(true, new String[]{"netbankacct"});
  2212. } else {
  2213. this.getView().setVisible(false, new String[]{"netbankacct"});
  2214. }
  2215. }
  2216. private Boolean cancelPayCheckSettle(DynamicObject payObj) {
  2217. Boolean result = Boolean.FALSE;
  2218. boolean exists = SettleRecordQueryHelperForCas.isExistsSettlesByMain("ap_settlerecord", "nckd_cas_arbill", new Object[]{payObj.getPkValue()}, (QFilter)null);
  2219. boolean exists2 = SettleRecordQueryHelperForCas.isExistsSettlesByAsst("ap_settlerecord", "nckd_cas_arbill", new Object[]{payObj.getPkValue()}, (QFilter)null);
  2220. if (exists || exists2) {
  2221. StringBuilder settleSb = new StringBuilder();
  2222. String billno = payObj.getString("billno");
  2223. settleSb.append(String.format(ResManager.loadKDString("(%s)单据已经完成结算", "PaymentBillList_28", "fi-cas-formplugin", new Object[0]), billno));
  2224. 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));
  2225. result = Boolean.TRUE;
  2226. }
  2227. return result;
  2228. }
  2229. public String getPayeeOrPayerInfoNumber(Object payeeOrPayer, Object payeeOrPayerType, String billName) {
  2230. String payeenumber = "";
  2231. String entityNameTemp = "";
  2232. String addressPropName = "";
  2233. if (isSupplier(payeeOrPayerType)) {
  2234. entityNameTemp = AsstActTypeEnum.SUPPLIER.getValue();
  2235. addressPropName = "supplieraddress";
  2236. }
  2237. if (isCustomer(payeeOrPayerType)) {
  2238. entityNameTemp = AsstActTypeEnum.CUSTOMER.getValue();
  2239. addressPropName = "customeraddress";
  2240. }
  2241. if (!CasHelper.isEmpty(entityNameTemp) && !CasHelper.isEmpty(payeeOrPayer)) {
  2242. DynamicObject supplierCustDO = BusinessDataServiceHelper.loadSingleFromCache(payeeOrPayer, entityNameTemp, "number,entry_bank.isdefault_bank,entry_bank.bankaccount,entry_bank.bank,entry_bank.accountname,entry_address." + addressPropName);
  2243. if (!CasHelper.isEmpty(supplierCustDO)) {
  2244. payeenumber = supplierCustDO.getString("number");
  2245. }
  2246. }
  2247. return payeenumber;
  2248. }
  2249. public String getUserOrOrgNumber(Object id, Object type) {
  2250. String entityNameTemp = "";
  2251. String payeenumber = "";
  2252. if (isUser(type)) {
  2253. entityNameTemp = AsstActTypeEnum.EMPLOYEE.getValue();
  2254. }
  2255. if (isOrg(type)) {
  2256. entityNameTemp = AsstActTypeEnum.COMPANY.getValue();
  2257. }
  2258. if (!CasHelper.isEmpty(entityNameTemp) && !CasHelper.isEmpty(id)) {
  2259. DynamicObject userOrgDO = BusinessDataServiceHelper.loadSingleFromCache(id, entityNameTemp, "number");
  2260. if (!CasHelper.isEmpty(userOrgDO)) {
  2261. payeenumber = userOrgDO.getString("number");
  2262. }
  2263. }
  2264. return payeenumber;
  2265. }
  2266. private void fillFundflowItem(boolean isCover, DynamicObject defaultFundsItem) {
  2267. if (defaultFundsItem != null) {
  2268. for(int i = 0; i < this.getModel().getEntryRowCount("entry"); ++i) {
  2269. if (isCover) {
  2270. this.setValue("e_fundflowitem", defaultFundsItem.getPkValue(), i);
  2271. } else {
  2272. this.setValueIfAbsent("e_fundflowitem", defaultFundsItem.getPkValue(), i);
  2273. }
  2274. }
  2275. }
  2276. }
  2277. private static boolean isSupplier(Object payeeType) {
  2278. return isAimType(AsstActTypeEnum.SUPPLIER, payeeType);
  2279. }
  2280. private static boolean isCustomer(Object payeeType) {
  2281. return isAimType(AsstActTypeEnum.CUSTOMER, payeeType);
  2282. }
  2283. private static boolean isUser(Object payeeType) {
  2284. return isAimType(AsstActTypeEnum.EMPLOYEE, payeeType);
  2285. }
  2286. private static boolean isOrg(Object payeeType) {
  2287. return isAimType(AsstActTypeEnum.COMPANY, payeeType);
  2288. }
  2289. private static boolean isOther(Object payeeType) {
  2290. return isAimType(AsstActTypeEnum.OTHER, payeeType);
  2291. }
  2292. private static boolean isAimType(AsstActTypeEnum asstactType, Object payeeType) {
  2293. return asstactType.getValue().equals(payeeType);
  2294. }
  2295. private boolean isLockSettleOrg() {
  2296. String sourceBillType = this.getString("sourcebilltype");
  2297. return "ap_finapbill".equals(sourceBillType) || "ar_finarbill".equals(sourceBillType) || "ap_payapply".equals(sourceBillType) || "pm_purorderbill".equals(sourceBillType);
  2298. }
  2299. private boolean isClearFeeSettleType() {
  2300. DynamicObject settleType = (DynamicObject)this.getModel().getValue("settletype");
  2301. if (settleType == null) {
  2302. return true;
  2303. } else {
  2304. String settlementType = settleType.getString("settlementtype");
  2305. return Objects.equals(settlementType, SettleMentTypeEnum.BANK.getValue()) || Objects.equals(settlementType, SettleMentTypeEnum.BUSINESS.getValue()) || Objects.equals(settlementType, SettleMentTypeEnum.CHECK.getValue());
  2306. }
  2307. }
  2308. private boolean hasPayeeInfo() {
  2309. String payeeformid = this.getString("payeetype");
  2310. Long payeeId = Long.parseLong(this.getValue("payee") == null ? "0" : this.getValue("payee").toString());
  2311. String payeeType = this.getString("payeetype");
  2312. if (isOther(payeeType)) {
  2313. return kd.bos.dataentity.utils.StringUtils.isNotBlank(this.getValue("payeename"));
  2314. } else {
  2315. return CasHelper.isNotEmpty(payeeformid) && CasHelper.isNotEmpty(payeeId);
  2316. }
  2317. }
  2318. public void signCallback(SignCallbackEvent evt) {
  2319. if (evt.getCallbackId().equals("signbeforecommitbe")) {
  2320. ClientMethodResult ret = evt.getResult();
  2321. if (ret.getSuccess()) {
  2322. OperateOption operateOption = OperateOption.create();
  2323. operateOption.setVariableValue("ishasright", "true");
  2324. operateOption.setVariableValue("signCallbackFlag", "true");
  2325. operateOption.setVariableValue("signFirstSave", "false");
  2326. operateOption.setVariableValue("signResult", SerializationUtils.toJsonString(evt.getResult().getResult()));
  2327. operateOption.setVariableValue("clearResult", evt.getClearText());
  2328. OperationResult operationResult = this.getView().invokeOperation("beforecommitbe", operateOption);
  2329. if (operationResult.isSuccess()) {
  2330. this.getView().invokeOperation("commitbe");
  2331. } else {
  2332. logger.info(" signcallback fail ");
  2333. if (EmptyUtil.isNoEmpty(operationResult.getMessage())) {
  2334. evt.getView().showTipNotification(operationResult.getMessage());
  2335. }
  2336. }
  2337. } else {
  2338. logger.info(" signbeforecommitbe SignCallbackEvent fail ");
  2339. }
  2340. }
  2341. }
  2342. }