Search in sources :

Example 1 with Bill

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;
}
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 Bill

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;
}
Also used : ArrayList(java.util.ArrayList) Bill(com.autentia.tnt.businessobject.Bill) BigDecimal(java.math.BigDecimal) Date(java.util.Date)

Example 3 with Bill

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);
}
Also used : BillType(com.autentia.tnt.businessobject.BillType) SortCriteria(com.autentia.tnt.dao.SortCriteria) ArrayList(java.util.ArrayList) Bill(com.autentia.tnt.businessobject.Bill) GregorianCalendar(java.util.GregorianCalendar)

Example 4 with Bill

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;
}
Also used : Bill(com.autentia.tnt.businessobject.Bill) HashSet(java.util.HashSet)

Example 5 with Bill

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;
}
Also used : Bill(com.autentia.tnt.businessobject.Bill) HashSet(java.util.HashSet)

Aggregations

Bill (com.autentia.tnt.businessobject.Bill)19 ArrayList (java.util.ArrayList)6 BillDAO (com.autentia.tnt.dao.hibernate.BillDAO)5 BillManager (com.autentia.tnt.manager.billing.BillManager)5 Test (org.junit.Test)5 SortCriteria (com.autentia.tnt.dao.SortCriteria)4 Date (java.util.Date)4 BigDecimal (java.math.BigDecimal)3 BillType (com.autentia.tnt.businessobject.BillType)2 GregorianCalendar (java.util.GregorianCalendar)2 HashSet (java.util.HashSet)2 BillBean (com.autentia.tnt.bean.billing.BillBean)1 BillBreakDown (com.autentia.tnt.businessobject.BillBreakDown)1 BillPayment (com.autentia.tnt.businessobject.BillPayment)1 CreditTitle (com.autentia.tnt.businessobject.CreditTitle)1 Project (com.autentia.tnt.businessobject.Project)1 ProjectDAO (com.autentia.tnt.dao.hibernate.ProjectDAO)1 Calendar (java.util.Calendar)1 LinkedHashSet (java.util.LinkedHashSet)1 SelectItem (javax.faces.model.SelectItem)1