Iterator itr = s.iterator();
while(itr.hasNext() )
{
float taxRate = 0.0f;
ItemElement ie = (ItemElement)itemLines.get(itr.next());
int id = ((Integer)((IntMember)ie.get("ItemId")).getMemberValue()).intValue();
try
{
InitialContext ic = CVUtility.getInitialContext();
ItemLocalHome home = (ItemLocalHome)ic.lookup("local/Item");
ItemLocal itemLocal = home.create();
itemLocal.setDataSource(this.dataSource);
ItemVO item = itemLocal.getItem(userId,id);
int taxClassId = item.getTaxClassId();
int taxJurisdictionId = 0;
if (purchaseOrderVO.getShipToId()!=0)
{
ContactHelperLocalHome home1 = ( ContactHelperLocalHome )ic.lookup("local/ContactHelper");
ContactHelperLocal contactHelperLocal = home1.create();
contactHelperLocal.setDataSource(this.dataSource);
AddressVO addVO = contactHelperLocal.getAddress(purchaseOrderVO.getShipToId());
taxJurisdictionId = 0;
if (taxJurisdictionId !=0)
{
taxRate = getTax(taxClassId, taxJurisdictionId);
}//if (taxJurisdictionId !=0)
}//if InvoiceVO.shipToId!=null
((FloatMember)ie.get("UnitTaxrate")).setMemberValue(taxRate);
}catch (Exception e)
{
((FloatMember)ie.get("UnitTaxrate")).setMemberValue(0.0f);
System.out.println("[Exception][AccountHelperEJB.calculatePurchaseOrderItems] Exception Thrown: "+e);
}
}//while
}//if counter!=0
if (newItemID != null && !newItemID.equals("") )
{
st = new StringTokenizer(newItemID, ",");
while (st.hasMoreTokens())
{
try
{
float taxRate = 0.0f;
token = (String)st.nextToken();
int intToken = Integer.parseInt(token);
InitialContext ic = CVUtility.getInitialContext();
ItemLocalHome home = (ItemLocalHome)ic.lookup("local/Item");
ItemLocal itemLocal = home.create();
itemLocal.setDataSource(this.dataSource);
ItemVO item = itemLocal.getItem(userId,intToken);
//Get the Required Fields from the Item VO
String name = item.getItemName();
String sku = item.getSku();
float price = (float)item.getPrice();
int id = item.getItemId();
int taxClassId = item.getTaxClassId();
int taxJurisdictionId = 0;
if (purchaseOrderVO.getShipToId()!=0)
{
try
{
ContactHelperLocalHome home2 =( ContactHelperLocalHome)ic.lookup("local/ContactHelper");
ContactHelperLocal contactHelperLocal = home2.create();
contactHelperLocal.setDataSource(this.dataSource);
AddressVO addVO = contactHelperLocal.getAddress(purchaseOrderVO.getShipToId());
taxJurisdictionId = 0;
if (taxJurisdictionId !=0)
{
taxRate = getTax(taxClassId, taxJurisdictionId);
}//if (taxJurisdictionId !=0)
}catch(Exception e)
{
System.out.println("[Exception][AccountHelperEJB.calculatePurchaseOrderItems] Exception Thrown: "+e);
e.printStackTrace();
}
}//if shipToId !=null
//Form the ItemLines
counter += 1;
IntMember LineId = new IntMember("LineId",counter,10,"",'T',false,20);
IntMember ItemId = new IntMember("ItemId",id,10,"",'T',false,20);
StringMember SKU = new StringMember("SKU",sku,10,"",'T',false);
StringMember Description = new StringMember("Description",name,10,"",'T',false);
FloatMember Quantity = new FloatMember("Quantity",new Float(1.0f),10,"",'T',false,20);
FloatMember PriceEach = new FloatMember("PriceEach",new Float(price),10,"",'T',false,20);
FloatMember PriceExtended = new FloatMember("PriceExtended",new Float(0.0f),10,"",'T',false,20);
FloatMember UnitTax = new FloatMember("UnitTax",new Float(0.0f),10,"",'T',false,20);
FloatMember TaxRate = new FloatMember("UnitTaxrate",new Float(taxRate),10,"",'T',false,20);
FloatMember OrderQuantity = new FloatMember("OrderQuantity",new Float(1.0f),10,"",'T',false,20);
FloatMember PendingQuantity = new FloatMember("PendingQuantity",new Float(0.0f),10,"",'T',false,20);
ItemElement ie = new ItemElement(counter);
ie.put ("LineId",LineId);
ie.put ("ItemId",ItemId);
ie.put ("SKU",SKU);
ie.put ("Description",Description);
ie.put ("Quantity",Quantity);
ie.put ("PriceEach",PriceEach);
ie.put ("PriceExtended",PriceExtended);
ie.put ("UnitTax",UnitTax);
ie.put ("UnitTaxrate",TaxRate);
ie.put ("OrderQuantity",OrderQuantity);
ie.put ("PendingQuantity",PendingQuantity);
ie.setLineStatus("New");
itemLines.put(new Integer(counter), ie);
}catch(Exception e)
{
System.out.println("[Exception][AccountHelperEJB.calculatePurchaseOrderItems] Exception Thrown: "+e);