in service/src/main/java/org/apache/fineract/cn/customer/internal/command/handler/CustomerAggregate.java [165:210]
public String updateCustomer(final UpdateCustomerCommand updateCustomerCommand) {
final Customer customer = updateCustomerCommand.customer();
final CustomerEntity customerEntity = findCustomerEntityOrThrow(customer.getIdentifier());
customerEntity.setGivenName(customer.getGivenName());
customerEntity.setMiddleName(customer.getMiddleName());
customerEntity.setSurname(customer.getSurname());
customerEntity.setAccountBeneficiary(customer.getAccountBeneficiary());
customerEntity.setReferenceCustomer(customer.getReferenceCustomer());
customerEntity.setAssignedOffice(customer.getAssignedOffice());
customerEntity.setAssignedEmployee(customer.getAssignedEmployee());
if (customer.getDateOfBirth() != null ) {
final LocalDate newDateOfBirth = customer.getDateOfBirth().toLocalDate();
if (customerEntity.getDateOfBirth() == null) {
customerEntity.setDateOfBirth(Date.valueOf(newDateOfBirth));
} else {
final LocalDate dateOfBirth = customerEntity.getDateOfBirth().toLocalDate();
if (!dateOfBirth.isEqual(newDateOfBirth)) {
customerEntity.setDateOfBirth(Date.valueOf(newDateOfBirth));
}
}
} else {
customerEntity.setDateOfBirth(null);
}
if (customer.getCustomValues() != null) {
this.fieldValueRepository.deleteByCustomer(customerEntity);
this.fieldValueRepository.flush();
this.setCustomValues(customer, customerEntity);
}
if (customer.getAddress() != null) {
this.updateAddress(new UpdateAddressCommand(customer.getIdentifier(), customer.getAddress()));
}
this.updateContactDetails(new UpdateContactDetailsCommand(customer.getIdentifier(), customer.getContactDetails()));
customerEntity.setLastModifiedBy(UserContextHolder.checkedGetUser());
customerEntity.setLastModifiedOn(LocalDateTime.now(Clock.systemUTC()));
this.customerRepository.save(customerEntity);
return customer.getIdentifier();
}