示例#1
0
  public boolean delete() {

    if (accountTypeDTO.getCustomers().size() > 0) {
      return false;
    }

    for (AccountInformationTypeDTO ait : accountTypeDTO.getInformationTypes()) {
      new AccountInformationTypeBL(ait.getId()).delete();
    }
    accountTypeDTO.getInformationTypes().clear();
    accountTypeDAS.delete(accountTypeDTO);
    return true;
  }
示例#2
0
  public boolean isAccountTypeUnique(Integer entityId, String name, boolean isNew) {

    List<AccountTypeDTO> accountTypeDTOList = new AccountTypeDAS().findAll(entityId);
    List<String> descriptionList = new ArrayList<String>();
    for (AccountTypeDTO accountType1 : accountTypeDTOList) {

      descriptionList.add(accountType1.getDescription());
    }

    if (isNew) {
      return !descriptionList.contains(name);
    } else {
      return Collections.frequency(descriptionList, name) < 2;
    }
  }
示例#3
0
  public AccountTypeDTO create(AccountTypeDTO accountTypeDTO) {

    accountTypeDTO.setDateCreated(new Date());
    accountTypeDTO = accountTypeDAS.save(accountTypeDTO);

    accountTypeDAS.flush();
    accountTypeDAS.clear();
    return accountTypeDTO;
  }
示例#4
0
  public static final AccountTypeWS getWS(AccountTypeDTO dto) {

    return getWS(
        dto.getId(),
        dto.getCompany().getId(),
        dto.getInvoiceDesign(),
        dto.getDateCreated(),
        dto.getCreditNotificationLimit1(),
        dto.getCreditNotificationLimit2(),
        dto.getCreditLimit(),
        dto.getInvoiceDeliveryMethod(),
        dto.getCurrencyId(),
        dto.getLanguageId(),
        dto.getDescription(),
        UserBL.convertMainSubscriptionToWS(dto.getBillingCycle()),
        dto.getInformationTypes(),
        dto.getPaymentMethodTypes(),
        dto.getPreferredNotificationAitId());
  }
示例#5
0
  public void update(AccountTypeDTO accountType) {

    AccountTypeDTO accountTypeDTO = accountTypeDAS.find(accountType.getId());

    accountTypeDTO.setCreditLimit(accountType.getCreditLimit());
    accountTypeDTO.setCreditNotificationLimit1(accountType.getCreditNotificationLimit1());
    accountTypeDTO.setCreditNotificationLimit2(accountType.getCreditNotificationLimit2());
    accountTypeDTO.setInvoiceDesign(accountType.getInvoiceDesign());
    accountTypeDTO.setBillingCycle(accountType.getBillingCycle());
    accountTypeDTO.setLanguage(new LanguageDAS().find(accountType.getLanguageId()));
    accountTypeDTO.setCurrency(new CurrencyDAS().find(accountType.getCurrencyId()));
    accountTypeDTO.setInvoiceDeliveryMethod(
        new InvoiceDeliveryMethodDAS().find(accountType.getInvoiceDeliveryMethod().getId()));
    accountTypeDTO.setPaymentMethodTypes(accountType.getPaymentMethodTypes());
    accountTypeDTO.setPreferredNotificationAitId(accountType.getPreferredNotificationAitId());
    accountTypeDAS.save(accountTypeDTO);

    accountTypeDAS.flush();
    accountTypeDAS.clear();
  }
示例#6
0
  public static final AccountTypeDTO getDTO(AccountTypeWS ws, Integer entityId) {

    AccountTypeDTO accountTypeDTO = new AccountTypeDTO();
    if (ws.getId() != null && ws.getId() > 0) {
      accountTypeDTO.setId(ws.getId());
    }

    accountTypeDTO.setCompany(new CompanyDTO(entityId));

    accountTypeDTO.setCreditLimit(ws.getCreditLimitAsDecimal());
    accountTypeDTO.setCreditNotificationLimit1(ws.getCreditNotificationLimit1AsDecimal());
    accountTypeDTO.setCreditNotificationLimit2(ws.getCreditNotificationLimit2AsDecimal());
    accountTypeDTO.setInvoiceDesign(ws.getInvoiceDesign());
    accountTypeDTO.setBillingCycle(
        UserBL.convertMainSubscriptionFromWS(ws.getMainSubscription(), entityId));
    accountTypeDTO.setLanguage(new LanguageDAS().find(ws.getLanguageId()));
    accountTypeDTO.setCurrency(new CurrencyDAS().find(ws.getCurrencyId()));
    accountTypeDTO.setInvoiceDeliveryMethod(
        new InvoiceDeliveryMethodDTO(ws.getInvoiceDeliveryMethodId()));
    accountTypeDTO.setPreferredNotificationAitId(ws.getpreferredNotificationAitId());
    // set payment method types
    if (ws.getPaymentMethodTypeIds() != null) {
      Set<PaymentMethodTypeDTO> paymentMethodTypes = new HashSet<PaymentMethodTypeDTO>(0);
      PaymentMethodTypeDAS das = new PaymentMethodTypeDAS();

      for (Integer paymentMethodTypeId : ws.getPaymentMethodTypeIds()) {
        paymentMethodTypes.add(das.find(paymentMethodTypeId));
      }
      accountTypeDTO.setPaymentMethodTypes(paymentMethodTypes);
    }
    List<PaymentMethodTypeDTO> globalPaymentMethods =
        new PaymentMethodTypeDAS().findByAllAccountType(entityId);
    for (PaymentMethodTypeDTO globalPaymentMethod : globalPaymentMethods) {
      accountTypeDTO.getPaymentMethodTypes().add(globalPaymentMethod);
    }
    return accountTypeDTO;
  }