<p>Make description for warehouse entry.</p>
@param pEntity movement
@param pLangDef Lang Default
@param pDateFormat DateFormat
@return description
188100
public final String makeDescription(final Manufacture pEntity,
    final String pLangDef, final DateFormat pDateFormat) {
    String strWho = getSrvI18n().getMsg(pEntity.getClass().getSimpleName()
      + "short", pLangDef) + " #" + pEntity.getIdDatabaseBirth() + "-" + pEntity
        .getItsId() + ", " + pDateFormat.format(pEntity.getItsDate());
    String strFrom = " " + getSrvI18n().getMsg("from", pLangDef) + " "
  + getSrvI18n().getMsg(ManufacturingProcess.class.getSimpleName() + "short",
    pLangDef) + " #" + pEntity.getManufacturingProcess().getIdDatabaseBirth()
      + "-" + pEntity.getManufacturingProcess().getItsId(); //local
    return getSrvI18n().getMsg("made_at", pLangDef) + " " + pDateFormat
      .format(new Date()) + " " + getSrvI18n().getMsg("by", pLangDef) + " "
        + strWho + strFrom;
  }
349305
@Override
	public void setFormatPatternMap(
		Map<java.util.Locale, String> formatPatternMap) {
		_commerceCurrency.setFormatPatternMap(formatPatternMap);
	}
307851
@Override
  public final String toIso8601Full(final Date pDate,
    final Map<String, Object> pAddParam) throws Exception {
    return this.dateTimeFullFormatIso8601.format(pDate);
  }
678259
public static Date toDate(final String pString, final DateFormat pFormat) {
        try {
            synchronized (pFormat) {
                // Parse date using given format
                return pFormat.parse(pString);
            }
        }
        catch (ParseException pe) {
            // Wrap in RuntimeException
            throw new IllegalArgumentException(pe.getMessage());
        }
    }
744773
@Override
  public final void load(final Map<String, Object> pAddParam,
    final IMakingWarehouseEntry pEntity,
      final WarehouseSite pWhSiteTo) throws Exception {
    if (!pEntity.getIdDatabaseBirth()
      .equals(getSrvOrm().getIdDatabase())) {
      throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER,
        "can_not_make_ws_entry_for_foreign_src");
    }
    WarehouseEntry wms = null;
    if (pEntity.getReversedId() != null) {
      String tblNm = WarehouseEntry.class.getSimpleName().toUpperCase();
      wms = getSrvOrm().retrieveEntityWithConditions(pAddParam,
        WarehouseEntry.class, " where SOURCETYPE=" + pEntity.constTypeCode()
          + " and SOURCEID=" + pEntity.getReversedId()
            + " and " + tblNm + ".IDDATABASEBIRTH=" + getSrvOrm()
              .getIdDatabase() + " and WAREHOUSESITETO=" + pWhSiteTo.getItsId()
                + " and INVITEM=" + pEntity.getInvItem()
        .getItsId());
      if (wms == null) {
        throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER,
          "cant_find_reverced_source");
      }
    }
    String langDef = (String) pAddParam.get("langDef");
    DateFormat dateFormat = DateFormat.getDateTimeInstance(
      DateFormat.MEDIUM, DateFormat.SHORT, new Locale(langDef));
    WarehouseEntry wm = new WarehouseEntry();
    wm.setIdDatabaseBirth(getSrvOrm().getIdDatabase());
    wm.setSourceId(pEntity.getItsId());
    wm.setSourceType(pEntity.constTypeCode());
    wm.setWarehouseSiteTo(pWhSiteTo);
    wm.setInvItem(pEntity.getInvItem());
    wm.setUnitOfMeasure(pEntity.getUnitOfMeasure());
    wm.setItsQuantity(pEntity.getItsQuantity());
    wm.setSourceOwnerId(pEntity.getOwnerId());
    wm.setSourceOwnerType(pEntity.getOwnerType());
    if (wms != null) {
      wm.setReversedId(wms.getItsId());
      wm.setDescription(makeDescription(pEntity, langDef, dateFormat) + " "
        + getSrvI18n().getMsg("reversed_entry_n", langDef) + getSrvOrm()
          .getIdDatabase() + "-" + wms.getItsId()); //only local
    } else {
      wm.setDescription(makeDescription(pEntity, langDef, dateFormat));
    }
    getSrvOrm().insertEntity(pAddParam, wm);
    wm.setIsNew(false);
    makeWarehouseRest(pAddParam, pEntity, pWhSiteTo, pEntity.getItsQuantity());
    if (wms != null) {
      wms.setReversedId(wm.getItsId());
      wms.setDescription(wms.getDescription() + " " + getSrvI18n()
        .getMsg("reversing_entry_n", langDef) + getSrvOrm().getIdDatabase()
          + "-" + wm.getItsId());
      getSrvOrm().updateEntity(pAddParam, wms);
    }
  }
