<p>Make other entries include reversing if it's need when save.</p>
@param pAddParam additional param
@param pEntity entity
@param pRequestData Request Data
@param pIsNew if entity was new
@throws Exception - an exception
490766
@Override
  public final void makeOtherEntries(final Map<String, Object> pAddParam,
    final PaymentFrom pEntity, final IRequestData pRequestData,
      final boolean pIsNew) throws Exception {
    String actionAdd = pRequestData.getParameter("actionAdd");
    if ("makeAccEntries".equals(actionAdd)) {
      this.prcSalesInvoiceSave.calculateTotalPayment(pAddParam, pEntity
        .getSalesInvoice());
      getSrvOrm().updateEntity(pAddParam, pEntity.getSalesInvoice());
    }
  }
247391
@Override
  public final void retrievePage(final Map<String, Object> pAddParam,
    final IRequestData pRequestData) throws Exception {
    this.isDbgSh = this.logger.getDbgSh(this.getClass())
        && this.logger.getDbgFl() < 7001 && this.logger.getDbgCl() > 7003;
    this.hlpEntitiesPage.retrievePage(pAddParam, pRequestData, this.entitiesMap,
      this.isDbgSh, this.filterFiMaker);
  }
221941
protected final PrcEntityFSave<RS, IHasId<Object>, Object>
    createPutPrcEntityFSave(
      final Map<String, Object> pAddParam) throws Exception {
    @SuppressWarnings("unchecked")
    PrcEntityFSave<RS, IHasId<Object>, Object> proc =
      (PrcEntityFSave<RS, IHasId<Object>, Object>)
        this.fctBnEntitiesProcessors
          .lazyGet(pAddParam, PrcEntityFSave.class.getSimpleName());
    //assigning fully initialized object:
    this.processorsMap.put(PrcEntityFSave.class.getSimpleName(), proc);
    return proc;
  }
78172
public final <T extends IHasIdLongVersionName> void makeIt(
    final Map<String, Object> pAddParam, final IRequestData pRequestData,
      final Class<T> pItemClass) throws Exception {
    Set<String> filterAppearance = new HashSet<String>();
    pAddParam.put("filterAppearance", filterAppearance);
    StringBuffer sbWhere = this.srvEntitiesPage
      .revealPageFilterData(pAddParam, pRequestData, pItemClass);
    if (sbWhere.length() == 0) {
      throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER,
        "filter_must_be_not_empty");
    }
    String itemsCatalogAction = pRequestData
      .getParameter("itemsCatalogAction");
    if (!("add".equals(itemsCatalogAction)
      || "remove".equals(itemsCatalogAction))) {
      throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER,
        "wrong_action");
    }
    Long catalogId = Long.valueOf(pRequestData
      .getParameter(CatalogGs.class.getSimpleName() + ".itsId"));
    if (catalogId == null) {
      throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER,
        "catalog_must_be_not_empty");
    }
    CatalogGs catalogOfGoods = this.srvOrm
      .retrieveEntityById(pAddParam, CatalogGs.class, catalogId);
    if (catalogOfGoods == null) {
      throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER,
        "catalog_must_be_not_empty");
    }
    if (catalogOfGoods.getHasSubcatalogs()) {
      throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER,
        "catalog_must_not_has_subcatalog");
    }
    String whereStr = sbWhere.toString();
    Integer rowCount = this.srvOrm.evalRowCountWhere(pAddParam, pItemClass,
        whereStr);
    TradingSettings ts = (TradingSettings) pAddParam.get("tradSet");
    if (rowCount > ts.getMaxQuantityOfBulkItems()) {
      throw new ExceptionWithCode(ExceptionWithCode.SOMETHING_WRONG,
        "filtered_list_size_exceed_max_bulk");
    }
    Integer totalItems = Integer
      .valueOf(pRequestData.getParameter("totalItems"));
    if (!rowCount.equals(totalItems)) {
      throw new ExceptionWithCode(ExceptionWithCode.SOMETHING_WRONG,
        "filtered_list_has_changed");
    }
    List<T> itemsList = this.srvOrm.retrieveListWithConditions(pAddParam,
      pItemClass, "where " + whereStr);
    for (T items : itemsList) {
      AItemCatalog ic;
      if (pItemClass == InvItem.class) {
        ic = new GoodsCatalog();
      } else if (pItemClass == ServiceToSale.class) {
        ic = new ServiceCatalog();
      } else {
        throw new Exception("NEI: " + pItemClass);
      }
      ic.setItsCatalog(catalogOfGoods);
      ic.setItem(items);
      if ("add".equals(itemsCatalogAction)) {
        // add items to catalog
        this.srvOrm.insertEntity(pAddParam, ic);
      } else {
        // remove items from catalog
        this.srvOrm.deleteEntity(pAddParam, ic);
      }
    }
    pRequestData.setAttribute("itemsCatalogAction", itemsCatalogAction);
    pRequestData.setAttribute("filterAppearance", filterAppearance);
    pRequestData.setAttribute("totalItems", totalItems);
    pRequestData.setAttribute("itemsList", itemsList);
    pRequestData.setAttribute("catalogOfItems", catalogOfGoods);
  }
