<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[FrontAccounting forum — Show bank account in Customer Transactions type:payment]]></title>
	<link rel="self" href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=10403&amp;type=atom" />
	<updated>2023-11-18T20:52:43Z</updated>
	<generator>PunBB</generator>
	<id>https://frontaccounting.com/punbb/viewtopic.php?id=10403</id>
		<entry>
			<title type="html"><![CDATA[Re: Show bank account in Customer Transactions type:payment]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=42709#p42709" />
			<content type="html"><![CDATA[<p>Mr Apmuthu, Thank you for your observations, but it is not to replace any other code. With your vast experience, I appreciate improving this functionality, which is important for any accountant.<br />Rafael</p>]]></content>
			<author>
				<name><![CDATA[Rmendez]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=40570</uri>
			</author>
			<updated>2023-11-18T20:52:43Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=42709#p42709</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Show bank account in Customer Transactions type:payment]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=42703#p42703" />
			<content type="html"><![CDATA[<p>Looks like you are using an older version of <a href="https://github.com/FrontAccountingERP/FA/blob/master/sales/includes/db/cust_trans_db.inc"><strong>sales/includes/db/cust_trans_db.inc</strong></a>. You have added a function at nearly the end of the said file as:<br /></p><div class="codebox"><pre><code>function get_sql_for_customer_inquiry_with_bank($from, $to, $cust_id = ALL_TEXT, $filter = ALL_TEXT, $show_voided = 0, $bank=&quot;&quot;)
{
    $date_after = date2sql($from);
    $date_to = date2sql($to);

    $sql = &quot;SELECT 
          trans.type, 
        trans.trans_no, 
        trans.order_, 
        trans.reference,
        trans.tran_date, 
        trans.due_date, 
        debtor.name, 
        branch.br_name,
        debtor.curr_code,
        bank_account_name,
        IF(prep_amount, prep_amount, trans.ov_amount + trans.ov_gst + trans.ov_freight 
            + trans.ov_freight_tax + trans.ov_discount)    AS TotalAmount,&quot;
//       if ($filter != ALL_TEXT)
//          $sql .= &quot;@bal := @bal+IF(prep_amount, prep_amount, trans.ov_amount + trans.ov_gst + trans.ov_freight + trans.ov_freight_tax + trans.ov_discount), &quot;;

//    else
//        $sql .= &quot;IF(trans.type=&quot;.ST_CUSTDELIVERY.&quot;,&#039;&#039;, IF(trans.type=&quot;.ST_SALESINVOICE.&quot; OR trans.type=&quot;.ST_BANKPAYMENT.&quot;,@bal := @bal+
//            (trans.ov_amount + trans.ov_gst + trans.ov_freight + trans.ov_freight_tax + trans.ov_discount), @bal := @bal-
//            (trans.ov_amount + trans.ov_gst + trans.ov_freight + trans.ov_freight_tax + trans.ov_discount))) , &quot;;
        . &quot;IF(trans.type IN(&quot;.implode(&#039;,&#039;,  array(ST_CUSTCREDIT,ST_CUSTPAYMENT,ST_BANKDEPOSIT)).&quot;), -1, 1)
                *(IF(prep_amount, prep_amount, trans.ov_amount + trans.ov_gst + trans.ov_freight 
            + trans.ov_freight_tax + trans.ov_discount)-trans.alloc) Balance, 
        debtor.debtor_no,&quot;;

    $sql .= &quot;trans.alloc AS Allocated,
        ((trans.type = &quot;.ST_SALESINVOICE.&quot; || trans.type = &quot;.ST_JOURNAL.&quot;)
            AND trans.due_date &lt; &#039;&quot; . date2sql(Today()) . &quot;&#039;) AS OverDue ,
        Sum(line.quantity-line.qty_done) AS Outstanding,
        Sum(line.qty_done) AS HasChild,
        prep_amount&quot;;
    // it&#039;s a payment so also get the bank account
    $sql .= &quot;, bank_act,&quot;.TB_PREF.&quot;bank_accounts.account_type AS BankTransType,
        &quot;.TB_PREF.&quot;bank_accounts.bank_curr_code,
        &quot;.TB_PREF.&quot;bank_accounts.id,
        &quot;.TB_PREF.&quot;bank_trans.amount as bank_amount&quot;;
    $sql .= &quot; FROM &quot;
        .TB_PREF.&quot;debtor_trans as trans
            LEFT JOIN &quot;.TB_PREF.&quot;debtor_trans_details as line
                ON trans.trans_no=line.debtor_trans_no AND trans.type=line.debtor_trans_type
            LEFT JOIN &quot;.TB_PREF.&quot;voided as v
                ON trans.trans_no=v.id AND trans.type=v.type
                        LEFT JOIN &quot;.TB_PREF.&quot;audit_trail as audit ON (trans.type=audit.type AND trans.trans_no=audit.trans_no)
                        LEFT JOIN &quot;.TB_PREF.&quot;users as user ON (audit.user=user.id)
            LEFT JOIN &quot;.TB_PREF.&quot;cust_branch as branch ON trans.branch_code=branch.branch_code,&quot;
        .TB_PREF.&quot;debtors_master as debtor&quot;;
    $sql .= &quot;, &quot;.TB_PREF.&quot;bank_trans, &quot;.TB_PREF.&quot;bank_accounts&quot;;

    $sql .= &quot; WHERE debtor.debtor_no = trans.debtor_no&quot;; // exclude voided transactions and self-balancing (journal) transactions:
    if (!$show_voided)
        $sql .= &quot; AND ISNULL(v.date_) AND (trans.ov_amount + trans.ov_gst + trans.ov_freight + trans.ov_freight_tax + trans.ov_discount) != 0&quot;;

    if ($filter == &#039;2&#039;)
        $sql .= &quot; AND ABS(IF(prep_amount, prep_amount, ABS(trans.ov_amount) + trans.ov_gst + trans.ov_freight + trans.ov_freight_tax + trans.ov_discount)-trans.alloc)&gt;&quot;
            .FLOAT_COMP_DELTA;
    else {
        $sql .= &quot; AND trans.tran_date &gt;= &#039;$date_after&#039;
            AND trans.tran_date &lt;= &#039;$date_to&#039;&quot;;
    }

    if ($cust_id != ALL_TEXT)
        $sql .= &quot; AND trans.debtor_no = &quot;.db_escape($cust_id);

    if ($filter != ALL_TEXT)
    {
        if ($filter == &#039;1&#039;)
        {
            $sql .= &quot; AND (trans.type = &quot;.ST_SALESINVOICE.&quot;) &quot;;
        }
        elseif ($filter == &#039;2&#039;)
        {
            $sql .= &quot; AND (trans.type &lt;&gt; &quot;.ST_CUSTDELIVERY.&quot;) &quot;;
        }
        elseif ($filter == &#039;3&#039;)
        {
            $sql .= &quot; AND (trans.type = &quot; . ST_CUSTPAYMENT
                .&quot; OR trans.type = &quot;.ST_BANKDEPOSIT.&quot; OR trans.type = &quot;.ST_BANKPAYMENT.&quot;) &quot;;
        }
        elseif ($filter == &#039;4&#039;)
        {
            $sql .= &quot; AND trans.type = &quot;.ST_CUSTCREDIT.&quot; &quot;;
        }
        elseif ($filter == &#039;5&#039;)
        {
            $sql .= &quot; AND trans.type = &quot;.ST_CUSTDELIVERY.&quot; &quot;;
        }

        if ($filter == &#039;2&#039;)
        {
            $today =  date2sql(Today());
            $sql .= &quot; AND trans.due_date &lt; &#039;$today&#039;
                AND (ABS(trans.ov_amount) + trans.ov_gst + trans.ov_freight_tax + 
                trans.ov_freight + trans.ov_discount - trans.alloc &gt; 0) &quot;;
        }
    }

    // it&#039;s a payment so also get the bank account
    $sql .= &quot; AND &quot;.TB_PREF.&quot;bank_trans.trans_no = trans.trans_no
            AND &quot;.TB_PREF.&quot;bank_trans.type = trans.type
            AND &quot;.TB_PREF.&quot;bank_trans.amount != 0
            AND &quot;.TB_PREF.&quot;bank_accounts.id=&quot;.TB_PREF.&quot;bank_trans.bank_act&quot;;
    if($bank!=&quot;&quot;){
        $sql .= &quot; AND &quot;.TB_PREF.&quot;bank_accounts.id=&quot;.db_escape($bank);
    }

    $sql .= &quot; GROUP BY trans.trans_no, trans.type, trans.debtor_no&quot;;

    return $sql;
}</code></pre></div><p>What did you mean by &quot;insert the files at this address&quot; ? Should some function calls in the said files be replaced with the above function?</p>]]></content>
			<author>
				<name><![CDATA[apmuthu]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=364</uri>
			</author>
			<updated>2023-11-18T20:25:15Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=42703#p42703</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Show bank account in Customer Transactions type:payment]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=42678#p42678" />
			<content type="html"><![CDATA[<p>Hi</p><p>As a contribution for this forum included the customisation files to show the bank account then user consult customer transactions, type: Payment.</p><p>For those who are interested, insert the files at this address</p><p>sales/inquiry/customer_inquiry.php<br />sales/includes/db/cust_trans_db.inc</p>]]></content>
			<author>
				<name><![CDATA[Rmendez]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=40570</uri>
			</author>
			<updated>2023-11-09T18:23:19Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=42678#p42678</id>
		</entry>
</feed>
