From: Joe Hunt Date: Mon, 1 Nov 2021 23:47:32 +0000 (+0100) Subject: Bug 5512: Customer Allocation Inquiry - No alloc-icon for DEBET-Accounts-receivable... X-Git-Url: https://delta.frontaccounting.com/gitweb/?p=fa-stable.git;a=commitdiff_plain;h=15637f687c7fc48fde54904fe54c0386b7e90859 Bug 5512: Customer Allocation Inquiry - No alloc-icon for DEBET-Accounts-receivable-Journal Entries by @advocaat.pollet. Fixed. --- diff --git a/sales/customer_payments.php b/sales/customer_payments.php index 25f3b3f8..7612a2b4 100644 --- a/sales/customer_payments.php +++ b/sales/customer_payments.php @@ -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; diff --git a/sales/includes/db/cust_trans_db.inc b/sales/includes/db/cust_trans_db.inc index e71ecad0..f0bae1ca 100644 --- a/sales/includes/db/cust_trans_db.inc +++ b/sales/includes/db/cust_trans_db.inc @@ -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) "; } } diff --git a/sales/inquiry/customer_allocation_inquiry.php b/sales/inquiry/customer_allocation_inquiry.php index 5630f04d..7dd21b43 100644 --- a/sales/inquiry/customer_allocation_inquiry.php +++ b/sales/inquiry/customer_allocation_inquiry.php @@ -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); } diff --git a/sales/inquiry/customer_inquiry.php b/sales/inquiry/customer_inquiry.php index 989e6ddd..5bdbe785 100644 --- a/sales/inquiry/customer_inquiry.php +++ b/sales/inquiry/customer_inquiry.php @@ -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; } //------------------------------------------------------------------------------------------------