Jump to content

convert price in math equation


ruisonika

Recommended Posts

Hello i have the following code (is a table).
How do i make convertPrice price= the result of math equation (is where this line starts here).
Thanks 

<tbody>
            {foreach $contaCorrente as $linha}
            <tr>
                <td style="display:none;">{$linha.email}</td>
                <td>{$linha.data}</td>
                <td>{$linha.venc|date_format:"%Y-%m-%d"}</td>
                <td>{$linha.doc}</td>
                <td>{$linha.num_doc}</td>
                <td>{convertPrice price=$linha.deb}</td>
                <td style="display:none;">{convertPrice price=$linha.debf}</td>
                <td>{convertPrice price=$linha.cred}</td>
                <td style="display:none;">{convertPrice price=$linha.credf}</td>
                <td style="display:none;">{$linha.obs}</td>
                <td style="display:none;">{$linha.erpid}</td>
              <!-- this line starts here -->
                <td>{math equation="x - y" x=$linha.deb y=$linha.cred}</td>
               <!-- this line ends here --> 
            </tr>
            {assign var="sum" value="`$sum+$linha.deb`"}
            {assign var="sum2" value="`$sum2+$linha.cred`"}
            {/foreach} 
            
         </tbody>

 

Link to comment
Share on other sites

2 hours ago, ruisonika said:

Hello i have the following code (is a table).
How do i make convertPrice price= the result of math equation (is where this line starts here).
Thanks 

 

This should work:

<tbody>
            {foreach $contaCorrente as $linha}
  			{capture name="eq"}{math equation="x - y" x=$linha.deb y=$linha.cred}{/capture}
            <tr>
                <td style="display:none;">{$linha.email}</td>
                <td>{$linha.data}</td>
                <td>{$linha.venc|date_format:"%Y-%m-%d"}</td>
                <td>{$linha.doc}</td>
                <td>{$linha.num_doc}</td>
                <td>{convertPrice price=$linha.deb}</td>
                <td style="display:none;">{convertPrice price=$linha.debf}</td>
                <td>{convertPrice price=$linha.cred}</td>
                <td style="display:none;">{convertPrice price=$linha.credf}</td>
                <td style="display:none;">{$linha.obs}</td>
                <td style="display:none;">{$linha.erpid}</td>
              <!-- this line starts here -->
                <td>{convertPrice price=$smarty.capture.eq}</td>
               <!-- this line ends here --> 
            </tr>
            {assign var="sum" value="`$sum+$linha.deb`"}
            {assign var="sum2" value="`$sum2+$linha.cred`"}
            {/foreach} 
            
         </tbody>

 

Link to comment
Share on other sites

3 hours ago, rrataj said:

This should work:


<tbody>
            {foreach $contaCorrente as $linha}
  			{capture name="eq"}{math equation="x - y" x=$linha.deb y=$linha.cred}{/capture}
            <tr>
                <td style="display:none;">{$linha.email}</td>
                <td>{$linha.data}</td>
                <td>{$linha.venc|date_format:"%Y-%m-%d"}</td>
                <td>{$linha.doc}</td>
                <td>{$linha.num_doc}</td>
                <td>{convertPrice price=$linha.deb}</td>
                <td style="display:none;">{convertPrice price=$linha.debf}</td>
                <td>{convertPrice price=$linha.cred}</td>
                <td style="display:none;">{convertPrice price=$linha.credf}</td>
                <td style="display:none;">{$linha.obs}</td>
                <td style="display:none;">{$linha.erpid}</td>
              <!-- this line starts here -->
                <td>{convertPrice price=$smarty.capture.eq}</td>
               <!-- this line ends here --> 
            </tr>
            {assign var="sum" value="`$sum+$linha.deb`"}
            {assign var="sum2" value="`$sum2+$linha.cred`"}
            {/foreach} 
            
         </tbody>

 

Thanks it works :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...