<p>Recalculate if need for all balances for all dates less
or equals pDateFor, this method is always invoked by report ledger.</p>
@param pAddParam additional param
@param pDateFor date for
@throws Exception - an exception
493239
@Override
  public final synchronized void recalculateAllIfNeed(
    final Map<String, Object> pAddParam, final Date pDateFor) throws Exception {
    //must be before evalDateBalanceStoreStart!!!
    evalBalanceStorePeriod(pAddParam);
    evalDateBalanceStoreStart(pAddParam);
    Date datePeriodStartFor = evalDatePeriodStartFor(pAddParam, pDateFor);
    Calendar calCurrYear = Calendar.getInstance(new Locale("en", "US"));
    calCurrYear.setTime(getSrvAccSettings().lazyGetAccSettings(pAddParam)
      .getCurrentAccYear());
    calCurrYear.set(Calendar.MONTH, 0);
    calCurrYear.set(Calendar.DAY_OF_MONTH, 1);
    calCurrYear.set(Calendar.HOUR_OF_DAY, 0);
    calCurrYear.set(Calendar.MINUTE, 0);
    calCurrYear.set(Calendar.SECOND, 0);
    calCurrYear.set(Calendar.MILLISECOND, 0);
    Calendar calStBl = Calendar.getInstance(new Locale("en", "US"));
    calStBl.setTime(this.balanceAtAllDirtyCheck.getDateBalanceStoreStart());
    calStBl.set(Calendar.MONTH, 0);
    calStBl.set(Calendar.DAY_OF_MONTH, 1);
    calStBl.set(Calendar.HOUR_OF_DAY, 0);
    calStBl.set(Calendar.MINUTE, 0);
    calStBl.set(Calendar.SECOND, 0);
    calStBl.set(Calendar.MILLISECOND, 0);
    if (calCurrYear.getTime().getTime() < calStBl.getTime().getTime()
      || this.balanceAtAllDirtyCheck
          .getLeastAccountingEntryDate()
            .getTime() < this.balanceAtAllDirtyCheck
              .getDateBalanceStoreStart().getTime()) {
      this.balanceAtAllDirtyCheck
        .setCurrentBalanceDate(initDate);
      this.balanceAtAllDirtyCheck
        .setDateBalanceStoreStart(initDate);
      evalDateBalanceStoreStart(pAddParam);
      recalculateAll(pAddParam, pDateFor, false);
    } else if (datePeriodStartFor.getTime() > this.balanceAtAllDirtyCheck
      .getCurrentBalanceDate().getTime()
        || this.balanceAtAllDirtyCheck
          .getLeastAccountingEntryDate()
            .getTime() < this.balanceAtAllDirtyCheck
              .getCurrentBalanceDate().getTime()) {
      recalculateAll(pAddParam, pDateFor, false);
    }
  }
592031
@Override
  public final void process(final Map<String, Object> pAddParam,
    final IRequestData pRequestData) throws Exception {
    this.srvEntitiesPage.retrievePage(pAddParam, pRequestData);
  }
