use of com.autentia.tnt.businessobject.OfferRole in project TNTConcept by autentia.
the class OfferManager method duplicateOffer.
/* Offer - generated by stajanov (do not edit/delete) */
public Offer duplicateOffer(final Offer offer) {
final Set<Interaction> interactions = new LinkedHashSet<Interaction>();
final Set<OfferRole> offerRoles = new LinkedHashSet<OfferRole>();
final Set<OfferCost> offerCosts = new LinkedHashSet<OfferCost>();
// copy simple data and delete identificative info
final Offer duplicatedOffer = (Offer) SerializationUtils.clone(offer);
duplicatedOffer.setId(null);
duplicatedOffer.setNumber(null);
// copy interactions
if (offer.getInteractions() != null) {
for (Interaction interaction : offer.getInteractions()) {
Interaction duplicatedInteraction = (Interaction) SerializationUtils.clone(interaction);
duplicatedInteraction.setId(null);
duplicatedInteraction.setOffer(duplicatedOffer);
interactions.add(duplicatedInteraction);
}
}
duplicatedOffer.setInteractions(interactions);
// copy roles
if (offer.getRoles() != null) {
for (OfferRole offerRole : offer.getRoles()) {
OfferRole duplicatedRole = (OfferRole) SerializationUtils.clone(offerRole);
duplicatedRole.setId(null);
duplicatedRole.setOffer(duplicatedOffer);
offerRoles.add(duplicatedRole);
}
}
duplicatedOffer.setRoles(offerRoles);
// copy costs
if (offer.getCosts() != null) {
for (OfferCost offerCost : offer.getCosts()) {
OfferCost duplicatedCost = (OfferCost) SerializationUtils.clone(offerCost);
duplicatedCost.setId(null);
duplicatedCost.setOffer(duplicatedOffer);
offerCosts.add(duplicatedCost);
}
}
duplicatedOffer.setCosts(offerCosts);
return duplicatedOffer;
}
use of com.autentia.tnt.businessobject.OfferRole 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.OfferRole in project TNTConcept by autentia.
the class OfferBeanTest method createRolesIn2009Test.
@Test
public void createRolesIn2009Test() {
final OfferBean offerBean = new OfferBean();
offerBean.create();
final GregorianCalendar calendar = new GregorianCalendar(2009, 8, 31);
offerBean.setCreationDate(calendar.getTime());
offerBean.createRoles();
for (OfferRole offerRole : offerBean.getRoles()) {
assertEquals(IVA16, offerRole.getIva());
}
}
use of com.autentia.tnt.businessobject.OfferRole in project TNTConcept by autentia.
the class OfferBeanTest method createRolesInLastDayOf18Test.
@Test
public void createRolesInLastDayOf18Test() {
OfferBean offerBean = new OfferBean();
offerBean.create();
final GregorianCalendar calendar = new GregorianCalendar(2012, 7, 31);
offerBean.setCreationDate(calendar.getTime());
offerBean.createRoles();
for (OfferRole offerRole : offerBean.getRoles()) {
assertEquals(IVA18, offerRole.getIva());
}
}
use of com.autentia.tnt.businessobject.OfferRole in project TNTConcept by autentia.
the class OfferBean method createRoles.
// 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 createRoles() {
OfferRole item = new OfferRole();
item.setOffer(offer);
IvaApplicator.applyIvaToTaxableObject(offer.getCreationDate(), item);
if (offer.getRoles() == null) {
offer.setRoles(new HashSet());
}
offer.getRoles().add(item);
return null;
}
Aggregations