Example #1
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;
  }