<link rel="import" href="../polymer/polymer.html">
<script>
  /** @polymerBehavior etoolsBehaviors.EtoolsCurrencyBehavior */
  window.etoolsBehaviors = window.etoolsBehaviors || {};
  etoolsBehaviors.EtoolsCurrencyBehavior = {

    /**
     * Format value as currency amount. Delimited used ', '
     */
    addCurrencyAmountDelimiter: function(value) {
      if (!value) {
        return '';
      }
      value = value.toString();
      if (value === '') {
        return '';
      }
      return value.replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,');
    },

    /**
     * Format value as currency amount and return it to be displayed
     * Use this to display readonly currency amounts on interface
     */
    displayCurrencyAmount: function(value, placeholder) {
      if (!placeholder) {
        placeholder = '—';
      }
      if (!value) {
        return placeholder;
      }
      var floatValue = parseFloat(value).toFixed(2);
      if (isNaN(floatValue)) {
        return placeholder;
      }

      return this.addCurrencyAmountDelimiter(floatValue);
    }

  };
</script>

<link rel="import" href="../polymer/polymer.html">
<script>
  /** @polymerBehavior etoolsBehaviors.EtoolsCurrencyBehavior */
  window.etoolsBehaviors = window.etoolsBehaviors || {};
  etoolsBehaviors.EtoolsCurrencyBehavior = {

    /**
     * Format value as currency amount. Delimited used ', '
     */
    addCurrencyAmountDelimiter: function(value) {
      if (!value) {
        return '';
      }
      value = value.toString();
      if (value === '') {
        return '';
      }
      return value.replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,');
    },

    /**
     * Format value as currency amount and return it to be displayed
     * Use this to display readonly currency amounts on interface
     */
    displayCurrencyAmount: function(value, placeholder, noOfDecimals) {
      if (!placeholder) {
        placeholder = '—';
      }
       if(typeof noOfDecimals != 'number')
        noOfDecimals = 2;
      if (!value) {
        return placeholder;
      }
      var floatValue = parseFloat(value).toFixed(noOfDecimals);
      if (isNaN(floatValue)) {
        return placeholder;
      }

      return this.addCurrencyAmountDelimiter(floatValue);
    }

  };
</script>

Allow to specify number of decimals
Allow to specify number of decimals