Search in sources :

Example 16 with Bill

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

the class FromOfferToBillTest method testConversionWithoutConceptsAndSaving.

/**
 * Comprobacion de que se haga la conversion guardando sin conceptos
 */
@Test
public void testConversionWithoutConceptsAndSaving() {
    final BillManager billManager = (BillManager) SpringUtilsForTesting.getSpringBean("managerBill");
    final BillDAO billDAO = (BillDAO) SpringUtilsForTesting.getSpringBean("daoBill");
    insertInitialData();
    Bill bill = billManager.convertFromOfferToBill(offer);
    // esto deberia hacerlo el usuario a traves de la página
    bill = insertDataByUserInWeb(bill);
    billDAO.insert(bill);
    if (bill.getTotal().floatValue() != new BigDecimal(0).floatValue()) {
        fail("es una factura sin conceptos ... el total deberia ser de 0 en vez de '" + bill.getTotal() + "'");
    }
}
Also used : BillManager(com.autentia.tnt.manager.billing.BillManager) BillDAO(com.autentia.tnt.dao.hibernate.BillDAO) Bill(com.autentia.tnt.businessobject.Bill) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 17 with Bill

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

the class BillExpirationDateBean method updateExpirationDate.

// private Set<BillPayment> billPayment = new LinkedHashSet<BillPayment>();
public void updateExpirationDate() {
    // TODO extract login name to a properties file
    authenticateAs(ConfigurationUtil.getDefault().getAdminUser());
    List<Bill> bills = BillManager.getDefault().getAllEntities(null, new SortCriteria("name"));
    for (Bill b : bills) {
        Date creationDate = b.getCreationDate();
        creationDate.setMonth(creationDate.getMonth() + 1);
        if (!b.getBillPayment().isEmpty()) {
            for (BillPayment bp : b.getBillPayment()) {
                bp.setExpirationDate(creationDate);
            }
        } else {
            // creamos el billPayment para el expirationDate
            createBillPayment(b);
            for (BillPayment bp : b.getBillPayment()) {
                bp.setExpirationDate(creationDate);
            }
        }
    }
}
Also used : SortCriteria(com.autentia.tnt.dao.SortCriteria) BillPayment(com.autentia.tnt.businessobject.BillPayment) Bill(com.autentia.tnt.businessobject.Bill) Date(java.util.Date)

Example 18 with Bill

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

the class BillManager method getAllEntities.

/**
 * Get a list of bills between start and end dates
 * @param search
 * @param sort
 * @param start
 * @param end
 * @return
 */
public List<Bill> getAllEntities(BillSearch search, SortCriteria sort, Date start, Date end) {
    List<Bill> res = billDAO.search(search, sort);
    List<Bill> list = new ArrayList<Bill>();
    Calendar calendar = Calendar.getInstance();
    // Recorremos la lista de Bills
    for (Bill item : res) {
        if (item.getExpiration() != null) {
            // Metemos en el calendar la fecha del item
            calendar.setTime(item.getExpiration());
            // 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) Bill(com.autentia.tnt.businessobject.Bill) ArrayList(java.util.ArrayList)

Example 19 with Bill

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

the class NOFBean method getAllNOFIssuedBills.

public List<GenericNOF> getAllNOFIssuedBills() {
    /**
     ** 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.ISSUED);
    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)

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