<p>Evaluate I18N overseas sales invoice service lines query.</p>
@param pItsOwnerId ID of sales invoice
@param pLang lang
@return query
@throws Exception - an exception
160478
public final String evalSalesInvOverseaseServiceLinesSql(
    final String pItsOwnerId, final String pLang) throws Exception {
    if (this.salesInvOverseaseServiceLinesSql == null) {
      synchronized (this) {
        if (this.salesInvOverseaseServiceLinesSql == null) {
          String flName = "/accounting/trade/salesInvOverseaseServiceLines.sql";
          this.salesInvOverseaseServiceLinesSql = loadString(flName);
        }
      }
    }
    String query = this.salesInvOverseaseServiceLinesSql.replace(":ITSOWNER",
      pItsOwnerId).replace(":LANG", pLang);
    return query;
  }
833572
@Override
  public final void fillWageLines(final Map<String, Object> pAddParam,
    final Wage pWage) throws Exception {
    List<WageTaxTableEmployee> wttel = getSrvOrm()
      .retrieveListWithConditions(pAddParam, WageTaxTableEmployee.class,
        "where EMPLOYEE=" + pWage.getEmployee().getItsId());
    if (wttel != null && wttel.size() > 0) {
      String queryTotalWageYear =
        "select sum(TOTALWAGEYEAR) as TOTALWAGEYEAR from "
          + EmployeeYearWage.class.getSimpleName().toUpperCase()
            + " where ITSOWNER=" + pWage.getEmployee().getItsId();
      Double totalWageYearDbl = getSrvDatabase()
        .evalDoubleResult(queryTotalWageYear, "TOTALWAGEYEAR");
      if (totalWageYearDbl == null) {
        totalWageYearDbl = 0d;
      }
      BigDecimal totalWageYear = BigDecimal.valueOf(totalWageYearDbl);
      getSrvOrm().deleteEntityWhere(pAddParam, WageTaxLine.class,
        "ITSOWNER=" + pWage.getItsId());
      BigDecimal bigDecimal100 = new BigDecimal("100.00");
      BigDecimal totalTaxesEmployee = BigDecimal.ZERO;
      BigDecimal totalTaxesEmployer = BigDecimal.ZERO;
      //BeigeORM refresh lines:
      WageLine wlfr = new WageLine();
      wlfr.setItsOwner(pWage);
      String ownerFldName = "itsOwner";
      pWage.setItsLines(getSrvOrm()
        .retrieveListForField(pAddParam, wlfr, ownerFldName));
      Map<WageType, BigDecimal> empleeTotTaxLnMap =
        new  HashMap<WageType, BigDecimal>();
      for (WageLine wl : pWage.getItsLines()) {
        empleeTotTaxLnMap.put(wl.getWageType(), BigDecimal.ZERO);
      }
      for (WageTaxTableEmployee wtte : wttel) {
        //BeigeORM refresh lines:
        wtte.getItsOwner().setTax(getSrvOrm()
          .retrieveEntity(pAddParam, wtte.getItsOwner().getTax()));
        //BeigeORM refresh lines:
        WageTaxTableLine wttlfr = new WageTaxTableLine();
        wttlfr.setItsOwner(wtte.getItsOwner());
        wtte.getItsOwner().setItsLines(getSrvOrm()
          .retrieveListForField(pAddParam, wttlfr, ownerFldName));
        //BeigeORM refresh lines:
        WageTaxTableType wttt = new WageTaxTableType();
        wttt.setItsOwner(wtte.getItsOwner());
        wtte.getItsOwner().setWageTypes(getSrvOrm()
          .retrieveListForField(pAddParam, wttt, ownerFldName));
        BigDecimal totalTaxableForTax = BigDecimal.ZERO;
        for (WageLine wl : pWage.getItsLines()) {
          if (isWageApplied(wl.getWageType(), wtte.getItsOwner())) {
            totalTaxableForTax = totalTaxableForTax.add(wl.getGrossWage());
          }
        }
        if (totalTaxableForTax.doubleValue() > 0) {
          BigDecimal wageMinusAllowance = totalTaxableForTax
            .subtract(wtte.getAllowance());
          boolean isFilled = false;
          for (WageTaxTableLine wttl : wtte.getItsOwner().getItsLines()) {
            if (wageMinusAllowance.compareTo(wttl.getWageFrom()) >= 0
              && wageMinusAllowance.compareTo(wttl.getWageTo()) < 0
                && totalWageYear
                  .compareTo(wttl.getYearWageFrom()) >= 0
                    && totalWageYear
                      .compareTo(wttl.getYearWageTo()) < 0) {
              WageTaxLine wtl = new WageTaxLine();
              wtl.setIsNew(true);
              wtl.setIdDatabaseBirth(getSrvOrm().getIdDatabase());
              wtl.setItsOwner(pWage);
              wtl.setAllowance(wtte.getAllowance());
              wtl.setPlusAmount(wttl.getPlusAmount());
              wtl.setTax(wtte.getItsOwner().getTax());
              wtl.setItsPercentage(wttl.getItsPercentage());
              wtl.setItsTotal(wageMinusAllowance.subtract(wttl.getAllowance())
                .multiply(wttl.getItsPercentage()).divide(bigDecimal100,
                  getSrvAccSettings().lazyGetAccSettings(pAddParam)
                    .getPricePrecision(), getSrvAccSettings()
                      .lazyGetAccSettings(pAddParam).getRoundingMode())
                        .add(wttl.getPlusAmount()));
              wtl.setDescription("TableID/Name/taxable: " + wtte.getItsOwner()
                .getItsId() + "/" + wtte.getItsOwner().getItsName() + "/"
                  + totalTaxableForTax);
              getSrvOrm().insertEntity(pAddParam, wtl);
              wtl.setIsNew(false);
              if (wtl.getTax().getItsType()
                .equals(ETaxType.EMPLOYMENT_TAX_EMPLOYEE)) {
                totalTaxesEmployee = totalTaxesEmployee.add(wtl.getItsTotal());
                for (WageLine wl : pWage.getItsLines()) {
                  BigDecimal newTotalTaxEmpleeLn = empleeTotTaxLnMap.get(wl
                    .getWageType()).add(wl.getGrossWage().multiply(wtl
                      .getItsTotal()).divide(totalTaxableForTax,
                        getSrvAccSettings().lazyGetAccSettings(pAddParam)
                          .getPricePrecision(), getSrvAccSettings()
                            .lazyGetAccSettings(pAddParam).getRoundingMode()));
                  empleeTotTaxLnMap.put(wl.getWageType(), newTotalTaxEmpleeLn);
                }
              } else if (wtl.getTax().getItsType()
                .equals(ETaxType.EMPLOYMENT_TAX_EMPLOYER)) {
                totalTaxesEmployer = totalTaxesEmployer.add(wtl.getItsTotal());
              }
              isFilled = true;
              break;
            }
          }
          if (!isFilled) {
            throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER,
              "where_is_no_suitable_tax_percent_entry_for::"
                + wtte.getItsOwner().getTax().getItsName());
          }
        }
      }
      for (WageLine wl : pWage.getItsLines()) {
        wl.setTaxesEmployee(empleeTotTaxLnMap.get(wl.getWageType()));
        getSrvOrm().updateEntity(pAddParam, wl);
      }
      pWage.setTotalTaxesEmployee(totalTaxesEmployee);
      pWage.setTotalTaxesEmployer(totalTaxesEmployer);
      pWage.setNetWage(pWage.getItsTotal()
        .subtract(pWage.getTotalTaxesEmployee()));
      getSrvOrm().updateEntity(pAddParam, pWage);
    }
  }