969938
@Override
  public final AItemSpecifics<T, ID> process(
    final Map<String, Object> pReqVars,
      final AItemSpecifics<T, ID> pEntity,
        final IRequestData pRequestData) throws Exception {
    String fileToUploadName = (String) pRequestData
      .getAttribute("fileToUploadName");
    OutputStream outs = null;
    InputStream ins = null;
    try {
      String filePath;
      if (pEntity.getStringValue1() == null) { //in base language:
        String ft = String.valueOf(new Date().getTime());
        filePath = this.webAppPath + File.separator
          + this.uploadDirectory + File.separator
            + ft + fileToUploadName;
        pEntity.setStringValue2(filePath);
        pEntity.setStringValue1(this.uploadDirectory
              + "/" + ft + fileToUploadName);
      } else { //I18N files:
        String fileLang = pRequestData.getParameter("fileLang");
        if (pEntity.getStringValue3() == null
          || !pEntity.getStringValue3().contains(fileLang)) {
          throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER,
            "notset_language");
        }
        int idhHtml = pEntity.getStringValue1().indexOf(".html");
        String urlWithoutHtml = pEntity.getStringValue1().substring(0, idhHtml);
        filePath = this.webAppPath + File.separator
          + urlWithoutHtml + "_" + fileLang + ".html";
      }
      ins = (InputStream) pRequestData.getAttribute("fileToUploadInputStream");
      outs = new BufferedOutputStream(new FileOutputStream(filePath));
      byte[] data = new byte[1024];
      int count;
      while ((count = ins.read(data)) != -1) {
        outs.write(data, 0, count);
      }
      outs.flush();
    } finally {
      if (ins != null) {
        ins.close();
      }
      if (outs != null) {
        outs.close();
      }
    }
    getSrvOrm().updateEntity(pReqVars, pEntity);
    return pEntity;
  }
1189825
@Override
  public final synchronized void changeBalanceStorePeriod(
    final Map<String, Object> pAddParam,
      final EPeriod pPeriod) throws Exception {
    if (pPeriod == null) {
      throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER,
        "null_not_accepted");
    }
    if (!lazyGetBalanceAtAllDirtyCheck(pAddParam).getBalanceStorePeriod()
      .equals(pPeriod)) {
      getLogger().info(null, SrvBalanceStd.class,
        "changing period from " + this.balanceAtAllDirtyCheck
          .getBalanceStorePeriod() + " to " + pPeriod);
      this.balanceAtAllDirtyCheck.setBalanceStorePeriod(pPeriod);
      if (!getSrvAccSettings().lazyGetAccSettings(pAddParam)
        .getBalanceStorePeriod().equals(pPeriod)) {
        getSrvAccSettings().lazyGetAccSettings(pAddParam)
          .setBalanceStorePeriod(pPeriod);
        getSrvAccSettings().saveAccSettings(pAddParam, getSrvAccSettings()
          .lazyGetAccSettings(pAddParam));
      }
      this.balanceAtAllDirtyCheck
        .setCurrentBalanceDate(initDate);
      this.balanceAtAllDirtyCheck.setIsPeriodChanged(true);
      getSrvOrm()
        .updateEntity(pAddParam, this.balanceAtAllDirtyCheck);
    }
  }
