use of com.autentia.tnt.businessobject.PeriodicalAccountEntry in project TNTConcept by autentia.
the class PeriodicalAccountEntryManager method createNewPeriodicalAccountEntry.
/**
* Create a new PeriodicalAccountEntry
* @param periodicalAccountEntry
* @param nextDate
* @return
*/
private PeriodicalAccountEntry createNewPeriodicalAccountEntry(PeriodicalAccountEntry periodicalAccountEntry, Date nextDate) {
PeriodicalAccountEntry newPeriodicalAccountEntry = new PeriodicalAccountEntry();
newPeriodicalAccountEntry.setDate(nextDate);
newPeriodicalAccountEntry.setAccount(periodicalAccountEntry.getAccount());
newPeriodicalAccountEntry.setAmount(periodicalAccountEntry.getAmount());
newPeriodicalAccountEntry.setConcept(periodicalAccountEntry.getConcept());
newPeriodicalAccountEntry.setFrequency(periodicalAccountEntry.getFrequency());
newPeriodicalAccountEntry.setOrganization(periodicalAccountEntry.getOrganization());
newPeriodicalAccountEntry.setObservations(periodicalAccountEntry.getObservations());
newPeriodicalAccountEntry.setRise(periodicalAccountEntry.getRise());
newPeriodicalAccountEntry.setType(periodicalAccountEntry.getType());
return newPeriodicalAccountEntry;
}
use of com.autentia.tnt.businessobject.PeriodicalAccountEntry in project TNTConcept by autentia.
the class PeriodicalAccountEntryManager method copy.
public PeriodicalAccountEntry copy(int id) {
PeriodicalAccountEntry periodicalAccountEntry = new PeriodicalAccountEntry();
AccountEntryDAO accountEntryDAO = new AccountEntryDAO();
AccountEntry copyAccountEntry = accountEntryDAO.loadById(id);
/*
periodicalAccountEntry.setConcept(copyAccountEntry.getConcept());
periodicalAccountEntry.setAccount(copyAccountEntry.getAccount());
periodicalAccountEntry.setDate(copyAccountEntry.getDate());
periodicalAccountEntry.setObservations(copyAccountEntry.getObservations());
periodicalAccountEntry.setType(copyAccountEntry.getType());
periodicalAccountEntry.setAmount(copyAccountEntry.getAmount());
*/
BeanUtils.copyTransferObject(copyAccountEntry, periodicalAccountEntry);
return periodicalAccountEntry;
}
use of com.autentia.tnt.businessobject.PeriodicalAccountEntry in project TNTConcept by autentia.
the class PeriodicalAccountEntryManager method getEntities.
/**
* List periodicalAccountEntrys between start and end dates
* @param search search filter to apply
* @param sort sorting criteria
* @param start the start date
* @param end the end date
* @return the list of all periodicalAccountEntrys sorted by requested criterion
*/
public List<PeriodicalAccountEntry> getEntities(PeriodicalAccountEntrySearch search, SortCriteria sort, Date start, Date end) {
List<PeriodicalAccountEntry> res = periodicalAccountEntryDAO.search(search, sort);
List<PeriodicalAccountEntry> list = new ArrayList<PeriodicalAccountEntry>();
Calendar calendar = Calendar.getInstance();
boolean outOfRange;
PeriodicalAccountEntry newPeriodicalAccountEntry = null;
// Recorremos la lista de PeriodicalAccountEntry
for (PeriodicalAccountEntry item : res) {
// Metemos en el calendar la fecha del item
calendar.setTime(item.getDate());
outOfRange = false;
/* Comparamos la fecha del item con el rango de fechas seleccionado por el usuario. Mientras no nos salgamos del rango
se calculan tantos pagos como entren en el periodo que va entre las fechas start y end*/
while (!outOfRange) {
// 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())) {
// Creamos un nuevo PeriodicalAccountEntry
newPeriodicalAccountEntry = createNewPeriodicalAccountEntry(item, new Date(calendar.getTimeInMillis()));
// Añadimos a la lista
list.add(newPeriodicalAccountEntry);
// Si la frecuencia es 'ocasional' terminamos con este item
if (item.getFrequency().getMonths() == 0) {
outOfRange = true;
} else {
// Sumamos la frecuencia del pago a la fecha del item
calendar.add(Calendar.MONTH, item.getFrequency().getMonths());
}
} else if (calendar.getTimeInMillis() > end.getTime()) {
// Si la fecha calculada se ha salido de rango terminamos con este item
outOfRange = true;
} else {
// Sumamos la frecuencia del pago a la fecha del item
calendar.add(Calendar.MONTH, item.getFrequency().getMonths());
}
}
}
return list;
}
use of com.autentia.tnt.businessobject.PeriodicalAccountEntry in project TNTConcept by autentia.
the class NOFBean method orderListByDate.
/**
* Order list by date.
* @param res the list of PeriodicaAccountEntry
*/
private void orderListByDate(List<PeriodicalAccountEntry> res) {
PeriodicalAccountEntry temp = null;
boolean sorted = false;
for (int i = 0; i < res.size() && !sorted; i++) {
sorted = true;
for (int j = res.size() - 1; j > i; j--) {
PeriodicalAccountEntry first = null;
PeriodicalAccountEntry second = null;
// Ascending order
first = res.get(j);
second = res.get(j - 1);
if (first.getDate().getTime() < second.getDate().getTime()) {
temp = res.get(j);
res.set(j, res.get(j - 1));
res.set(j - 1, temp);
sorted = false;
}
}
}
}
use of com.autentia.tnt.businessobject.PeriodicalAccountEntry in project TNTConcept by autentia.
the class NOFBean method convertFromPeriodicalAccountEntryToGenericNOF.
/**
* Converts from list of periodical account entries to a list of GeneticNOF objects to be seen in the page
*/
public List<GenericNOF> convertFromPeriodicalAccountEntryToGenericNOF(List<PeriodicalAccountEntry> periodicalAccountEntries) {
List<GenericNOF> genericNOFList = new ArrayList<GenericNOF>(periodicalAccountEntries.size());
for (PeriodicalAccountEntry periodicalAccountEntry : periodicalAccountEntries) {
GenericNOF genericNOF = new GenericNOF();
genericNOF.setEndDate(periodicalAccountEntry.getDate());
genericNOF.setType(NOFType.PERIODICAL_ACCOUNT_ENTRY);
genericNOF.setProvider(periodicalAccountEntry.getAccount().getName());
genericNOF.setBillType(BillType.RECIEVED);
genericNOF.setOrganization(periodicalAccountEntry.getOrganization());
genericNOF.setDescription(periodicalAccountEntry.getConcept());
genericNOF.setFrecuency(periodicalAccountEntry.getFrequency().getName());
genericNOF.setTotal(periodicalAccountEntry.getAmount().multiply(new BigDecimal(-1)));
genericNOF.setPeriodicalTypeDescription(periodicalAccountEntry.getType().getName());
genericNOFList.add(genericNOF);
}
return genericNOFList;
}
Aggregations