コード例 #1
0
  @SuppressWarnings("deprecation")
  private CustomerAccountView getCustomerAccountView(final CustomerBO customer) {
    CustomerAccountView customerAccountView =
        new CustomerAccountView(customer.getCustomerAccount().getAccountId(), getCurrency());

    List<AccountActionDateEntity> accountAction = new ArrayList<AccountActionDateEntity>();
    accountAction.add(customer.getCustomerAccount().getAccountActionDate(Short.valueOf("1")));
    customerAccountView.setAccountActionDates(
        TestObjectFactory.getBulkEntryAccountActionViews(accountAction));
    customerAccountView.setCustomerAccountAmountEntered("100.0");
    customerAccountView.setValidCustomerAccountAmountEntered(true);
    return customerAccountView;
  }
コード例 #2
0
  @Override
  public void createCustomerNote(CustomerNoteFormDto customerNoteForm) {

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

    CustomerBO customer = this.customerDao.findCustomerBySystemId(customerNoteForm.getGlobalNum());
    customer.updateDetails(userContext);

    PersonnelBO loggedInUser = this.personnelDao.findPersonnelById(userContext.getId());

    CustomerNoteEntity customerNote =
        new CustomerNoteEntity(
            customerNoteForm.getComment(),
            new DateTimeService().getCurrentJavaSqlDate(),
            loggedInUser,
            customer);
    customer.addCustomerNotes(customerNote);

    try {
      this.transactionHelper.startTransaction();
      this.customerDao.save(customer);
      this.transactionHelper.commitTransaction();
    } catch (Exception e) {
      this.transactionHelper.rollbackTransaction();
      throw new BusinessRuleException(customer.getCustomerAccount().getAccountId().toString(), e);
    } finally {
      this.transactionHelper.closeSession();
    }
  }
コード例 #3
0
  @Override
  public void revertLastChargesPayment(String globalCustNum, String adjustmentNote) {

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

    PersonnelBO loggedInUser = this.personnelDao.findPersonnelById(userContext.getId());
    CustomerBO customerBO = this.customerDao.findCustomerBySystemId(globalCustNum);
    customerBO.updateDetails(userContext);

    if (customerBO.getCustomerAccount().findMostRecentNonzeroPaymentByPaymentDate() != null) {
      customerBO.getCustomerAccount().updateDetails(userContext);

      try {
        if (customerBO.getPersonnel() != null) {
          new AccountBusinessService()
              .checkPermissionForAdjustment(
                  AccountTypes.CUSTOMER_ACCOUNT,
                  customerBO.getLevel(),
                  userContext,
                  customerBO.getOffice().getOfficeId(),
                  customerBO.getPersonnel().getPersonnelId());
        } else {
          new AccountBusinessService()
              .checkPermissionForAdjustment(
                  AccountTypes.CUSTOMER_ACCOUNT,
                  customerBO.getLevel(),
                  userContext,
                  customerBO.getOffice().getOfficeId(),
                  userContext.getId());
        }

        this.transactionHelper.startTransaction();
        customerBO.adjustPmnt(adjustmentNote, loggedInUser);
        this.customerDao.save(customerBO);
        this.transactionHelper.commitTransaction();
      } catch (SystemException e) {
        this.transactionHelper.rollbackTransaction();
        throw new MifosRuntimeException(e);
      } catch (ApplicationException e) {
        this.transactionHelper.rollbackTransaction();
        throw new BusinessRuleException(e.getKey(), e);
      }
    }
  }
コード例 #4
0
  @Override
  public CustomerChargesDetailsDto retrieveChargesDetails(Integer customerId) {

    MifosUser mifosUser =
        (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = new UserContextFactory().create(mifosUser);

    CustomerBO customerBO = this.customerDao.findCustomerById(customerId);
    CustomerAccountBO customerAccount = customerBO.getCustomerAccount();

    List<AccountFeesDto> accountFeesDtos = new ArrayList<AccountFeesDto>();
    if (!customerAccount.getAccountFees().isEmpty()) {
      for (AccountFeesEntity accountFeesEntity : customerAccount.getAccountFees()) {
        AccountFeesDto accountFeesDto =
            new AccountFeesDto(
                accountFeesEntity.getFees().getFeeFrequency().getFeeFrequencyType().getId(),
                (accountFeesEntity.getFees().getFeeFrequency().getFeePayment() != null
                    ? accountFeesEntity.getFees().getFeeFrequency().getFeePayment().getId()
                    : null),
                accountFeesEntity.getFeeStatus(),
                accountFeesEntity.getFees().getFeeName(),
                accountFeesEntity.getAccountFeeAmount().toString(),
                getMeetingRecurrence(
                    accountFeesEntity.getFees().getFeeFrequency().getFeeMeetingFrequency(),
                    userContext),
                accountFeesEntity.getFees().getFeeId());
        accountFeesDtos.add(accountFeesDto);
      }
    }

    CustomerScheduleDto customerSchedule = null;
    CustomerScheduleEntity scheduleEntity =
        (CustomerScheduleEntity) customerAccount.getUpcomingInstallment();
    if (scheduleEntity != null) {
      Set<AccountFeesActionDetailEntity> feeEntities = scheduleEntity.getAccountFeesActionDetails();

      List<AccountFeeScheduleDto> feeDtos = new ArrayList<AccountFeeScheduleDto>();
      for (AccountFeesActionDetailEntity feeEntity : feeEntities) {
        feeDtos.add(convertToDto(feeEntity));
      }

      customerSchedule =
          new CustomerScheduleDto(
              scheduleEntity.getMiscFee().toString(),
              scheduleEntity.getMiscFeePaid().toString(),
              scheduleEntity.getMiscPenalty().toString(),
              scheduleEntity.getMiscPenaltyPaid().toString(),
              feeDtos);
    }

    return new CustomerChargesDetailsDto(
        customerAccount.getNextDueAmount().toString(),
        customerAccount.getTotalAmountInArrears().toString(),
        customerAccount.getTotalAmountDue().toString(),
        customerAccount.getUpcomingChargesDate(),
        customerSchedule,
        accountFeesDtos);
  }
コード例 #5
0
  @Override
  public List<CustomerRecentActivityDto> retrieveAllAccountActivity(String globalCustNum) {
    List<CustomerRecentActivityDto> customerActivityViewList =
        new ArrayList<CustomerRecentActivityDto>();

    CustomerBO customerBO = this.customerDao.findCustomerBySystemId(globalCustNum);
    List<CustomerActivityEntity> customerActivityDetails =
        customerBO.getCustomerAccount().getCustomerActivitDetails();

    for (CustomerActivityEntity customerActivityEntity : customerActivityDetails) {
      customerActivityViewList.add(
          assembleCustomerActivityDto(customerActivityEntity, Locale.getDefault()));
    }
    return customerActivityViewList;
  }
コード例 #6
0
  @Override
  public List<CustomerRecentActivityDto> retrieveRecentActivities(
      Integer customerId, Integer countOfActivities) {
    CustomerBO customerBO = this.customerDao.findCustomerById(customerId);
    List<CustomerActivityEntity> customerActivityDetails =
        customerBO.getCustomerAccount().getCustomerActivitDetails();

    List<CustomerRecentActivityDto> customerActivityViewList =
        new ArrayList<CustomerRecentActivityDto>();
    int count = 0;
    for (CustomerActivityEntity customerActivityEntity : customerActivityDetails) {
      customerActivityViewList.add(getCustomerActivityView(customerActivityEntity));
      if (++count == countOfActivities) {
        break;
      }
    }
    return customerActivityViewList;
  }