Re: Bank Account Payment Entry / gl/gl_bank.php?NewPayment=Yes

4. gl/includes/db/gl_db_banking.inc

function write_bank_transaction($trans_type, $trans_no, $from_account, $items, $date_,
    $person_type_id, $person_id, $person_detail_id,    $ref, $check_no, $source_ref ,$memo_, $use_transaction=true, $settled_amount=null)
{
    global $Refs, $SysPrefs;

    // we can only handle type 1 (payment)and type 2 (deposit)
    if ($trans_type != ST_BANKPAYMENT && $trans_type != ST_BANKDEPOSIT)
        display_db_error("Invalid type ($trans_type) sent to add_bank_transaction");

    $do_exchange_variance = false;
    $exchanged = false;
    if ($use_transaction)
        begin_transaction();

    $args = func_get_args(); if (count($args) < 11) $args[] = true;
    $args = (object)array_combine(array('trans_type', 'trans_no', 'from_account', 'items', 'date_',
        'person_type_id', 'person_id', 'person_detail_id', 'ref','check_no','source_ref', 'memo_', 'use_transaction', 'settled_amount'),
        $args);

52 (edited by cedricktshiyoyo 01/28/2021 09:12:33 pm)

Re: Bank Account Payment Entry / gl/gl_bank.php?NewPayment=Yes

5. in gl/includes/ui/gl_bank_ui.inc

text_row(_("Cheque No:"),  'check_no', $_POST['check_no'], 16, 40);

payment_person_types_list_row( $payment ? _("Pay To:"):_("From:"),
         'PayType', $_POST['PayType'], true);
    switch ($_POST['PayType'])
    {
        case PT_MISC :
            text_row_ex($payment ?_("To the Order of:"):_("Name:"),
                 'person_id', 20, 50);
            text_row(_("Voucher No:"), 'source_ref', null, 20, 50);    // Newly Added
            break;

Re: Bank Account Payment Entry / gl/gl_bank.php?NewPayment=Yes

And of course the validation to not accept empty field in cheque no... that's all I did

if (strlen($_POST['check_no']) == 0 || $_POST['check_no'] == "") // new line validation added on sunday november 21 2020
    {
        display_error(_("The cheque no  reference field must be entered.")); // new line validation
         if (get_post('currency') != get_company_pref('curr_default'))
        set_focus('check_no'); if (isset($_POST['_ex_rate']) && !check_num('_ex_rate', 0.000001))
        return false; {
    }                  display_error(_("The exchange rate must be numeric and greater than zero."));
                set_focus('_ex_rate');
            $input_error = 1;
        }

Re: Bank Account Payment Entry / gl/gl_bank.php?NewPayment=Yes

cedricktshiyoyo wrote:

yeah it may be confusing for sure.

I think you know what I was trying to do recently with bank payments.

1. I have altered bank_trans , added 2 extra fields, check_no & source_ref
2. I have made little changes in gl/gl_bank.php
3. gl/includes/db/gl_db_bank_trans.inc // New code

function add_bank_trans($type, $trans_no, $bank_act, $ref,$check_no, $source_ref, $date_,
    $amount, $person_type_id, $person_id, $currency="", $err_msg="", $rate=0)
{
    $sqlDate = date2sql($date_);

    // convert $amount to the bank's currency
    if ($currency != "")
    {
        $bank_account_currency = get_bank_account_currency($bank_act);
        if ($rate == 0)
            $to_bank_currency = get_exchange_rate_from_to($currency, $bank_account_currency, $date_);
        else
            $to_bank_currency = 1 / $rate;
        $amount_bank = ($amount / $to_bank_currency);
    }
    else
        $amount_bank = $amount;
    $amount_bank = round2($amount_bank, user_price_dec());   

    $sql = "INSERT INTO ".TB_PREF."bank_trans (type, trans_no, bank_act, ref, check_no, source_ref,
        trans_date, amount, person_type_id, person_id) ";

    $sql .= "VALUES ($type, $trans_no, '$bank_act', ".db_escape($ref).", ".db_escape($check_no).",".db_escape($source_ref).",'$sqlDate',
        ".db_escape($amount_bank).", ".db_escape($person_type_id)
        .", ". db_escape($person_id).")";

    if ($err_msg == "")
        $err_msg = "The bank transaction could not be inserted";

    db_query($sql, $err_msg);
}

I don't think there is anything wrong with the above from what I can see. Do you know where this is being called from in this instance where you are getting the error message?

Re: Bank Account Payment Entry / gl/gl_bank.php?NewPayment=Yes

Yeah, i am getting this error from journal entry   

finance/gl/gl_journal.php?NewJournal=Yes