1121817
@Override
  public final void reverseEntries(final Map<String, Object> pAddParam,
    final IDoc pReversing,
      final IDoc pReversed) throws Exception {
    List<AccountingEntry> sources = getSrvOrm().retrieveListWithConditions(
      pAddParam, AccountingEntry.class, " where SOURCETYPE="
        + pReversing.constTypeCode() + " and SOURCEID="
          + pReversing.getReversedId() + " and SOURCEDATABASEBIRTH="
            + pReversing.getReversedIdDatabaseBirth());
    Long itsDateLong = null;
    String langDef = (String) pAddParam.get("langDef");
    DateFormat dateFormat = DateFormat.getDateTimeInstance(
      DateFormat.MEDIUM, DateFormat.SHORT, new Locale(langDef));
    for (AccountingEntry source : sources) {
      if (!source.getIdDatabaseBirth()
        .equals(getSrvDatabase().getIdDatabase())) {
        throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER,
          "can_not_reverse_foreign_acconting_entries");
      }
      if (itsDateLong == null) {
        itsDateLong = pReversing.getItsDate().getTime();
        getSrvBalance().handleNewAccountEntry(pAddParam, null, null,
          new Date(itsDateLong)); //This is for SrvBalanceStd only!!!
      }
      AccountingEntry accEntry = new AccountingEntry();
      accEntry.setItsDate(new Date(itsDateLong++));
      accEntry.setIdDatabaseBirth(getSrvDatabase().getIdDatabase());
      accEntry.setSourceType(pReversing.constTypeCode());
      Long reversingDocId = pReversing.getItsId();
      if (pReversing.getIdBirth() != null) {
        reversingDocId = pReversing.getIdBirth();
      }
      accEntry.setSourceId(reversingDocId);
      accEntry.setSourceDatabaseBirth(pReversing.getIdDatabaseBirth());
      accEntry.setAccDebit(source.getAccDebit());
      accEntry.setSubaccDebitType(source.getSubaccDebitType());
      accEntry.setSubaccDebitId(source.getSubaccDebitId());
      accEntry.setSubaccDebit(source.getSubaccDebit());
      if (source.getDebit() != null) {
        accEntry.setDebit(source.getDebit().negate());
      }
      accEntry.setAccCredit(source.getAccCredit());
      accEntry.setSubaccCreditType(source.getSubaccCreditType());
      accEntry.setSubaccCreditId(source.getSubaccCreditId());
      accEntry.setSubaccCredit(source.getSubaccCredit());
      if (source.getCredit() != null) {
        accEntry.setCredit(source.getCredit().negate());
      }
      accEntry.setDescription(getSrvI18n().getMsg("made_at", langDef) + " "
    + dateFormat.format(new Date()) + " " + getSrvI18n()
  .getMsg("by", langDef) + " " + getSrvI18n().getMsg(pReversing.getClass()
.getSimpleName() + "short", langDef) + " #" + pReversing.getIdDatabaseBirth()
  + "-" + reversingDocId + ", " + dateFormat.format(pReversing.getItsDate())
    // reversed from  current DB:
    + ", " + getSrvI18n().getMsg("reversed_entry_n", langDef) + source
      .getIdDatabaseBirth() + "-" + source.getItsId());
      accEntry.setReversedId(source.getItsId());
      accEntry.setReversedIdDatabaseBirth(source.getIdDatabaseBirth());
      srvOrm.insertEntity(pAddParam, accEntry);
      accEntry.setIsNew(false);
      source.setDescription(source.getDescription().trim()
        + " " + getSrvI18n().getMsg("reversing_entry_n", langDef) + accEntry
          .getIdDatabaseBirth() + "-"
            + accEntry.getItsId()); // new in current DB
      source.setReversedId(accEntry.getItsId());
      source.setReversedIdDatabaseBirth(accEntry.getIdDatabaseBirth());
      srvOrm.updateEntity(pAddParam, source);
    }
    pReversing.setHasMadeAccEntries(true);
    srvOrm.updateEntity(pAddParam, pReversing);
  }