93900
@Override
  public final void makeEntries(final Map<String, Object> pAddParam,
    final IDoc pEntity) throws Exception {
    Calendar calCurrYear = Calendar.getInstance(new Locale("en", "US"));
    calCurrYear.setTime(getSrvAccSettings().lazyGetAccSettings(pAddParam)
      .getCurrentAccYear());
    calCurrYear.set(Calendar.MONTH, 0);
    calCurrYear.set(Calendar.DAY_OF_MONTH, 1);
    calCurrYear.set(Calendar.HOUR_OF_DAY, 0);
    calCurrYear.set(Calendar.MINUTE, 0);
    calCurrYear.set(Calendar.SECOND, 0);
    calCurrYear.set(Calendar.MILLISECOND, 0);
    Calendar calDoc = Calendar.getInstance(new Locale("en", "US"));
    calDoc.setTime(pEntity.getItsDate());
    calDoc.set(Calendar.MONTH, 0);
    calDoc.set(Calendar.DAY_OF_MONTH, 1);
    calDoc.set(Calendar.HOUR_OF_DAY, 0);
    calDoc.set(Calendar.MINUTE, 0);
    calDoc.set(Calendar.SECOND, 0);
    calDoc.set(Calendar.MILLISECOND, 0);
    if (calCurrYear.getTime().getTime() != calDoc.getTime().getTime()) {
      throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER,
        "wrong_year");
    }
    StringBuffer sb = new StringBuffer();
    List<AccEntriesSourcesLine> sourcesLines = srvAccSettings
      .lazyGetAccSettings(pAddParam).getAccEntriesSources();
    java.util.Collections.sort(sourcesLines, this.cmprAccSourcesByType);
    int i = 0;
    for (AccEntriesSourcesLine sourcesLine : sourcesLines) {
      if (sourcesLine.getIsUsed()
        && sourcesLine.getSourceType().equals(pEntity.constTypeCode())) {
        String query = lazyGetQuery(sourcesLine.getFileName());
        String idName = "ITSID";
        if (pEntity.getIdBirth() != null) {
          idName = "IDBIRTH";
        }
        query = query.replace(":IDNAME", idName);
        //for foreign document this algorithm is also right:
        String strWhereDocId = sourcesLine.getSourceIdName() + " = "
          + pEntity.getItsId().toString();
        if (query.contains(":WHEREADD")) {
          query = query.replace(":WHEREADD", " and " + strWhereDocId);
        } else if (query.contains(":WHERE")) {
          query = query.replace(":WHERE", " where " + strWhereDocId);
        }
        if (i++ > 0) {
          sb.append("\nunion all\n\n");
        }
        sb.append(query);
      }
    }
    String langDef = (String) pAddParam.get("langDef");
    DateFormat dateFormat = DateFormat.getDateTimeInstance(
      DateFormat.MEDIUM, DateFormat.SHORT, new Locale(langDef));
    String query = sb.toString();
    if (query.trim().length() == 0) {
      throw new ExceptionWithCode(ExceptionWithCode.CONFIGURATION_MISTAKE,
        "there_is_no_accounting_sources");
    }
    IRecordSet<RS> recordSet = null;
    try {
      recordSet = getSrvDatabase().retrieveRecords(query);
      if (recordSet.moveToFirst()) {
        Long itsDateLong = null;
        do {
          AccountingEntry accEntry = new AccountingEntry();
          accEntry.setIdDatabaseBirth(getSrvDatabase().getIdDatabase());
          if (itsDateLong == null) {
            itsDateLong = pEntity.getItsDate().getTime();
            getSrvBalance().handleNewAccountEntry(pAddParam, null, null,
              new Date(itsDateLong)); //This is for SrvBalanceStd only!!!
          }
          Date itsDate = new Date(itsDateLong++);
          accEntry.setItsDate(itsDate);
          accEntry.setSourceType(pEntity.constTypeCode());
          if (pEntity.getIdBirth() != null) { //accounting foreign document
            accEntry.setSourceId(pEntity.getIdBirth());
          } else {
            accEntry.setSourceId(pEntity.getItsId());
          }
          accEntry.setSourceDatabaseBirth(pEntity.getIdDatabaseBirth());
          String accDebitId = recordSet.getString("ACCDEBIT");
          Account accDebit = new Account();
          accDebit.setItsId(accDebitId);
          accEntry.setAccDebit(accDebit);
          accEntry.setSubaccDebitType(recordSet.getInteger("SUBACCDEBITTYPE"));
          accEntry.setSubaccDebitId(recordSet.getLong("SUBACCDEBITID"));
          accEntry.setSubaccDebit(recordSet.getString("SUBACCDEBIT"));
          accEntry.setDebit(BigDecimal.valueOf(recordSet.getDouble("DEBIT"))
            .setScale(getSrvAccSettings().lazyGetAccSettings(pAddParam)
              .getCostPrecision(), getSrvAccSettings()
                .lazyGetAccSettings(pAddParam).getRoundingMode()));
          String accCreditId = recordSet.getString("ACCCREDIT");
          Account accCredit = new Account();
          accCredit.setItsId(accCreditId);
          accEntry.setAccCredit(accCredit);
          accEntry
            .setSubaccCreditType(recordSet.getInteger("SUBACCCREDITTYPE"));
          accEntry.setSubaccCreditId(recordSet.getLong("SUBACCCREDITID"));
          accEntry.setSubaccCredit(recordSet.getString("SUBACCCREDIT"));
          accEntry.setCredit(BigDecimal
            .valueOf(recordSet.getDouble("CREDIT")).setScale(
              getSrvAccSettings().lazyGetAccSettings(pAddParam)
                .getCostPrecision(), getSrvAccSettings()
                  .lazyGetAccSettings(pAddParam).getRoundingMode()));
          String docId = pEntity.getItsId().toString();
          if (pEntity.getIdBirth() != null) {
            docId = pEntity.getIdBirth().toString();
          }
          String descr = "";
          if (pEntity.getDescription() != null) {
            descr = " " + pEntity.getDescription();
          }
          accEntry.setDescription(getSrvI18n().getMsg(pEntity.getClass().
      getSimpleName() + "short", langDef) + " #" + pEntity.getIdDatabaseBirth()
    + "-" + docId + ", " + dateFormat.format(pEntity.getItsDate()) + descr);
          this.srvOrm.insertEntity(pAddParam, accEntry);
          accEntry.setIsNew(false);
        } while (recordSet.moveToNext());
      }
    } finally {
      if (recordSet != null) {
        recordSet.close();
      }
    }
    pEntity.setHasMadeAccEntries(true);
    srvOrm.updateEntity(pAddParam, pEntity);
  }