1323000
protected final InvTxMeth<SalesReturn, SalesReturnTaxLine>
    lazyGetSalRetTxMeth(final Map<String, Object> pAddParam) throws Exception {
    InvTxMeth<SalesReturn, SalesReturnTaxLine> salRetTxMe =
      this.salRetTxMeth;
    if (salRetTxMe == null) {
      salRetTxMe = new InvTxMeth<SalesReturn, SalesReturnTaxLine>();
      salRetTxMe.setGoodLnCl(SalesReturnLine.class);
      salRetTxMe.setInvTxLnCl(SalesReturnTaxLine.class);
      salRetTxMe.setIsTxByUser(true);
      salRetTxMe.setStWhereAdjGdLnInvBas(
        "where SALESRETURNLINE.TAXCATEGORY is not null and REVERSEDID "
          + "is null and ITSOWNER=");
      salRetTxMe.setFlTotals("invGdTotals.sql");
      salRetTxMe.setFlTxItBas("invGdTxItBas.sql");
      salRetTxMe.setFlTxItBasAggr("invGdTxItBasAggr.sql");
      salRetTxMe.setFlTxInvBas("invGdTxInvBas.sql");
      salRetTxMe.setFlTxInvAdj("invGdTxInvAdj.sql");
      salRetTxMe.setFlTxInvBasAggr("invGdTxInvBasAggr.sql");
      salRetTxMe.setTblNmsTot(new String[] {"SALESRETURNLINE",
        "SALESRETURNTAXLINE", "SALESRETURNGOODSTAXLINE"});
      FactoryPersistableBase<SalesReturnTaxLine> fctItl =
        new FactoryPersistableBase<SalesReturnTaxLine>();
      fctItl.setObjectClass(SalesReturnTaxLine.class);
      fctItl.setDatabaseId(getSrvDatabase().getIdDatabase());
      salRetTxMe.setFctInvTxLn(fctItl);
      //assigning fully initialized object:
      this.salRetTxMeth = salRetTxMe;
    }
    return salRetTxMe;
  }
