001// -------------------------------------------------------------------------------- 002// Copyright 2002-2026 Echo Three, LLC 003// 004// Licensed under the Apache License, Version 2.0 (the "License"); 005// you may not use this file except in compliance with the License. 006// You may obtain a copy of the License at 007// 008// http://www.apache.org/licenses/LICENSE-2.0 009// 010// Unless required by applicable law or agreed to in writing, software 011// distributed under the License is distributed on an "AS IS" BASIS, 012// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013// See the License for the specific language governing permissions and 014// limitations under the License. 015// -------------------------------------------------------------------------------- 016 017package com.echothree.control.user.party.server.command; 018 019import com.echothree.control.user.party.common.form.CreateCustomerWithLoginForm; 020import com.echothree.control.user.party.common.result.PartyResultFactory; 021import com.echothree.model.control.accounting.common.AccountingConstants; 022import com.echothree.model.control.accounting.server.control.AccountingControl; 023import com.echothree.model.control.cancellationpolicy.common.CancellationKinds; 024import com.echothree.model.control.cancellationpolicy.server.control.CancellationPolicyControl; 025import com.echothree.model.control.contact.common.ContactMechanismPurposes; 026import com.echothree.model.control.contact.server.logic.ContactEmailAddressLogic; 027import com.echothree.model.control.contactlist.server.logic.ContactListLogic; 028import com.echothree.model.control.core.server.control.EntityInstanceControl; 029import com.echothree.model.control.customer.common.workflow.CustomerCreditStatusConstants; 030import com.echothree.model.control.customer.common.workflow.CustomerStatusConstants; 031import com.echothree.model.control.customer.server.control.CustomerControl; 032import com.echothree.model.control.offer.server.control.OfferControl; 033import com.echothree.model.control.offer.server.control.OfferUseControl; 034import com.echothree.model.control.offer.server.control.SourceControl; 035import com.echothree.model.control.offer.server.control.UseControl; 036import com.echothree.model.control.party.common.PartyTypes; 037import com.echothree.model.control.party.server.control.PartyControl; 038import com.echothree.model.control.party.server.logic.PartyChainLogic; 039import com.echothree.model.control.party.server.logic.PasswordStringPolicyLogic; 040import com.echothree.model.control.returnpolicy.common.ReturnKinds; 041import com.echothree.model.control.returnpolicy.server.control.ReturnPolicyControl; 042import com.echothree.model.control.term.server.control.TermControl; 043import com.echothree.model.control.user.common.UserConstants; 044import com.echothree.model.control.workflow.server.control.WorkflowControl; 045import com.echothree.model.data.accounting.server.entity.Currency; 046import com.echothree.model.data.cancellationpolicy.server.entity.CancellationPolicy; 047import com.echothree.model.data.customer.server.entity.Customer; 048import com.echothree.model.data.offer.server.entity.OfferUse; 049import com.echothree.model.data.returnpolicy.server.entity.ReturnPolicy; 050import com.echothree.util.common.command.BaseResult; 051import com.echothree.util.common.form.ValidationResult; 052import com.echothree.util.common.message.ExecutionErrors; 053import com.echothree.util.common.persistence.BasePK; 054import com.echothree.util.common.validation.FieldDefinition; 055import com.echothree.util.common.validation.FieldType; 056import com.echothree.util.server.control.BaseSimpleCommand; 057import com.echothree.util.server.persistence.EntityPermission; 058import com.echothree.util.server.persistence.Session; 059import com.echothree.util.server.validation.Validator; 060import java.util.List; 061import org.apache.commons.codec.language.Soundex; 062import javax.enterprise.context.Dependent; 063 064@Dependent 065public class CreateCustomerWithLoginCommand 066 extends BaseSimpleCommand<CreateCustomerWithLoginForm> { 067 068 // No COMMAND_SECURITY_DEFINITION, anyone may execute this command. 069 private final static List<FieldDefinition> customerFormFieldDefinitions; 070 private final static List<FieldDefinition> otherFormFieldDefinitions; 071 072 static { 073 // customerFormFieldDefinitions differs from otherFormFieldDefinitions in that when the PartyType 074 // executing this command is null, or equal to CUSTOMER, FirstName and LastName are required fields. 075 // For all other PartyTypes, that requirement is relaxed. 076 customerFormFieldDefinitions = List.of( 077 new FieldDefinition("CustomerTypeName", FieldType.ENTITY_NAME, false, null, null), 078 new FieldDefinition("CancellationPolicyName", FieldType.ENTITY_NAME, false, null, null), 079 new FieldDefinition("ReturnPolicyName", FieldType.ENTITY_NAME, false, null, null), 080 new FieldDefinition("ArGlAccountName", FieldType.ENTITY_NAME, false, null, null), 081 new FieldDefinition("InitialOfferName", FieldType.ENTITY_NAME, false, null, null), 082 new FieldDefinition("InitialUseName", FieldType.ENTITY_NAME, false, null, null), 083 new FieldDefinition("InitialSourceName", FieldType.ENTITY_NAME, false, null, null), 084 new FieldDefinition("PersonalTitleId", FieldType.ID, false, null, null), 085 new FieldDefinition("FirstName", FieldType.STRING, true, 1L, 20L), 086 new FieldDefinition("MiddleName", FieldType.STRING, false, 1L, 20L), 087 new FieldDefinition("LastName", FieldType.STRING, true, 1L, 20L), 088 new FieldDefinition("NameSuffixId", FieldType.ID, false, null, null), 089 new FieldDefinition("Name", FieldType.STRING, false, 1L, 60L), 090 new FieldDefinition("PreferredLanguageIsoName", FieldType.ENTITY_NAME, false, null, null), 091 new FieldDefinition("PreferredCurrencyIsoName", FieldType.ENTITY_NAME, false, null, null), 092 new FieldDefinition("PreferredJavaTimeZoneName", FieldType.TIME_ZONE_NAME, false, null, null), 093 new FieldDefinition("PreferredDateTimeFormatName", FieldType.ENTITY_NAME, false, null, null), 094 new FieldDefinition("EmailAddress", FieldType.EMAIL_ADDRESS, true, null, null), 095 new FieldDefinition("AllowSolicitation", FieldType.BOOLEAN, true, null, null), 096 new FieldDefinition("Username", FieldType.STRING, true, 1L, 80L), 097 new FieldDefinition("Password1", FieldType.STRING, true, 1L, 40L), 098 new FieldDefinition("Password2", FieldType.STRING, true, 1L, 40L), 099 new FieldDefinition("RecoveryQuestionName", FieldType.ENTITY_NAME, true, null, null), 100 new FieldDefinition("Answer", FieldType.STRING, true, 1L, 40L), 101 new FieldDefinition("CustomerStatusChoice", FieldType.ENTITY_NAME, false, null, null), 102 new FieldDefinition("CustomerCreditStatusChoice", FieldType.ENTITY_NAME, false, null, null) 103 ); 104 105 otherFormFieldDefinitions = List.of( 106 new FieldDefinition("CustomerTypeName", FieldType.ENTITY_NAME, false, null, null), 107 new FieldDefinition("CancellationPolicyName", FieldType.ENTITY_NAME, false, null, null), 108 new FieldDefinition("ReturnPolicyName", FieldType.ENTITY_NAME, false, null, null), 109 new FieldDefinition("ArGlAccountName", FieldType.ENTITY_NAME, false, null, null), 110 new FieldDefinition("InitialOfferName", FieldType.ENTITY_NAME, false, null, null), 111 new FieldDefinition("InitialUseName", FieldType.ENTITY_NAME, false, null, null), 112 new FieldDefinition("InitialSourceName", FieldType.ENTITY_NAME, false, null, null), 113 new FieldDefinition("PersonalTitleId", FieldType.ID, false, null, null), 114 new FieldDefinition("FirstName", FieldType.STRING, false, 1L, 20L), 115 new FieldDefinition("MiddleName", FieldType.STRING, false, 1L, 20L), 116 new FieldDefinition("LastName", FieldType.STRING, false, 1L, 20L), 117 new FieldDefinition("NameSuffixId", FieldType.ID, false, null, null), 118 new FieldDefinition("Name", FieldType.STRING, false, 1L, 60L), 119 new FieldDefinition("PreferredLanguageIsoName", FieldType.ENTITY_NAME, false, null, null), 120 new FieldDefinition("PreferredCurrencyIsoName", FieldType.ENTITY_NAME, false, null, null), 121 new FieldDefinition("PreferredJavaTimeZoneName", FieldType.TIME_ZONE_NAME, false, null, null), 122 new FieldDefinition("PreferredDateTimeFormatName", FieldType.ENTITY_NAME, false, null, null), 123 new FieldDefinition("EmailAddress", FieldType.EMAIL_ADDRESS, true, null, null), 124 new FieldDefinition("AllowSolicitation", FieldType.BOOLEAN, true, null, null), 125 new FieldDefinition("Username", FieldType.STRING, true, 1L, 80L), 126 new FieldDefinition("Password1", FieldType.STRING, true, 1L, 40L), 127 new FieldDefinition("Password2", FieldType.STRING, true, 1L, 40L), 128 new FieldDefinition("RecoveryQuestionName", FieldType.ENTITY_NAME, true, null, null), 129 new FieldDefinition("Answer", FieldType.STRING, true, 1L, 40L), 130 new FieldDefinition("CustomerStatusChoice", FieldType.ENTITY_NAME, false, null, null), 131 new FieldDefinition("CustomerCreditStatusChoice", FieldType.ENTITY_NAME, false, null, null) 132 ); 133 } 134 135 /** Creates a new instance of CreateCustomerWithLoginCommand */ 136 public CreateCustomerWithLoginCommand() { 137 super(null, null, false); 138 } 139 140 @Override 141 protected ValidationResult validate() { 142 var partyTypeName = getPartyTypeName(); 143 var FORM_FIELD_DEFINITIONS = partyTypeName == null || partyTypeName.equals(PartyTypes.CUSTOMER.name())? customerFormFieldDefinitions: otherFormFieldDefinitions; 144 var validator = new Validator(this); 145 var validationResult = validator.validate(form, FORM_FIELD_DEFINITIONS); 146 147 return validationResult; 148 } 149 150 @Override 151 protected BaseResult execute() { 152 var userControl = getUserControl(); 153 var result = PartyResultFactory.getCreateCustomerWithLoginResult(); 154 var customerControl = Session.getModelController(CustomerControl.class); 155 Customer customer = null; 156 var username = form.getUsername(); 157 var userLogin = userControl.getUserLoginByUsername(username); 158 159 if(userLogin == null) { 160 var password1 = form.getPassword1(); 161 var password2 = form.getPassword2(); 162 163 if(password1.equals(password2)) { 164 var partyControl = Session.getModelController(PartyControl.class); 165 var partyType = partyControl.getPartyTypeByName(PartyTypes.CUSTOMER.name()); 166 var partyTypePasswordStringPolicy = PasswordStringPolicyLogic.getInstance().checkStringPassword(session, 167 getUserVisit(), this, partyType, null, null, password1); 168 169 if(!hasExecutionErrors()) { 170 var customerTypeName = form.getCustomerTypeName(); 171 var customerType = customerTypeName == null ? customerControl.getDefaultCustomerType() : customerControl.getCustomerTypeByName(customerTypeName); 172 173 if(customerType != null) { 174 var cancellationPolicyName = form.getCancellationPolicyName(); 175 CancellationPolicy cancellationPolicy = null; 176 177 if(cancellationPolicyName != null) { 178 var cancellationPolicyControl = Session.getModelController(CancellationPolicyControl.class); 179 var returnKind = cancellationPolicyControl.getCancellationKindByName(CancellationKinds.CUSTOMER_CANCELLATION.name()); 180 181 cancellationPolicy = cancellationPolicyControl.getCancellationPolicyByName(returnKind, cancellationPolicyName); 182 } 183 184 if(cancellationPolicyName == null || cancellationPolicy != null) { 185 var returnPolicyName = form.getReturnPolicyName(); 186 ReturnPolicy returnPolicy = null; 187 188 if(returnPolicyName != null) { 189 var returnPolicyControl = Session.getModelController(ReturnPolicyControl.class); 190 var returnKind = returnPolicyControl.getReturnKindByName(ReturnKinds.CUSTOMER_RETURN.name()); 191 192 returnPolicy = returnPolicyControl.getReturnPolicyByName(returnKind, returnPolicyName); 193 } 194 195 if(returnPolicyName == null || returnPolicy != null) { 196 var accountingControl = Session.getModelController(AccountingControl.class); 197 var arGlAccountName = form.getArGlAccountName(); 198 var arGlAccount = arGlAccountName == null ? null : accountingControl.getGlAccountByName(arGlAccountName); 199 200 if(arGlAccountName == null || arGlAccount != null) { 201 var glAccountCategoryName = arGlAccount == null ? null 202 : arGlAccount.getLastDetail().getGlAccountCategory().getLastDetail().getGlAccountCategoryName(); 203 204 if(glAccountCategoryName == null || glAccountCategoryName.equals(AccountingConstants.GlAccountCategory_ACCOUNTS_RECEIVABLE)) { 205 var termControl = Session.getModelController(TermControl.class); 206 var customerTypeDetail = customerType.getLastDetail(); 207 var term = customerTypeDetail.getDefaultTerm(); 208 209 if(term == null) { 210 term = termControl.getDefaultTerm(); 211 } 212 213 if(term != null) { 214 var initialOfferName = form.getInitialOfferName(); 215 var initialUseName = form.getInitialUseName(); 216 var initialSourceName = form.getInitialSourceName(); 217 OfferUse initialOfferUse = null; 218 var invalidInitialOfferOrSourceSpecification = false; 219 220 if(initialOfferName != null && initialUseName != null && initialSourceName == null) { 221 var offerControl = Session.getModelController(OfferControl.class); 222 var initialOffer = offerControl.getOfferByName(initialOfferName); 223 224 if(initialOffer != null) { 225 var useControl = Session.getModelController(UseControl.class); 226 var initialUse = useControl.getUseByName(initialUseName); 227 228 if(initialUse != null) { 229 var offerUseControl = Session.getModelController(OfferUseControl.class); 230 initialOfferUse = offerUseControl.getOfferUse(initialOffer, initialUse); 231 232 if(initialOfferUse == null) { 233 addExecutionError(ExecutionErrors.UnknownInitialOfferUse.name()); 234 } 235 } else { 236 addExecutionError(ExecutionErrors.UnknownInitialUseName.name(), initialUseName); 237 } 238 } else { 239 addExecutionError(ExecutionErrors.UnknownInitialOfferName.name(), initialOfferName); 240 } 241 } else { 242 var sourceControl = Session.getModelController(SourceControl.class); 243 244 if(initialOfferName == null && initialUseName == null && initialSourceName != null) { 245 var source = sourceControl.getSourceByName(initialSourceName); 246 247 if(source != null) { 248 initialOfferUse = source.getLastDetail().getOfferUse(); 249 } else { 250 addExecutionError(ExecutionErrors.UnknownInitialSourceName.name(), initialSourceName); 251 } 252 } else { 253 initialOfferUse = getUserVisit().getOfferUse(); 254 255 if(initialOfferUse == null) { 256 // If all three parameters are null, then try to get the default Source and use its OfferUse. 257 var source = sourceControl.getDefaultSource(); 258 259 if(source != null) { 260 initialOfferUse = source.getLastDetail().getOfferUse(); 261 } else { 262 addExecutionError(ExecutionErrors.InvalidInitialOfferOrSourceSpecification.name()); 263 invalidInitialOfferOrSourceSpecification = true; 264 } 265 } 266 } 267 } 268 269 if(initialOfferUse != null) { 270 var preferredLanguageIsoName = form.getPreferredLanguageIsoName(); 271 var preferredLanguage = preferredLanguageIsoName == null ? null : partyControl.getLanguageByIsoName(preferredLanguageIsoName); 272 273 if(preferredLanguageIsoName == null || (preferredLanguage != null)) { 274 var preferredJavaTimeZoneName = form.getPreferredJavaTimeZoneName(); 275 var preferredTimeZone = preferredJavaTimeZoneName == null ? null : partyControl.getTimeZoneByJavaName(preferredJavaTimeZoneName); 276 277 if(preferredJavaTimeZoneName == null || (preferredTimeZone != null)) { 278 var preferredDateTimeFormatName = form.getPreferredDateTimeFormatName(); 279 var preferredDateTimeFormat = preferredDateTimeFormatName == null ? null 280 : partyControl.getDateTimeFormatByName(preferredDateTimeFormatName); 281 282 if(preferredDateTimeFormatName == null || (preferredDateTimeFormat != null)) { 283 var preferredCurrencyIsoName = form.getPreferredCurrencyIsoName(); 284 Currency preferredCurrency; 285 286 if(preferredCurrencyIsoName == null) { 287 preferredCurrency = null; 288 } else { 289 preferredCurrency = accountingControl.getCurrencyByIsoName(preferredCurrencyIsoName); 290 } 291 292 if(preferredCurrencyIsoName == null || (preferredCurrency != null)) { 293 var recoveryQuestionName = form.getRecoveryQuestionName(); 294 var recoveryQuestion = userControl.getRecoveryQuestionByName(recoveryQuestionName); 295 296 if(recoveryQuestion != null) { 297 var workflowControl = Session.getModelController(WorkflowControl.class); 298 var soundex = new Soundex(); 299 BasePK createdBy = getPartyPK(); 300 var personalTitleId = form.getPersonalTitleId(); 301 var personalTitle = personalTitleId == null ? null 302 : partyControl.convertPersonalTitleIdToEntity(personalTitleId, EntityPermission.READ_ONLY); 303 var firstName = form.getFirstName(); 304 var middleName = form.getMiddleName(); 305 var lastName = form.getLastName(); 306 var nameSuffixId = form.getNameSuffixId(); 307 var nameSuffix = nameSuffixId == null ? null 308 : partyControl.convertNameSuffixIdToEntity(nameSuffixId, EntityPermission.READ_ONLY); 309 var name = form.getName(); 310 var emailAddress = form.getEmailAddress(); 311 var allowSolicitation = Boolean.valueOf(form.getAllowSolicitation()); 312 313 String firstNameSdx; 314 try { 315 firstNameSdx = firstName == null ? null : soundex.encode(firstName); 316 } catch(IllegalArgumentException iae) { 317 firstNameSdx = null; 318 } 319 320 String middleNameSdx; 321 try { 322 middleNameSdx = middleName == null ? null : soundex.encode(middleName); 323 } catch(IllegalArgumentException iae) { 324 middleNameSdx = null; 325 } 326 327 String lastNameSdx; 328 try { 329 lastNameSdx = lastName == null ? null : soundex.encode(lastName); 330 } catch(IllegalArgumentException iae) { 331 lastNameSdx = null; 332 } 333 334 var party = partyControl.createParty(null, partyType, preferredLanguage, preferredCurrency, preferredTimeZone, preferredDateTimeFormat, 335 createdBy); 336 337 if(createdBy == null) { 338 createdBy = party.getPrimaryKey(); 339 } 340 if(personalTitle != null || firstName != null || middleName != null || lastName != null || nameSuffix != null) { 341 partyControl.createPerson(party, personalTitle, firstName, firstNameSdx, middleName, 342 middleNameSdx, lastName, lastNameSdx, nameSuffix, createdBy); 343 } 344 345 if(name != null) { 346 partyControl.createPartyGroup(party, name, createdBy); 347 } 348 349 customer = customerControl.createCustomer(party, customerType, initialOfferUse, cancellationPolicy, returnPolicy, arGlAccount, 350 customerTypeDetail.getDefaultHoldUntilComplete(), customerTypeDetail.getDefaultAllowBackorders(), 351 customerTypeDetail.getDefaultAllowSubstitutions(), customerTypeDetail.getDefaultAllowCombiningShipments(), 352 customerTypeDetail.getDefaultRequireReference(), customerTypeDetail.getDefaultAllowReferenceDuplicates(), 353 customerTypeDetail.getDefaultReferenceValidationPattern(), createdBy); 354 userControl.createUserLogin(party, username, createdBy); 355 356 ContactEmailAddressLogic.getInstance().createContactEmailAddress(party, 357 emailAddress, allowSolicitation, null, 358 ContactMechanismPurposes.PRIMARY_EMAIL.name(), 359 createdBy); 360 361 termControl.createPartyTerm(party, term, customerTypeDetail.getDefaultTaxable(), createdBy); 362 363 for(var customerTypeCreditLimit : termControl.getCustomerTypeCreditLimitsByCustomerType(customerType)) { 364 var currency = customerTypeCreditLimit.getCurrency(); 365 var creditLimit = customerTypeCreditLimit.getCreditLimit(); 366 var potentialCreditLimit = customerTypeCreditLimit.getPotentialCreditLimit(); 367 368 termControl.createPartyCreditLimit(party, currency, creditLimit, potentialCreditLimit, createdBy); 369 } 370 371 var userLoginPasswordType = userControl.getUserLoginPasswordTypeByName(UserConstants.UserLoginPasswordType_STRING); 372 var userLoginPassword = userControl.createUserLoginPassword(party, userLoginPasswordType, createdBy); 373 userControl.createUserLoginPasswordString(userLoginPassword, password1, session.getStartTime(), false, createdBy); 374 375 if(partyTypePasswordStringPolicy != null && partyTypePasswordStringPolicy.getLastDetail().getForceChangeAfterCreate()) { 376 var userLoginStatus = userControl.getUserLoginStatusForUpdate(party); 377 378 userLoginStatus.setForceChange(true); 379 } 380 381 var answer = form.getAnswer(); 382 userControl.createRecoveryAnswer(party, recoveryQuestion, answer, createdBy); 383 384 // TODO: error checking for unknown customerStatusChoice 385 var customerStatusChoice = form.getCustomerStatusChoice(); 386 var customerStatusWorkflow = workflowControl.getWorkflowByName(CustomerStatusConstants.Workflow_CUSTOMER_STATUS); 387 var customerStatusWorkflowEntrance = customerStatusChoice == null ? customerTypeDetail.getDefaultCustomerStatus() 388 : workflowControl.getWorkflowEntranceByName(customerStatusWorkflow, customerStatusChoice); 389 390 if(customerStatusWorkflowEntrance == null) { 391 customerStatusWorkflowEntrance = workflowControl.getDefaultWorkflowEntrance(customerStatusWorkflow); 392 } 393 394 // TODO: error checking for unknown customerCreditStatusChoice 395 var customerCreditStatusChoice = form.getCustomerCreditStatusChoice(); 396 var customerCreditStatusWorkflow = workflowControl.getWorkflowByName(CustomerCreditStatusConstants.Workflow_CUSTOMER_CREDIT_STATUS); 397 var customerCreditStatusWorkflowEntrance = customerCreditStatusChoice == null 398 ? customerTypeDetail.getDefaultCustomerCreditStatus() 399 : workflowControl.getWorkflowEntranceByName(customerCreditStatusWorkflow, customerCreditStatusChoice); 400 401 if(customerCreditStatusWorkflowEntrance == null) { 402 customerCreditStatusWorkflowEntrance = workflowControl.getDefaultWorkflowEntrance(customerCreditStatusWorkflow); 403 } 404 405 var entityInstanceControl = Session.getModelController(EntityInstanceControl.class); 406 var entityInstance = entityInstanceControl.getEntityInstanceByBasePK(party.getPrimaryKey()); 407 workflowControl.addEntityToWorkflow(customerStatusWorkflowEntrance, entityInstance, null, null, createdBy); 408 workflowControl.addEntityToWorkflow(customerCreditStatusWorkflowEntrance, entityInstance, null, null, createdBy); 409 410 ContactListLogic.getInstance().setupInitialContactLists(this, party, createdBy); 411 412 // ExecutionErrorAccumulator is passed in as null so that an Exception will be thrown if there is an error. 413 PartyChainLogic.getInstance().createPartyWelcomeChainInstance(null, party, createdBy); 414 } else { 415 addExecutionError(ExecutionErrors.UnknownRecoveryQuestionName.name(), recoveryQuestionName); 416 } 417 } else { 418 addExecutionError(ExecutionErrors.UnknownCurrencyIsoName.name(), preferredCurrencyIsoName); 419 } 420 } else { 421 addExecutionError(ExecutionErrors.UnknownDateTimeFormatName.name(), preferredDateTimeFormatName); 422 } 423 } else { 424 addExecutionError(ExecutionErrors.UnknownJavaTimeZoneName.name(), preferredJavaTimeZoneName); 425 } 426 } else { 427 addExecutionError(ExecutionErrors.UnknownLanguageIsoName.name(), preferredLanguageIsoName); 428 } 429 } 430 } else { 431 addExecutionError(ExecutionErrors.UnknownDefaultTerm.name()); 432 } 433 } else { 434 addExecutionError(ExecutionErrors.InvalidGlAccountCategory.name(), glAccountCategoryName); 435 } 436 } else { 437 addExecutionError(ExecutionErrors.UnknownArGlAccountName.name(), arGlAccountName); 438 } 439 } else { 440 addExecutionError(ExecutionErrors.UnknownReturnPolicyName.name(), returnPolicyName); 441 } 442 } else { 443 addExecutionError(ExecutionErrors.UnknownCancellationPolicyName.name(), cancellationPolicyName); 444 } 445 } else { 446 if(customerTypeName != null) { 447 addExecutionError(ExecutionErrors.UnknownCustomerTypeName.name(), customerTypeName); 448 } else { 449 addExecutionError(ExecutionErrors.UnknownDefaultCustomerType.name()); 450 } 451 } 452 } 453 } else { 454 addExecutionError(ExecutionErrors.MismatchedPasswords.name()); 455 } 456 } else { 457 addExecutionError(ExecutionErrors.DuplicateUsername.name()); 458 459 var party = userLogin.getParty(); 460 customer = customerControl.getCustomer(party); 461 } 462 463 if(customer != null) { 464 var party = customer.getParty(); 465 466 result.setEntityRef(party.getPrimaryKey().getEntityRef()); 467 result.setCustomerName(customer.getCustomerName()); 468 result.setPartyName(party.getLastDetail().getPartyName()); 469 } 470 471 return result; 472 } 473 474}