Search in sources :

Example 1 with ProjectCost

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

the class BillManagerTest method createProjectCost.

private ProjectCost createProjectCost(Project project) {
    final ProjectCost projectCost = new ProjectCost();
    projectCost.setProject(project);
    projectCost.setName("Desarrollo");
    projectCost.setCost(new BigDecimal("100"));
    projectCost.setBillable(true);
    daoProjectCost.insert(projectCost);
    return projectCost;
}
Also used : ProjectCost(com.autentia.tnt.businessobject.ProjectCost) BigDecimal(java.math.BigDecimal)

Example 2 with ProjectCost

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

the class BillManager method getAllBitacoreBreakDowns.

public List<BillBreakDown> getAllBitacoreBreakDowns(Date start, Date end, Project project) {
    final List<BillBreakDown> desgloses = new ArrayList<BillBreakDown>();
    ActivityDAO activityDAO = ActivityDAO.getDefault();
    ActivitySearch actSearch = new ActivitySearch();
    actSearch.setBillable(new Boolean(true));
    actSearch.setStartStartDate(start);
    actSearch.setEndStartDate(end);
    List<Activity> actividadesTotal = new ArrayList<Activity>();
    Hashtable user_roles = new Hashtable();
    ProjectRoleDAO projectRoleDAO = ProjectRoleDAO.getDefault();
    ProjectRoleSearch prjRolSearch = new ProjectRoleSearch();
    prjRolSearch.setProject(project);
    List<ProjectRole> roles = projectRoleDAO.search(prjRolSearch, new SortCriteria("id", false));
    for (ProjectRole proyRole : roles) {
        actSearch.setRole(proyRole);
        List<Activity> actividades = activityDAO.search(actSearch, new SortCriteria("startDate", false));
        actividadesTotal.addAll(actividades);
    }
    for (Activity act : actividadesTotal) {
        String key = act.getRole().getId().toString() + act.getUser().getId().toString();
        if (!user_roles.containsKey(key)) {
            Hashtable value = new Hashtable();
            value.put("ROLE", act.getRole());
            value.put("USER", act.getUser());
            user_roles.put(key, value);
        }
    }
    Enumeration en = user_roles.keys();
    while (en.hasMoreElements()) {
        String key = (String) en.nextElement();
        Hashtable pair = (Hashtable) user_roles.get(key);
        actSearch.setBillable(new Boolean(true));
        actSearch.setStartStartDate(start);
        actSearch.setEndStartDate(end);
        ProjectRole pR = (ProjectRole) pair.get("ROLE");
        User u = (User) pair.get("USER");
        actSearch.setRole(pR);
        actSearch.setUser(u);
        List<Activity> actividadesUsuarioRol = activityDAO.search(actSearch, new SortCriteria("startDate", false));
        BillBreakDown brd = new BillBreakDown();
        brd.setConcept("Imputaciones (usuario - rol): " + u.getName() + " - " + pR.getName());
        brd.setAmount(pR.getCostPerHour());
        IvaApplicator.applyIvaToTaxableObject(start, brd);
        BigDecimal unitsTotal = new BigDecimal(0);
        for (Activity act : actividadesUsuarioRol) {
            BigDecimal unitsActual = new BigDecimal(act.getDuration());
            unitsActual = unitsActual.divide(new BigDecimal(60), 2, RoundingMode.HALF_UP);
            unitsTotal = unitsTotal.add(unitsActual);
        }
        brd.setUnits(unitsTotal);
        brd.setSelected(true);
        desgloses.add(brd);
    }
    ProjectCostDAO prjCostDAO = ProjectCostDAO.getDefault();
    ProjectCostSearch prjCostSearch = new ProjectCostSearch();
    prjCostSearch.setProject(project);
    List<ProjectCost> costes = prjCostDAO.search(prjCostSearch, new SortCriteria("id", false));
    for (ProjectCost proyCost : costes) {
        BillBreakDown brd = new BillBreakDown();
        brd.setConcept("Coste: " + proyCost.getName());
        brd.setUnits(new BigDecimal(1));
        brd.setAmount(proyCost.getCost());
        IvaApplicator.applyIvaToTaxableObject(start, brd);
        brd.setSelected(true);
        desgloses.add(brd);
    }
    return desgloses;
}
Also used : ProjectRoleDAO(com.autentia.tnt.dao.hibernate.ProjectRoleDAO) Enumeration(java.util.Enumeration) User(com.autentia.tnt.businessobject.User) ProjectCostDAO(com.autentia.tnt.dao.hibernate.ProjectCostDAO) Hashtable(java.util.Hashtable) ArrayList(java.util.ArrayList) ProjectCostSearch(com.autentia.tnt.dao.search.ProjectCostSearch) Activity(com.autentia.tnt.businessobject.Activity) ProjectRole(com.autentia.tnt.businessobject.ProjectRole) BigDecimal(java.math.BigDecimal) SortCriteria(com.autentia.tnt.dao.SortCriteria) ProjectRoleSearch(com.autentia.tnt.dao.search.ProjectRoleSearch) ActivitySearch(com.autentia.tnt.dao.search.ActivitySearch) ProjectCost(com.autentia.tnt.businessobject.ProjectCost) BillBreakDown(com.autentia.tnt.businessobject.BillBreakDown) ActivityDAO(com.autentia.tnt.dao.hibernate.ActivityDAO)

