diff --git a/invoices.php b/invoices.php
index 7a90721d..2675633c 100644
--- a/invoices.php
+++ b/invoices.php
@@ -20,6 +20,7 @@
Number |
Client |
Amount |
+ Balance |
Date |
Due |
Status |
@@ -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 = "";
+ }
+
+
?>
| INV- |
|
$ |
+ $ |
|
- |
+ |
diff --git a/pdf_invoice.php b/pdf_invoice.php
index 7472ace1..65fce0f8 100644
--- a/pdf_invoice.php
+++ b/pdf_invoice.php
@@ -160,8 +160,8 @@ mpdf-->
| $ '.number_format($total_tax,2).' |
-| TOTAL: |
-$ '.number_format($invoice_amount,2).' |
+Total: |
+$ '.number_format($invoice_amount,2).' |
| Paid: |
diff --git a/uploads/invoice.pdf b/uploads/invoice.pdf
new file mode 100644
index 00000000..e1cfc5ab
Binary files /dev/null and b/uploads/invoice.pdf differ