public String createCustomer()

in service/src/main/java/org/apache/fineract/cn/customer/internal/command/handler/CustomerAggregate.java [130:160]


  public String createCustomer(final CreateCustomerCommand createCustomerCommand) {
    final Customer customer = createCustomerCommand.customer();
    final CustomerEntity customerEntity = CustomerMapper.map(customer);
    customerEntity.setCurrentState(Customer.State.PENDING.name());
    if(customer.getAddress() !=null) {
      final AddressEntity savedAddress = this.addressRepository.save(AddressMapper.map(customer.getAddress()));
      customerEntity.setAddress(savedAddress);
    }
    final CustomerEntity savedCustomerEntity = this.customerRepository.save(customerEntity);

    if (customer.getContactDetails() != null) {
      this.contactDetailRepository.save(
          customer.getContactDetails()
              .stream()
              .map(contact -> {
                final ContactDetailEntity contactDetailEntity = ContactDetailMapper.map(contact);
                contactDetailEntity.setCustomer(savedCustomerEntity);
                return contactDetailEntity;
              })
              .collect(Collectors.toList())
      );
    }

    if (customer.getCustomValues() != null) {
      this.setCustomValues(customer, savedCustomerEntity);
    }

    this.taskAggregate.onCustomerCommand(savedCustomerEntity, Command.Action.ACTIVATE);

    return customer.getIdentifier();
  }