1 4 package com.nightlabs.ipanema.trade; 5 6 import java.util.Collection ; 7 import java.util.Iterator ; 8 9 20 public class OfferPrice extends com.nightlabs.ipanema.accounting.Price 21 { 22 25 private Offer offer; 26 27 public OfferPrice() { } 28 29 36 public OfferPrice(Offer offer, String organisationID, long priceConfigID, long priceID) 37 { 38 super(organisationID, priceConfigID, priceID, offer.getCurrency()); 39 this.offer = offer; 40 41 calculatePrice(); 42 } 43 44 protected void calculatePrice() 45 { 46 setAmount(0); 47 clearFragments(); 48 49 for (int i = 0; i < 2; ++i) { 50 Collection items; 51 if (i == 0) 52 items = offer.getItemsToSell(); 53 else 54 items = offer.getItemsToRefund(); 55 56 for (Iterator it = items.iterator(); it.hasNext(); ) { 57 OfferItem offerItem = (OfferItem)it.next(); 58 OfferItemPrice offerItemPrice = offerItem.getPrice(); 59 sumPrice(offerItemPrice); 60 } 61 } 62 } 63 64 67 protected Offer getOffer() 68 { 69 return offer; 70 } 71 } 72 | Popular Tags |