920475
@Override
  public final void process(final Map<String, Object> pRqVs,
    final IRequestData pRqDt) throws Exception {
    pRqDt.setAttribute("catalogs", lazyRetrieveCatalogs(pRqVs));
    TradingSettings ts = (TradingSettings)
      pRqVs.get("tradSet");
    String catalogIdStr = pRqDt.getParameter("catalogId");
    Long catId = null;
    if (catalogIdStr != null) {
      catId = Long.valueOf(catalogIdStr);
    }
    if (catId == null && ts.getCatalogOnStart() != null) {
      catId = ts.getCatalogOnStart().getItsId();
    }
    Cart cart = (Cart) pRqDt.getAttribute("cart");
    if (cart == null) {
      cart = this.srvShoppingCart
        .getShoppingCart(pRqVs, pRqDt, false, false);
    }
    AccSettings as = (AccSettings) pRqVs.get("accSet");
    Currency curr = (Currency) pRqVs.get("wscurr");
    List<CurrRate> currRates = (List<CurrRate>) pRqVs.get("currRates");
    BigDecimal cuRt = BigDecimal.ONE;
    for (CurrRate cr: currRates) {
      if (cr.getCurr().getItsId().equals(curr.getItsId())) {
        cuRt = cr.getRate();
        break;
      }
    }
    if (cart != null) {
      if (cart.getTot().compareTo(BigDecimal.ZERO) == 0) {
        pRqDt.setAttribute("cart", null);
      } else {
        if (!cart.getCurr().getItsId().equals(curr.getItsId())) {
          cart.setCurr(curr);
          cart.setExcRt(cuRt);
          this.srvShoppingCart.handleCurrencyChanged(pRqVs, cart, as, ts);
        }
        if (pRqDt.getAttribute("txRules") == null) {
          TaxDestination txRules = this.srvShoppingCart
            .revealTaxRules(pRqVs, cart, as);
          pRqDt.setAttribute("txRules", txRules);
        }
        Map<EShopItemType, Map<Long, CartLn>> cartMap =
          new HashMap<EShopItemType, Map<Long, CartLn>>();
        for (CartLn ci : cart.getItems()) {
          if (!ci.getDisab()) {
            Map<Long, CartLn> typedMap = cartMap.get(ci.getItTyp());
            if (typedMap == null) {
              typedMap = new HashMap<Long, CartLn>();
              cartMap.put(ci.getItTyp(), typedMap);
            }
            typedMap.put(ci.getItId(), ci);
          }
        }
        pRqDt.setAttribute("cartMap", cartMap);
      }
    }
    if (catId != null) {
      // either selected by user catalog or "on start" must be
      // if user additionally selected filters (include set of subcatalogs)
      // then the main (root) catalog ID still present in request
      TradingCatalog tcat = findTradingCatalogById(this.catalogs, catId);
      if (tcat == null) {
        this.logger.warn(pRqVs, PrcWebstorePage.class,
          "Can't find catalog #" + catId);
      } else {
        String ordb = pRqDt.getParameter("ordb");
        pRqDt.setAttribute("ordb", ordb);
        String orderBy = null;
        if (ordb != null) {
          if (ordb.equals("pa")) {
            orderBy = " order by ITSPRICE asc";
          } else if (ordb.equals("pd")) {
            orderBy = " order by ITSPRICE desc";
          }
        }
        FilterInteger filterPrice = revialFilterPrice(tcat,
          pRqVs, pRqDt);
        FilterItems<CatalogGs> filterCatalog = revialFilterCatalog(tcat,
          pRqVs, pRqDt);
        List<SpecificsFilter> filtersSpecifics = revialFiltersSpecifics(tcat,
          pRqVs, pRqDt);
        String whereAdd = revWhePri(filterPrice, cuRt);
        String whereCatalog = revealWhereCatalog(tcat, filterCatalog);
        //TODO StringBuffer
        String queryg = null;
        String querys = null;
        String queryseg = null;
        String queryses = null;
        if (ts.getUseAdvancedI18n()) {
          String lang = (String) pRqVs.get("lang");
          String langDef = (String) pRqVs.get("langDef");
          if (!lang.equals(langDef)) {
            if (tcat.getCatalog().getHasGoods()) {
              queryg = lazyGetQuItInLstCaIn().replace(":ITTYP", "0")
    .replace(":TITCAT", "GOODSCATALOG").replace(":CATALOGFILTER", whereCatalog)
  .replace(":WHEREADD", whereAdd).replace(":LANG", lang);
            }
            if (tcat.getCatalog().getHasServices()) {
              querys = lazyGetQuItInLstCaIn().replace(":ITTYP", "1")
  .replace(":TITCAT", "SERVICECATALOG").replace(":CATALOGFILTER", whereCatalog)
.replace(":WHEREADD", whereAdd).replace(":LANG", lang);
            }
            if (tcat.getCatalog().getHasSeGoods()) {
              queryseg = lazyGetQuItInLstCaIn().replace(":ITTYP", "2")
   .replace(":TITCAT", "SEGOODCATALOG").replace(":CATALOGFILTER", whereCatalog)
 .replace(":WHEREADD", whereAdd).replace(":LANG", lang);
            }
            if (tcat.getCatalog().getHasSeServices()) {
              queryses = lazyGetQuItInLstCaIn().replace(":ITTYP", "3")
          .replace(":TITCAT", "SESRCA").replace(":CATALOGFILTER", whereCatalog)
        .replace(":WHEREADD", whereAdd).replace(":LANG", lang);
            }
          }
        }
        if (tcat.getCatalog().getHasGoods() && queryg == null) {
          queryg = lazyGetQuItInLstCa().replace(":ITTYP", "0")
    .replace(":TITCAT", "GOODSCATALOG").replace(":CATALOGFILTER", whereCatalog)
  .replace(":WHEREADD", whereAdd);
        }
        if (tcat.getCatalog().getHasServices() && querys == null) {
          querys = lazyGetQuItInLstCa().replace(":ITTYP", "1")
  .replace(":TITCAT", "SERVICECATALOG").replace(":CATALOGFILTER", whereCatalog)
.replace(":WHEREADD", whereAdd);
        }
        if (tcat.getCatalog().getHasSeGoods() && queryseg == null) {
          queryseg = lazyGetQuItInLstCa().replace(":ITTYP", "2")
   .replace(":TITCAT", "SEGOODCATALOG").replace(":CATALOGFILTER", whereCatalog)
 .replace(":WHEREADD", whereAdd);
        }
        if (tcat.getCatalog().getHasSeServices() && queryses == null) {
          queryses = lazyGetQuItInLstCa().replace(":ITTYP", "3")
       .replace(":TITCAT", "SESRCA").replace(":CATALOGFILTER", whereCatalog)
     .replace(":WHEREADD", whereAdd);
        }
        String querygRc = null;
        if (tcat.getCatalog().getHasGoods()) {
          querygRc = lazyGetQuItInLstCaTo().replace(":ITTYP", "0")
    .replace(":TITCAT", "GOODSCATALOG").replace(":CATALOGFILTER", whereCatalog)
  .replace(":WHEREADD", whereAdd);
        }
        String querysRc = null;
        if (tcat.getCatalog().getHasServices()) {
          querysRc = lazyGetQuItInLstCaTo().replace(":ITTYP", "1")
  .replace(":TITCAT", "SERVICECATALOG").replace(":CATALOGFILTER", whereCatalog)
.replace(":WHEREADD", whereAdd);
        }
        String querysegRc = null;
        if (tcat.getCatalog().getHasSeGoods()) {
          querysegRc = lazyGetQuItInLstCaTo().replace(":ITTYP", "2")
   .replace(":TITCAT", "SEGOODCATALOG").replace(":CATALOGFILTER", whereCatalog)
  .replace(":WHEREADD", whereAdd);
        }
        String querysesRc = null;
        if (tcat.getCatalog().getHasSeServices()) {
          querysesRc = lazyGetQuItInLstCaTo().replace(":ITTYP", "3")
           .replace(":TITCAT", "SESRCA").replace(":CATALOGFILTER", whereCatalog)
            .replace(":WHEREADD", whereAdd);
        }
        boolean isDbgSh = getLogger().getDbgSh(this.getClass())
          && getLogger().getDbgFl() < 13011 && getLogger().getDbgCl() > 13013;
        if (filtersSpecifics != null) {
          if (isDbgSh) {
            getLogger().debug(pRqVs, PrcWebstorePage.class,
              "filters apecifics: size: " + filtersSpecifics.size());
          }
          SpecificsFiltersWhere whereSpec =
            revealWhereSpecifics(filtersSpecifics);
          if (whereSpec != null) {
            if (queryg != null) {
              String querySpec = lazyGetQuItSpFlt()
    .replace(":TITSPEC", "GOODSSPECIFICS").replace(":WHESPITFLR", whereSpec
  .getWhere()).replace(":SPITFLTCO", whereSpec.getWhereCount().toString());
              queryg += querySpec;
              querygRc += querySpec;
            }
            if (querys != null) {
              String querySpec = lazyGetQuItSpFlt()
    .replace(":TITSPEC", "SERVICESPECIFICS").replace(":WHESPITFLR", whereSpec
  .getWhere()).replace(":SPITFLTCO", whereSpec.getWhereCount().toString());
              querys += querySpec;
              querysRc += querySpec;
            }
            if (queryseg != null) {
              String querySpec = lazyGetQuItSpFlt()
    .replace(":TITSPEC", "SEGOODSSPECIFICS").replace(":WHESPITFLR", whereSpec
  .getWhere()).replace(":SPITFLTCO", whereSpec.getWhereCount().toString());
              queryseg += querySpec;
              querysegRc += querySpec;
            }
            if (queryses != null) {
              String querySpec = lazyGetQuItSpFlt()
    .replace(":TITSPEC", "SESERVICESPECIFICS").replace(":WHESPITFLR", whereSpec
  .getWhere()).replace(":SPITFLTCO", whereSpec.getWhereCount().toString());
              queryses += querySpec;
              querysesRc += querySpec;
            }
          }
        }
        if (queryg != null || querys != null || queryseg != null
          || queryses != null) {
          String query = null;
          String queryRc = null;
          if (queryg != null) {
            query = queryg;
            queryRc = querygRc;
          }
          if (querys != null) {
            if (query == null) {
              query = querys;
              queryRc = querysRc;
            } else {
              query += "\n union all \n" + querys;
              queryRc += "\n union all \n" + querysRc;
            }
          }
          if (queryseg != null) {
            if (query == null) {
              query = queryseg;
              queryRc = querysegRc;
            } else {
              query += "\n union all \n" + queryseg;
              queryRc += "\n union all \n" + querysegRc;
            }
          }
          if (queryses != null) {
            if (query == null) {
              query = queryses;
              queryRc = querysesRc;
            } else {
              query += "\n union all \n" + queryses;
              queryRc += "\n union all \n" + querysesRc;
            }
          }
          queryRc = "select count(*) as TOTALROWS from (" + queryRc
            + ") as ALL_TOT";
          if (orderBy != null) {
            query += orderBy;
            queryRc += orderBy;
          }
          queryRc += ";";
          Integer rowCount = this.srvOrm
            .evalRowCountByQuery(pRqVs, ItemInList.class, queryRc);
          Set<String> neededFields = new HashSet<String>();
          neededFields.add("itsType");
          neededFields.add("itemId");
          neededFields.add("itsName");
          neededFields.add("imageUrl");
          neededFields.add("specificInList");
          neededFields.add("itsPrice");
          neededFields.add("previousPrice");
          neededFields.add("availableQuantity");
          neededFields.add("itsRating");
          neededFields.add("detailsMethod");
          pRqVs.put("ItemInListneededFields", neededFields);
          String pageStr = pRqDt.getParameter("page");
          Integer page;
          if (pageStr != null) {
            page = Integer.valueOf(pageStr);
          } else {
            page = 1;
          }
          Integer itemsPerPage = ts.getItemsPerPage();
          int totalPages = this.srvPage.evalPageCount(rowCount, itemsPerPage);
          if (page > totalPages) {
            page = totalPages;
          }
          int firstResult = (page - 1) * itemsPerPage; //0-20,20-40
          List<ItemInList> itemsList = getSrvOrm()
            .retrievePageByQuery(pRqVs, ItemInList.class,
              query, firstResult, itemsPerPage);
          pRqVs.remove("ItemInListneededFields");
          if (ts.getIsUsePriceForCustomer() && cart != null
            && cart.getBuyer().getRegEmail() != null) {
            List<BuyerPriceCategory> buyerPrCats = getSrvOrm()
              .retrieveListWithConditions(pRqVs, BuyerPriceCategory.class,
                "where BUYER=" + cart.getBuyer().getItsId());
            if (buyerPrCats.size() > 1) {
              this.logger.error(pRqVs, PrcWebstorePage.class,
                "Several price category for same buyer! buyer ID="
                  + cart.getBuyer().getItsId());
            throw new ExceptionWithCode(ExceptionWithCode.CONFIGURATION_MISTAKE,
                "several_price_category_for_same_buyer");
            }
            if (buyerPrCats.size() == 1) {
              StringBuffer sbg = null;
              StringBuffer sbs = null;
              StringBuffer sbsg = null;
              StringBuffer sbss = null;
              for (ItemInList iil : itemsList) {
                if (iil.getItsType().equals(EShopItemType.GOODS)) {
                  if (sbg == null) {
                    sbg = new StringBuffer();
                    sbg.append("(" + iil.getItemId());
                  } else {
                    sbg.append("," + iil.getItemId());
                  }
                } else if (iil.getItsType().equals(EShopItemType.SERVICE)) {
                  if (sbs == null) {
                    sbs = new StringBuffer();
                    sbs.append("(" + iil.getItemId());
                  } else {
                    sbs.append("," + iil.getItemId());
                  }
                } else if (iil.getItsType().equals(EShopItemType.SEGOODS)) {
                  if (sbsg == null) {
                    sbsg = new StringBuffer();
                    sbsg.append("(" + iil.getItemId());
                  } else {
                    sbsg.append("," + iil.getItemId());
                  }
                } else if (iil.getItsType().equals(EShopItemType.SESERVICE)) {
                  if (sbss == null) {
                    sbss = new StringBuffer();
                    sbss.append("(" + iil.getItemId());
                  } else {
                    sbss.append("," + iil.getItemId());
                  }
                }
              }
              StringBuffer sbq = null;
              if (sbg != null) {
                sbq = new StringBuffer();
                sbq.append(
       "select 0 as ITSVERSION, ITEM, ITSPRICE from PRICEGOODS where ITEM in "
    + sbg + ")");
              }
              if (sbs != null) {
                if (sbq == null) {
                  sbq = new StringBuffer();
                } else {
                  sbq.append("\n union all \n");
                }
                sbq.append(
       "select 1 as ITSVERSION, ITEM, ITSPRICE from SERVICEPRICE where ITEM in "
    + sbs + ")");
              }
              if (sbsg != null) {
                if (sbq == null) {
                  sbq = new StringBuffer();
                } else {
                  sbq.append("\n union all \n");
                }
                sbq.append(
       "select 2 as ITSVERSION, ITEM, ITSPRICE from SEGOODSPRICE where ITEM in "
    + sbsg + ")");
              }
              if (sbss != null) {
                if (sbq == null) {
                  sbq = new StringBuffer();
                } else {
                  sbq.append("\n union all \n");
                }
                sbq.append(
     "select 3 as ITSVERSION, ITEM, ITSPRICE from SESERVICEPRICE where ITEM in "
    + sbss + ")");
              }
              if (sbq != null) {
                sbq.append(";");
                Set<String> ndFlPr = new HashSet<String>();
                ndFlPr.add("item");
                ndFlPr.add("itsPrice");
                ndFlPr.add("itsVersion"); //actually item type!
                pRqVs.put("PriceGoodsneededFields", ndFlPr);
                pRqVs.put("PriceGoodsitemdeepLevel", 1);
             List<PriceGoods> prcs = this.srvOrm.retrieveListByQuery(pRqVs,
                  PriceGoods.class, sbq.toString());
                pRqVs.remove("PriceGoodsneededFields");
                pRqVs.remove("PriceGoodsitemdeepLevel");
                for (PriceGoods pri : prcs) {
                  for (ItemInList iil : itemsList) {
                    long itTyp = iil.getItsType().ordinal();
                    if (iil.getItemId().equals(pri.getItem().getItsId())
                      && itTyp == pri.getItsVersion()) {
                      iil.setItsPrice(pri.getItsPrice());
                      break;
                    }
                  }
                }
              }
            }
          }
          Integer paginationTail = Integer.valueOf(mngUvdSettings
            .getAppSettings().get("paginationTail"));
          List<Page> pages = this.srvPage.evalPages(page, totalPages,
            paginationTail);
          pRqDt.setAttribute("pages", pages);
          pRqDt.setAttribute("itemsList", itemsList);
          pRqDt.setAttribute("totalItems", rowCount);
        }
        if (filterPrice != null) {
          pRqDt.setAttribute("filterPrice", filterPrice);
        }
        if (filterCatalog != null) {
          pRqDt.setAttribute("filterCatalog", filterCatalog);
        }
        if (filtersSpecifics != null) {
          pRqDt.setAttribute("filtersSpecifics", filtersSpecifics);
        }
        pRqDt.setAttribute("catalog", tcat.getCatalog());
      }
    }
  }
