in service/src/main/java/org/apache/fineract/cn/customer/rest/controller/CustomerRestController.java [195:219]
ResponseEntity<Void> createNonPerson(@RequestBody @Valid final NonPerson nonPerson) throws InterruptedException {
Customer customer = new Customer();
customer.setIdentifier(nonPerson.getAccountNumber());
customer.setType(Customer.Type.BUSINESS.name());
customer.setCurrentState(Customer.State.PENDING.name());
customer.setMember(false);
if (this.customerService.customerExists(customer.getIdentifier())) {
throw ServiceException.conflict("Customer {0} already exists.", customer.getIdentifier());
}
this.commandGateway.process(new CreateCustomerCommand(customer));
ProductInstance productInstance = new ProductInstance();
productInstance.setProductIdentifier(nonPerson.getProductIdentifier());
productInstance.setCustomerIdentifier(customer.getIdentifier());
productInstance.setAccountIdentifier(customer.getIdentifier());
//create account
depositAccountManager.create(productInstance);
//activate
if(nonPerson.isActive()){
this.commandGateway.process(new ActivateCustomerCommand(customer.getIdentifier(), "ACTIVATE"));
this.depositAccountManager.postProductInstanceCommand(customer.getIdentifier(), "ACTIVATE");
}
return ResponseEntity.accepted().build();
}