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;
}
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);
}
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;
}
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);
}
Aggregations