34725
public JSONObject getByBuyersCompany(String buyerCompanyReference, HashMap<String, String> params) throws JSONException {
        return oClient.get("/finreports/v2/buyer_companies/" + buyerCompanyReference + "/billings", params);
    }
945970
@Override
  public final void setLang(final Languages pLang) {
    this.lang = pLang;
    if (this.itsId == null) {
      this.itsId = new IdI18nSeGoods();
    }
    this.itsId.setLang(this.lang);
  }
779159
public final void updateOwner(final Map<String, Object> pAddParam,
    final AdditionCostLine pEntity) throws Exception {
    String query =
    "select sum(ITSTOTAL) as ITSTOTAL from"
      + " ADDITIONCOSTLINE where ITSOWNER="
        + pEntity.getItsOwner().getItsId();
    Double total = getSrvDatabase().evalDoubleResult(query, "ITSTOTAL");
    pEntity.getItsOwner().setTotalAdditionCost(BigDecimal.valueOf(total)
.setScale(getSrvAccSettings().lazyGetAccSettings(pAddParam).getCostPrecision(),
  getSrvAccSettings().lazyGetAccSettings(pAddParam).getRoundingMode()));
    pEntity.getItsOwner().setItsTotal(pEntity.getItsOwner()
      .getTotalMaterialsCost().add(pEntity.getItsOwner()
        .getTotalAdditionCost()).setScale(getSrvAccSettings()
      .lazyGetAccSettings(pAddParam).getCostPrecision(),
    getSrvAccSettings().lazyGetAccSettings(pAddParam).getRoundingMode()));
    pEntity.getItsOwner().setItsCost(pEntity.getItsOwner().getItsTotal()
      .divide(pEntity.getItsOwner().getItsQuantity(),
        getSrvAccSettings().lazyGetAccSettings(pAddParam).getCostPrecision(),
          getSrvAccSettings().lazyGetAccSettings(pAddParam).getRoundingMode()));
    getSrvOrm().updateEntity(pAddParam, pEntity.getItsOwner());
  }
