Hi Holbok,<div><br></div><div>Thanks for your contribution.</div><div><br></div><div>Providing option to configure the number of decimal places, is in our roadmap.</div><div><br></div><div>In any case, the changes suggested would be helpful. We shall evaluate and update you sooner.<br>

<br><div class="gmail_quote">On Fri, Nov 25, 2011 at 11:11 PM, Holbok István <span dir="ltr">&lt;<a href="mailto:holbok@gmail.com">holbok@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">


  

    
  
  <div bgcolor="#FFFFFF" text="#000000">
    Hi All,<br>
    <br>
    Here is a small modification of <b>....\include\fields\CurrencyField.php</b><br>
    <br>
    It would be useful, if the parameter $numberOfDecimal could be set
    up from settings panel.<br>
    <br>
    Due to actual state of economics and inflation in Hungary we are not
    using anymore cents only whole Forints. Even now we are using only 0
    or 5 end integers for the prices and currency values because so we
    should round all prices:<br>
    Numbers with end ...xxx1 , ...xxx2, ...xxx8  and ...xxx9 to the  
    ..xxx0 and <br>
    numbers with end ...xxx3 , ...xxx4, ...xxx6  and ...xxx7 to the  
    ..xxx5 <br>
    <br>
    There are a var $numberOfDecimal = 3; in this file.<br>
    <br>
    If this var set <b>$numberOfDecimal = 0;</b><br>
    <br>
    and adding and/or changing the blue lines in the <b>function </b>_formatCurrencyValue($value),
    the numbers will round well in the PDF Invoice.<br>
    <tt><br>
          /**<br>
           * Function that formats the Number based on the User
      configured Pattern, Currency separator and Decimal separator<br>
           * @param Number $value<br>
           * @return Formatted Currency<br>
           */<br>
          private function _formatCurrencyValue($value) {<br>
      <br>
              $currencyPattern = $this-&gt;currencyFormat;<br>
              $currencySeparator = $this-&gt;currencySeparator;<br>
              $decimalSeparator  = $this-&gt;decimalSeparator;<br>
              if(empty($currencySeparator)) $currencySeparator = &#39; &#39;;<br>
              if(empty($decimalSeparator)) $decimalSeparator = &#39; &#39;;<br>
      <b><font color="#000099">        // Rounding value to the given
          decimals<br>
                  $value = round($value, $this-&gt;numberOfDecimal);</font></b><br>
      <br>
              if($currencyPattern == $this-&gt;CURRENCY_PATTERN_PLAIN) {<br>
                  // Replace &#39;.&#39; with Decimal Separator<br>
                  $number = str_replace(&#39;.&#39;, $decimalSeparator, $value);<br>
                  return $number;<br>
              }<br>
              if($currencyPattern ==
      $this-&gt;CURRENCY_PATTERN_SINGLE_GROUPING) {<br>
                  // Separate the numeric and decimal parts<br>
                  $numericParts = explode(&#39;.&#39;, $value);<br>
                  $wholeNumber = $numericParts[0];<br>
                  // First part of the number which remains intact<br>
                  if(strlen($wholeNumber) &gt; 3) {<br>
                      $wholeNumberFirstPart =
      substr($wholeNumber,0,strlen($wholeNumber)-3);<br>
                  }<br>
                  // Second Part of the number (last 3 digits) which
      should be separated from the First part using Currency Separator<br>
                  $wholeNumberLastPart = substr($wholeNumber,-3);<br>
                  // Re-create the whole number with user&#39;s configured
      currency separator<br>
                  if(!empty($wholeNumberFirstPart)) {<br>
                      $numericParts[0] =
      $wholeNumberFirstPart.$currencySeparator.$wholeNumberLastPart;<br>
                  } else {<br>
                      $numericParts[0] = $wholeNumberLastPart;<br>
                  }<br>
      <b><font color="#000099">            // Handling number rounding<br>
                      if ( $this-&gt;numberOfDecimal == 0) {<br>
                          //No decimal parts: No $decimalSeparator and
          No $numericParts[1]<br>
                          // Re-create the currency value combining the
          whole number and the decimal part using Decimal separator<br>
                          $number = $numericParts[0];    <br>
                      }<br>
                      else {<br>
                          // Re-create the currency value combining the
          whole number and the decimal part using Decimal separator<br>
                          $number = implode($decimalSeparator,
          $numericParts);<br>
                      }</font></b><br>
                  return $number;<br>
              }<br>
              if($currencyPattern ==
      $this-&gt;CURRENCY_PATTERN_THOUSAND_GROUPING) {<br>
                  // Separate the numeric and decimal parts<br>
                  $numericParts = explode(&#39;.&#39;, $value);<br>
                  $wholeNumber = $numericParts[0];<br>
                  // Pad the rest of the length in the number string
      with Leading 0, to get it to the multiples of 3<br>
                  $numberLength = strlen($wholeNumber);<br>
                  // First grouping digits length<br>
                  $OddGroupLength = $numberLength%3;<br>
                  $gapsToBeFilled = 0;<br>
                  if($OddGroupLength &gt; 0) $gapsToBeFilled = 3 -
      $OddGroupLength;<br>
                  $wholeNumber = str_pad($wholeNumber,
      $numberLength+$gapsToBeFilled, &#39;0&#39;, STR_PAD_LEFT);<br>
                  // Split the whole number into chunks of 3 digits<br>
                  $wholeNumberParts = str_split($wholeNumber,3);<br>
                  // Re-create the whole number with user&#39;s configured
      currency separator<br>
                  $numericParts[0] = $wholeNumber =
      implode($currencySeparator, $wholeNumberParts);<br>
                  if($wholeNumber &gt; 0) {<br>
                      $numericParts[0] = ltrim($wholeNumber, &#39;0&#39;);<br>
                  } else {<br>
                      $numericParts[0] = 0;<br>
                  }<br>
      <font color="#000099"><b>            // Handling number rounding<br>
                      if ( $this-&gt;numberOfDecimal == 0) {<br>
                          //No decimal parts: No $decimalSeparator and
          No $numericParts[1]<br>
                          // Re-create the currency value combining the
          whole number and the decimal part using Decimal separator<br>
                          $number = $numericParts[0];    <br>
                      }<br>
                      else {<br>
                          // Re-create the currency value combining the
          whole number and the decimal part using Decimal separator<br>
                          $number = implode($decimalSeparator,
          $numericParts);<br>
                      }</b></font><br>
                  return $number;<br>
              }<br>
              if($currencyPattern ==
      $this-&gt;CURRENCY_PATTERN_MIXED_GROUPING) {<br>
                  // Separate the numeric and decimal parts<br>
                  $numericParts = explode(&#39;.&#39;, $value);<br>
                  $wholeNumber = $numericParts[0];<br>
                  // First part of the number which needs separate
      division<br>
                  if(strlen($wholeNumber) &gt; 3) {<br>
                      $wholeNumberFirstPart =
      substr($wholeNumber,0,strlen($wholeNumber)-3);<br>
                  }<br>
                  // Second Part of the number (last 3 digits) which
      should be separated from the First part using Currency Separator<br>
                  $wholeNumberLastPart = substr($wholeNumber,-3);<br>
                  if(!empty($wholeNumberFirstPart)) {<br>
                      // Pad the rest of the length in the number string
      with Leading 0, to get it to the multiples of 2<br>
                      $numberLength = strlen($wholeNumberFirstPart);<br>
                      // First grouping digits length<br>
                      $OddGroupLength = $numberLength%2;<br>
                      $gapsToBeFilled = 0;<br>
                      if($OddGroupLength &gt; 0) $gapsToBeFilled = 2 -
      $OddGroupLength;<br>
                      $wholeNumberFirstPart =
      str_pad($wholeNumberFirstPart, $numberLength+$gapsToBeFilled, &#39;0&#39;,
      STR_PAD_LEFT);<br>
                      // Split the first part of tne number into chunks
      of 2 digits<br>
                      $wholeNumberFirstPartElements =
      str_split($wholeNumberFirstPart,2);<br>
                      $wholeNumberFirstPart =
      ltrim(implode($currencySeparator, $wholeNumberFirstPartElements),
      &#39;0&#39;);<br>
                      $wholeNumberFirstPart =
      implode($currencySeparator, $wholeNumberFirstPartElements);<br>
                      if($wholeNumberFirstPart &gt; 0) {<br>
                          $wholeNumberFirstPart =
      ltrim($wholeNumberFirstPart, &#39;0&#39;);<br>
                      } else {<br>
                          $wholeNumberFirstPart = 0;<br>
                      }<br>
                      // Re-create the whole number with user&#39;s
      configured currency separator<br>
                      $numericParts[0] =
      $wholeNumberFirstPart.$currencySeparator.$wholeNumberLastPart;<br>
                  } else {<br>
                      $numericParts[0] = $wholeNumberLastPart;<br>
                  }<br>
      <font color="#000099"><b>            // Handling number rounding<br>
                      if ( $this-&gt;numberOfDecimal == 0) {<br>
                          //No decimal parts: No $decimalSeparator and
          No $numericParts[1]<br>
                          // Re-create the currency value combining the
          whole number and the decimal part using Decimal separator<br>
                          $number = $numericParts[0];    <br>
                      }<br>
                      else {<br>
                          // Re-create the currency value combining the
          whole number and the decimal part using Decimal separator<br>
                          $number = implode($decimalSeparator,
          $numericParts);<br>
                      }</b></font><br>
                  return $number;<br>
              }<br>
              return $number;<br>
          }</tt><br>
    <br>
    ---------------------------------------------------<br>
    Plus we should change the <b>....\include\InventoryPDFController.php</b>
    a little also.<br>
    <br>
    About line 135 - 140: <br>
    <br>
    Change:<tt><br>
                  $contentModel-&gt;set(&#39;Quantity&#39;, $quantity);</tt><br>
    Into:<br>
    <tt>            <b>$contentModel-&gt;set(&#39;Quantity&#39;,
        round($quantity,0));</b></tt><br>
    <br>
    and<br>
    <br>
    Change:<br>
    <tt>            $contentModel-&gt;set(&#39;Discount&#39;, 
      $this-&gt;formatPrice($discount).&quot;\n ($discountPercentage%)&quot;);</tt><br>
    Into:<br>
    <b><tt>           </tt><tt> $contentModel-&gt;set(&#39;Discount&#39;, 
        $this-&gt;formatPrice($discount).&quot;\n
        (&quot;.round($discountPercentage,1).&quot;%)&quot;);</tt><br>
    </b><br>
    <br>
    Also should be changed 2 lines about lines: 210-214<br>
    <tt><br>
              $summaryModel-&gt;set(getTranslatedString(&quot;Shipping &amp;
      Handling Tax:&quot;, $this-&gt;moduleName).&quot;($sh_tax_percent%)&quot;,
      $this-&gt;formatPrice($final_details[&#39;shtax_totalamount&#39;]));<br>
      <br>
              $summaryModel-&gt;set(getTranslatedString(&quot;Grand Total :
      (in $currencySymbol)&quot;, $this-&gt;moduleName),
      $this-&gt;formatPrice($final_details[&#39;grandTotal&#39;]));</tt><br>
    <br>
    Into the:<br>
    <b><br>
    </b><tt><b>       
        $summaryModel-&gt;set(getTranslatedString(&quot;Shipping &amp;
        Handling Tax&quot;, $this-&gt;moduleName).&quot; ($sh_tax_percent%):&quot;,
        $this-&gt;formatPrice($final_details[&#39;shtax_totalamount&#39;]));<br>
        <br>
                $summaryModel-&gt;set(getTranslatedString(&quot;Grand Total&quot;,
        $this-&gt;moduleName).&quot; ($currencySymbol):&quot;,
        $this-&gt;formatPrice($final_details[&#39;grandTotal&#39;]));</b><br>
    </tt><br>
    The first line for the better look, but the second line for the
    availability to translate.<br>
    The original version consists a variable in the
    getTranslatedString(&quot;<b>argument</b>&quot;, $this-&gt;moduleName) - so it
    very hard to translate.<br>
    <br>
    <br>
    Best regards:<br><font color="#888888">
    <br>
    <div>-- <br>
      <br>
      Holbok István<br>
      telefon: +3670-342-0900<br>
      e-mail: <a href="mailto:holbok@gmail.com" target="_blank">holbok@gmail.com</a><br>
      <br>
      <br>
      <br>
    </div>
  </font></div>

<br>_______________________________________________<br>
<a href="http://www.vtiger.com/" target="_blank">http://www.vtiger.com/</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br>Regards,<br>Asha<br>vtiger Team<br><br><b>Connect with us on: </b><a href="http://twitter.com/#%21/vtigercrm" target="_blank">Twitter</a> <b>I</b> <a href="http://www.facebook.com/pages/vtiger/226866697333578?sk=wall" target="_blank">Facebook</a> <b>I</b> <a href="http://blog.vtiger.com/" target="_blank">Blog</a><b> I</b> <a href="http://wiki.vtiger.com/index.php/Main_Page" target="_blank">Wiki</a> <b>I </b><a href="http://forums.vtiger.com/" target="_blank">Forums </a><b>I</b> <a href="http://vtiger.com/" target="_blank">Website</a><br>

<br>
</div>