if (isset($_POST['_DateBanked_changed'])) {
    $Ajax->activate('_ex_rate');
}
//----------------------------------------------------------------------------------------------
if (get_post('AddPaymentItem') && can_process()) {
    $cust_currency = get_customer_currency($_POST['customer_id']);
    $bank_currency = get_bank_account_currency($_POST['bank_account']);
    $comp_currency = get_company_currency();
    if ($comp_currency != $bank_currency && $bank_currency != $cust_currency) {
        $rate = 0;
    } else {
        $rate = input_num('_ex_rate');
    }
    new_doc_date($_POST['DateBanked']);
    //Chaitanya : 13-OCT-2011 - To support Edit feature
    $payment_no = write_customer_payment($_SESSION['alloc']->trans_no, $_POST['customer_id'], $_POST['BranchID'], $_POST['bank_account'], $_POST['DateBanked'], $_POST['ref'], input_num('amount'), input_num('discount'), $_POST['memo_'], $rate, input_num('charge'));
    $_SESSION['alloc']->trans_no = $payment_no;
    $_SESSION['alloc']->write();
    unset($_POST);
    unset($_SESSION);
    //Chaitanya : 13-OCT-2011 - To support Edit feature
    //meta_forward($_SERVER['PHP_SELF'], "AddedID=$payment_no");
    meta_forward($_SERVER['PHP_SELF'], !$_SESSION['alloc']->trans_no ? "AddedID={$payment_no}" : "UpdatedID={$payment_no}");
}
//----------------------------------------------------------------------------------------------
function read_customer_data()
{
    global $Refs;
    $myrow = get_customer_habit($_POST['customer_id']);
    $_POST['HoldAccount'] = $myrow["dissallow_invoices"];
    $_POST['pymt_discount'] = $myrow["pymt_discount"];
        display_error(tr("The balance of the amount and discout is zero or negative. Please enter valid amounts."));
        set_focus('discount');
        return false;
    }
    return true;
}
//----------------------------------------------------------------------------------------------
// validate inputs
if (isset($_POST['AddPaymentItem'])) {
    if (!can_process()) {
        unset($_POST['AddPaymentItem']);
    }
}
//----------------------------------------------------------------------------------------------
if (isset($_POST['AddPaymentItem'])) {
    $payment_no = write_customer_payment(0, $_POST['customer_id'], $_POST['BranchID'], $_POST['bank_account'], $_POST['DateBanked'], $_POST['ReceiptType'], $_POST['ref'], input_num('amount'), input_num('discount'), $_POST['memo_']);
    meta_forward($_SERVER['PHP_SELF'], "AddedID={$payment_no}");
}
//----------------------------------------------------------------------------------------------
function read_customer_data()
{
    $sql = "SELECT debtors_master.pymt_discount,\n\t\tcredit_status.dissallow_invoices\n\t\tFROM debtors_master, credit_status\n\t\tWHERE debtors_master.credit_status = credit_status.id\n\t\t\tAND debtors_master.debtor_no = '" . $_POST['customer_id'] . "'";
    $result = db_query($sql, "could not query customers");
    $myrow = db_fetch($result);
    $_POST['HoldAccount'] = $myrow["dissallow_invoices"];
    $_POST['pymt_discount'] = $myrow["pymt_discount"];
    $_POST['ref'] = references::get_next(12);
}
//-------------------------------------------------------------------------------------------------
function display_item_form()
{