6
I’m using the Boletophp project to generate bank slips, but I noticed that the pennies are not recorded correctly, because when I buy a product with the value of for example, R $ 245,00 plus the bank rate R $ 2,95, it prints correctly the amount of R $ 247,95.
But when I buy a product with the value of 2.399,99 plus the bank rate of R $ 2,95, it prints the value of R $ 2.401,95, when the correct would be R $ 2.402,94.
In other words, he ignores the pennies of the products, but he doesn’t ignore the pennies of the bank tax.
Friends could tell me where I’m going wrong, or what the solution would be for him to print the pennies of the products as well.
In the Database I am writing in the column as type "decimal(10,2)".
Below I relate the code line of the boleto related to the value.
$dias_de_prazo_para_pagamento = 5;
$taxa_boleto = 2.95;
$data_venc = date("d/m/Y", time() + (5 * 86400)); // Prazo de X dias OU informe data: "13/04/2006";
$valor_cobrado = $_POST["total"]; // Valor - REGRA: Sem pontos na milhar e tanto faz com "." ou "," ou com 1 ou 2 ou sem casa decimal
$valor_cobrado = str_replace(".", "",$valor_cobrado);
$valor_boleto=number_format($valor_cobrado+$taxa_boleto,2,",",".");
Below I list the code line of the form referring to the value.
<?php
if(count($_SESSION['carrinho']) == 0){
echo '<tr><td colspan="5">Não há produto no carrinho</td></tr>';
}else{
require("conexao.php");
$total = 0;
foreach($_SESSION['carrinho'] as $codigo => $qtd){
$sql = "SELECT * FROM produto WHERE codigo= '$codigo'";
$qr = mysql_query($sql) or die(mysql_error());
$ln = mysql_fetch_assoc($qr);
$titulo = $ln['titulo'];
$preco = number_format($ln['preco'], 2, ',', '.');
$sub = number_format($ln['preco'] * $qtd, 2, ',', '.');
$total += $ln['preco'] * $qtd;
echo '<tr style="font-size:11px; font-weight:bold; color:#000;">
<td align="left">'.$titulo.'</td>
<td align="center">'.$qtd.'</td>
<td align="center">R$ '.$preco.'</td>
<td align="center">R$ '.$sub.'</td>
<td align="center"><a href="?acao=del&codigo='.$codigo.'">
<img width="25" src="img/del.png" title="Remover '.$titulo.'"/>
</a></td>
</tr>';
}
$total = number_format($total, 2, ',', '.');
echo '<tr></tr><tr></tr><tr></tr><tr></tr><tr></tr>
<tr>
<td align="right" style="font-size:16px; font-weight:bold; color:#990000;" colspan="3">Total</td>
<td align="left" style="font-size:16px; font-weight:bold; color:#000;" colspan="4">R$ '.$total.'</td>
</tr>';
}
?>
How do I get the billet to print the pennies of the products?
Can format the currency value thus
– rray