use of com.autentia.tnt.businessobject.OfferCost 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.OfferCost in project TNTConcept by autentia.
the class DuplicateOfferTest method insertOfferCosts.
/**
* Inserta costes materiales en la ofertas
*/
private void insertOfferCosts() {
final Set<OfferCost> offerCosts = new LinkedHashSet<OfferCost>(2);
final OfferCost paneles = new OfferCost();
paneles.setBillable(true);
paneles.setCost(new BigDecimal(1000));
paneles.setIva(new BigDecimal(16));
paneles.setName("paneles");
paneles.setUnits(new BigDecimal(5));
paneles.setOffer(offer);
final OfferCost cristales = new OfferCost();
cristales.setBillable(false);
cristales.setCost(new BigDecimal(10));
cristales.setIva(new BigDecimal(16));
cristales.setName("paneles");
cristales.setUnits(new BigDecimal(1));
cristales.setOffer(offer);
offerCosts.add(paneles);
offerCosts.add(cristales);
offer.setCosts(offerCosts);
}
use of com.autentia.tnt.businessobject.OfferCost in project TNTConcept by autentia.
the class FromOfferToBillTest method insertOfferCosts.
/**
* Inserta costes materiales en la ofertas
*/
private void insertOfferCosts() {
final Set<OfferCost> offerCosts = new LinkedHashSet<OfferCost>(2);
final OfferCost paneles = new OfferCost();
paneles.setBillable(true);
paneles.setCost(new BigDecimal(1000));
paneles.setIva(new BigDecimal(16));
paneles.setName("paneles");
paneles.setUnits(new BigDecimal(5));
paneles.setOffer(offer);
final OfferCost cristales = new OfferCost();
cristales.setBillable(false);
cristales.setCost(new BigDecimal(10));
cristales.setIva(new BigDecimal(16));
cristales.setName("paneles");
cristales.setUnits(new BigDecimal(1));
cristales.setOffer(offer);
offerCosts.add(paneles);
offerCosts.add(cristales);
offer.setCosts(offerCosts);
}
use of com.autentia.tnt.businessobject.OfferCost in project TNTConcept by autentia.
the class OfferBeanTest method createCostsInFirstDayOf21Test.
@Test
public void createCostsInFirstDayOf21Test() {
OfferBean offerBean = new OfferBean();
offerBean.create();
final GregorianCalendar calendar = new GregorianCalendar(2012, 8, 1);
offerBean.setCreationDate(calendar.getTime());
offerBean.createCosts();
for (OfferCost offerCost : offerBean.getCosts()) {
assertEquals(IVA21, offerCost.getIva());
}
}
use of com.autentia.tnt.businessobject.OfferCost in project TNTConcept by autentia.
the class OfferBean method createCosts.
/**
* Create a new empty instance of the one-to-many field
*
* @return forward to the same page
*/
public String createCosts() {
OfferCost item = new OfferCost();
item.setOffer(offer);
IvaApplicator.applyIvaToTaxableObject(offer.getCreationDate(), item);
if (offer.getCosts() == null) {
offer.setCosts(new HashSet());
}
offer.getCosts().add(item);
return null;
}
Aggregations