1329876
protected final PrcTradingSettingsSave<RS> lazyGetPrcTradingSettingsSave(final Map<String, Object> pAddParam) throws Exception {
    String beanName = PrcTradingSettingsSave.class.getSimpleName();
    @SuppressWarnings("unchecked")
    PrcTradingSettingsSave<RS> proc = (PrcTradingSettingsSave<RS>) this.processorsMap.get(beanName);
    if (proc == null) {
      proc = new PrcTradingSettingsSave<RS>();
      proc.setSrvTradingSettings(getSrvTradingSettings());
      //assigning fully initialized object:
      this.processorsMap.put(beanName, proc);
      this.logger.info(null, FctBnTradeEntitiesProcessors.class, beanName + " has been created.");
    }
    return proc;
  }
365339
@Override
  public final void process(final Map<String, Object> pAddParam,
    final IRequestData pRequestData) throws Exception {
    for (ILstnCatalogChanged lstn : this.listeners) {
      lstn.onCatalogChanged();
    }
  }
1206406
protected final PrcPaymentToGfr<RS> createPutPrcPaymentToGfr(
    final Map<String, Object> pAddParam) throws Exception {
    PrcPaymentToGfr<RS> proc = new PrcPaymentToGfr<RS>();
    @SuppressWarnings("unchecked")
    IEntityProcessor<PaymentTo, Long> procDlg =
      (IEntityProcessor<PaymentTo, Long>)
        lazyGetPrcAccDocGetForReverse(pAddParam);
    proc.setPrcAccDocGetForReverse(procDlg);
    proc.setSrvTypeCode(getSrvTypeCode());
    //assigning fully initialized object:
    this.processorsMap.put(PrcPaymentToGfr.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());
  }
307851
@Override
  public final String toIso8601Full(final Date pDate,
    final Map<String, Object> pAddParam) throws Exception {
    return this.dateTimeFullFormatIso8601.format(pDate);
  }
528669
@Override
  public final String toDateTimeString(final Date pDate,
    final Map<String, Object> pAddParam) throws Exception {
    return this.dateTimeFormat.format(pDate);
  }