795456
@Override
  public final T process(final Map<String, Object> pReqVars,
    final T pEntity, final IRequestData pRequestData) throws Exception {
    SeSeller ses = findSeSeller.find(pReqVars, pRequestData.getUserName());
    pEntity.setSeller(ses);
    if (pEntity.getIsNew()) {
      this.srvOrm.insertEntity(pReqVars, pEntity);
      pEntity.setIsNew(false);
    } else {
      T entOld = this.srvOrm.retrieveEntity(pReqVars, pEntity);
      if (!entOld.getSeller().getItsId().getItsId()
        .equals(pEntity.getSeller().getItsId().getItsId())) {
        throw new ExceptionWithCode(ExceptionWithCode.FORBIDDEN,
        "Attempt to update smb. else's entity: user/entity/EID/SEOLDID/SEID - "
          + pRequestData.getUserName() + "/" + pEntity.getClass()
           .getSimpleName() + "/" + pEntity.getItsId() + "/" + entOld
            .getSeller().getItsId().getItsId() + "/" + pEntity.getSeller()
              .getItsId().getItsId());
      }
      this.srvOrm.updateEntity(pReqVars, pEntity);
    }
    return pEntity;
  }
409520
@Override
  public final void makeOtherEntries(final Map<String, Object> pAddParam,
    final SalesReturn pEntity, final IRequestData pRequestData,
      final boolean pIsNew) throws Exception {
    String actionAdd = pRequestData.getParameter("actionAdd");
    if ("makeAccEntries".equals(actionAdd)
      && pEntity.getReversedId() != null) {
      //reverse none-reversed lines:
      SalesReturnLine srl = new SalesReturnLine();
      SalesReturn reversed = new SalesReturn();
      reversed.setItsId(pEntity.getReversedId());
      srl.setItsOwner(reversed);
      List<SalesReturnLine> reversedLines = getSrvOrm().
        retrieveListForField(pAddParam, srl, "itsOwner");
      String langDef = (String) pAddParam.get("langDef");
      for (SalesReturnLine reversedLine : reversedLines) {
        if (reversedLine.getReversedId() == null) {
          if (!reversedLine.getItsQuantity()
            .equals(reversedLine.getTheRest())) {
            throw new ExceptionWithCode(PurchaseInvoice.SOURSE_IS_IN_USE,
              "There is withdrawals from this source!");
          }
          SalesReturnLine reversingLine = new SalesReturnLine();
          reversingLine.setIdDatabaseBirth(getSrvOrm().getIdDatabase());
          reversingLine.setReversedId(reversedLine.getItsId());
          reversingLine.setWarehouseSite(reversedLine.getWarehouseSite());
          reversingLine.setInvItem(reversedLine.getInvItem());
          reversingLine.setUnitOfMeasure(reversedLine.getUnitOfMeasure());
          reversingLine.setItsCost(reversedLine.getItsCost());
          reversingLine.setItsQuantity(reversedLine.getItsQuantity()
            .negate());
          reversingLine.setItsTotal(reversedLine.getItsTotal().negate());
          reversingLine.setSubtotal(reversedLine.getSubtotal().negate());
          reversingLine.setTotalTaxes(reversedLine.getTotalTaxes().negate());
          reversingLine.setTaxesDescription(reversedLine
            .getTaxesDescription());
          reversingLine.setIsNew(true);
          reversingLine.setItsOwner(pEntity);
          reversingLine.setDescription(getSrvI18n()
            .getMsg("reversed_n", langDef) + reversedLine.getIdDatabaseBirth()
              + "-" + reversedLine.getItsId()); //local
          getSrvOrm().insertEntity(pAddParam, reversingLine);
          reversingLine.setIsNew(false);
          getSrvWarehouseEntry().load(pAddParam, reversingLine,
            reversingLine.getWarehouseSite());
          String descr;
          if (reversedLine.getDescription() == null) {
            descr = "";
          } else {
            descr = reversedLine.getDescription();
          }
          reversedLine.setDescription(descr
            + " " + getSrvI18n().getMsg("reversing_n", langDef) + reversingLine
              .getIdDatabaseBirth() + "-" + reversingLine.getItsId());
          reversedLine.setReversedId(reversingLine.getItsId());
          reversedLine.setTheRest(BigDecimal.ZERO);
          getSrvOrm().updateEntity(pAddParam, reversedLine);
          SalesReturnGoodsTaxLine pigtlt =
            new SalesReturnGoodsTaxLine();
          pigtlt.setItsOwner(reversedLine);
          List<SalesReturnGoodsTaxLine> tls = getSrvOrm()
            .retrieveListForField(pAddParam, pigtlt, "itsOwner");
          for (SalesReturnGoodsTaxLine pigtl : tls) {
            getSrvOrm().deleteEntity(pAddParam, pigtl);
          }
        }
      }
      SalesReturnTaxLine srtl = new SalesReturnTaxLine();
      srtl.setItsOwner(reversed);
      List<SalesReturnTaxLine> reversedTaxLines = getSrvOrm().
        retrieveListForField(pAddParam, srtl, "itsOwner");
      for (SalesReturnTaxLine reversedLine : reversedTaxLines) {
        if (reversedLine.getReversedId() == null) {
          SalesReturnTaxLine reversingLine = new SalesReturnTaxLine();
          reversingLine.setIdDatabaseBirth(getSrvOrm().getIdDatabase());
          reversingLine.setReversedId(reversedLine.getItsId());
          reversingLine.setItsTotal(reversedLine.getItsTotal().negate());
          reversingLine.setTax(reversedLine.getTax());
          reversingLine.setIsNew(true);
          reversingLine.setItsOwner(pEntity);
          getSrvOrm().insertEntity(pAddParam, reversingLine);
          reversingLine.setIsNew(false);
          reversedLine.setReversedId(reversingLine.getItsId());
          getSrvOrm().updateEntity(pAddParam, reversedLine);
        }
      }
    }
  }
