Invoices now shows the remaining balance after amount

This commit is contained in:
root 2019-04-13 22:41:03 -04:00
parent 4ba961e533
commit 06b1f55849
3 changed files with 21 additions and 3 deletions

View File

@ -20,6 +20,7 @@
<th>Number</th>
<th>Client</th>
<th class="text-right">Amount</th>
<th class="text-right">Balance</th>
<th>Date</th>
<th>Due</th>
<th>Status</th>
@ -56,14 +57,31 @@
$invoice_badge_color = "secondary";
}
//Add up all the payments for the invoice and get the total amount paid to the invoice
$sql_amount_paid = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS amount_paid FROM payments WHERE invoice_id = $invoice_id");
$row = mysqli_fetch_array($sql_amount_paid);
$amount_paid = $row['amount_paid'];
$balance = $invoice_amount - $amount_paid;
//set Text color on balance
if($balance > 0){
$balance_text_color = "text-danger";
}else{
$balance_text_color = "";
}
?>
<tr>
<td><a href="invoice.php?invoice_id=<?php echo $invoice_id; ?>">INV-<?php echo $invoice_number; ?></a></td>
<td><a href="client.php?client_id=<?php echo $client_id; ?>"><?php echo $client_name; ?></a></td>
<td class="text-right text-monospace">$<?php echo number_format($invoice_amount,2); ?></td>
<td class="text-right text-monospace <?php echo $balance_text_color; ?>">$<?php echo number_format($balance,2); ?></td>
<td><?php echo $invoice_date; ?></td>
<td><div class="<?php echo $overdue_color; ?>"><?php echo $invoice_due; ?></div></td>
<td class="<?php echo $overdue_color; ?>"><?php echo $invoice_due; ?></td>
<td>
<span class="p-2 badge badge-<?php echo $invoice_badge_color; ?>">
<?php echo $invoice_status; ?>

View File

@ -160,8 +160,8 @@ mpdf-->
<td class="totals cost">$ '.number_format($total_tax,2).' </td>
</tr>
<tr>
<td class="totals"><b>TOTAL:</b></td>
<td class="totals cost"><b>$ '.number_format($invoice_amount,2).' </b></td>
<td class="totals">Total:</td>
<td class="totals cost">$ '.number_format($invoice_amount,2).' </td>
</tr>
<tr>
<td class="totals">Paid:</td>

BIN
uploads/invoice.pdf Normal file

Binary file not shown.