I am using the BoletoPHP project to generate bank notes, but I noticed that the cents are not recorded properly, because when I buy a product with the value of for example, $ 245.00 plus the bank fee $ 2.95 , it correctly prints the value of $ 247.95.
But when I buy a product with the value of 2,399.99 plus the bank fee of $ 2.95, it prints the value of $ 2,401.95, when the correct would be $ 2,402.94. >
In other words, it ignores the penny of the goods, but does not ignore the cents of the bank rate.
Friends could tell me where I'm going wrong, or what would be the solution for him to print the product cents as well.
In the database I'm writing to the column as type "decimal (10,2)".
Below I relate the line of code of the ticket for 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 relate the form's line of code 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 ticket to print the product cents?