58101
@Override
  public final String toIso8601FullNoTz(final Date pDate,
    final Map<String, Object> pAddParam) throws Exception {
    return this.dateTimeFullNoTzFormatIso8601.format(pDate);
  }
989802
@Override
    public DateCalculator<LocalDate> moveByDays(final int days) {
        setCurrentIncrement(days);

        setCurrentBusinessDate(getCurrentBusinessDate().plusDays(days));

        if (getHolidayHandler() != null) {
            setCurrentBusinessDate(getHolidayHandler().moveCurrentDate(this));
        }

        return this;
    }
492134
public final synchronized Date evalDateNextPeriodStart(
    final Map<String, Object> pAddParam,
      final Date pDateFor) throws Exception {
    EPeriod period = evalBalanceStorePeriod(pAddParam);
    if (!(period.equals(EPeriod.MONTHLY)
      || period.equals(EPeriod.WEEKLY)
        || period.equals(EPeriod.DAILY))) {
      throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER,
        "stored_balance_period_must_be_dwm");
    }
    Calendar cal = Calendar.getInstance(new Locale("en", "US"));
    cal.setTime(pDateFor);
    cal.set(Calendar.HOUR_OF_DAY, 0);
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);
    if (period.equals(EPeriod.DAILY)) {
      cal.add(Calendar.DATE, 1);
    } else if (period.equals(EPeriod.MONTHLY)) {
      cal.add(Calendar.MONTH, 1);
      cal.set(Calendar.DAY_OF_MONTH, 1);
    } else if (period.equals(EPeriod.WEEKLY)) {
      cal.add(Calendar.DAY_OF_YEAR, 7);
      cal.set(Calendar.DAY_OF_WEEK, 1);
    }
    return cal.getTime();
  }
317040
public final String makeBslResDescr(final EBankEntryResultAction pResAct,
    final DateFormat pDateFormat, final APersistableBase pRecord,
      final Date pDate, final String pLangDef) {
    StringBuffer sb = new StringBuffer();
    if (EBankEntryResultAction.MATCH.equals(pResAct)) {
      sb.append(getSrvI18n().getMsg("Found", pLangDef));
    } else {
      sb.append(getSrvI18n().getMsg("Created", pLangDef));
    }
    sb.append(" " + getSrvI18n()
      .getMsg(pRecord.getClass().getSimpleName() + "short", pLangDef));
    sb.append("#" + pRecord.getIdDatabaseBirth() + "-" + pRecord.getItsId()
      + ", " + pDateFormat.format(pDate));
    return sb.toString();
  }
353616
protected String createDDMFormRuleAction(
		DDMForm ddmForm, long groupId, long commerceAccountId,
		long cpDefinitionId) {

		String callFunctionStatement =
			"call('getCPInstanceOptionsValues', concat(%s), '%s')";

		return String.format(
			callFunctionStatement,
			createDDMFormRuleInputMapping(
				ddmForm, groupId, commerceAccountId, cpDefinitionId),
			createDDMFormRuleOutputMapping(ddmForm));
	}
240163
public static String getFormattedDate(final Long lastQueryDate, final String datePattern) {
        return formatDate(lastQueryDate, null, datePattern);
    }
840163
public static String formatDate(String format, Locale loc) {
		return formatDate(timestamp(), format, loc);
	}
