Esempio n. 1
0
  @Override
  public CustomerStatusDetailDto retrieveCustomerStatusDetails(
      Short newStatusId, Short flagIdValue, Short customerLevelId) {

    CustomerLevel customerLevel = CustomerLevel.getLevel(customerLevelId);
    CustomerStatus customerStatus = CustomerStatus.fromInt(newStatusId);

    CustomerStatusFlag statusFlag = null;
    if (customerStatus.isCustomerCancelledOrClosed()) {
      statusFlag = CustomerStatusFlag.getStatusFlag(flagIdValue);
    }

    String statusName =
        AccountStateMachines.getInstance().getCustomerStatusName(customerStatus, customerLevel);
    String flagName =
        AccountStateMachines.getInstance().getCustomerFlagName(statusFlag, customerLevel);

    return new CustomerStatusDetailDto(statusName, flagName);
  }
Esempio n. 2
0
  @Override
  public void updateCustomerStatus(
      Integer customerId,
      Integer previousCustomerVersionNo,
      String flagIdAsString,
      String newStatusIdAsString,
      String notes) {

    MifosUser user =
        (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);

    Short flagId = null;
    Short newStatusId = null;
    if (StringUtils.isNotBlank(flagIdAsString)) {
      flagId = Short.valueOf(flagIdAsString);
    }
    if (StringUtils.isNotBlank(newStatusIdAsString)) {
      newStatusId = Short.valueOf(newStatusIdAsString);
    }

    CustomerStatusFlag customerStatusFlag = null;
    if (flagId != null) {
      customerStatusFlag = CustomerStatusFlag.fromInt(flagId);
    }

    CustomerStatus newStatus = CustomerStatus.fromInt(newStatusId);

    CustomerStatusUpdate customerStatusUpdate =
        new CustomerStatusUpdate(
            customerId, previousCustomerVersionNo, customerStatusFlag, newStatus, notes);

    try {
      this.customerService.updateCustomerStatus(userContext, customerStatusUpdate);
    } catch (CustomerException e) {
      throw new BusinessRuleException(e.getKey(), e);
    }
  }