389766
public final void useMaterialReverse(final Map<String, Object> pAddParam,
    final Manufacture pEntity)
    throws Exception {
    //reverse draw product in process from manufacturing process
    UseMaterialEntry dies = getSrvOrm()
      .retrieveEntityWithConditions(pAddParam, UseMaterialEntry.class,
        " where DRAWINGTYPE=" + pEntity.constTypeCode()
          + " and DRAWINGID=" + pEntity.getReversedId());
    UseMaterialEntry die = new UseMaterialEntry();
    die.setItsDate(pEntity.getItsDate());
    die.setIdDatabaseBirth(getSrvOrm().getIdDatabase());
    die.setSourceType(dies.getSourceType());
    die.setSourceId(dies.getSourceId());
    die.setDrawingType(pEntity.constTypeCode());
    die.setDrawingId(pEntity.getItsId());
    die.setDrawingOwnerId(null);
    die.setDrawingOwnerType(null);
    die.setSourceOwnerId(dies.getSourceOwnerId());
    die.setSourceOwnerType(dies.getSourceOwnerType());
    die.setItsCost(dies.getItsCost());
    die.setItsTotal(dies.getItsTotal().negate());
    die.setUnitOfMeasure(dies.getUnitOfMeasure());
    die.setInvItem(dies.getInvItem());
    die.setItsQuantity(dies.getItsQuantity().negate());
    die.setReversedId(die.getItsId());
    String langDef = (String) pAddParam.get("langDef");
    DateFormat dateFormat = DateFormat.getDateTimeInstance(
      DateFormat.MEDIUM, DateFormat.SHORT, new Locale(langDef));
    die.setDescription(makeDescription(pEntity, langDef, dateFormat)
      + " " + getSrvI18n().getMsg("reversed_entry_n", langDef)
        + dies.getIdDatabaseBirth() + "-" + dies.getItsId());
    getSrvOrm().insertEntity(pAddParam, die);
    die.setIsNew(false);
    pEntity.getManufacturingProcess().setTheRest(pEntity
      .getManufacturingProcess().getTheRest().add(dies.getItsQuantity()));
    getSrvOrm().updateEntity(pAddParam, pEntity.getManufacturingProcess());
    dies.setReversedId(die.getItsId());
    dies.setDescription(dies.getDescription() + " " + getSrvI18n()
      .getMsg("reversing_entry_n", langDef) + die.getIdDatabaseBirth() + "-"
        + die.getItsId()); //local
    getSrvOrm().updateEntity(pAddParam, dies);
  }
861917
@Override
  public final List<AccountingEntry> retrieveAccEntriesFor(
    final Map<String, Object> pAddParam,
      final IDoc pEntity) throws Exception {
    Long docId = pEntity.getItsId();
    if (pEntity.getIdBirth() != null) {
      docId = pEntity.getIdBirth();
    }
    List<AccountingEntry> result = getSrvOrm().retrieveListWithConditions(
      pAddParam, AccountingEntry.class, " where SOURCETYPE="
        + pEntity.constTypeCode() + " and SOURCEID=" + docId
          + " and SOURCEDATABASEBIRTH=" + pEntity.getIdDatabaseBirth());
    return result;
  }
543381
protected final PrcPaymentFromSave<RS> createPutPrcPaymentFromSave(
      final Map<String, Object> pAddParam) throws Exception {
    PrcPaymentFromSave<RS> proc = new PrcPaymentFromSave<RS>();
    proc.setSrvAccSettings(getSrvAccSettings());
    proc.setSrvAccEntry(getSrvAccEntry());
    proc.setSrvOrm(getSrvOrm());
    proc.setSrvI18n(getSrvI18n());
    proc.setPrcSalesInvoiceSave(lazyGetPrcSalesInvoiceSave(pAddParam));
    //assigning fully initialized object:
    this.processorsMap.put(PrcPaymentFromSave.class.getSimpleName(), proc);
    return proc;
  }
