Search in sources :

Example 1 with CreditTitle

use of com.autentia.tnt.businessobject.CreditTitle in project TNTConcept by autentia.

the class NOFBean method convertFromCreditTitleToGenericNOF.

/**
 * Converts from list of credit titles to a list of GeneticNOF objects to be seen in the page
 */
public List<GenericNOF> convertFromCreditTitleToGenericNOF(List<CreditTitle> creditTitles) {
    List<GenericNOF> genericNOFList = new ArrayList<GenericNOF>(creditTitles.size());
    for (CreditTitle creditTitle : creditTitles) {
        GenericNOF genericNOF = new GenericNOF();
        genericNOF.setEndDate(creditTitle.getExpirationDate());
        if (creditTitle.getType().equals(CreditTitleType.ISSUED)) {
            genericNOF.setBillType(BillType.ISSUED);
        } else {
            genericNOF.setBillType(BillType.RECIEVED);
        }
        genericNOF.setType(NOFType.CREDIT_TITLE);
        genericNOF.setProvider(creditTitle.getOrganization().getName());
        genericNOF.setNumber(creditTitle.getNumber());
        genericNOF.setOrganization(creditTitle.getOrganization());
        genericNOF.setDescription(creditTitle.getObservations());
        // [bugzilla:2638] se resta el montante de las facturas pagadas del pagare del montante del propio pagare
        BigDecimal amountInBills = new BigDecimal(0);
        for (Bill bill : creditTitle.getBills()) {
            if (bill.getState().equals(BillState.PAID)) {
                amountInBills = amountInBills.add(bill.getAmount());
            }
        }
        genericNOF.setTotal(creditTitle.getAmount().subtract(amountInBills));
        genericNOF.setExpired(creditTitle.getExpirationDate().before(new Date()));
        if (!genericNOF.getTotal().toString().equals("0.00")) {
            genericNOFList.add(genericNOF);
        }
    }
    return genericNOFList;
}
Also used : ArrayList(java.util.ArrayList) Bill(com.autentia.tnt.businessobject.Bill) CreditTitle(com.autentia.tnt.businessobject.CreditTitle) BigDecimal(java.math.BigDecimal) Date(java.util.Date)

Example 2 with CreditTitle

use of com.autentia.tnt.businessobject.CreditTitle in project TNTConcept by autentia.

the class NOFBean method getAllNOFIssuedCreditTitle.

/**
 * Recover a list of issued credit titles that has to be paid in the period
 */
public List<GenericNOF> getAllNOFIssuedCreditTitle() {
    int years = ConfigurationUtil.getDefault().getYearsBackSearchNotPaidBillsNOF();
    creditTitleSearch.setCreditTitleType(CreditTitleType.ISSUED);
    creditTitleSearch.setCreditTitleState(CreditTitleState.EMITTED);
    creditTitleSearch.setStartExpirationDate(calculateStartEndByPassedYear(years));
    List<CreditTitle> creditTitles = creditTitleManager.getAllEntities(creditTitleSearch, new SortCriteria("issueDate", true), new GregorianCalendar(1900, 1, 1).getTime(), getEndDate());
    return convertFromCreditTitleToGenericNOF(creditTitles);
}
Also used : SortCriteria(com.autentia.tnt.dao.SortCriteria) GregorianCalendar(java.util.GregorianCalendar) CreditTitle(com.autentia.tnt.businessobject.CreditTitle)

Example 3 with CreditTitle

use of com.autentia.tnt.businessobject.CreditTitle in project TNTConcept by autentia.

the class CreditTitleManager method getAllEntities.

/* CreditTitle - generated by stajanov (do not edit/delete) */
/**
 * Get a list of bills between start and end dates
 * @param search
 * @param sort
 * @param start
 * @param end
 * @return
 */
public List<CreditTitle> getAllEntities(CreditTitleSearch search, SortCriteria sort, Date start, Date end) {
    List<CreditTitle> res = creditTitleDAO.search(search, sort);
    List<CreditTitle> list = new ArrayList<CreditTitle>();
    Calendar calendar = Calendar.getInstance();
    // Recorremos la lista de CreditTitle
    for (CreditTitle item : res) {
        if (item.getIssueDate() != null) {
            // Metemos en el calendar la fecha del item
            calendar.setTime(item.getIssueDate());
            // Si la fecha está dentro del rango de fechas seleccionado se añade a la lista con la fecha calculada del próximo pago
            if ((calendar.getTimeInMillis() >= start.getTime()) && (calendar.getTimeInMillis() <= end.getTime())) {
                // Añadimos a la lista
                list.add(item);
            }
        }
    }
    return list;
}
Also used : Calendar(java.util.Calendar) ArrayList(java.util.ArrayList) CreditTitle(com.autentia.tnt.businessobject.CreditTitle)

Example 4 with CreditTitle

use of com.autentia.tnt.businessobject.CreditTitle in project TNTConcept by autentia.

the class NOFBean method getAllNOFReceivedCreditTitle.

/**
 * Recover a list of received credit titles that has to be paid in the period
 */
public List<GenericNOF> getAllNOFReceivedCreditTitle() {
    int years = ConfigurationUtil.getDefault().getYearsBackSearchNotPaidBillsNOF();
    creditTitleSearch.setCreditTitleType(CreditTitleType.RECEIVED);
    creditTitleSearch.setCreditTitleState(CreditTitleState.EMITTED);
    creditTitleSearch.setStartExpirationDate(calculateStartEndByPassedYear(years));
    List<CreditTitle> creditTitles = creditTitleManager.getAllEntities(creditTitleSearch, new SortCriteria("issueDate", true), new GregorianCalendar(1900, 1, 1).getTime(), getEndDate());
    return convertFromCreditTitleToGenericNOF(creditTitles);
}
Also used : SortCriteria(com.autentia.tnt.dao.SortCriteria) GregorianCalendar(java.util.GregorianCalendar) CreditTitle(com.autentia.tnt.businessobject.CreditTitle)

Aggregations

CreditTitle (com.autentia.tnt.businessobject.CreditTitle)4 SortCriteria (com.autentia.tnt.dao.SortCriteria)2 ArrayList (java.util.ArrayList)2 GregorianCalendar (java.util.GregorianCalendar)2 Bill (com.autentia.tnt.businessobject.Bill)1 BigDecimal (java.math.BigDecimal)1 Calendar (java.util.Calendar)1 Date (java.util.Date)1