PHP 8 rerun of number_format fix.
[fa-stable.git] / sales / inquiry / customer_allocation_inquiry.php
index 2bd2d58e38f94c1d648e87065280d04c84f539fc..7dd21b43b7d7a4109dc1d27f9a6946f44f034381 100644 (file)
@@ -87,7 +87,7 @@ function due_date($row)
 
 function fmt_balance($row)
 {
-       return $row["TotalAmount"] - $row["Allocated"];
+       return ($row["type"] == ST_JOURNAL && $row["TotalAmount"] < 0 ? -$row["TotalAmount"] : $row["TotalAmount"]) - $row["Allocated"];
 }
 
 function alloc_link($row)
@@ -114,9 +114,10 @@ function alloc_link($row)
        {
                /*its a negative receipt */
                return '';
-       } elseif (($row["type"] == ST_SALESINVOICE && ($row['TotalAmount'] - $row['Allocated']) > 0) || $row["type"] == ST_BANKPAYMENT)
+       } elseif (($row["type"] == ST_SALESINVOICE && ($row['TotalAmount'] - $row['Allocated']) > 0) || 
+               ($row["type"] == ST_JOURNAL && (ABS($row['TotalAmount']) - $row['Allocated']) > 0) || $row["type"] == ST_BANKPAYMENT)
                return pager_link(_("Payment"),
-                       "/sales/customer_payments.php?customer_id=".$row["debtor_no"]."&SInvoice=" . $row["trans_no"], ICON_MONEY);
+                       "/sales/customer_payments.php?customer_id=".$row["debtor_no"]."&SInvoice=" . $row["trans_no"]."&Type=".$row["type"], ICON_MONEY);
 
 }