592031
@Override
  public final void process(final Map<String, Object> pAddParam,
    final IRequestData pRequestData) throws Exception {
    this.srvEntitiesPage.retrievePage(pAddParam, pRequestData);
  }
854105
protected final PrcPrepaymentFromSave<RS> createPutPrcPrepaymentFromSave(
    final Map<String, Object> pAddParam) throws Exception {
    PrcPrepaymentFromSave<RS> proc = new PrcPrepaymentFromSave<RS>();
    proc.setSrvAccSettings(getSrvAccSettings());
    proc.setSrvAccEntry(getSrvAccEntry());
    proc.setSrvOrm(getSrvOrm());
    proc.setSrvI18n(getSrvI18n());
    //assigning fully initialized object:
    this.processorsMap.put(PrcPrepaymentFromSave.class.getSimpleName(), proc);
    return proc;
  }
247012
protected final PrcRefreshItemsInList<RS>
    lazyGetPrcRefreshItemsInList(
      final Map<String, Object> pAddParam) throws Exception {
    String beanName = PrcRefreshItemsInList.class.getSimpleName();
    @SuppressWarnings("unchecked")
    PrcRefreshItemsInList<RS> proc = (PrcRefreshItemsInList<RS>)
      this.processorsMap.get(beanName);
    if (proc == null) {
      proc = new PrcRefreshItemsInList<RS>();
      proc.setSrvOrm(getSrvOrm());
      proc.setSrvDatabase(getSrvDatabase());
      proc.setSrvNumberToString(getSrvNumberToString());
      //assigning fully initialized object:
      this.processorsMap.put(beanName, proc);
      this.logger.info(null, FctBnTradeProcessors.class,
        beanName + " has been created.");
    }
    return proc;
  }
