mirror of https://github.com/itflow-org/itflow
Invoices now shows the remaining balance after amount
This commit is contained in:
parent
4ba961e533
commit
06b1f55849
20
invoices.php
20
invoices.php
|
|
@ -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; ?>
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Reference in New Issue