Example 3 with ProjectCost

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

the class BillManagerTest method getAllBitacoreBreakDownsHaveCorrectIvaFirstDayOf21IvaTest.

@Test
public void getAllBitacoreBreakDownsHaveCorrectIvaFirstDayOf21IvaTest() {
    final Project project = insertProjectIntoContext(firstDateFor21Iva);
    ProjectCost projectCost = createProjectCost(project);
    final GregorianCalendar calendarEnd = new GregorianCalendar(2012, 10, 1);
    final List<BillBreakDown> billBreakDownList = billManager.getAllBitacoreBreakDowns(firstDateFor21Iva, calendarEnd.getTime(), project);
    assertEquals(IVA21, billBreakDownList.get(0).getIva());
    assertEquals(IVA21, billBreakDownList.get(1).getIva());
    deleteProjectCostFromContext(projectCost);
    deleteProjectFromContext(project);
}
Also used : Project(com.autentia.tnt.businessobject.Project) GregorianCalendar(java.util.GregorianCalendar) ProjectCost(com.autentia.tnt.businessobject.ProjectCost) BillBreakDown(com.autentia.tnt.businessobject.BillBreakDown) Test(org.junit.Test)

Example 4 with ProjectCost

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

the class BillManagerTest method getAllBitacoreBreakDownsHaveCorrectIvaForJune2009Test.

@Test
public void getAllBitacoreBreakDownsHaveCorrectIvaForJune2009Test() {
    final Project project = insertProjectIntoContext(dateFor16Iva);
    ProjectCost projectCost = createProjectCost(project);
    final GregorianCalendar calendarEnd = new GregorianCalendar(2009, 10, 21);
    final List<BillBreakDown> billBreakDownList = billManager.getAllBitacoreBreakDowns(dateFor16Iva, calendarEnd.getTime(), project);
    assertEquals(IVA16, billBreakDownList.get(0).getIva());
    assertEquals(IVA16, billBreakDownList.get(1).getIva());
    deleteProjectCostFromContext(projectCost);
    deleteProjectFromContext(project);
}
Also used : Project(com.autentia.tnt.businessobject.Project) GregorianCalendar(java.util.GregorianCalendar) ProjectCost(com.autentia.tnt.businessobject.ProjectCost) BillBreakDown(com.autentia.tnt.businessobject.BillBreakDown) Test(org.junit.Test)

Example 5 with ProjectCost

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

the class BillManagerTest method getAllBitacoreBreakDownsHaveCorrectIvaFirstDayOf18IvaTest.

@Test
public void getAllBitacoreBreakDownsHaveCorrectIvaFirstDayOf18IvaTest() {
    final Project project = insertProjectIntoContext(firstDateFor18Iva);
    ProjectCost projectCost = createProjectCost(project);
    final GregorianCalendar calendarEnd = new GregorianCalendar(2010, 10, 1);
    final List<BillBreakDown> billBreakDownList = billManager.getAllBitacoreBreakDowns(firstDateFor18Iva, calendarEnd.getTime(), project);
    assertEquals(IVA18, billBreakDownList.get(0).getIva());
    assertEquals(IVA18, billBreakDownList.get(1).getIva());
    deleteProjectCostFromContext(projectCost);
    deleteProjectFromContext(project);
}
Also used : Project(com.autentia.tnt.businessobject.Project) GregorianCalendar(java.util.GregorianCalendar) ProjectCost(com.autentia.tnt.businessobject.ProjectCost) BillBreakDown(com.autentia.tnt.businessobject.BillBreakDown) Test(org.junit.Test)

Aggregations

ProjectCost (com.autentia.tnt.businessobject.ProjectCost)6 BillBreakDown (com.autentia.tnt.businessobject.BillBreakDown)5 Project (com.autentia.tnt.businessobject.Project)4 GregorianCalendar (java.util.GregorianCalendar)4 Test (org.junit.Test)4 BigDecimal (java.math.BigDecimal)2 Activity (com.autentia.tnt.businessobject.Activity)1 ProjectRole (com.autentia.tnt.businessobject.ProjectRole)1 User (com.autentia.tnt.businessobject.User)1 SortCriteria (com.autentia.tnt.dao.SortCriteria)1 ActivityDAO (com.autentia.tnt.dao.hibernate.ActivityDAO)1 ProjectCostDAO (com.autentia.tnt.dao.hibernate.ProjectCostDAO)1 ProjectRoleDAO (com.autentia.tnt.dao.hibernate.ProjectRoleDAO)1 ActivitySearch (com.autentia.tnt.dao.search.ActivitySearch)1 ProjectCostSearch (com.autentia.tnt.dao.search.ProjectCostSearch)1 ProjectRoleSearch (com.autentia.tnt.dao.search.ProjectRoleSearch)1 ArrayList (java.util.ArrayList)1 Enumeration (java.util.Enumeration)1 Hashtable (java.util.Hashtable)1