101

(4 replies, posted in Report Bugs here)

If you are running a current version of FA, the null date problem you are experiencing could be a bug that was unmasked by the introduction of STRICT_ALL_TABLES.   You could try reverting it.  See this post.

Fixed in 2.4.7

103

(3 replies, posted in Installation)

Google php memory_limit.  Update your php.ini file and restart web server.

See also, 0004745: Restore dies with php memory error

104

(7 replies, posted in Modules Add-on's)

Regarding the import_transactions extension,

I tried the former and I get a "Green" result but nothing actually gets imported.

Did you unclick the trial run box?

If so, try to import the examples (or similar) and see if that works.

105

(13 replies, posted in Report Bugs here)

This is not my area of expertise, as I am just guessing at this.  So take this with a grain of salt.

Although session data is stored on the server, FA chose to store the session id as a cookie on the browser, rather than in the URL.  Both mechanisms can be vulnerable to session stealing, and FA has code to detect it, perhaps by looking at the ip address.

Running Chrome in incognito mode could be the source of the problem, because it will not store the session id cookie.   See, https://stackoverflow.com/questions/30475878/remembering-php-session-private-browsing.   The selected answer of the question makes a suggestion that a session id could be forged from other server data, but I do not know if FA does that (I doubt it).

My suggestion on clearing browser cache/cookies was to clear an old session id.  I doubt that this would fix anything, but just worth a shot.

FA already makes extensive use of POST data including hidden fields.  I am guessing that the reason why cart was not one of them (coded into SESSION)  is because an array is not straightforward to code in this manner, which is why I had to add the serialize/unserialize functions.    I am of the opinion that coding the cart into POST data is preferable to SESSION data and solves the multiple tab problem.  It eliminates the error message in question and use of the configuration override which could cause other problems.

106

(13 replies, posted in Report Bugs here)

@boxygen:

I'm guessing no, because the only thing stored in the browser is the session cookie.   If this happens again, you might suggest to the client to clear the browser cache and try again.

My opinion is that storing page operational data in a php session rather than post is bad practice because session is browser wide and poses conflicts with multiple tabs  It seems to be a common practice, but one easily avoided.  In the aforementioned bug report, all I did was search and replace SESSION with POST, add a hidden cart variable to the form and because the cart was an array, I also had to serialize and unserialize it.  So while the bug fix is conceptually simple, it did hit a large number of lines.  This fixed the multiple open tab problem for sales, purchasing, and banking.  This was essential because often a clerk is reviewing one sales order/purchase/bank transaction in one tab and entering another in another tab.  Indeed, I am surprised that no one else complains about this in vanilla FA.

107

(13 replies, posted in Report Bugs here)

You can signup for an account: http://mantis.frontaccounting.com/login_page.php.

108

(13 replies, posted in Report Bugs here)

On Windows, change config.php

   /* No check on edit conflicts. Maybe needed to be set to 1 in certains Windows Servers */
    $no_check_edit_conflicts = 1;

Or change the code to allow multiple open tabs by replacing session variables (see, http://mantis.frontaccounting.com/view.php?id=4664).

Or you could just use the shell script approach to running any web page, i.e.:

#!/bin/bash

wget -q --save-cookies /tmp/cookies$$.txt \
     --keep-session-cookies \
     --post-data 'user_name_entry_field=xxx&password=yyy&company_login_name=1' \
     --delete-after \
     https://myfawebsite/index.php

# customer detail list
wget -q --load-cookies /tmp/cookies$$.txt \
    -O - https://myfawebsite/reporting/rep103.php \
    --post-data "PARAM_0=09/13/2019&PARAM_1=&PARAM_2=&PARAM_3=&PARAM_4=&PARAM_5=&PARAM_6=&PARAM_7=0&REP_ID=103" > /tmp/foo.pdf

where post-data are the $_POST fields sent by the FA web page.

I don't know how anyone else does it, but I found that decimal precise stock quantities cause problems in FA because it is impossible to get them zeroed out.

So I had to make the following change to my fork.  My fork assumes stock is zero when it falls below the precision specified in Setup.

--- a/core/includes/db/inventory_db.inc
+++ b/core/includes/db/inventory_db.inc
@@ -79,7 +79,8 @@ function check_negative_stock($stock_id, $delta_qty, $location=null, $date=null)
        if ($min_qos && ($min_qos['qty'] < $qos['qty']))
                $qos = $min_qos;
 
-       return  -$delta_qty > $qos['qty'] ? $qos : null;
+        $row = get_item_edit_info($stock_id);
+       return  round($delta_qty + $qos['qty'], $row['decimals']) < 0 ? $qos : null;
 }

Change the billing address in the branch.

112

(10 replies, posted in Wish List)

Concerning if item/supplier conversion is correct, Price column on PO does show correctly when using the base current_user.inc file, but maybe that is not an accurate comparison (because I don't fully understand the changes to that file).

I'm afraid I do not have any explanation.  The change to current_user.inc was the price_decimal_format () function.  The printed PO rounds using user_price_dec().  Perhaps you had to login/logout after changing Preferences->Prices/Amounts for it to take effect.   I don't know.  It would be silly, but you could just hard code the line in rep209 to use 2 decimals:

             if ($data['conversion_factor'] != 1)
                {
                    $myrow2['unit_price'] = round2($myrow2['unit_price'] * $data['conversion_factor'], 2);
                    $myrow2['quantity_ordered'] = round2($myrow2['quantity_ordered'] / $data['conversion_factor'], user_qty_dec());
                }

113

(10 replies, posted in Wish List)

The printed PO does  should show the supplier qty units and cost correctly (in supplier units and 2 decimal pricing) if you enter the units and conversions into Items->Purchasing Pricing.   Make sure your user decimal price is 2.

Looking at the PO print code that does the conversion back to supplier units,

                if ($data['conversion_factor'] != 1)
                {
                    $myrow2['unit_price'] = round2($myrow2['unit_price'] * $data['conversion_factor'], user_price_dec());
                    $myrow2['quantity_ordered'] = round2($myrow2['quantity_ordered'] / $data['conversion_factor'], user_qty_dec());
                }

it seems to me that if user_price_dec() is 2, it must round to 2 decimal places, so that is why I am guessing that you might have changed Preferences->Decimal Places?  Or maybe you don't have the supplier pricing/conversion set in the Item?

114

(10 replies, posted in Wish List)

This works correctly in my fork without changing price decimals.    I fixed this bug a few years ago and I think the fix was rather obscure.  I think this was it:

Change the includes/current_user.inc function to:

function price_decimal_format($number, &$dec)
{
    $dec = user_price_dec();
    $str = strval($number);
    $pos = strpos($str, '.');
    if ($pos !== false)
    {
        $len = strlen(substr($str, $pos + 1));
        if ($len > ini_get('precision')-3)
                    $len = ini_get('precision')-3;
        if ($len > $dec)
            $dec = $len;
    }
    return number_format2($number, $dec);
}

from the base

function price_decimal_format($number, &$dec)
{
    $dec = user_price_dec();
    $str = strval($number);
    $pos = strpos($str, '.');
    if ($pos !== false)
    {
        $len = strlen(substr($str, $pos + 1));
        if ($len > $dec && $len < ini_get('precision')-3)
            $dec = $len;
    }
    return number_format2($number, $dec);

I think the base code sees the desired precision ($len > $dec) but only sets $dec to $len if $len happens to be less than the php.ini precision.   It usually isn't so it uses the user decimals (which is probably 2, which causes the rounding problem you describe).

In my code, the desired precision is tested against the php.ini precision and truncates if necessary.  Then if the result is greater than user decimals, it uses that.  I think this is what the base coder wanted but just didn't code it right.

If that doesn't fix your problem, I will have to look deeper into how I fixed it.

115

(2 replies, posted in Report Bugs here)

Possibly fixed in 2.4.7 "Supplier Transaction Inquiry for GRN did not filter by date. Fixed.".

Another approach: https://github.com/FrontAccountingERP/FA/pull/10.    This is the approach I took in my fork, generalizing the concept of last used account to customers and suppliers on any payment page.

My guess: you discovered a bug.  It happens if you have a tax exempt item on an invoice.   The fact that the account is blank is a clear giveaway.  While it does not cause any operational problem, the extra entries bloat the database.  I would report this on mantis.

118

(1 replies, posted in Modules Add-on's)

You have an old version.  Download the latest version from https://github.com/apmuthu/FA24extensions.

This was fixed with https://github.com/apmuthu/FA24extensions/commit/a7b7510b1d37ed62cd3cd11dd9da57d0167afc4a#diff-21faf20455e1f59df4ca335d3cb26e65.

119

(3 replies, posted in Accounts Receivable)

Invoice Editable.  Otherwise, void and recreate.

Cloning does not copy the BOM.

My fork has code to copy the BOM under Manufacturing->Bills Of Materials

diff --git a/core/manufacturing/manage/bom_edit.php b/core/manufacturing/manage/bom_edit.php
index 35230dd..9d6fbfd 100644
--- a/core/manufacturing/manage/bom_edit.php
+++ b/core/manufacturing/manage/bom_edit.php
@@ -45,9 +45,10 @@ function display_bom_items($selected_parent)
        table_header($th);
 
        $k = 0;
+    $found = false;
        while ($myrow = db_fetch($result))
        {
-
+        $found = true;
                alt_table_row_color($k);
 
                label_cell($myrow["component"]);
@@ -62,9 +63,30 @@ function display_bom_items($selected_parent)
 
        } //END WHILE LIST LOOP
        end_table();
+
+    if ($found) {
+        start_table(TABLESTYLE, "width='60%'");
+        stock_manufactured_items_list_row(_("Copy BOM to another manufacturable item"), 'new_stock_id', $selected_parent, false, true);
+        end_table();
+    }
+
        div_end();
 }
 
+function copy_bom_items($stock_id, $new_stock_id)
+{
+       $result = get_bom($stock_id);
+       while ($myrow = db_fetch($result))
+       {
+               $_POST['component'] = $myrow["component"];
+        $_POST['loc_code'] = $myrow["loc_code"];
+        $_POST['workcentre_added'] = $myrow["workcentre_added"];
+        $_POST['quantity'] = $myrow["quantity"];
+        on_submit($new_stock_id, -1);
+    }
+}
+
+
 
 
 //--------------------------------------------------------------------------------------------------
 
+if (list_updated('new_stock_id')) {
+    copy_bom_items($_POST['stock_id'], $_POST['new_stock_id']);
+    $item = get_item($_POST['new_stock_id']);
+    $_POST['stock_id'] = $_POST['new_stock_id'];
+    $Ajax->activate('_page_body');
+    display_notification("BOM copied to " . $item['description']);
+}
+

 start_form();
 
 start_form(false, true);

121

(35 replies, posted in Banking and General Ledger)

@rafat

I forget to mention that you still need the new gl/inquiry/journal_inquiry.php file as well.  Download that and you should be good.

122

(35 replies, posted in Banking and General Ledger)

@boxygen

Thanks for testing.

This next version should fix those problems, remove unused code, and re-add support for names on PO Deliveries.

function get_sql_for_journal_inquiry($filter, $from, $to, $ref='', $memo='', $alsoclosed=false,
         $user_id=null)
{
    $sql = "SELECT  IFNULL(a.gl_seq,0) as gl_seq,
        gl.tran_date,
        gl.type as trans_type,
        gl.type_no as trans_no,
        IFNULL(gl.person_id, IFNULL(st.supplier_id, IFNULL(grn.supplier_id, IFNULL(dt.debtor_no, bt.person_id)))) as person_id,
        IF(ISNULL(st.supp_reference), '', st.supp_reference) AS supp_reference,
        refs.reference,
        IF(gl.type=".ST_BANKTRANSFER.",MAX(gl.amount),SUM(IF(gl.amount>0, gl.amount,0))) as amount,
        com.memo_,
        IF(ISNULL(u.user_id),'',u.user_id) as user_id,
        IF(gl.person_id, gl.person_type_id, IF(!ISNULL(st.supplier_id) OR !ISNULL(grn.supplier_id),".  PT_SUPPLIER . "," .  "IF(dt.debtor_no," . PT_CUSTOMER . "," .
        "IF(bt.person_id != '' AND !ISNULL(bt.person_id), bt.person_type_id, -1)))) as person_type_id
        FROM ".TB_PREF."gl_trans as gl
         LEFT JOIN ".TB_PREF."audit_trail as a ON
            (gl.type=a.type AND gl.type_no=a.trans_no)
         LEFT JOIN ".TB_PREF."comments as com ON
            (gl.type=com.type AND gl.type_no=com.id)
         LEFT JOIN ".TB_PREF."refs as refs ON
            (gl.type=refs.type AND gl.type_no=refs.id)
         LEFT JOIN ".TB_PREF."users as u ON
            a.user=u.id
         LEFT JOIN ".TB_PREF."grn_batch grn ON grn.id=gl.type_no AND gl.type=".ST_SUPPRECEIVE."
         LEFT JOIN ".TB_PREF."bank_trans bt ON bt.type=gl.type AND bt.trans_no=gl.type_no AND bt.amount!=0
                 AND (bt.person_id != '' AND !ISNULL(bt.person_id))
         LEFT JOIN ".TB_PREF."debtor_trans dt ON dt.type=gl.type AND gl.type_no=dt.trans_no
         LEFT JOIN ".TB_PREF."supp_trans st ON st.type=gl.type AND gl.type_no=st.trans_no
         WHERE gl.tran_date >= '" . date2sql($from) . "'
        AND gl.tran_date <= '" . date2sql($to) . "'
        AND gl.amount!=0";
    if ($ref) {
        $sql .= " AND refs.reference LIKE ". db_escape("%$ref%");
    }
    if ($memo) {
        $sql .= " AND com.memo_ LIKE ". db_escape("%$memo%");
    }
    if ($filter != -1) {
        $sql .= " AND gl.type=".db_escape($filter);
    }
    if (!$alsoclosed) {
        $sql .= " AND gl_seq=0";
    }
    else
        $sql .= " AND NOT ISNULL(a.gl_seq)";

    if ($user_id != null)
        $sql .= " AND user_id = ".db_escape($user_id);

    $sql .= " GROUP BY gl.tran_date, a.gl_seq, gl.type, gl.type_no";
    return $sql;
}

diff

-- a/core/gl/includes/db/gl_db_trans.inc
+++ b/core/gl/includes/db/gl_db_trans.inc
@@ -606,25 +606,21 @@ function clear_gl_trans($type, $trans_id, $nested=false)
 }
 
 function get_sql_for_journal_inquiry($filter, $from, $to, $ref='', $memo='', $alsoclosed=false,
-                $user_id=null, $contractor_id=null, $dimension=null)
+                $user_id=null)
 {
-
        $sql = "SELECT  IFNULL(a.gl_seq,0) as gl_seq,
                gl.tran_date,
                gl.type as trans_type,
                gl.type_no as trans_no,
-               IFNULL(MAX(supp.supp_name), MAX(cust.name)) as name,
+        IFNULL(gl.person_id, IFNULL(st.supplier_id, IFNULL(grn.supplier_id, IFNULL(dt.debtor_no, bt.person_id)))) as person_id,
                IF(ISNULL(st.supp_reference), '', st.supp_reference) AS supp_reference,
-               refs.reference,"
-               .($dimension ? " -SUM(IF(dim.dimension in(gl.dimension_id,gl.dimension2_id), gl.amount, 0)) as amount,":" SUM(IF(gl.amount>0, gl.amount,0)) as amount,")
-               ."com.memo_,
-               IF(ISNULL(u.user_id),'',u.user_id) as user_id";
-
-       if ($contractor_id > 0) {
-       $sql.= " FROM ".TB_PREF."gl_trans as gl
+               refs.reference,
+               IF(gl.type=".ST_BANKTRANSFER.",MAX(gl.amount),SUM(IF(gl.amount>0, gl.amount,0))) as amount,
+               com.memo_,
+               IF(ISNULL(u.user_id),'',u.user_id) as user_id,
+        IF(gl.person_id, gl.person_type_id, IF(!ISNULL(st.supplier_id) OR !ISNULL(grn.supplier_id),".  PT_SUPPLIER . "," .  "IF(dt.debtor_no," . PT_CUSTOMER . "," . 
+        "IF(bt.person_id != '' AND !ISNULL(bt.person_id), bt.person_type_id, -1)))) as person_type_id
+           FROM ".TB_PREF."gl_trans as gl
                 LEFT JOIN ".TB_PREF."audit_trail as a ON
                        (gl.type=a.type AND gl.type_no=a.trans_no)
                 LEFT JOIN ".TB_PREF."comments as com ON
@@ -633,14 +629,12 @@ function get_sql_for_journal_inquiry($filter, $from, $to, $ref='', $memo='', $al
                        (gl.type=refs.type AND gl.type_no=refs.id)
                 LEFT JOIN ".TB_PREF."users as u ON
                        a.user=u.id
+         LEFT JOIN ".TB_PREF."grn_batch grn ON grn.id=gl.type_no AND gl.type=".ST_SUPPRECEIVE."
+         LEFT JOIN ".TB_PREF."bank_trans bt ON bt.type=gl.type AND bt.trans_no=gl.type_no AND bt.amount!=0
+                 AND (bt.person_id != '' AND !ISNULL(bt.person_id))
                 LEFT JOIN ".TB_PREF."debtor_trans dt ON dt.type=gl.type AND gl.type_no=dt.trans_no
-                LEFT JOIN ".TB_PREF."debtors_master cust ON gl.person_type_id=2 AND gl.person_id=cust.debtor_no
                 LEFT JOIN ".TB_PREF."supp_trans st ON st.type=gl.type AND gl.type_no=st.trans_no
-                LEFT JOIN ".TB_PREF."suppliers supp ON gl.person_type_id=3 AND gl.person_id=supp.supplier_id"
-                .($dimension ? 
-                " LEFT JOIN (SELECT type, type_no, MAX(IFNULL(dimension_id, dimension2_id)) dimension FROM ".TB_PREF."gl_trans GROUP BY type, type_no) dim 
-                               ON gl.type=dim.type AND gl.type_no=dim.type_no" : '')
-               ." WHERE gl.tran_date >= '" . date2sql($from) . "'
+                WHERE gl.tran_date >= '" . date2sql($from) . "'
                AND gl.tran_date <= '" . date2sql($to) . "'
                AND gl.amount!=0";
        if ($ref) {
@@ -661,14 +655,6 @@ function get_sql_for_journal_inquiry($filter, $from, $to, $ref='', $memo='', $al
        if ($user_id != null)
                $sql .= " AND user_id = ".db_escape($user_id);
 
-       if ($contractor_id > 0) {
-               $sql.= " AND (dt.debtor_no =".$contractor_id;
-               $sql.= " OR st.supplier_id =".$contractor_id.") ";
-       }       
-
-       if ($dimension != null)
-               $sql .= " AND dim.dimension = ".db_escape($dimension);
-
        $sql .= " GROUP BY gl.tran_date, a.gl_seq, gl.type, gl.type_no";
 
        return $sql;

123

(35 replies, posted in Banking and General Ledger)

My suggestion is to replace the name conjuring with a function instead of sql.  This adds quick entry support as well.

--- a/core/gl/includes/db/gl_db_trans.inc
+++ b/core/gl/includes/db/gl_db_trans.inc

 function get_sql_for_journal_inquiry($filter, $from, $to, $ref='', $memo='', $alsoclosed=false,
                 $user_id=null, $contractor_id=null, $dimension=null)
 {
@@ -613,7 +614,7 @@ function get_sql_for_journal_inquiry($filter, $from, $to, $ref='', $memo='', $al
-               IFNULL(MAX(supp.supp_name), MAX(cust.name)) as name,
+        IFNULL(MAX(gl.person_id), IFNULL(bt.person_id, dt.debtor_no)) as person_id,
                IF(ISNULL(st.supp_reference), '', st.supp_reference) AS supp_reference,
                refs.reference,"
                .($dimension ? " -SUM(IF(dim.dimension in(gl.dimension_id,gl.dimension2_id), gl.amount, 0)) as amount,":" SUM(IF(gl.amount>0, gl.amount,0)) as amount,")
@@ -624,6 +625,8 @@ function get_sql_for_journal_inquiry($filter, $from, $to, $ref='', $memo='', $al
                $sql.= ", st.supplier_id, dt.debtor_no ";
        }
 
+        $sql.=", IFNULL(MAX(gl.person_type_id), IFNULL(bt.person_type_id, ".PT_CUSTOMER.")) as person_type_id";
+
        $sql.= " FROM ".TB_PREF."gl_trans as gl
                 LEFT JOIN ".TB_PREF."audit_trail as a ON
                        (gl.type=a.type AND gl.type_no=a.trans_no)
@@ -633,10 +636,10 @@ function get_sql_for_journal_inquiry($filter, $from, $to, $ref='', $memo='', $al
                        (gl.type=refs.type AND gl.type_no=refs.id)
                 LEFT JOIN ".TB_PREF."users as u ON
                        a.user=u.id
+         LEFT JOIN ".TB_PREF."bank_trans bt ON bt.type=gl.type AND bt.trans_no=gl.type_no AND bt.amount!=0
+                 AND (bt.person_id != '' AND !ISNULL(bt.person_id))
                 LEFT JOIN ".TB_PREF."debtor_trans dt ON dt.type=gl.type AND gl.type_no=dt.trans_no
-                LEFT JOIN ".TB_PREF."debtors_master cust ON gl.person_type_id=2 AND gl.person_id=cust.debtor_no
-                LEFT JOIN ".TB_PREF."supp_trans st ON st.type=gl.type AND gl.type_no=st.trans_no
-                LEFT JOIN ".TB_PREF."suppliers supp ON gl.person_type_id=3 AND gl.person_id=supp.supplier_id"
+                LEFT JOIN ".TB_PREF."supp_trans st ON st.type=gl.type AND gl.type_no=st.trans_no "
                 .($dimension ? 
                 " LEFT JOIN (SELECT type, type_no, MAX(IFNULL(dimension_id, dimension2_id)) dimension FROM ".TB_PREF."gl_trans GROUP BY type, type_no) dim 
                                ON gl.type=dim.type AND gl.type_no=dim.type_no" : '')
diff --git a/core/gl/inquiry/journal_inquiry.php b/core/gl/inquiry/journal_inquiry.php
index 70338b4..2a727eb 100644
--- a/core/gl/inquiry/journal_inquiry.php
+++ b/core/gl/inquiry/journal_inquiry.php
@@ -78,6 +78,11 @@ function systype_name($dummy, $type)
        return $systypes_array[$type];
 }
 
+function person_link($row) 
+{
+    return payment_person_name($row["person_type_id"],$row["person_id"]);
+}
+
 function view_link($row) 
 {
        return get_trans_view_str($row["trans_type"], $row["trans_no"]);
@@ -121,7 +126,7 @@ $cols = array(
        _("Date") =>array('name'=>'tran_date','type'=>'date','ord'=>'desc'),
        _("Type") => array('fun'=>'systype_name'), 
        _("Trans #") => array('fun'=>'view_link'), 
-       _("Counterparty") => array('ord' => ''),
+       _("Counterparty") => array('fun' => 'person_link'),
        _("Supplier's Reference") => 'skip',
        _("Reference"), 
        _("Amount") => array('type'=>'amount'),

124

(35 replies, posted in Banking and General Ledger)

Well I guess the sql still needs to use the MAX function (because one of the two gl_trans entries is null):

IFNULL(IFNULL(MAX(supp.supp_name), MAX(cust.name)), bt.person_id) as person_name,

Note that quick entries do not display the name, just the quick entry number.  I will leave it as an exercise for the reader to write the sql for that.

Note that g/l inquiry does display the quick entry names.   It is able to do this because its sql returns the person type/person id and then it uses a function to display them.  This is what journal inquiry could do as well because it is much more powerful and easier to write.   In my fork, I changed the function to display hyperlinks and a magnifying glass for each name.  The hyperlink takes you to the customer/supplier/qe info page and the magnifying glass shows the g/l detail for just that customer/supplier/qe using the selected date range.

125

(35 replies, posted in Banking and General Ledger)

Please be more specific about what kind of transaction on which inquiry screen and what kind of name (misc/cust/supp/qe) does not appear.

There have been fixes in this area so include your FA version as well.

Names are difficult to pull out of the FA database because they are inconveniently null in gl_trans.   Thus the code has to look for them elsewhere which is quite ugly.

For example, if you wanted to see a miscellaneous name from a bank payment using journal inquiry, the code does not display it.  Bank inquiry would display it because the name is in the banking trans file.   But if you are using g/l inquiry or journal inquiry, the sql is not as easy.

Say you wanted to change the code in journal inquiry to display a banking payment name.   You might try:

+++ b/core/gl/includes/db/gl_db_trans.inc
@@ -613,7 +613,8 @@ function get_sql_for_journal_inquiry($filter, $from, $to, $ref='', $memo='', $al
                gl.tran_date,
                gl.type as trans_type,
                gl.type_no as trans_no,
-               IFNULL(MAX(supp.supp_name), MAX(cust.name)) as name,
+        IFNULL(IFNULL(supp.supp_name, cust.name), bt.person_id) as person_name,
+
                IF(ISNULL(st.supp_reference), '', st.supp_reference) AS supp_reference,
                refs.reference,"
                .($dimension ? " -SUM(IF(dim.dimension in(gl.dimension_id,gl.dimension2_id), gl.amount, 0)) as amount,":" SUM(IF(gl.amount>0, gl.amount,0)) as amount,")
@@ -633,6 +634,8 @@ function get_sql_for_journal_inquiry($filter, $from, $to, $ref='', $memo='', $al
                        (gl.type=refs.type AND gl.type_no=refs.id)
                 LEFT JOIN ".TB_PREF."users as u ON
                        a.user=u.id
+         LEFT JOIN ".TB_PREF."bank_trans bt ON bt.type=gl.type AND bt.trans_no=gl.type_no AND bt.amount!=0
+                 AND (bt.person_id != '' AND !ISNULL(bt.person_id))
                 LEFT JOIN ".TB_PREF."debtor_trans dt ON dt.type=gl.type AND gl.type_no=dt.trans_no
                 LEFT JOIN ".TB_PREF."debtors_master cust ON gl.person_type_id=2 AND gl.person_id=cust.debtor_no
                 LEFT JOIN ".TB_PREF."supp_trans st ON st.type=gl.type AND gl.type_no=st.trans_no