コード例 #1
0
ファイル: InvoiceBL.java プロジェクト: rahith/ComtalkA-S
  public InvoiceDTO getDTOEx(Integer languageId, boolean forDisplay) {

    if (!forDisplay) {
      return invoice;
    }

    InvoiceDTO invoiceDTO = new InvoiceDTO(invoice);
    // make sure that the lines are properly ordered
    List<InvoiceLineDTO> orderdLines = new ArrayList<InvoiceLineDTO>(invoiceDTO.getInvoiceLines());
    Collections.sort(orderdLines, new InvoiceLineComparator());
    invoiceDTO.setInvoiceLines(orderdLines);

    UserBL userBl = new UserBL(invoice.getBaseUser());
    Locale locale = userBl.getLocale();
    ResourceBundle bundle = ResourceBundle.getBundle("entityNotifications", locale);

    // now add headres and footers if this invoices has subaccount
    // lines
    if (invoiceDTO.hasSubAccounts()) {
      addHeadersFooters(orderdLines, bundle);
    }
    // add a grand total final line
    InvoiceLineDTO total = new InvoiceLineDTO();
    total.setDescription(bundle.getString("invoice.line.total"));
    total.setAmount(invoice.getTotal());
    total.setIsPercentage(0);
    invoiceDTO.getInvoiceLines().add(total);

    // add some currency info for the human
    CurrencyBL currency = new CurrencyBL(invoice.getCurrency().getId());
    if (languageId != null) {
      invoiceDTO.setCurrencyName(currency.getEntity().getDescription(languageId));
    }
    invoiceDTO.setCurrencySymbol(currency.getEntity().getSymbol());

    return invoiceDTO;
  }