use of com.autentia.tnt.businessobject.BillBreakDown 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;
}
use of com.autentia.tnt.businessobject.BillBreakDown in project TNTConcept by autentia.
the class BillManager method convertFromOfferToBill.
public Bill convertFromOfferToBill(final Offer offer) {
final Bill bill = new Bill();
// simple values
bill.setContact(offer.getContact());
bill.setName(offer.getDescription());
bill.setState(BillState.EMITTED);
bill.setBillType(BillType.ISSUED);
// concepts
final Set<BillBreakDown> billBreakDowns = new LinkedHashSet<BillBreakDown>();
billBreakDowns.addAll(convertFromOfferCostsToBillBreakDowns(bill, offer.getCosts()));
billBreakDowns.addAll(convertFromOfferRolesToBillBreakDowns(bill, offer.getRoles()));
bill.setBreakDown(billBreakDowns);
return bill;
}
use of com.autentia.tnt.businessobject.BillBreakDown in project TNTConcept by autentia.
the class BillManager method convertFromOfferRolesToBillBreakDowns.
private Set<BillBreakDown> convertFromOfferRolesToBillBreakDowns(final Bill bill, final Set<OfferRole> offerRoles) {
final Set<BillBreakDown> billBreakDowns = new LinkedHashSet<BillBreakDown>();
if (offerRoles != null) {
for (OfferRole role : offerRoles) {
BillBreakDown billBreakDown = new BillBreakDown();
billBreakDown.setConcept(role.getName());
billBreakDown.setUnits(new BigDecimal(role.getExpectedHours()));
billBreakDown.setAmount(role.getCostPerHour());
billBreakDown.setIva(role.getIva());
billBreakDown.setBill(bill);
billBreakDowns.add(billBreakDown);
}
}
return billBreakDowns;
}
use of com.autentia.tnt.businessobject.BillBreakDown in project TNTConcept by autentia.
the class BillBeanTest method createBreakDownInLastDayOf18Test.
@Test
public void createBreakDownInLastDayOf18Test() {
this.prepareTestsIVA();
final GregorianCalendar calendar = new GregorianCalendar(2012, 7, 31);
billBean.setCreationDate(calendar.getTime());
billBean.createBreakDown();
for (BillBreakDown billBreakDown : billBean.getBill().getBreakDown()) {
assertThat(billBreakDown.getIva(), is(new BigDecimal(IVA_UNTIL_SEPT_2012)));
}
}
use of com.autentia.tnt.businessobject.BillBreakDown in project TNTConcept by autentia.
the class BillBeanTest method createBreakDownInFirstDayOf18Test.
@Test
public void createBreakDownInFirstDayOf18Test() {
this.prepareTestsIVA();
final GregorianCalendar calendar = new GregorianCalendar(2010, 6, 1);
billBean.setCreationDate(calendar.getTime());
billBean.createBreakDown();
for (BillBreakDown billBreakDown : billBean.getBill().getBreakDown()) {
assertThat(billBreakDown.getIva(), is(new BigDecimal(IVA_UNTIL_SEPT_2012)));
}
}
Aggregations