1043342
protected final PrcSalesReturnLineGfr lazyGetPrcSalesReturnLineGfr(
    final Map<String, Object> pAddParam) throws Exception {
    @SuppressWarnings("unchecked")
    PrcSalesReturnLineGfr<RS> proc = (PrcSalesReturnLineGfr<RS>)
      this.processorsMap.get(PrcSalesReturnLineGfr.class.getSimpleName());
    if (proc == null) {
      proc = new PrcSalesReturnLineGfr<RS>();
      @SuppressWarnings("unchecked")
      PrcEntityPbCopy<RS, SalesReturnLine> procDlg =
        (PrcEntityPbCopy<RS, SalesReturnLine>) this.fctBnEntitiesProcessors
          .lazyGet(pAddParam, PrcEntityPbCopy.class.getSimpleName());
      proc.setPrcAccEntityPbCopy(procDlg);
      //assigning fully initialized object:
      this.processorsMap.put(PrcSalesReturnLineGfr.class.getSimpleName(), proc);
    }
    return proc;
  }
737424
public final void updateOwner(final Map<String, Object> pAddParam,
    final WageTaxLine pEntity) throws Exception {
    String query =
    "select sum(ITSTOTAL) as ITSTOTAL from WAGETAXLINE"
      + " join TAX on TAX.ITSID = WAGETAXLINE.TAX"
        + " where TAX.ITSTYPE=3 and ITSOWNER="
          + pEntity.getItsOwner().getItsId();
    Double total = getSrvDatabase().evalDoubleResult(query, "ITSTOTAL");
    if (total == null) {
      total = 0d;
    }
    pEntity.getItsOwner().setTotalTaxesEmployee(BigDecimal.valueOf(total)
      .setScale(getSrvAccSettings().lazyGetAccSettings(pAddParam)
        .getPricePrecision(), getSrvAccSettings()
          .lazyGetAccSettings(pAddParam).getRoundingMode()));
    query =
    "select sum(ITSTOTAL) as ITSTOTAL from WAGETAXLINE"
      + " join TAX on TAX.ITSID = WAGETAXLINE.TAX"
        + " where TAX.ITSTYPE=4 and ITSOWNER="
          + pEntity.getItsOwner().getItsId();
    total = getSrvDatabase().evalDoubleResult(query, "ITSTOTAL");
    if (total == null) {
      total = 0d;
    }
    pEntity.getItsOwner().setTotalTaxesEmployer(BigDecimal.valueOf(total)
      .setScale(getSrvAccSettings().lazyGetAccSettings(pAddParam)
        .getPricePrecision(), getSrvAccSettings()
          .lazyGetAccSettings(pAddParam).getRoundingMode()));
    pEntity.getItsOwner().setNetWage(pEntity.getItsOwner()
      .getItsTotal().subtract(pEntity.getItsOwner()
        .getTotalTaxesEmployee()));
    getSrvOrm().updateEntity(pAddParam, pEntity.getItsOwner());
  }