72076
@Override
  public final void makeFirstPrepareForSave(final Map<String, Object> pAddParam,
    final PaymentTo pEntity, final IRequestData pRequestData) throws Exception {
    //BeigeORM refresh:
    pEntity.setAccCash(getSrvOrm()
      .retrieveEntity(pAddParam, pEntity.getAccCash()));
    if (pEntity.getAccCash().getSubaccType() != null
      && pEntity.getSubaccCashId() == null) {
      throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER,
        "select_subaccount");
    }
    if (pEntity.getPurchaseInvoice() != null) {
      PurchaseInvoice purchaseInvoice = getSrvOrm()
        .retrieveEntity(pAddParam, pEntity.getPurchaseInvoice());
      if (!purchaseInvoice.getHasMadeAccEntries()
        || purchaseInvoice.getReversedId() != null) {
        throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER,
          "purchase_invoice_must_be_accounted");
      }
      pEntity.setPurchaseInvoice(purchaseInvoice);
    }
  }
1014201
protected final PrcBankStatementSave<RS> lazyGetPrcBankStatementSave(
    final Map<String, Object> pAddParam) throws Exception {
    @SuppressWarnings("unchecked")
    PrcBankStatementSave<RS> proc = (PrcBankStatementSave<RS>)
      this.processorsMap.get(PrcBankStatementSave.class.getSimpleName());
    if (proc == null) {
      proc = new PrcBankStatementSave<RS>();
      proc.setSrvOrm(getSrvOrm());
      proc.setCsvReader(getCsvReader());
      //assigning fully initialized object:
      this.processorsMap.put(PrcBankStatementSave.class.getSimpleName(), proc);
    }
    return proc;
  }
770360
@Override
  public final void reverseDraw(final Map<String, Object> pAddParam,
    final IMakingWarehouseEntry pEntity) throws Exception {
    if (!pEntity.getIdDatabaseBirth()
      .equals(getSrvOrm().getIdDatabase())) {
      throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER,
        "can_not_make_ws_entry_for_foreign_src");
    }
    if (pEntity.getItsQuantity().doubleValue() > 0) {
      throw new ExceptionWithCode(ExceptionWithCode.SOMETHING_WRONG,
        "reversing_source_must_has_negative_quantity");
    }
    String tblNm = WarehouseEntry.class.getSimpleName().toUpperCase();
    List<WarehouseEntry> wml = getSrvOrm().retrieveListWithConditions(
      pAddParam, WarehouseEntry.class, "where SOURCETYPE=" + pEntity
        .constTypeCode() + " and " + tblNm + ".IDDATABASEBIRTH=" + getSrvOrm()
          .getIdDatabase() + " and SOURCEID=" + pEntity.getReversedId()
            + " and INVITEM=" + pEntity.getInvItem().getItsId()
              +  " and WAREHOUSESITEFROM is not null");
    BigDecimal quantityToLeaveRst = pEntity.getItsQuantity();
    String langDef = (String) pAddParam.get("langDef");
    DateFormat dateFormat = DateFormat.getDateTimeInstance(
      DateFormat.MEDIUM, DateFormat.SHORT, new Locale(langDef));
    for (WarehouseEntry wms : wml) {
      if (wms.getItsQuantity().doubleValue() < 0) {
        throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER,
          "attempt_to_reverse_reversed");
      }
      WarehouseEntry wm = new WarehouseEntry();
      wm.setIdDatabaseBirth(getSrvOrm().getIdDatabase());
      wm.setSourceId(pEntity.getItsId());
      wm.setSourceType(pEntity.constTypeCode());
      wm.setWarehouseSiteFrom(wms.getWarehouseSiteFrom());
      wm.setUnitOfMeasure(wms.getUnitOfMeasure());
      wm.setInvItem(wms.getInvItem());
      wm.setItsQuantity(wms.getItsQuantity().negate());
      quantityToLeaveRst = quantityToLeaveRst.add(wms.getItsQuantity());
      if (quantityToLeaveRst.doubleValue() > 0) {
        throw new ExceptionWithCode(ExceptionWithCode.SOMETHING_WRONG,
          "reversing_source_has_different_quantity_against_movement_entries");
      }
      wm.setSourceOwnerId(pEntity.getOwnerId());
      wm.setSourceOwnerType(pEntity.getOwnerType());
      wm.setReversedId(wms.getItsId());
      wm.setDescription(makeDescription(pEntity, langDef, dateFormat) + " "
        + getSrvI18n().getMsg("reversed_entry_n", langDef) + getSrvOrm()
          .getIdDatabase() + "-" + wms.getItsId());
      getSrvOrm().insertEntity(pAddParam, wm);
      wm.setIsNew(false);
      makeWarehouseRest(pAddParam, pEntity, wm.getWarehouseSiteFrom(),
        wms.getItsQuantity());
      wms.setReversedId(wm.getItsId());
      wms.setDescription(wms.getDescription() + " " + getSrvI18n()
        .getMsg("reversing_entry_n", langDef) + getSrvOrm().getIdDatabase()
          + "-" + wm.getItsId());
      getSrvOrm().updateEntity(pAddParam, wms);
    }
    if (quantityToLeaveRst.doubleValue() != 0) {
      throw new ExceptionWithCode(ExceptionWithCode.SOMETHING_WRONG,
        "reversing_source_has_different_quantity_against_movement_entries");
    }
  }
