use of com.autentia.tnt.businessobject.Bill 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.Bill in project TNTConcept by autentia.
the class NOFBean method convertFromBillToGenericNOF.
/**
* Converts from list of bills to a list of GeneticNOF objects to be seen in the page
*/
public List<GenericNOF> convertFromBillToGenericNOF(List<Bill> bills) {
List<GenericNOF> genericNOFList = new ArrayList<GenericNOF>(bills.size());
for (Bill bill : bills) {
// no se incluyen las facturas que estan en pagares
if (bill.getState() != BillState.IN_CREDITTITLE) {
GenericNOF genericNOF = new GenericNOF();
genericNOF.setEndDate(bill.getExpiration());
genericNOF.setType(NOFType.BILL);
if (bill.getBillType().equals(BillType.RECIEVED)) {
genericNOF.setProvider(bill.getProvider().getName());
}
genericNOF.setDescription(bill.getName());
genericNOF.setBillType(bill.getBillType());
genericNOF.setNumber(bill.getNumber());
genericNOF.setOrganization(bill.getProject().getClient());
// [bugzilla:2638] se resta el montante de los asientos de la factura del montante de la propia factura
/*
BigDecimal amountInAccountEntries = new BigDecimal(0);
for (AccountEntry accountEntry: bill.getEntries()) {
amountInAccountEntries = amountInAccountEntries.add(accountEntry.getAmount());
}
// si la factura es recibida se deberia sumar el valor de los asientos por cómo se presentan
// los datos en el jsp. Para no hacer logica de sumar o restar, en caso de ser recibida el valor
// de los asientos se multiplica por -1 y se resta, que es equivalente a sumar.
if (bill.getBillType().equals(BillType.RECIEVED)) {
amountInAccountEntries = amountInAccountEntries.multiply(new BigDecimal(-1));
}
genericNOF.setTotal(bill.getTotal().subtract(amountInAccountEntries));
*/
genericNOF.setTotal(bill.getUnpaid());
// logica de presentacion de datos en el jsp
if (bill.getBillType().equals(BillType.RECIEVED)) {
genericNOF.setTotal(genericNOF.getTotal().multiply(new BigDecimal(-1)));
}
genericNOF.setExpired(bill.getExpiration().before(new Date()));
// finalmente se añade si se debe o se nos debe algo
if (!genericNOF.getTotal().toString().equals("0.00")) {
genericNOFList.add(genericNOF);
}
}
}
return genericNOFList;
}
use of com.autentia.tnt.businessobject.Bill in project TNTConcept by autentia.
the class NOFBean method getAllNOFReceivedBills.
public List<GenericNOF> getAllNOFReceivedBills() {
/**
** Facturas emitidas impagadas que vencen en el periodo ***
*/
/**
** Facturas emitidas impagadas ya vencidas ***
*/
/**
** Facturas recibidas impagadas que vencen en el periodo ***
*/
/**
** Facturas recibidas impagadas ya vencidas ***
*/
int years = ConfigurationUtil.getDefault().getYearsBackSearchNotPaidBillsNOF();
List<BillType> billTypes = new ArrayList<BillType>();
billTypes.add(BillType.RECIEVED);
billSearch.setBillTypes(billTypes);
billSearch.setState(BillState.EMITTED);
billSearch.setStartEndBillDate(calculateStartEndByPassedYear(years));
List<Bill> total = billManager.getAllEntities(billSearch, new SortCriteria("creationDate", true), new GregorianCalendar(1900, 1, 1).getTime(), getEndDate());
return convertFromBillToGenericNOF(total);
}
use of com.autentia.tnt.businessobject.Bill in project TNTConcept by autentia.
the class CreditTitleBean method createBills.
// Methods to create/remove instances of one-to-many entities (slave entities)
/**
* Create a new empty instance of the one-to-many field
* @return forward to the same page
*/
public String createBills() {
Bill item = new Bill();
if (creditTitle.getBills() == null) {
creditTitle.setBills(new HashSet());
}
creditTitle.getBills().add(item);
return null;
}
use of com.autentia.tnt.businessobject.Bill in project TNTConcept by autentia.
the class CreditTitleBean method editBills.
/**
* Create a new empty instance of the one-to-many field
* @return forward to the same page
*/
public String editBills() {
Bill item = new Bill();
if (creditTitle.getBills() == null) {
creditTitle.setBills(new HashSet());
}
creditTitle.getBills().add(item);
return null;
}
Aggregations