220841
protected final void lazyInitRetrievers(
      final Map<String, Object> pAddParam) throws Exception {
    if (this.retrievers == null) {
      this.retrievers = new HashMap<String, ICsvDataRetriever>();
      GoodsPriceListRetriever<RS> gpr = new GoodsPriceListRetriever<RS>();
      gpr.setSrvI18n(getSrvI18n());
      gpr.setSrvOrm(getSrvOrm());
      gpr.setSrvDatabase(getSrvDatabase());
      gpr.setSrvAccSettings(getSrvAccSettings());
      this.retrievers.put("GoodsPriceListRetriever", gpr);
      ServicePriceListRetriever<RS> spr = new ServicePriceListRetriever<RS>();
      spr.setSrvI18n(getSrvI18n());
      spr.setSrvOrm(getSrvOrm());
      spr.setSrvAccSettings(getSrvAccSettings());
      this.retrievers.put("ServicePriceListRetriever", spr);
    }
  }
57528
protected final UtlInvLine<RS, PurchaseInvoice, PurchaseInvoiceServiceLine,
    PurchaseInvoiceTaxLine, PurchaseInvoiceServiceTaxLine> lazyGetUtlPurSrLn(
      final Map<String, Object> pAddParam) throws Exception {
    UtlInvLine<RS, PurchaseInvoice, PurchaseInvoiceServiceLine,
      PurchaseInvoiceTaxLine, PurchaseInvoiceServiceTaxLine> utlInvLn = this
        .utlPurInvSrLn;
    if (utlInvLn == null) {
      utlInvLn = new UtlInvLine<RS, PurchaseInvoice, PurchaseInvoiceServiceLine,
        PurchaseInvoiceTaxLine, PurchaseInvoiceServiceTaxLine>();
      utlInvLn.setUtlInvBase(lazyGetUtlInvBase(pAddParam));
      utlInvLn.setInvTxMeth(lazyGetPurInvTxMeth(pAddParam));
      utlInvLn.setIsMutable(true);
      utlInvLn.setNeedMkTxCat(true);
      utlInvLn.setLtlCl(PurchaseInvoiceServiceTaxLine.class);
      utlInvLn.setDstTxItLnCl(DestTaxServPurchLn.class);
      FactoryPersistableBase<PurchaseInvoiceServiceTaxLine> fctLtl =
        new FactoryPersistableBase<PurchaseInvoiceServiceTaxLine>();
      fctLtl.setObjectClass(PurchaseInvoiceServiceTaxLine.class);
      fctLtl.setDatabaseId(getSrvDatabase().getIdDatabase());
      utlInvLn.setFctLineTxLn(fctLtl);
      //assigning fully initialized object:
      this.utlPurInvSrLn = utlInvLn;
    }
    return utlInvLn;
  }