85363
public final void createPayment(final Map<String, Object> pReqVars,
    final BankStatementLine pBsl, final DateFormat pDateFormat,
      final String pLangDef, final IRequestData pRequestData) throws Exception {
    BigDecimal foreignTotal;
    Account accCash;
    Date itsDate;
    try {
      String forTotStr = pRequestData.getParameter("foreignTotal");
      if (forTotStr == null || "".equals(forTotStr)) {
        foreignTotal = BigDecimal.ZERO;
      } else {
        String dsep = (String) pReqVars.get("decSepv");
        if (dsep != null) {
          String dgsep = (String) pReqVars.get("decGrSepv");
          forTotStr = forTotStr.replace(dgsep, "").replace(dsep, ".");
        }
        foreignTotal = new BigDecimal(forTotStr);
      }
      String accCashStr = pRequestData.getParameter("accCash");
      accCash = new Account();
      accCash.setItsId(accCashStr);
      accCash = getSrvOrm().retrieveEntity(pReqVars, accCash);
      if (accCash == null) {
        throw new Exception("cant_find_account");
      }
      String itsDateStr = pRequestData.getParameter("itsDate");
      itsDate = this.dateTimeNoTzFormatIso8601.parse(itsDateStr);
    } catch (Exception e) {
      throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER,
        "wrong_paramaters", e);
    }
    EBankEntryResultType resultRecordType = null;
    EBankEntryResultAction resultAction = EBankEntryResultAction.CREATE;
    String resultDescription = null;
    Long resultRecordId = null;
    if (pBsl.getItsAmount().compareTo(BigDecimal.ZERO) > 0) {
      SalesInvoice inv;
      try {
        String invStr = pRequestData.getParameter("invoice");
        inv = new SalesInvoice();
        inv.setItsId(Long.parseLong(invStr));
        inv = getSrvOrm().retrieveEntity(pReqVars, inv);
        if (inv == null) {
          throw new Exception("cant_find_debtor_invoice");
        }
      } catch (Exception e) {
        throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER,
          "wrong_paramaters", e);
      }
      resultRecordType = EBankEntryResultType.PREPAYMENTFROM;
      PaymentFrom pay = new PaymentFrom();
      pay.setIdDatabaseBirth(getSrvOrm().getIdDatabase());
      pay.setItsDate(itsDate);
      pay.setSalesInvoice(inv);
      pay.setAccCash(accCash);
      pay.setSubaccCash(pBsl.getItsOwner().getBankAccount().getItsName());
      pay.setSubaccCashId(pBsl.getItsOwner().getBankAccount().getItsId());
      pay.setSubaccCashType(2002);
      pay.setItsTotal(pBsl.getItsAmount().abs());
      pay.setForeignTotal(foreignTotal);
      pay.setDescription(makeDescrForCreated(pBsl, pDateFormat, pLangDef));
      getSrvOrm().insertEntity(pReqVars, pay);
      this.srvAccEntry.makeEntries(pReqVars, pay);
      this.prcSalesInvoiceSave.calculateTotalPayment(pReqVars, pay
        .getSalesInvoice());
      getSrvOrm().updateEntity(pReqVars, pay.getSalesInvoice());
      resultRecordId = pay.getItsId();
      resultDescription = makeBslResDescr(resultAction, pDateFormat, pay,
        pay.getItsDate(), pLangDef);
    } else {
      PurchaseInvoice inv;
      try {
        String invStr = pRequestData.getParameter("invoice");
        inv = new PurchaseInvoice();
        inv.setItsId(Long.parseLong(invStr));
        inv = getSrvOrm().retrieveEntity(pReqVars, inv);
        if (inv == null) {
          throw new Exception("cant_find_debtor_invoice");
        }
      } catch (Exception e) {
        throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER,
          "wrong_paramaters", e);
      }
      resultRecordType = EBankEntryResultType.PREPAYMENTTO;
      PaymentTo pay = new PaymentTo();
      pay.setIdDatabaseBirth(getSrvOrm().getIdDatabase());
      pay.setItsDate(itsDate);
      pay.setPurchaseInvoice(inv);
      pay.setAccCash(accCash);
      pay.setSubaccCash(pBsl.getItsOwner().getBankAccount().getItsName());
      pay.setSubaccCashId(pBsl.getItsOwner().getBankAccount().getItsId());
      pay.setSubaccCashType(2002);
      pay.setItsTotal(pBsl.getItsAmount().abs());
      pay.setForeignTotal(foreignTotal);
      pay.setDescription(makeDescrForCreated(pBsl, pDateFormat, pLangDef));
      getSrvOrm().insertEntity(pReqVars, pay);
      this.srvAccEntry.makeEntries(pReqVars, pay);
      this.prcPurchaseInvoiceSave.calculateTotalPayment(pReqVars,
        pay.getPurchaseInvoice());
      getSrvOrm().updateEntity(pReqVars, pay.getPurchaseInvoice());
      resultRecordId = pay.getItsId();
      resultDescription = makeBslResDescr(resultAction, pDateFormat, pay,
        pay.getItsDate(), pLangDef);
    }
    pBsl.setResultAction(resultAction);
    pBsl.setResultRecordType(resultRecordType);
    pBsl.setResultRecordId(resultRecordId);
    pBsl.setResultDescription(resultDescription);
    getSrvOrm().updateEntity(pReqVars, pBsl);
  }
684633
public static Date toDate(String pString, String pFormat) {
        // Get the format from cache, or create new and insert
        // Return new date
        return toDate(pString, new SimpleDateFormat(pFormat));
    }
108198
@Override
  public final void makeOtherEntries(final Map<String, Object> pAddParam,
    final PaymentTo pEntity, final IRequestData pRequestData,
      final boolean pIsNew) throws Exception {
    String actionAdd = pRequestData.getParameter("actionAdd");
    if ("makeAccEntries".equals(actionAdd)) {
      this.prcPurchaseInvoiceSave.calculateTotalPayment(pAddParam,
        pEntity.getPurchaseInvoice());
      getSrvOrm().updateEntity(pAddParam, pEntity.getPurchaseInvoice());
    }
  }
87288
@Override
  public final String toDateString(final Date pDate,
    final Map<String, Object> pAddParam) throws Exception {
    return this.dateFormat.format(pDate);
  }
225888
public CellFormatResult format(final String formatPattern, final Date value, final Locale locale) {
        return format(new DateCell(value, formatPattern), locale);
    }