Package com.centraview.account.common

Examples of com.centraview.account.common.ItemLines


    try
    {
      PurchaseOrderForm purchaseForm = (PurchaseOrderForm)form;
      purchaseForm.convertItemLines();

      ItemLines itemLines = null;

      HttpSession session = request.getSession(true);
      UserObject  userobjectd = (UserObject)session.getAttribute( "userobject" );//get the user object
      int individualID = userobjectd.getIndividualID();

      request.setAttribute(AccountConstantKeys.TYPEOFSUBMODULE, AccountConstantKeys.PURCHASEORDER);

      request.setAttribute("body",AccountConstantKeys.EDIT);

      String typeOfOperation = request.getParameter(AccountConstantKeys.TYPEOFOPERATION);

      if ( typeOfOperation != null &&  typeOfOperation.equals("ShowPurchaseOrder"))
      {
        int purchaseID = 0;
        String purchaseIDStr = (String)request.getParameter("rowId");

        if(purchaseIDStr != null && !purchaseIDStr.equals(""))
          purchaseID  = Integer.parseInt(purchaseIDStr);

        // for getting data from EJB
        AccountFacade remote =(AccountFacade)accountFacadeHome.create();
        remote.setDataSource(dataSource);

        PurchaseOrderVO vo = remote.getPurchaseOrderVO(purchaseID,individualID);

        purchaseForm.setPurchaseOrderid(vo.getPurchaseOrderId()+"");
        purchaseForm.setVendorId(vo.getVendorId()+"");
        //      purchaseForm.setCustomerId(vo.getCustomerId()+"");

        purchaseForm.setBillto(vo.getBillToAddress()+"");
        purchaseForm.setBilltoID(vo.getBillToId()+"");

        purchaseForm.setShiptoID(vo.getShipToId()+"");
        purchaseForm.setShipto(vo.getShipToAddress()+"");

        purchaseForm.setStatusid(vo.getStatusId()+"");
        purchaseForm.setPurchaseOrderDate(vo.getPurchaseOrderDate());

        purchaseForm.setPoid(vo.getPurchaseOrderId()+"");
        purchaseForm.setTermid(vo.getTermId()+"");
        purchaseForm.setAccountmanagerid(vo.getAccountManagerId()+"");

        purchaseForm.setNotes(vo.getNotes());
        purchaseForm.setAccountmanagerName(vo.getAccountManagerName());
        purchaseForm.setItemLines(vo.getItemLines());
        itemLines = vo.getItemLines();

        purchaseForm.setVendorName(vo.getVendorName());
        java.sql.Date invDate = vo.getPurchaseOrderDate();

        if (invDate != null)
        {
          int month = invDate.getMonth();
          purchaseForm.setMonth(month+"");

          int date = invDate.getDate();
          purchaseForm.setDate(date+"");

          int year= invDate.getYear();
          purchaseForm.setYear(year+"");
        }//end of if (invDate != null)
        form = purchaseForm;
        request.setAttribute(AccountConstantKeys.TYPEOFOPERATION,"ShowPurchaseOrder");
      }//end of if ( typeOfOperation != null &&  typeOfOperation.equals("ShowPurchaseOrder"))
      else if ( typeOfOperation != null && typeOfOperation.equals("REMOVEITEM") )
      {
        String removeIDs = request.getParameter("removeID");
        StringTokenizer st;
        Iterator itr;
        Vector removeKeys = new Vector();

        itemLines = ((PurchaseOrderForm)form).getItemLines();
        if (itemLines != null)
        {
          st = new StringTokenizer(removeIDs, ",");
          while (st.hasMoreTokens())
          {
            String str = st.nextToken();
            int removeToken = Integer.parseInt(str);

            itr = itemLines.keySet().iterator();
            while (itr.hasNext())
            {
              Object obj = itr.next();
              ItemElement ILE = (ItemElement)itemLines.get(obj);
              IntMember ItemId = (IntMember)ILE.get("ItemId");
              Integer currItemId = (Integer)ItemId.getMemberValue();
              if ( currItemId.intValue() == removeToken)
              {
                String status = ILE.getLineStatus();
                if (status.equals("Active"))
                {
                  ILE.setLineStatus("Deleted");
                }//end of if (status.equals("Active"))
                else if (status.equals("New"))
                {
                  removeKeys.add(obj);
                }// end of else if (status.equals("New"))
              }//end of if ( currItemId.intValue() == removeToken)
            }//end of while (itr.hasNext())
          }//end of while (st.hasMoreTokens())

          for(int i=0; i<removeKeys.size(); i++)
          {
            itemLines.remove(removeKeys.get(i));
          }// end of for(int i=0; i<removeKeys.size(); i++)
        }// end of if (itemLines != null)

        ((PurchaseOrderForm)form).setItemLines(itemLines);
        request.setAttribute(AccountConstantKeys.TYPEOFOPERATION,"REMOVEITEM");
      }//end of else if ( typeOfOperation != null && typeOfOperation.equals("REMOVEITEM") )
      /*ADD item*/
      else if ( typeOfOperation != null && typeOfOperation.equals("ADDITEM") )
      {

        String newItemID = request.getParameter("theitemid");
        ItemList IL = null ;
        ListGenerator lg = ListGenerator.getListGenerator(dataSource);//get the List Generator object for Listing
        IL = (ItemList )lg.getItemList( individualID , 1, 10 , "" , "ItemID");//called when the request for the list is for first time

        StringTokenizer st;
        String token, nextItr;

        if (newItemID != null)
        {
          st = new StringTokenizer(newItemID, ",");
          itemLines = ((PurchaseOrderForm)form).getItemLines();

          if(itemLines == null)
          itemLines = new ItemLines();
          int counter = itemLines.size();
          while (st.hasMoreTokens())
          {
            token   = (String)st.nextToken();
            int intToken = Integer.parseInt(token);

            Iterator itr = IL.keySet().iterator();
            while (itr.hasNext())
            {
              nextItr = (String)itr.next();
              ListElement ile = (ListElement)IL.get(nextItr);
              IntMember smid = (IntMember)ile.get("ItemID");
              Integer listItemid = (Integer)smid.getMemberValue();
              if ( listItemid.intValue() == intToken )
              {
                StringMember smName = (StringMember)ile.get("Name"); // name = description
                String name = (String) smName.getMemberValue();

                StringMember smSku  = (StringMember) ile.get("SKU");
                String sku = (String)smSku.getMemberValue();
                FloatMember dmprice  = (FloatMember) ile.get("Price");

                float price = Float.parseFloat((dmprice.getMemberValue()).toString());

                int id = ile.getElementID();

                IntMember LineId = new IntMember("LineId",0,'D',"",'T',false,20);
                IntMember ItemId = new IntMember("ItemId",id,'D',"",'T',false,20);
                IntMember  Quantity = new IntMember("Quantity",1,'D',"",'T',false,20);
                FloatMember  PriceEach = new FloatMember("Price",new Float(price),'D',"",'T',false,20);
                StringMember SKU = new StringMember("SKU",sku,'D',"",'T',false);
                StringMember Description = new StringMember("Description",name,'D',"",'T',false);
                FloatMember  PriceExtended = new FloatMember("PriceExtended",new Float(0.0f),'D',"",'T',false,20);

                ItemElement ie = new ItemElement(0);
                ie.put ("LineId",LineId);
                ie.put ("ItemId",ItemId);
                ie.put ("SKU",SKU);
                ie.put ("Description",Description);
                ie.put ("Quantity",Quantity);
                ie.put ("Price",PriceEach);
                ie.put ("PriceExtended",PriceExtended);

                ie.setLineStatus("New");
                counter += 1;
                itemLines.put(new Integer(counter), ie);
                break;
              }// end of if ( listItemid.intValue() == intToken )
            }// end of while (itr.hasNext())
          }// end of while (st.hasMoreTokens())
          ((PurchaseOrderForm)form).setItemLines(itemLines);
View Full Code Here


      boolean itemPresent =false;
      int counter = 0;

      if (this.itemid != null)
      {
        ItemLines lines = this.getItemLines();

        for (int i=0;i<this.linestatus.length;i++)
        {
          if (this.linestatus[i] != null &&
              this.linestatus[i].equalsIgnoreCase("Deleted"))
View Full Code Here

  }

  public void  convertItemLines()
  {
    int count;
    itemLines= new ItemLines();
    if (itemid != null)
    {
      for (int i=0;i<itemid.length;i++)
      {
        ItemElement ie = new ItemElement();
View Full Code Here

        Vector removeKeys = new Vector();
       
        ((OrderForm)form).convertArrayToItemLines();
        ((OrderForm)form).convertFormbeanToValueObject("edit");
       
        ItemLines itemLines = ((OrderForm)form).getItemLines();
        if (itemLines != null) {
          st = new StringTokenizer(removeIDs, ",");
          while (st.hasMoreTokens()) {
            String str = st.nextToken();
            int removeToken = Integer.parseInt(str);
           
            itr = itemLines.keySet().iterator();
            while (itr.hasNext()) {
              Object obj = itr.next();
              ItemElement ILE = (ItemElement)itemLines.get(obj);
              IntMember ItemId = (IntMember)ILE.get("ItemId");
              Integer currItemId = (Integer)ItemId.getMemberValue();
              if (currItemId.intValue() == removeToken) {
                String status = ILE.getLineStatus();
                if (status.equals("Active")) {
                  ILE.setLineStatus("Deleted");
                } else if (status.equals("New")) {
                  removeKeys.add(obj);
                }
              }
            }
          }   // end while (st.hasMoreTokens())
         
          for (int i = 0; i < removeKeys.size(); i++) {
            itemLines.remove(removeKeys.get(i));
          }
        }
       
        ((OrderForm)form).setJurisdictionVec(taxJurisdiction);
        ((OrderForm)form).setItemLines(itemLines);
        request.setAttribute("ItemLines",itemLines);
      }
     
      if (typeOfOperation != null && typeOfOperation.equals("ADDITEM")) {
        String newItemID = request.getParameter("theitemid");
        ItemList IL = null;
        ListGenerator lg = ListGenerator.getListGenerator(dataSource);
        IL = (ItemList)lg.getItemList(individualID, 1, 10, "", "ItemID");
       
        OrderForm orderForm = (OrderForm)form;
        orderForm.convertArrayToItemLines();
        orderForm.convertFormbeanToValueObject("edit");
       
        StringTokenizer st;
        String token, nextItr;
       
        if (newItemID != null) {
          st = new StringTokenizer(newItemID, ",");
          ItemLines itemLines = (orderForm).getItemLines();
          Integer intJurisdictionID = (orderForm).getJurisdictionID();
          int jurisdictionID = intJurisdictionID.intValue();
         
          if (itemLines == null) {
            itemLines = new ItemLines();
          }
          int counter = itemLines.size();
         
          while (st.hasMoreTokens()) {
            token = (String)st.nextToken();
            int intToken = Integer.parseInt(token);
           
            Iterator itr = IL.keySet().iterator();
            while (itr.hasNext()) {
              nextItr = (String)itr.next();
              ListElement ile = (ListElement)IL.get(nextItr);
              IntMember smid = (IntMember)ile.get("ItemID");
              Integer listItemid = (Integer)smid.getMemberValue();
             
              if (listItemid.intValue() == intToken) {
                StringMember smName = (StringMember)ile.get("Name"); // name = description
                String name = (String)smName.getMemberValue();
               
                StringMember smSku = (StringMember)ile.get("SKU");
                String sku = (String)smSku.getMemberValue();
                FloatMember dmprice = (FloatMember)ile.get("Price");
               
                float price = Float.parseFloat((dmprice.getMemberValue()).toString());
               
                int id = ile.getElementID();
               
                IntMember LineId = new IntMember("LineId", 0, 'D', "", 'T', false, 20);
                IntMember ItemId = new IntMember("ItemId", id, 'D', "", 'T', false, 20);
                IntMember Quantity = new IntMember("Quantity", 1, 'D', "", 'T', false, 20);
                FloatMember PriceEach = new FloatMember("Price", new Float(price), 'D', "", 'T', false, 20);
                StringMember SKU = new StringMember("SKU", sku, 'D', "", 'T', false);
                StringMember Description = new StringMember("Description", name, 'D', "", 'T', false);
                FloatMember PriceExtended = new FloatMember("PriceExtended", new Float(0.0f), 'D', "", 'T', false, 20);
                FloatMember TaxAmount = new FloatMember("TaxAmount", new Float(0.0f), 'D', "", 'T', false, 20);

                ItemElement ie = new ItemElement(0);
                ie.put("LineId", LineId);
                ie.put("ItemId", ItemId);
                ie.put("SKU", SKU);
                ie.put("Description", Description);
                ie.put("Quantity", Quantity);
                ie.put("Price", PriceEach);
                ie.put("PriceExtended", PriceExtended);
                ie.put("TaxAmount", TaxAmount);

                ie.setLineStatus("New");
                counter += 1;
                itemLines.put(new Integer(counter), ie);
                break;
              }   // end if (listItemid.intValue() == intToken)
            }   // end while (itr.hasNext())
          }   // end while (st.hasMoreTokens())
          orderForm.setJurisdictionVec(taxJurisdiction);
          itemLines.calculate();
          orderForm.setItemLines(itemLines);
        }   // end if (newItemID != null)
       
        request.setAttribute("orderform",orderForm);
        request.setAttribute("ItemLines",orderForm.getItemLines());
View Full Code Here

  }

  /* convertItemLines method added for Item Lines */
  public void convertItemLines()
  {
    itemLines = new ItemLines();

    if (itemid != null) {
      for (int i = 0; i < itemid.length; i++) {

        ItemElement ie = new ItemElement();
View Full Code Here

      HttpSession session = request.getSession(true);
      request.setAttribute(AccountConstantKeys.TYPEOFSUBMODULE, AccountConstantKeys.EXPENSE);
      request.setAttribute("body", "ADD");

      ExpenseForm expenseForm = (ExpenseForm)form;
      ItemLines itemLines=null;
      expenseForm.convertItemLines();
      com.centraview.common.UserObject  userobjectd = (com.centraview.common.UserObject)session.getAttribute( "userobject" );//get the user object
      int individualID = userobjectd.getIndividualID();

      int expenseID = 0;

      UserPrefererences userPref = userobjectd.getUserPref();
      String dateFormat  = userPref.getDateFormat();

      dateFormat= "M/d/yyyy";
      String timeZone    = userPref.getTimeZone();
      if(timeZone == null)
        timeZone = "EST";

      GregorianCalendar gCal = new GregorianCalendar(TimeZone.getTimeZone(timeZone));
      SimpleDateFormat dForm = new SimpleDateFormat(dateFormat);
      dForm.setCalendar(gCal);


      String typeOfOperation = request.getParameter(AccountConstantKeys.TYPEOFOPERATION);

      /*
      Remove item
      */
      if(typeOfOperation != null &&  typeOfOperation.equals("REMOVEITEM") )
      {
        String removeIDs = request.getParameter("removeID");
        StringTokenizer st;
        Iterator itr;
        Vector removeKeys = new Vector();

        itemLines = expenseForm.getItemLines();
        if (itemLines != null)
        {
          st = new StringTokenizer(removeIDs, ",");
          while (st.hasMoreTokens())
          {
            String str = st.nextToken();
            int removeToken = Integer.parseInt(str);

            itr = itemLines.keySet().iterator();
            while (itr.hasNext())
            {
              Object obj = itr.next();
              ItemElement ILE = (ItemElement)itemLines.get(obj);
              IntMember ItemId = (IntMember)ILE.get("ItemId");
              Integer currItemId = (Integer)ItemId.getMemberValue();
              if ( currItemId.intValue() == removeToken)
              {
                String status = ILE.getLineStatus();
                if (status.equals("Active"))
                {
                  ILE.setLineStatus("Deleted");
                }//end of if (status.equals("Active"))
                else  if (status.equals("New"))
                {
                  removeKeys.add(obj);
                }//end of else  if (status.equals("New"))
              }//end of if ( currItemId.intValue() == removeToken)
            }//end of while (itr.hasNext())
          }//end of while (st.hasMoreTokens())

          for(int i=0; i<removeKeys.size(); i++)
          {
            itemLines.remove(removeKeys.get(i));
          }// end of for(int i=0; i<removeKeys.size(); i++)
        }//end of if (itemLines != null)

        expenseForm.setItemLines(itemLines);
        request.setAttribute("expenseform",expenseForm);

      }// end of if(typeOfOperation != null &&  typeOfOperation.equals("REMOVEITEM") )
      /*  ADD item  */
      else if(typeOfOperation != null && typeOfOperation.equals("ADDITEM") )
      {
        String newItemID = request.getParameter("theitemid");
        ItemList IL = null ;
        ListGenerator lg = ListGenerator.getListGenerator(dataSource);//get the List Generator object for Listing
        IL = (ItemList )lg.getItemList( individualID , 1, 10 , "" , "ItemID");//called when the request for the list is for first time

        StringTokenizer st;
        String token, nextItr;

        if (newItemID != null)
        {
          st = new StringTokenizer(newItemID, ",");
          itemLines = (expenseForm).getItemLines();

          if(itemLines == null)
            itemLines = new ItemLines();
          int counter = itemLines.size();
          while (st.hasMoreTokens())
          {
            token   = (String)st.nextToken();
            int intToken = Integer.parseInt(token);
            Iterator itr = IL.keySet().iterator();
            while (itr.hasNext())
            {
              nextItr = (String)itr.next();
              ListElement ile = (ListElement)IL.get(nextItr);
              IntMember smid = (IntMember)ile.get("ItemID");
              Integer listItemid = (Integer)smid.getMemberValue();

              if ( listItemid.intValue() == intToken )
              {

                StringMember smName = (StringMember)ile.get("Name"); // name = description
                String name = (String) smName.getMemberValue();

                StringMember smSku  = (StringMember) ile.get("SKU");
                String sku = (String)smSku.getMemberValue();
                FloatMember dmprice  = (FloatMember) ile.get("Price");

                float price = Float.parseFloat((dmprice.getMemberValue()).toString());

                int id = ile.getElementID();

                IntMember LineId = new IntMember("LineId",0,'D',"",'T',false,20);
                IntMember ItemId = new IntMember("ItemId",id,'D',"",'T',false,20);
                IntMember  Quantity = new IntMember("Quantity",1,'D',"",'T',false,20);
                FloatMember  PriceEach = new FloatMember("Price",new Float(price),'D',"",'T',false,20);
                StringMember SKU = new StringMember("SKU",sku,'D',"",'T',false);
                StringMember Description = new StringMember("Description",name,'D',"",'T',false);
                FloatMember  PriceExtended = new FloatMember("PriceExtended",new Float(0.0f),'D',"",'T',false,20);

                ItemElement ie = new ItemElement(0);
                ie.put ("LineId",LineId);
                ie.put ("ItemId",ItemId);
                ie.put ("SKU",SKU);
                ie.put ("Description",Description);
                ie.put ("Quantity",Quantity);
                ie.put ("Price",PriceEach);
                ie.put ("PriceExtended",PriceExtended);

                ie.setLineStatus("New");
                counter += 1;
                itemLines.put(new Integer(counter), ie);
                break;
              }// end of if ( listItemid.intValue() == intToken )
            }// end of while (itr.hasNext())
          }// end of while (st.hasMoreTokens())
          expenseForm.setItemLines(itemLines);
View Full Code Here

              tmpXML = "<" + tagName + "> \n" + "<" + TAG_LISTID + ">" + ret + "</" + TAG_LISTID + ">" + "</" + tagName + "> \n";
          }
        }
      } else if (attr.getNamedItem("cvtoaa").getNodeValue().equals("getTagsFromItemLines"))
      {
        ItemLines itemLines = null;
        method = classCV[0].getMethod("getItemLines", null);
        itemLines = (ItemLines)method.invoke(objectCV, null);
        tmpXML = getTagsFromItemLines(itemLines, tagName);
      } else
      {
View Full Code Here

   *@param String QB X-LineRet Tag values
   *@return ItemLines
   */
  public ItemLines getItemLinesFromTags(NodeList list)
  {
    ItemLines itemLines = new ItemLines();

    int length = list.getLength();

    Document document = null;

    for (int j = 0; j < length; j++)
    {
      document = getDocumentFromString(list.item(j).toString());

      ItemElement ie = new ItemElement();

      int itemId = 0;

      String sku = "";
      String externalID = "";
      String cvID = "";
      if (document.getElementsByTagName("ItemRef").getLength() != 0)
      {
        sku = getValueOfNodeByTagName(document.getElementsByTagName("ItemRef").item(0), "FullName");
        externalID = getValueOfNodeByTagName(document.getElementsByTagName("ItemRef").item(0), "ListID");
        cvID = getIDFromEXID("Item", externalID);

        if (!cvID.equals(""))
          itemId = Integer.parseInt(cvID);
      }
      if (cvID.equals("0") || cvID.equals(""))
        continue;
      IntMember ItemId = new IntMember("ItemId", itemId, 'D', "", 'T', false, 20);

      StringMember SKU = new StringMember("SKU", sku, 'D', "", 'T', false);

      String desc = "";
      if (document.getElementsByTagName("Desc").getLength() != 0)
      {
        desc = getValueOfNodeByTagName(document.getFirstChild(), "Desc");
      }

      StringMember Description = new StringMember("Description", desc, 'D', "", 'T', false);

      String qty = "0";

      if (document.getElementsByTagName("Quantity").getLength() != 0)
      {
        qty = getValueOfNodeByTagName(document.getFirstChild(), "Quantity");

      }

      FloatMember Quantity = new FloatMember("Quantity", new Float(qty), 'D', "0", 'T', false, 20);

      String priceEach = "0";
      if (document.getElementsByTagName("Rate").getLength() != 0)
      {
        priceEach = getValueOfNodeByTagName(document.getFirstChild(), "Rate");
      }

      FloatMember PriceEach = new FloatMember("PriceEach", new Float(priceEach), 'D', "", 'T', false, 20);

      String priceExt = "0";

      if (document.getElementsByTagName("PriceExtended").getLength() != 0)
      {
        priceExt = getValueOfNodeByTagName(document.getFirstChild(), "PriceExtended");
      }

      FloatMember PriceExtended = new FloatMember("PriceExtended", new Float(priceExt), 'D', "", 'T', false, 20);
      FloatMember UnitTax = new FloatMember("UnitTax", new Float("1"), 'D', "", 'T', false, 20);
      FloatMember unitTaxrate = new FloatMember("UnitTax", new Float("1"), 'D', "", 'T', false, 20);
      ie.put("ItemId", ItemId);
      ie.put("UnitTaxrate", unitTaxrate);
      ie.put("UnitTax", UnitTax);
      ie.put("SKU", SKU);
      ie.put("Description", Description);
      ie.put("Quantity", Quantity);
      ie.put("PriceEach", PriceEach);
      ie.put("PriceExtended", PriceExtended);
      ie.setLineStatus("New");
      itemLines.put(new Integer(j), ie);
    }
    //   itemLines.calculate();
    return itemLines;
  }
View Full Code Here

      int individualID = userobjectd.getIndividualID();

      request.setAttribute(AccountConstantKeys.TYPEOFSUBMODULE, AccountConstantKeys.ORDER);
      request.setAttribute("body", AccountConstantKeys.ADD );

      ItemLines itemLines = null;
     
      AccountHelper accHelper = (AccountHelper)accountHelperHome.create();
      accHelper.setDataSource(dataSource);
      Vector taxJurisdiction = accHelper.getTaxJurisdiction();
     
      OrderForm orderForm = (OrderForm)form;
      orderForm.setJurisdictionVec(taxJurisdiction);
     
      String typeOfOperation = request.getParameter(AccountConstantKeys.TYPEOFOPERATION);
     
      if (typeOfOperation != null && typeOfOperation.equals("REMOVEITEM")) {
        // Remove item
        String removeIDs = request.getParameter("removeID");
        StringTokenizer st;
        Iterator itr;
        Vector removeKeys = new Vector();
       
        orderForm.convertArrayToItemLines();
        itemLines = ((OrderForm)form).getItemLines();
        if (itemLines != null) {
          st = new StringTokenizer(removeIDs, ",");
          while (st.hasMoreTokens()) {
            String str = st.nextToken();
            int removeToken = Integer.parseInt(str);
           
            itr = itemLines.keySet().iterator();
            while (itr.hasNext()) {
              Object obj = itr.next();
              ItemElement ILE = (ItemElement)itemLines.get(obj);
              IntMember ItemId = (IntMember)ILE.get("ItemId");
              Integer currItemId = (Integer)ItemId.getMemberValue();
              if (currItemId.intValue() == removeToken) {
                String status = ILE.getLineStatus();
                if (status.equals("Active")) {
                  ILE.setLineStatus("Deleted");
                } else if (status.equals("New")) {
                  removeKeys.add(obj);
                }
              }
            }
          }
         
          for (int i=0; i < removeKeys.size(); i++) {
            itemLines.remove(removeKeys.get(i));
          }
        }
       
        ((OrderForm)form).setItemLines(itemLines);
      } else if (typeOfOperation != null && typeOfOperation.equals("ADDITEM")) {
        String newItemID = request.getParameter("theitemid");
        ItemList IL = null;
        ListGenerator lg = ListGenerator.getListGenerator(dataSource);      // get the List Generator object for Listing
        IL = (ItemList)lg.getItemList(individualID, 1, 10, "", "ItemID");   // called when the request for the list is for first time
       
        orderForm.convertArrayToItemLines();
        orderForm.convertFormbeanToValueObject("add");
       
        StringTokenizer st;
        String token, nextItr;
        if (newItemID != null) {
          st = new StringTokenizer(newItemID, ",");
          itemLines = (orderForm).getItemLines();
         
          if (itemLines == null) {
            itemLines = new ItemLines();
          }
          int counter = itemLines.size();
          while (st.hasMoreTokens()) {
            token = (String)st.nextToken();
            int intToken = Integer.parseInt(token);
           
            Iterator itr = IL.keySet().iterator();
            while (itr.hasNext()) {
              nextItr = (String)itr.next();
              ListElement ile = (ListElement)IL.get(nextItr);
              IntMember smid = (IntMember)ile.get("ItemID");
              Integer listItemid = (Integer)smid.getMemberValue();
             
              if (listItemid.intValue() == intToken) {
                StringMember smName = (StringMember)ile.get("Name"); // name = description
                String name = (String)smName.getMemberValue();
                StringMember smSku = (StringMember)ile.get("SKU");
                String sku = (String)smSku.getMemberValue();
                FloatMember dmprice = (FloatMember)ile.get("Price");
                float price = Float.parseFloat((dmprice.getMemberValue()).toString());
                int id = ile.getElementID();
                IntMember LineId = new IntMember("LineId", 0, 'D', "", 'T', false, 20);
                IntMember ItemId = new IntMember("ItemId", id, 'D', "", 'T', false, 20);
                IntMember Quantity = new IntMember("Quantity", 1, 'D', "", 'T', false, 20);
                FloatMember PriceEach = new FloatMember("Price", new Float(price), 'D', "", 'T', false, 20);
                StringMember SKU = new StringMember("SKU", sku, 'D', "", 'T', false);
                StringMember Description = new StringMember("Description", name, 'D', "", 'T', false);
                FloatMember PriceExtended = new FloatMember("PriceExtended", new Float(0.0f), 'D', "", 'T', false, 20);
                FloatMember TaxAmount = new FloatMember("TaxAmount", new Float(0.0f), 'D', "", 'T', false, 20);

                ItemElement ie = new ItemElement(0);
                ie.put("LineId", LineId);
                ie.put("ItemId", ItemId);
                ie.put("SKU", SKU);
                ie.put("Description", Description);
                ie.put("Quantity", Quantity);
                ie.put("Price", PriceEach);
                ie.put("PriceExtended", PriceExtended);
                ie.put("TaxAmount", TaxAmount);

                ie.setLineStatus("New");
                counter += 1;
                itemLines.put(new Integer(counter), ie);
                break;
              }
            }
          }
          orderForm.setJurisdictionVec(taxJurisdiction);
          itemLines.calculate();
          orderForm.setItemLines(itemLines);
        }
      }

      request.setAttribute("orderform",orderForm);
View Full Code Here

      HttpSession session = request.getSession(true);
      request.setAttribute(AccountConstantKeys.TYPEOFSUBMODULE, AccountConstantKeys.EXPENSE);
      request.setAttribute("body", "EDIT");

      ExpenseForm expenseForm = (ExpenseForm)request.getAttribute("expenseform");
      ItemLines itemLines=null;

      expenseForm.convertItemLines();

      com.centraview.common.UserObject  userobjectd = (com.centraview.common.UserObject)session.getAttribute( "userobject" );//get the user object
      int individualID = userobjectd.getIndividualID();

      int expenseID = 0;

      UserPrefererences userPref = userobjectd.getUserPref();
      String dateFormat  = userPref.getDateFormat();

      dateFormat= "M/d/yyyy";
      String timeZone    = userPref.getTimeZone();
      if(timeZone == null)
        timeZone = "EST";

      GregorianCalendar gCal = new GregorianCalendar(TimeZone.getTimeZone(timeZone));
      SimpleDateFormat dForm = new SimpleDateFormat(dateFormat);
      dForm.setCalendar(gCal);


      if(request.getParameter("rowId") != null)
        expenseID = Integer.parseInt((String)request.getParameter("rowId"));
      else
        expenseID = expenseForm.getExpenseID();

      String typeOfOperation = request.getParameter(AccountConstantKeys.TYPEOFOPERATION);

      /*
      Remove item
      */
      if(typeOfOperation != null &&  typeOfOperation.equals("REMOVEITEM") )
      {
        String removeIDs = request.getParameter("removeID");
        StringTokenizer st;
        Iterator itr;
        Vector removeKeys = new Vector();

        itemLines = expenseForm.getItemLines();
        if (itemLines != null)
        {
          st = new StringTokenizer(removeIDs, ",");
          while (st.hasMoreTokens())
          {
            String str = st.nextToken();
            int removeToken = Integer.parseInt(str);

            itr = itemLines.keySet().iterator();
            while (itr.hasNext())
            {
              Object obj = itr.next();
              ItemElement ILE = (ItemElement)itemLines.get(obj);
              IntMember ItemId = (IntMember)ILE.get("ItemId");
              Integer currItemId = (Integer)ItemId.getMemberValue();
              if ( currItemId.intValue() == removeToken)
              {
                String status = ILE.getLineStatus();
                if (status.equals("Active"))
                {
                  ILE.setLineStatus("Deleted");
                }//end of if (status.equals("Active"))
                else  if (status.equals("New"))
                {
                  removeKeys.add(obj);
                }//end of else  if (status.equals("New"))
              }//end of if ( currItemId.intValue() == removeToken)
            }//end of while (itr.hasNext())
          }//end of while (st.hasMoreTokens())

          for(int i=0; i<removeKeys.size(); i++)
          {
            itemLines.remove(removeKeys.get(i));
          }// end of for(int i=0; i<removeKeys.size(); i++)
        }//end of if (itemLines != null)

        expenseForm.setItemLines(itemLines);
        request.setAttribute("expenseform",expenseForm);
      }// end of if(typeOfOperation != null &&  typeOfOperation.equals("REMOVEITEM") )
      /*  ADD item  */
      else if(typeOfOperation != null && typeOfOperation.equals("ADDITEM") )
      {
        String newItemID = request.getParameter("theitemid");
        ItemList IL = null ;
        ListGenerator lg = ListGenerator.getListGenerator(dataSource);//get the List Generator object for Listing
        IL = (ItemList )lg.getItemList( individualID , 1, 10 , "" , "ItemID");//called when the request for the list is for first time

        StringTokenizer st;
        String token, nextItr;
        if (newItemID != null)
        {
          st = new StringTokenizer(newItemID, ",");
          itemLines = (expenseForm).getItemLines();

          if(itemLines == null)
            itemLines = new ItemLines();
          int counter = itemLines.size();
          while (st.hasMoreTokens())
          {
            token   = (String)st.nextToken();
            int intToken = Integer.parseInt(token);

            Iterator itr = IL.keySet().iterator();
            while (itr.hasNext())
            {
              nextItr = (String)itr.next();
              ListElement ile = (ListElement)IL.get(nextItr);
              IntMember smid = (IntMember)ile.get("ItemID");
              Integer listItemid = (Integer)smid.getMemberValue();

              if ( listItemid.intValue() == intToken )
              {

                StringMember smName = (StringMember)ile.get("Name"); // name = description
                String name = (String) smName.getMemberValue();

                StringMember smSku  = (StringMember) ile.get("SKU");
                String sku = (String)smSku.getMemberValue();
                FloatMember dmprice  = (FloatMember) ile.get("Price");

                float price = Float.parseFloat((dmprice.getMemberValue()).toString());

                int id = ile.getElementID();

                IntMember LineId = new IntMember("LineId",0,'D',"",'T',false,20);
                IntMember ItemId = new IntMember("ItemId",id,'D',"",'T',false,20);
                IntMember  Quantity = new IntMember("Quantity",1,'D',"",'T',false,20);
                FloatMember  PriceEach = new FloatMember("Price",new Float(price),'D',"",'T',false,20);
                StringMember SKU = new StringMember("SKU",sku,'D',"",'T',false);
                StringMember Description = new StringMember("Description",name,'D',"",'T',false);
                FloatMember  PriceExtended = new FloatMember("PriceExtended",new Float(0.0f),'D',"",'T',false,20);

                ItemElement ie = new ItemElement(0);
                ie.put ("LineId",LineId);
                ie.put ("ItemId",ItemId);
                ie.put ("SKU",SKU);
                ie.put ("Description",Description);
                ie.put ("Quantity",Quantity);
                ie.put ("Price",PriceEach);
                ie.put ("PriceExtended",PriceExtended);

                ie.setLineStatus("New");
                counter += 1;
                itemLines.put(new Integer(counter), ie);
                break;
              }// end of if ( listItemid.intValue() == intToken )
            }// end of while (itr.hasNext())
          }// end of while (st.hasMoreTokens())
          expenseForm.setItemLines(itemLines);
View Full Code Here

TOP

Related Classes of com.centraview.account.common.ItemLines

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.