Package com.jada.jpa.entity

Examples of com.jada.jpa.entity.ItemPriceCurrency


  public void saveCurrency(Item item, ItemMaintActionForm form, AdminBean adminBean) throws Exception {
      EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
      Long siteCurrencyClassId = form.getSiteCurrencyClassId();
      SiteCurrencyClass siteCurrencyClass = (SiteCurrencyClass) em.find(SiteCurrencyClass.class, siteCurrencyClassId);
      User user = adminBean.getUser();
      ItemPriceCurrency itemPriceCurrency = null;
      for (ItemPriceCurrency priceCurrency : item.getItemPriceCurrencies()) {
        if (priceCurrency.getItemPriceTypeCode() != Constants.ITEM_PRICE_TYPE_CODE_REGULAR) {
          continue;
        }
        if (priceCurrency.getSiteCurrencyClass().getSiteCurrencyClassId().equals(siteCurrencyClassId)) {
          itemPriceCurrency = priceCurrency;
          break;
        }
      }
      if (form.isItemPriceCurrFlag()) {
        if (itemPriceCurrency == null) {
          itemPriceCurrency = new ItemPriceCurrency();
          itemPriceCurrency.setItemPriceTypeCode(Constants.ITEM_PRICE_TYPE_CODE_REGULAR);
          itemPriceCurrency.setItemPricePublishOn(Format.LOWDATE);
          itemPriceCurrency.setItemPriceExpireOn(Format.HIGHDATE);
          itemPriceCurrency.setRecCreateBy(user.getUserId());
          itemPriceCurrency.setRecCreateDatetime(new Date(System.currentTimeMillis()));
          itemPriceCurrency.setSiteCurrencyClass(siteCurrencyClass);
          itemPriceCurrency.setItem(item);
          if (form.isSiteCurrencyClassDefault()) {
            item.setItemPrice(itemPriceCurrency);
          }
        }
        itemPriceCurrency.setItemPrice(Format.getFloat(form.getItemPriceCurr()));
        itemPriceCurrency.setRecUpdateBy(user.getUserId());
        itemPriceCurrency.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
        em.persist(itemPriceCurrency);
      }
      else {
        if (itemPriceCurrency != null) {
          item.getItemPriceCurrencies().remove(itemPriceCurrency);
          em.remove(itemPriceCurrency);
        }
      }
     
      itemPriceCurrency = null;
      for (ItemPriceCurrency priceCurrency : item.getItemPriceCurrencies()) {
        if (priceCurrency.getItemPriceTypeCode() != Constants.ITEM_PRICE_TYPE_CODE_SPECIAL) {
          continue;
        }
        if (priceCurrency.getSiteCurrencyClass().getSiteCurrencyClassId().equals(siteCurrencyClassId)) {
          itemPriceCurrency = priceCurrency;
          break;
        }
      }
      if (form.isItemSpecPriceCurrFlag()) {
        if (itemPriceCurrency == null) {
          itemPriceCurrency = new ItemPriceCurrency();
          itemPriceCurrency.setItemPriceTypeCode(Constants.ITEM_PRICE_TYPE_CODE_SPECIAL);
          itemPriceCurrency.setItemPricePublishOn(Format.getDate(form.getItemSpecPublishOn()));
          itemPriceCurrency.setItemPriceExpireOn(Format.getDate(form.getItemSpecExpireOn()));
          itemPriceCurrency.setRecCreateBy(user.getUserId());
          itemPriceCurrency.setRecCreateDatetime(new Date(System.currentTimeMillis()));
          itemPriceCurrency.setSiteCurrencyClass(siteCurrencyClass);
          itemPriceCurrency.setItem(item);
          if (form.isSiteCurrencyClassDefault()) {
            item.setItemSpecPrice(itemPriceCurrency);
          }
        }
        itemPriceCurrency.setItemPrice(Format.getFloat(form.getItemSpecPriceCurr()));
        itemPriceCurrency.setRecUpdateBy(user.getUserId());
        itemPriceCurrency.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
        em.persist(itemPriceCurrency);
      }
      else {
        if (itemPriceCurrency != null) {
          item.getItemPriceCurrencies().remove(itemPriceCurrency);
View Full Code Here


    item.setSeqNum(new Integer(0));
    item.setItemCost(Format.getFloatObj(form.getItemCost()));
   
      Long siteCurrencyClassId = form.getSiteCurrencyClassId();
    SiteCurrencyClass siteCurrencyClass = SiteCurrencyClassDAO.load(siteCurrencyClassId);
      ItemPriceCurrency regularPriceCurrency = null;
      ItemPriceCurrency specialPriceCurrency = null;
      for (ItemPriceCurrency priceCurrency : item.getItemPriceCurrencies()) {
        if (!priceCurrency.getSiteCurrencyClass().getSiteCurrencyClassId().equals(siteCurrencyClassId)) {
          continue;
        }
        if (priceCurrency.getItemPriceTypeCode() == Constants.ITEM_PRICE_TYPE_CODE_REGULAR) {
          regularPriceCurrency = priceCurrency;
        }
        if (priceCurrency.getItemPriceTypeCode() == Constants.ITEM_PRICE_TYPE_CODE_SPECIAL) {
          specialPriceCurrency = priceCurrency;
        }
      }
      if (regularPriceCurrency == null) {
        regularPriceCurrency = new ItemPriceCurrency();
        regularPriceCurrency.setItemPriceTypeCode(Constants.ITEM_PRICE_TYPE_CODE_REGULAR);
        regularPriceCurrency.setItemPricePublishOn(Format.LOWDATE);
        regularPriceCurrency.setItemPriceExpireOn(Format.HIGHDATE);
        regularPriceCurrency.setRecCreateBy(user.getUserId());
        regularPriceCurrency.setRecCreateDatetime(new Date(System.currentTimeMillis()));
        regularPriceCurrency.setSiteCurrencyClass(siteCurrencyClass);
        regularPriceCurrency.setItem(item);
        item.setItemPrice(regularPriceCurrency);
      }
      regularPriceCurrency.setItemPrice(Format.getFloat(form.getItemPrice()));
      regularPriceCurrency.setRecUpdateBy(user.getUserId());
    regularPriceCurrency.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
    em.persist(regularPriceCurrency);
   
      if (!Format.isNullOrEmpty(form.getItemSpecPrice())) {
        if (specialPriceCurrency == null) {
          specialPriceCurrency = new ItemPriceCurrency();
          specialPriceCurrency.setItemPriceTypeCode(Constants.ITEM_PRICE_TYPE_CODE_SPECIAL);
          specialPriceCurrency.setRecCreateBy(user.getUserId());
          specialPriceCurrency.setRecCreateDatetime(new Date(System.currentTimeMillis()));
          specialPriceCurrency.setSiteCurrencyClass(siteCurrencyClass);
          specialPriceCurrency.setItem(item);
          item.setItemSpecPrice(specialPriceCurrency);
        }
        specialPriceCurrency.setItemPrice(Format.getFloat(form.getItemSpecPrice()));
        specialPriceCurrency.setItemPricePublishOn(Format.getDate(form.getItemSpecPublishOn()));
        specialPriceCurrency.setItemPriceExpireOn(Format.getDate(form.getItemSpecExpireOn()));
        specialPriceCurrency.setRecUpdateBy(user.getUserId());
        specialPriceCurrency.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
        em.persist(specialPriceCurrency);
      }
      else {
        if (specialPriceCurrency != null) {
          item.setItemSpecPrice(null);
View Full Code Here

        if (language.getSiteProfileClass().getSiteProfileClassId().equals(form.getSiteProfileClassDefaultId())) {
          defaultItemLanguage = language;
        }
      }
     
      ItemPriceCurrency regularPrice = item.getItemPrice();
      ItemPriceCurrency specialPrice = item.getItemSpecPrice();
     
    MessageResources resources = this.getResources(request);
    form.setItemId(Format.getLong(item.getItemId()));
    form.setItemNum(item.getItemNum());
    form.setItemUpcCd(item.getItemUpcCd());
    form.setItemSkuCd(item.getItemSkuCd());
    form.setItemSellable(item.getItemSellable() == 'Y' ? true : false);
    form.setItemTypeCd(item.getItemTypeCd());
    form.setItemTypeDesc(resources.getMessage("item.typeCode." + item.getItemTypeCd()));
    form.setItemShortDesc(defaultItemLanguage.getItemShortDesc());
    form.setItemDesc(defaultItemLanguage.getItemDesc());
    form.setPageTitle(defaultItemLanguage.getPageTitle());
    form.setMetaKeywords(defaultItemLanguage.getMetaKeywords());
    form.setMetaDescription(defaultItemLanguage.getMetaDescription());
    form.setItemCost(Format.getFloatObj(item.getItemCost()));
    form.setItemPrice(Format.getFloatObj(regularPrice.getItemPrice()));
    form.setItemSpecPrice("");
    form.setItemSpecPublishOn("");
    form.setItemSpecExpireOn("");
    if (specialPrice != null) {
      form.setItemSpecPrice(Format.getFloatObj(specialPrice.getItemPrice()));
      form.setItemSpecPublishOn(Format.getDate(specialPrice.getItemPricePublishOn()));
      form.setItemSpecExpireOn(Format.getDate(specialPrice.getItemPriceExpireOn()))
    }
    form.setItemPublishOn(Format.getDate(item.getItemPublishOn()));
    form.setItemExpireOn(Format.getDate(item.getItemExpireOn()));
    form.setPublished(item.getPublished() == 'Y' ? true : false);
    if (item.getCustomAttributeGroup() != null) {
      form.setCustomAttribGroupId(Format.getLong(item.getCustomAttributeGroup().getCustomAttribGroupId()));
      form.setCustomAttribGroupName(item.getCustomAttributeGroup().getCustomAttribGroupName());
    }
    form.setRemoveImages(null);
    form.setRemoveMenus(null);
    form.setMenuWindowMode("");
    ShippingType shippingType = item.getShippingType();
    if (shippingType != null) {
      form.setShippingTypeId(shippingType.getShippingTypeId().toString());
    }
    ProductClass productClass = item.getProductClass();
    if (productClass != null) {
      form.setProductClassId(productClass.getProductClassId().toString());
    }
    form.setRecUpdateBy(item.getRecUpdateBy());
    form.setRecUpdateDatetime(Format.getFullDatetime(item.getRecUpdateDatetime()));
    form.setRecCreateBy(item.getRecCreateBy());
    form.setRecCreateDatetime(Format.getFullDatetime(item.getRecCreateDatetime()));
   
    if (!form.isSiteProfileClassDefault()) {
      form.setItemImageOverride(false);
      form.setItemShortDescLangFlag(false);
      form.setItemDescLangFlag(false);
      form.setPageTitleLangFlag(false);
      form.setMetaKeywordsLangFlag(false);
      form.setMetaDescriptionLangFlag(false);
      form.setItemShortDescLang(defaultItemLanguage.getItemShortDesc());
      form.setItemDescLang(defaultItemLanguage.getItemDesc());
      form.setPageTitleLang(defaultItemLanguage.getPageTitle());
      form.setMetaKeywordsLang(defaultItemLanguage.getMetaKeywords());
      form.setMetaDescriptionLang(defaultItemLanguage.getMetaDescription());
        Iterator<?> iterator = item.getItemLanguages().iterator();
        boolean found = false;
        ItemLanguage itemLanguage = null;
        Long siteProfileClassId = form.getSiteProfileClassId();
        while (iterator.hasNext()) {
          itemLanguage = (ItemLanguage) iterator.next();
          if (itemLanguage.getSiteProfileClass().getSiteProfileClassId().equals(siteProfileClassId)) {
            found = true;
            break;
          }
        }
        if (found) {
          if (itemLanguage.getItemShortDesc() != null) {
            form.setItemShortDescLangFlag(true);
            form.setItemShortDescLang(itemLanguage.getItemShortDesc());
          }
          if (itemLanguage.getItemDesc() != null) {
            form.setItemDescLangFlag(true);
            form.setItemDescLang(itemLanguage.getItemDesc());
          }
          if (itemLanguage.getPageTitle() != null) {
            form.setPageTitleLangFlag(true);
            form.setPageTitleLang(itemLanguage.getPageTitle());
          }
          if (itemLanguage.getMetaKeywords() != null) {
            form.setMetaKeywordsLangFlag(true);
            form.setMetaKeywordsLang(itemLanguage.getMetaKeywords());
          }
          if (itemLanguage.getMetaDescription() != null) {
            form.setMetaDescriptionLangFlag(true);
            form.setMetaDescriptionLang(itemLanguage.getMetaDescription());
          }
          if (itemLanguage.getItemImageOverride().equalsIgnoreCase(String.valueOf(Constants.VALUE_YES))) {
            form.setItemImageOverride(true);
          }
        }
    }
   
    if (!form.isSiteCurrencyClassDefault()) {
        ItemPriceCurrency regularPriceCurr = null;
        ItemPriceCurrency specialPriceCurr = null;
        for (ItemPriceCurrency itemPriceCurrency : item.getItemPriceCurrencies()) {
          if (!itemPriceCurrency.getSiteCurrencyClass().getSiteCurrencyClassId().equals(form.getSiteCurrencyClassId())) {
            continue;
          }
          if (itemPriceCurrency.getItemPriceTypeCode() == Constants.ITEM_PRICE_TYPE_CODE_REGULAR) {
            regularPriceCurr = itemPriceCurrency;
          }
          if (itemPriceCurrency.getItemPriceTypeCode() == Constants.ITEM_PRICE_TYPE_CODE_SPECIAL) {
            specialPriceCurr = itemPriceCurrency;
         
        }
        form.setItemPriceCurrFlag(false);
        form.setItemSpecPriceCurrFlag(false);
        form.setItemPriceCurr(form.getItemPrice());
        form.setItemSpecPriceCurr(form.getItemSpecPrice());
        if (regularPriceCurr != null) {
          form.setItemPriceCurr(Format.getFloatObj(regularPriceCurr.getItemPrice()));
          form.setItemPriceCurrFlag(true);
        }
        if (specialPriceCurr != null) {
          form.setItemSpecPriceCurr(Format.getFloatObj(specialPriceCurr.getItemPrice()));
          form.setItemSpecPriceCurrFlag(true);
        }
    }
   
    String sql = "select   customerClass " +
         "from     CustomerClass customerClass " +
         "left     join customerClass.site site " +
         "where    site.siteId = :siteId " +
         "order    by customerClass.custClassName ";  
    Query query = em.createQuery(sql);
    query.setParameter("siteId", item.getSite().getSiteId());
    Iterator<?> iterator = query.getResultList().iterator();
    Vector<LabelValueBean> custClassList = new Vector<LabelValueBean>();
    custClassList.add(new LabelValueBean("", ""));
    while (iterator.hasNext()) {
      CustomerClass customerClass = (CustomerClass) iterator.next();
      LabelValueBean bean = new LabelValueBean(customerClass.getCustClassName(), customerClass.getCustClassId().toString());;
      custClassList.add(bean);
    }
    LabelValueBean custClasses[] = new LabelValueBean[custClassList.size()];
    custClassList.copyInto(custClasses);
    form.setCustClasses(custClasses);

    Vector<ItemAttributeDetailDisplayForm> itemAttributeDetails = new Vector<ItemAttributeDetailDisplayForm>();
    if (item.getCustomAttributeGroup() != null) {
      sql = "select   customAttributeDetail " +
            "from     CustomAttributeGroup customAttributeGroup " +
            "join   customAttributeGroup.customAttributeDetails customAttributeDetail  " +
            "where    customAttributeGroup.customAttribGroupId = :customAttribGroupId " +
            "order    by customAttributeDetail.seqNum ";
      query = em.createQuery(sql);
      query.setParameter("customAttribGroupId", item.getCustomAttributeGroup().getCustomAttribGroupId());
      iterator = query.getResultList().iterator();
      boolean itemAttributeLangFlag = false;
      while (iterator.hasNext()) {
        CustomAttributeDetail customAttributeDetail = (CustomAttributeDetail) iterator.next();
        CustomAttribute customAttribute = customAttributeDetail.getCustomAttribute();
        ItemAttributeDetailDisplayForm displayForm = new ItemAttributeDetailDisplayForm();
        displayForm.setCustomAttribId(customAttribute.getCustomAttribId().toString());
        displayForm.setCustomAttribDetailId(customAttributeDetail.getCustomAttribDetailId().toString());
        displayForm.setCustomAttribName(customAttribute.getCustomAttribName());
        displayForm.setCustomAttribTypeCode(String.valueOf(customAttribute.getCustomAttribTypeCode()));
        boolean attributeExist = false;
        Iterator<?> details = item.getItemAttributeDetails().iterator();
        ItemAttributeDetail itemAttributeDetail = null;
        while (details.hasNext()) {
          itemAttributeDetail = (ItemAttributeDetail) details.next();
          if (itemAttributeDetail.getCustomAttributeDetail().getCustomAttribDetailId().equals(customAttributeDetail.getCustomAttribDetailId())) {
            attributeExist = true;
            break;
          }
        }
        if (attributeExist) {
          displayForm.setItemAttribDetailId(itemAttributeDetail.getItemAttribDetailId().toString());
          if (customAttribute.getCustomAttribTypeCode() == Constants.CUSTOM_ATTRIBUTE_TYPE_USER_INPUT) {
            displayForm.setItemAttribDetailValue(itemAttributeDetail.getItemAttributeDetailLanguage().getItemAttribDetailValue());
          }
          CustomAttributeOption customAttributeOption = itemAttributeDetail.getCustomAttributeOption();
          if (customAttributeOption != null) {
            displayForm.setCustomAttribOptionId(customAttributeOption.getCustomAttribOptionId().toString());
            if (customAttribute.getCustomAttribDataTypeCode() == Constants.CUSTOM_ATTRIBUTE_DATA_TYPE_CURRENCY) {
              displayForm.setItemAttribDetailValue(customAttributeOption.getCustomAttributeOptionCurrency().getCustomAttribValue());
            }
            else {
              displayForm.setItemAttribDetailValue(customAttributeOption.getCustomAttributeOptionLanguage().getCustomAttribValue());
            }
          }
          if (!form.isSiteProfileClassDefault()) {
            boolean found = false;
              Long siteProfileClassId = form.getSiteProfileClassId();
              ItemAttributeDetailLanguage itemAttributeDetailLanguage = null;
            Iterator<?> detailLanguages = itemAttributeDetail.getItemAttributeDetailLanguages().iterator();
            while (detailLanguages.hasNext()) {
              itemAttributeDetailLanguage = (ItemAttributeDetailLanguage) detailLanguages.next();
                if (itemAttributeDetailLanguage.getSiteProfileClass().getSiteProfileClassId().equals(siteProfileClassId)) {
                  found = true;
                  break;
                }
            }
            displayForm.setItemAttribDetailValueLangFlag(false);
            displayForm.setItemAttribDetailValueLang(displayForm.getItemAttribDetailValue());
            if (found) {
              itemAttributeLangFlag = true;
              displayForm.setItemAttribDetailValueLangFlag(false);
              if (itemAttributeDetailLanguage.getItemAttribDetailValue() != null) {
                displayForm.setItemAttribDetailValueLangFlag(true);
                displayForm.setItemAttribDetailValueLang(itemAttributeDetailLanguage.getItemAttribDetailValue());
              }
            }
          }
        }
        else {
          displayForm.setItemAttribDetailId("");
          displayForm.setItemAttribDetailValue("");
          displayForm.setCustomAttribOptionId("");
        }
        itemAttributeDetails.add(displayForm);
      }
      form.setItemAttribDetailValueLangFlag(itemAttributeLangFlag);
    }
    ItemAttributeDetailDisplayForm[] itemAttributeDetailDisplayForms = new ItemAttributeDetailDisplayForm[itemAttributeDetails.size()];
    itemAttributeDetails.copyInto(itemAttributeDetailDisplayForms);
    form.setItemAttributeDetails(itemAttributeDetailDisplayForms);
   
    if (!form.isSiteCurrencyClassDefault()) {
      form.setItemPriceCurrFlag(false);
      form.setItemPriceCurr(Format.getFloat(regularPrice.getItemPrice()));
      form.setItemSpecPriceCurrFlag(false);
      if (specialPrice != null) {
        form.setItemSpecPriceCurr(Format.getFloat(specialPrice.getItemPrice()));
      }
      ItemPriceCurrency regularPriceCurrency = null;
      ItemPriceCurrency specialPriceCurrency = null;
      for (ItemPriceCurrency itemPriceCurrency : item.getItemPriceCurrencies()) {
        if (!itemPriceCurrency.getSiteCurrencyClass().getSiteCurrencyClassId().equals(siteCurrencyClassId)) {
            continue;
          }
        if (itemPriceCurrency.getItemPriceTypeCode() == Constants.ITEM_PRICE_TYPE_CODE_REGULAR) {
          regularPriceCurrency = itemPriceCurrency;
        }
        if (itemPriceCurrency.getItemPriceTypeCode() == Constants.ITEM_PRICE_TYPE_CODE_SPECIAL) {
          specialPriceCurrency = itemPriceCurrency;
        }
      }
      if (regularPriceCurrency != null) {
          form.setItemPriceCurrFlag(true);
          form.setItemPriceCurr(Format.getFloat(regularPriceCurrency.getItemPrice()));
      }
      if (specialPriceCurrency != null) {
          form.setItemSpecPriceCurrFlag(true);
          form.setItemSpecPriceCurr(Format.getFloat(specialPriceCurrency.getItemPrice()));
      }
    }
   
    form.setItemSkusExist(false);
    if (item.getItemTypeCd().equals(Constants.ITEM_TYPE_TEMPLATE)) {
View Full Code Here

        em.persist(itemImage);
      }
    }
   
    for (ItemPriceCurrency sourcePriceCurrency : source.getItemPriceCurrencies()) {
      ItemPriceCurrency itemPriceCurrency = new ItemPriceCurrency();
      itemPriceCurrency.setItemPrice(sourcePriceCurrency.getItemPrice());
      itemPriceCurrency.setItemPriceTypeCode(sourcePriceCurrency.getItemPriceTypeCode());
      itemPriceCurrency.setItemPriceExpireOn(sourcePriceCurrency.getItemPriceExpireOn());
      itemPriceCurrency.setItemPricePublishOn(sourcePriceCurrency.getItemPricePublishOn());
      itemPriceCurrency.setRecUpdateBy(user.getUserId());
      itemPriceCurrency.setRecUpdateDatetime(new Date());
      itemPriceCurrency.setRecCreateBy(user.getUserId());
      itemPriceCurrency.setRecCreateDatetime(new Date());
      itemPriceCurrency.setSiteCurrencyClass(sourcePriceCurrency.getSiteCurrencyClass());
      itemPriceCurrency.setItem(item);
      item.getItemPriceCurrencies().add(itemPriceCurrency);
      if (sourcePriceCurrency.getSiteCurrencyClass().getSiteCurrencyClassId().equals(adminBean.getSite().getSiteCurrencyClassDefault().getSiteCurrencyClassId())) {
        if (sourcePriceCurrency.getItemPriceTypeCode() == Constants.ITEM_PRICE_TYPE_CODE_REGULAR) {
          item.setItemPrice(itemPriceCurrency);
        }
View Full Code Here

    }
  }
 
  static void createItemPriceSearch(Item master, Item item, Site site, AdminBean adminBean) throws Exception {
    EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
    ItemPriceCurrency regularPrice = item.getItemPrice();
    ItemPriceCurrency specialPrice = item.getItemSpecPrice();

    Query query = em.createQuery("from SiteCurrencyClass siteCurrencyClass where siteCurrencyClass.site.siteId = :siteId");
    query.setParameter("siteId", site.getSiteId());
    Iterator<?> iterator = query.getResultList().iterator();
    while (iterator.hasNext()) {
      SiteCurrencyClass siteCurrencyClass = (SiteCurrencyClass) iterator.next();
      if (specialPrice != null) {
        ItemPriceSearch itemPriceSearch = new ItemPriceSearch();
        ItemPriceCurrency itemPriceCurrency = null;
        for (ItemPriceCurrency currency : item.getItemPriceCurrencies()) {
          if (currency.getItemPriceTypeCode() != Constants.ITEM_PRICE_TYPE_CODE_SPECIAL) {
            continue;
          }
          if (currency.getSiteCurrencyClass().getSiteCurrencyClassId().equals(siteCurrencyClass.getSiteCurrencyClassId())) {
            itemPriceCurrency = currency;
            break;
          }
        }
        if (itemPriceCurrency == null || itemPriceCurrency.getItemPrice() == null) {
          itemPriceSearch.setItemPrice(specialPrice.getItemPrice());
          itemPriceSearch.setExchangeFactor(Integer.valueOf(1));
        }
        else {
          itemPriceSearch.setItemPrice(itemPriceCurrency.getItemPrice());
          itemPriceSearch.setExchangeFactor(Integer.valueOf(0))
        }
        itemPriceSearch.setItemPricePublishOn(specialPrice.getItemPricePublishOn());
        itemPriceSearch.setItemPriceExpireOn(specialPrice.getItemPriceExpireOn());
        itemPriceSearch.setRecUpdateBy(adminBean.getUser().getUserId());
        itemPriceSearch.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
        itemPriceSearch.setRecCreateBy(adminBean.getUser().getUserId());
        itemPriceSearch.setRecCreateDatetime(new Date(System.currentTimeMillis()));
        itemPriceSearch.setSiteCurrencyClass(siteCurrencyClass);
        itemPriceSearch.setItem(master);
        em.persist(itemPriceSearch);
        master.getItemPriceSearches().add(itemPriceSearch);
      }
      ItemPriceCurrency itemPriceCurrency = null;
      for (ItemPriceCurrency currency : item.getItemPriceCurrencies()) {
        if (currency.getItemPriceTypeCode() != Constants.ITEM_PRICE_TYPE_CODE_REGULAR) {
          continue;
        }
        if (currency.getSiteCurrencyClass().getSiteCurrencyClassId().equals(siteCurrencyClass.getSiteCurrencyClassId())) {
          itemPriceCurrency = currency;
          break;
        }
      }
      ItemPriceSearch itemPriceSearch = new ItemPriceSearch();
      if (itemPriceCurrency == null || itemPriceCurrency.getItemPrice() == null) {
        itemPriceSearch.setItemPrice(regularPrice.getItemPrice());
        itemPriceSearch.setExchangeFactor(Integer.valueOf(1));
      }
      else {
        itemPriceSearch.setItemPrice(itemPriceCurrency.getItemPrice());
        itemPriceSearch.setExchangeFactor(Integer.valueOf(0))
      }
      itemPriceSearch.setRecUpdateBy(adminBean.getUser().getUserId());
      itemPriceSearch.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
      itemPriceSearch.setRecCreateBy(adminBean.getUser().getUserId());
View Full Code Here

    }
  }
 
  static void createItemPriceSearch(Item master, Item item, Site site, AdminBean adminBean) throws Exception {
    EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
    ItemPriceCurrency regularPrice = item.getItemPrice();
    ItemPriceCurrency specialPrice = item.getItemSpecPrice();

    Query query = em.createQuery("from SiteCurrencyClass siteCurrencyClass where siteCurrencyClass.site.siteId = :siteId");
    query.setParameter("siteId", site.getSiteId());
    Iterator<?> iterator = query.getResultList().iterator();
    while (iterator.hasNext()) {
      SiteCurrencyClass siteCurrencyClass = (SiteCurrencyClass) iterator.next();
      if (specialPrice != null) {
        ItemPriceSearch itemPriceSearch = new ItemPriceSearch();
        ItemPriceCurrency itemPriceCurrency = null;
        for (ItemPriceCurrency currency : item.getItemPriceCurrencies()) {
          if (currency.getItemPriceTypeCode() != Constants.ITEM_PRICE_TYPE_CODE_SPECIAL) {
            continue;
          }
          if (currency.getSiteCurrencyClass().getSiteCurrencyClassId().equals(siteCurrencyClass.getSiteCurrencyClassId())) {
            itemPriceCurrency = currency;
            break;
          }
        }
        if (itemPriceCurrency == null || itemPriceCurrency.getItemPrice() == null) {
          itemPriceSearch.setItemPrice(specialPrice.getItemPrice());
          itemPriceSearch.setExchangeFactor(Integer.valueOf(1));
        }
        else {
          itemPriceSearch.setItemPrice(itemPriceCurrency.getItemPrice());
          itemPriceSearch.setExchangeFactor(Integer.valueOf(0))
        }
        itemPriceSearch.setItemPricePublishOn(specialPrice.getItemPricePublishOn());
        itemPriceSearch.setItemPriceExpireOn(specialPrice.getItemPriceExpireOn());
        itemPriceSearch.setRecUpdateBy(adminBean.getUser().getUserId());
        itemPriceSearch.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
        itemPriceSearch.setRecCreateBy(adminBean.getUser().getUserId());
        itemPriceSearch.setRecCreateDatetime(new Date(System.currentTimeMillis()));
        itemPriceSearch.setSiteCurrencyClass(siteCurrencyClass);
        em.persist(itemPriceSearch);
        master.getItemPriceSearches().add(itemPriceSearch);
      }
      ItemPriceCurrency itemPriceCurrency = null;
      for (ItemPriceCurrency currency : item.getItemPriceCurrencies()) {
        if (currency.getItemPriceTypeCode() != Constants.ITEM_PRICE_TYPE_CODE_REGULAR) {
          continue;
        }
        if (currency.getSiteCurrencyClass().getSiteCurrencyClassId().equals(siteCurrencyClass.getSiteCurrencyClassId())) {
          itemPriceCurrency = currency;
          break;
        }
      }
      ItemPriceSearch itemPriceSearch = new ItemPriceSearch();
      if (itemPriceCurrency == null || itemPriceCurrency.getItemPrice() == null) {
        itemPriceSearch.setItemPrice(regularPrice.getItemPrice());
        itemPriceSearch.setExchangeFactor(Integer.valueOf(1));
      }
      else {
        itemPriceSearch.setItemPrice(itemPriceCurrency.getItemPrice());
        itemPriceSearch.setExchangeFactor(Integer.valueOf(0))
      }
      itemPriceSearch.setRecUpdateBy(adminBean.getUser().getUserId());
      itemPriceSearch.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
      itemPriceSearch.setRecCreateBy(adminBean.getUser().getUserId());
View Full Code Here

    return false;
  }
 
  public float getItemSpecPrice(Item item) throws Exception {
    float itemSpecPrice = 0;
    ItemPriceCurrency itemPriceCurrDefault = null;
    ItemPriceCurrency itemPriceCurr = null;
    Long defaultSiteCurrencyClassId = contentBean.getSiteDomain().getSite().getSiteCurrencyClassDefault().getSiteCurrencyClassId();
    for (ItemPriceCurrency currency : item.getItemPriceCurrencies()) {
      if (currency.getItemPriceTypeCode() != Constants.ITEM_PRICE_TYPE_CODE_SPECIAL) {
        continue;
      }
      if (currency.getSiteCurrencyClass().getSiteCurrencyClassId().equals(defaultSiteCurrencyClassId)) {
        itemPriceCurrDefault = currency;
      }
      if (currency.getSiteCurrencyClass().getSiteCurrencyClassId().equals(siteCurrencyClassId)) {
        itemPriceCurr = currency;
      }
    }
    itemSpecPrice = itemPriceCurrDefault.getItemPrice().floatValue();
    if (!defaultSiteCurrencyClassId.equals(siteCurrencyClassId)) {
      if (itemPriceCurr != null && itemPriceCurr.getItemPrice() != null) {
        itemSpecPrice = itemPriceCurr.getItemPrice();
      }
      else {
        itemSpecPrice = currencyConverter.convert(itemSpecPrice);
      }
    }
View Full Code Here

TOP

Related Classes of com.jada.jpa.entity.ItemPriceCurrency

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.