813220
protected final InvTxMeth<SalesInvoice, SalesInvoiceTaxLine>
    lazyGetSalInvTxMeth(final Map<String, Object> pAddParam) throws Exception {
    InvTxMeth<SalesInvoice, SalesInvoiceTaxLine> salInvTxMe =
      this.salInvTxMeth;
    if (salInvTxMe == null) {
      salInvTxMe = new InvTxMeth<SalesInvoice, SalesInvoiceTaxLine>();
      salInvTxMe.setGoodLnCl(SalesInvoiceLine.class);
      salInvTxMe.setServiceLnCl(SalesInvoiceServiceLine.class);
      salInvTxMe.setInvTxLnCl(SalesInvoiceTaxLine.class);
      salInvTxMe.setIsTxByUser(true);
      salInvTxMe.setStWhereAdjGdLnInvBas(
        "where SALESINVOICELINE.TAXCATEGORY is not null and REVERSEDID "
          + "is null and ITSOWNER=");
      salInvTxMe.setStWhereAdjSrLnInvBas(
      "where SALESINVOICESERVICELINE.TAXCATEGORY is not null and REVERSEDID "
          + "is null and ITSOWNER=");
      salInvTxMe.setFlTotals("invTotals.sql");
      salInvTxMe.setFlTxItBas("invTxItBas.sql");
      salInvTxMe.setFlTxItBasAggr("invTxItBasAggr.sql");
      salInvTxMe.setFlTxInvBas("invTxInvBas.sql");
      salInvTxMe.setFlTxInvAdj("invTxInvAdj.sql");
      salInvTxMe.setFlTxInvBasAggr("invTxInvBasAggr.sql");
      salInvTxMe.setTblNmsTot(new String[] {"SALESINVOICELINE",
        "SALESINVOICESERVICELINE", "SALESINVOICETAXLINE",
           "SALESINVOICEGOODSTAXLINE", "SALESINVOICESERVICETAXLINE"});
      FactoryPersistableBase<SalesInvoiceTaxLine> fctItl =
        new FactoryPersistableBase<SalesInvoiceTaxLine>();
      fctItl.setObjectClass(SalesInvoiceTaxLine.class);
      fctItl.setDatabaseId(getSrvDatabase().getIdDatabase());
      salInvTxMe.setFctInvTxLn(fctItl);
      //assigning fully initialized object:
      this.salInvTxMeth = salInvTxMe;
    }
    return salInvTxMe;
  }
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);
  }
1110537
@Override
  public final void fill(final Map<String, Object> pAddParam, final T pObject,
    final Object pFieldVal, final String pFieldName) throws Exception {
    Method fldSetter = this.settersRapiHolder
      .getFor(this.objectClass, pFieldName);
    fldSetter.invoke(pObject, pFieldVal);
  }
883662
protected final PrcAccDocRetrieve lazyGetPrcAccDocRetrieve(
    final Map<String, Object> pAddParam) throws Exception {
    @SuppressWarnings("unchecked")
    PrcAccDocRetrieve<RS, IDoc> proc = (PrcAccDocRetrieve<RS, IDoc>)
      this.processorsMap.get(PrcAccDocRetrieve.class.getSimpleName());
    if (proc == null) {
      proc = new PrcAccDocRetrieve<RS, IDoc>();
      proc.setSrvAccEntry(getSrvAccEntry());
      @SuppressWarnings("unchecked")
      IEntityProcessor<IDoc, Long> delegate = (IEntityProcessor<IDoc, Long>)
        this.fctBnEntitiesProcessors
          .lazyGet(pAddParam, PrcEntityRetrieve.class.getSimpleName());
      proc.setPrcAccEntityRetrieve(delegate);
      //assigning fully initialized object:
      this.processorsMap.put(PrcAccDocRetrieve.class.getSimpleName(), proc);
    }
    return proc;
  }
828773
@Override
  public final synchronized void saveTradingSettings(
    final Map<String, Object> pAddParam,
      final TradingSettings pEntity) throws Exception {
    if (pEntity.getIsNew()) {
      throw new ExceptionWithCode(ExceptionWithCode.FORBIDDEN,
        "insert_not_allowed::" + pAddParam.get("user"));
    } else if (pEntity.getItsId() != 1L) {
      throw new ExceptionWithCode(ExceptionWithCode.FORBIDDEN,
        "id_not_allowed::" + pAddParam.get("user"));
    } else {
      getSrvOrm().updateEntity(pAddParam, pEntity);
      this.tradingSettings = null;
      lazyGetTradingSettings(pAddParam);
    }
  }