Search in sources :

Example 6 with Activity

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

the class ActivityEvidenceNotificationBean method groupedActivitiesByProject.

private HashMap<Project, List<Activity>> groupedActivitiesByProject(List<Activity> activities) {
    HashMap<Project, List<Activity>> map = new HashMap<>();
    activities.forEach(activity -> {
        Project project = activity.getRole().getProject();
        List<Activity> prjActivities = map.getOrDefault(project, new ArrayList<>());
        prjActivities.add(activity);
        map.put(project, prjActivities);
    });
    return map;
}
Also used : Project(com.autentia.tnt.businessobject.Project) Activity(com.autentia.tnt.businessobject.Activity)

Example 7 with Activity

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

the class BillManagerTest method createActivitiesForContext.

private Set<Activity> createActivitiesForContext(ProjectRole role, Date date) {
    final Set<Activity> activities = new HashSet<Activity>();
    final Activity activity = new Activity();
    activity.setRole(role);
    activity.setUser(SpringUtilsForTesting.createUserInContextWithRoleAndDepartment());
    activity.setBillable(true);
    activity.setStartDate(date);
    activities.add(activity);
    return activities;
}
Also used : Activity(com.autentia.tnt.businessobject.Activity) HashSet(java.util.HashSet)

Example 8 with Activity

use of com.autentia.tnt.businessobject.Activity 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 9 with Activity

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

the class ActivityManager method workedTime.

/**
 * Time worked.
 * @param activities to count working time
 * @return Time worked
 */
public long workedTime(final List<Activity> activities) {
    long duration = 0L;
    List<Integer> notWorkableProjectIds = ConfigurationUtil.getDefault().getNotWorkingTimeProjectIds();
    for (Activity activity : activities) {
        if (!notWorkableProjectIds.contains(activity.getRole().getProject().getId())) {
            duration += activity.getDuration();
        }
    }
    return duration;
}
Also used : Activity(com.autentia.tnt.businessobject.Activity)

Example 10 with Activity

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

the class ActivityImageUploaderTest method imageShouldBeSaved.

@Test
public void imageShouldBeSaved() throws IOException {
    Activity activity = mock(Activity.class);
    UploadedFile file = mock(UploadedFile.class);
    when(activity.getId()).thenReturn(666);
    when(activity.getStartDate()).thenReturn(new Date());
    when(activity.getEndDate()).thenReturn(new Date());
    when(activity.getInsertDate()).thenReturn(new Date());
    InputStream inputStream = getClass().getClassLoader().getResourceAsStream("testImage.jpg");
    when(file.getInputStream()).thenReturn(inputStream);
    ActivityImageUploader.store(file, activity);
}
Also used : UploadedFile(org.apache.myfaces.custom.fileupload.UploadedFile) InputStream(java.io.InputStream) Activity(com.autentia.tnt.businessobject.Activity) Date(java.util.Date) Test(org.junit.Test)

Aggregations

Activity (com.autentia.tnt.businessobject.Activity)16 ActivitySearch (com.autentia.tnt.dao.search.ActivitySearch)8 Project (com.autentia.tnt.businessobject.Project)6 SortCriteria (com.autentia.tnt.dao.SortCriteria)6 User (com.autentia.tnt.businessobject.User)5 Calendar (java.util.Calendar)5 ExternalActivity (com.autentia.tnt.businessobject.ExternalActivity)4 ProjectRole (com.autentia.tnt.businessobject.ProjectRole)3 AccountEntry (com.autentia.tnt.businessobject.AccountEntry)2 AccountEntryType (com.autentia.tnt.businessobject.AccountEntryType)2 AdminHoliday (com.autentia.tnt.businessobject.AdminHoliday)2 Bill (com.autentia.tnt.businessobject.Bill)2 Book (com.autentia.tnt.businessobject.Book)2 BulletinBoard (com.autentia.tnt.businessobject.BulletinBoard)2 BulletinBoardCategory (com.autentia.tnt.businessobject.BulletinBoardCategory)2 CompanyState (com.autentia.tnt.businessobject.CompanyState)2 Contact (com.autentia.tnt.businessobject.Contact)2 ContractType (com.autentia.tnt.businessobject.ContractType)2 Department (com.autentia.tnt.businessobject.Department)2 FinancialRatio (com.autentia.tnt.businessobject.FinancialRatio)2