Bug 5512: Customer Allocation Inquiry - No alloc-icon for DEBET-Accounts-receivable...
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Mon, 1 Nov 2021 23:47:32 +0000 (00:47 +0100)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Mon, 1 Nov 2021 23:47:32 +0000 (00:47 +0100)
sales/customer_payments.php
sales/includes/db/cust_trans_db.inc
sales/inquiry/customer_allocation_inquiry.php
sales/inquiry/customer_inquiry.php

index 25f3b3f8090ce1aa6ec73c5ad71ba8ca8b5b6311..7612a2b4b68cf66bb30bc3432644cdc6b431ec9b 100644 (file)
@@ -48,7 +48,8 @@ if (!isset($_POST['bank_account'])) { // first page call
 
        if (isset($_GET['SInvoice'])) {
                //  get date and supplier
-               $inv = get_customer_trans($_GET['SInvoice'], ST_SALESINVOICE);
+               $type = !isset($_GET['Type']) ? ST_SALESINVOICE : $_GET['Type'];
+               $inv = get_customer_trans($_GET['SInvoice'], $type);
                $dflt_act = get_default_bank_account($inv['curr_code']);
                $_POST['bank_account'] = $dflt_act['id'];
                if ($inv) {
@@ -58,7 +59,7 @@ if (!isset($_POST['bank_account'])) { // first page call
                        $_POST['BranchID'] = $inv['branch_code'];
                        $_POST['DateBanked'] = sql2date($inv['tran_date']);
                        foreach($_SESSION['alloc']->allocs as $line => $trans) {
-                               if ($trans->type == ST_SALESINVOICE && $trans->type_no == $_GET['SInvoice']) {
+                               if ($trans->type == $type && $trans->type_no == $_GET['SInvoice']) {
                                        $un_allocated = $trans->amount - $trans->amount_allocated;
                                        if ($un_allocated){
                                                $_SESSION['alloc']->allocs[$line]->current_allocated = $un_allocated;
index e71ecad05543f872cd98aa9bb6b833865c437e69..f0bae1caaed9c146cd247d6b143c3e5a69704bf3 100644 (file)
@@ -318,7 +318,7 @@ function get_sql_for_customer_inquiry($from, $to, $cust_id = ALL_TEXT, $filter =
                debtor.name, 
                branch.br_name,
                debtor.curr_code,
-               IF(prep_amount, prep_amount, abs(trans.ov_amount) + trans.ov_gst + trans.ov_freight 
+               IF(prep_amount, prep_amount, trans.ov_amount + trans.ov_gst + trans.ov_freight 
                        + trans.ov_freight_tax + trans.ov_discount)     AS TotalAmount,"
 //     if ($filter != ALL_TEXT)
 //             $sql .= "@bal := @bal+IF(prep_amount, prep_amount, trans.ov_amount + trans.ov_gst + trans.ov_freight + trans.ov_freight_tax + trans.ov_discount), ";
@@ -391,7 +391,7 @@ function get_sql_for_customer_inquiry($from, $to, $cust_id = ALL_TEXT, $filter =
        {
                $today =  date2sql(Today());
                $sql .= " AND trans.due_date < '$today'
-                               AND (trans.ov_amount + trans.ov_gst + trans.ov_freight_tax + 
+                               AND (ABS(trans.ov_amount) + trans.ov_gst + trans.ov_freight_tax + 
                                trans.ov_freight + trans.ov_discount - trans.alloc > 0) ";
        }
        }
index 5630f04d20facd74821acb5918f19a9266f9c6ff..7dd21b43b7d7a4109dc1d27f9a6946f44f034381 100644 (file)
@@ -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);
 
 }
 
index 989e6ddd61467bbea0b0814fa932cedf384e9e43..5bdbe785e4b7f4fcee10767fc09fed31718d6a74 100644 (file)
@@ -58,9 +58,13 @@ function gl_view($row)
 
 function fmt_amount($row)
 {
+       /*
        $value =
-           $row['type']==ST_CUSTCREDIT || $row['type']==ST_CUSTPAYMENT || $row['type']==ST_BANKDEPOSIT || $row['type']==ST_JOURNAL ?
-               -$row["TotalAmount"] : $row["TotalAmount"];
+           $row['type']==ST_CUSTCREDIT || $row['type']==ST_CUSTPAYMENT || $row['type']==ST_BANKDEPOSIT || 
+               ($row['type']==ST_JOURNAL && $row['TotalAmount'] < 0) ? -$row["TotalAmount"] : $row["TotalAmount"];
+       */      
+       $value =
+           $row['type']==ST_CUSTCREDIT || $row['type']==ST_CUSTPAYMENT || $row['type']==ST_BANKDEPOSIT ? -$row["TotalAmount"] : $row["TotalAmount"];
     return price_format($value);
 }
 
@@ -106,7 +110,7 @@ function prt_link($row)
 function check_overdue($row)
 {
        return $row['OverDue'] == 1
-               && floatcmp($row["TotalAmount"], $row["Allocated"]) != 0;
+               && floatcmp(ABS($row["TotalAmount"]), $row["Allocated"]) != 0;
 }
 //------------------------------------------------------------------------------------------------