1300233
@Override
  public final List<WarehouseEntry> retrieveEntriesForOwner(
    final Map<String, Object> pAddParam,
      final Integer pOwnerTypeCode, final Long pOwnerId) throws Exception {
    String tblNm = WarehouseEntry.class.getSimpleName().toUpperCase();
    String where = " where SOURCEOWNERTYPE=" + pOwnerTypeCode
        + " and " + tblNm + ".IDDATABASEBIRTH=" + getSrvOrm().getIdDatabase()
          + " and SOURCEOWNERID=" + pOwnerId;
    return getSrvOrm()
      .retrieveListWithConditions(pAddParam, WarehouseEntry.class, where);
  }
380375
public final void updateOwner(final Map<String, Object> pAddParam,
    final WageLine pEntity) throws Exception {
    String query =
    "select sum(GROSSWAGE) as GROSSWAGE from " + WageLine.class
      .getSimpleName().toUpperCase() + " where ITSOWNER="
        + pEntity.getItsOwner().getItsId();
    Double total = getSrvDatabase().evalDoubleResult(query, "GROSSWAGE");
    if (total == null) {
      total = 0d;
    }
    pEntity.getItsOwner().setItsTotal(BigDecimal.valueOf(total).setScale(
      getSrvAccSettings().lazyGetAccSettings(pAddParam).getPricePrecision(),
        getSrvAccSettings().lazyGetAccSettings(pAddParam).getRoundingMode()));
    getSrvOrm().updateEntity(pAddParam, pEntity.getItsOwner());
  }