1218142
@Override
  public final void makeFirstPrepareForSave(final Map<String, Object> pAddParam,
    final GoodsLoss pEntity,
      final IRequestData pRequestData) throws Exception {
    // nothing
  }
139266
@Override
  public final void withdrawalFrom(final Map<String, Object> pAddParam,
    final IMakingWarehouseEntry pEntity, final IDrawItemSource pSource,
        final BigDecimal pQuantityToDraw) throws Exception {
    if (!pEntity.getIdDatabaseBirth()
      .equals(getSrvOrm().getIdDatabase())) {
      throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER,
        "can_not_make_di_entry_for_foreign_src");
    }
    T die = createDrawItemEntry(pAddParam);
    die.setItsDate(pEntity.getDocumentDate());
    die.setIdDatabaseBirth(getSrvOrm().getIdDatabase());
    die.setSourceType(pSource.constTypeCode());
    die.setSourceId(pSource.getItsId());
    die.setDrawingType(pEntity.constTypeCode());
    die.setDrawingId(pEntity.getItsId());
    die.setDrawingOwnerId(pEntity.getOwnerId());
    die.setDrawingOwnerType(pEntity.getOwnerType());
    die.setSourceOwnerId(pSource.getOwnerId());
    die.setSourceOwnerType(pSource.getOwnerType());
    die.setItsQuantity(pQuantityToDraw);
    die.setItsCost(pSource.getItsCost());
    die.setInvItem(pEntity.getInvItem());
    die.setUnitOfMeasure(pEntity.getUnitOfMeasure());
    die.setItsTotal(pSource.getItsCost().
      multiply(die.getItsQuantity()).setScale(getSrvAccSettings()
        .lazyGetAccSettings(pAddParam).getCostPrecision(), getSrvAccSettings()
          .lazyGetAccSettings(pAddParam).getRoundingMode()));
    die.setDescription(makeDescription(pAddParam, pEntity, die));
    this.srvOrm.insertEntity(pAddParam, die);
    die.setIsNew(false);
    pSource.setTheRest(pSource.getTheRest().subtract(pQuantityToDraw));
    this.srvOrm.updateEntity(pAddParam, pSource);
  }