Search in sources :

Example 1 with OfferCost

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;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Offer(com.autentia.tnt.businessobject.Offer) Interaction(com.autentia.tnt.businessobject.Interaction) OfferCost(com.autentia.tnt.businessobject.OfferCost) OfferRole(com.autentia.tnt.businessobject.OfferRole)

Example 2 with OfferCost

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);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) OfferCost(com.autentia.tnt.businessobject.OfferCost) BigDecimal(java.math.BigDecimal)

Example 3 with OfferCost

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);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) OfferCost(com.autentia.tnt.businessobject.OfferCost) BigDecimal(java.math.BigDecimal)

Example 4 with OfferCost

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());
    }
}
Also used : GregorianCalendar(java.util.GregorianCalendar) OfferCost(com.autentia.tnt.businessobject.OfferCost) Test(org.junit.Test)

Example 5 with OfferCost

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;
}
Also used : OfferCost(com.autentia.tnt.businessobject.OfferCost) HashSet(java.util.HashSet)

Aggregations

OfferCost (com.autentia.tnt.businessobject.OfferCost)10 GregorianCalendar (java.util.GregorianCalendar)4 LinkedHashSet (java.util.LinkedHashSet)4 Test (org.junit.Test)4 BigDecimal (java.math.BigDecimal)2 BillBreakDown (com.autentia.tnt.businessobject.BillBreakDown)1 Interaction (com.autentia.tnt.businessobject.Interaction)1 Offer (com.autentia.tnt.businessobject.Offer)1 OfferRole (com.autentia.tnt.businessobject.OfferRole)1 SortCriteria (com.autentia.tnt.dao.SortCriteria)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 SelectItem (javax.faces.model.SelectItem)1