1169581
protected final PrcSalesRetGfe lazyGetPrcSalesRetGfe(
    final Map<String, Object> pAddParam) throws Exception {
    PrcSalesRetGfe proc = (PrcSalesRetGfe)
      this.processorsMap.get(PrcSalesRetGfe.class.getSimpleName());
    if (proc == null) {
      proc = new PrcSalesRetGfe();
      @SuppressWarnings("unchecked")
      PrcEntityPbEditDelete<RS, SalesReturn> procDlg =
    (PrcEntityPbEditDelete<RS, SalesReturn>) this.fctBnEntitiesProcessors
  .lazyGet(pAddParam, PrcEntityPbEditDelete.class.getSimpleName());
      proc.setPrcEntityPbEditDelete(procDlg);
      //assigning fully initialized object:
      this.processorsMap
        .put(PrcSalesRetGfe.class.getSimpleName(), proc);
    }
    return proc;
  }
668695
public JSONObject getOwned(String freelancerReference, HashMap<String, String> params) throws JSONException {
        return oClient.get("/finreports/v2/financial_account_owner/" + freelancerReference, params);
    }
206125
public final String makeDescription(final IMakingWarehouseEntry pEntity,
    final String pLangDef, final DateFormat pDateFormat) {
    String strWho = getSrvI18n().getMsg(pEntity.getClass().getSimpleName()
      + "short", pLangDef) + " #" + getSrvOrm().getIdDatabase() + "-"
        + pEntity.getItsId(); //only local
    if (pEntity.getOwnerId() == null) {
      strWho += ", " + pDateFormat.format(pEntity
        .getDocumentDate());
    } else {
      strWho += " " + getSrvI18n().getMsg("in", pLangDef) + " " + getSrvI18n()
    .getMsg(getSrvTypeCodeDocuments().getTypeCodeMap().get(pEntity
  .getOwnerType()).getSimpleName() + "short", pLangDef) + " #" + getSrvOrm()
    .getIdDatabase() + "-" + pEntity.getOwnerId() + ", "
      + pDateFormat.format(pEntity.getDocumentDate());
    }
    return getSrvI18n().getMsg("made_at", pLangDef) + " " + pDateFormat.format(
      new Date()) + " " + getSrvI18n().getMsg("by", pLangDef) + " " + strWho;
  }
413360
public final void procSeSrv(final Map<String, Object> pRqVs,
    final IRequestData pRqDt, final TradingSettings pTs,
      final OnlineBuyer pBuyer, final Long pItemId) throws Exception {
    List<SeServiceSpecifics> itemSpecLst;
    List<SeServicePlace> itemPlaceLst;
    itemSpecLst = retrieveItemSpecificsList(pRqVs, pTs, pItemId,
      SeServiceSpecifics.class, SeService.class.getSimpleName());
    //extract main image if exist:
    int miIdx = -1;
    for (int i = 0; i < itemSpecLst.size(); i++) {
      if (itemSpecLst.get(i).getSpecifics().getItsType()
        .equals(ESpecificsItemType.IMAGE)) {
        pRqDt.setAttribute("itemImage", itemSpecLst.get(i));
        miIdx = i;
        break;
      }
    }
    if (miIdx != -1) {
      itemSpecLst.remove(miIdx);
    }
    AItemPrice<?, ?> itemPrice = getSrvCart().revealItemPrice(pRqVs, pTs,
        pBuyer, EShopItemType.SESERVICE, pItemId);
    itemPlaceLst = getSrvOrm().retrieveListWithConditions(pRqVs,
        SeServicePlace.class, " where ITEM=" + pItemId);
    pRqDt.setAttribute("itemSpecLst", itemSpecLst);
    pRqDt.setAttribute("itemPlaceLst", itemPlaceLst);
    pRqDt.setAttribute("itemPrice", itemPrice);
  }