Esempio n. 1
0
function gl_payment_controls()
{
    global $table_style2;
    $home_currency = get_company_currency();
    start_form(false, true);
    start_table($table_style2, 5, 7);
    echo "<tr><td valign=top>";
    // outer table
    echo "<table>";
    bank_accounts_list_row(tr("From Account:"), 'FromBankAccount', null, true);
    bank_accounts_list_row(tr("To Account:"), 'ToBankAccount', null, true);
    date_row(tr("Transfer Date:"), 'DatePaid');
    $from_currency = get_bank_account_currency($_POST['FromBankAccount']);
    $to_currency = get_bank_account_currency($_POST['ToBankAccount']);
    if ($from_currency != "" && $to_currency != "" && $from_currency != $to_currency) {
        amount_row(tr("Amount:"), 'amount', null, null, $from_currency);
        exchange_rate_display($from_currency, $to_currency, $_POST['DatePaid']);
    } else {
        amount_row(tr("Amount:"), 'amount');
    }
    echo "</table>";
    echo "</td><td valign=top class='tableseparator'>";
    // outer table
    echo "<table>";
    bank_trans_types_list_row(tr("Transfer Type:"), 'TransferType', null);
    ref_row(tr("Reference:"), 'ref', references::get_next(systypes::bank_transfer()));
    textarea_row(tr("Memo:"), 'memo_', null, 40, 4);
    end_table(1);
    echo "</td></tr>";
    end_table(1);
    // outer table
    submit_center('AddPayment', tr("Enter Transfer"));
    end_form();
}
Esempio n. 2
0
function display_controls()
{
    global $table_style2;
    start_form(false, true);
    if (!isset($_POST['supplier_id'])) {
        $_POST['supplier_id'] = get_global_supplier(false);
    }
    if (!isset($_POST['DatePaid'])) {
        $_POST['DatePaid'] = Today();
        if (!is_date_in_fiscalyear($_POST['DatePaid'])) {
            $_POST['DatePaid'] = end_fiscalyear();
        }
    }
    start_table($table_style2, 5, 7);
    echo "<tr><td valign=top>";
    // outer table
    echo "<table>";
    bank_accounts_list_row(tr("From Bank Account:"), 'bank_account', null, true);
    amount_row(tr("Amount of Payment:"), 'amount');
    amount_row(tr("Amount of Discount:"), 'discount');
    date_row(tr("Date Paid") . ":", 'DatePaid');
    echo "</table>";
    echo "</td><td valign=top class='tableseparator'>";
    // outer table
    echo "<table>";
    supplier_list_row(tr("Payment To:"), 'supplier_id', null, false, true);
    set_global_supplier($_POST['supplier_id']);
    $supplier_currency = get_supplier_currency($_POST['supplier_id']);
    $bank_currency = get_bank_account_currency($_POST['bank_account']);
    if ($bank_currency != $supplier_currency) {
        exchange_rate_display($bank_currency, $supplier_currency, $_POST['DatePaid']);
    }
    bank_trans_types_list_row(tr("Payment Type:"), 'PaymentType', null);
    ref_row(tr("Reference:"), 'ref', references::get_next(22));
    text_row(tr("Memo:"), 'memo_', null, 52, 50);
    echo "</table>";
    echo "</td></tr>";
    end_table(1);
    // outer table
    submit_center('ProcessSuppPayment', tr("Enter Payment"));
    if ($bank_currency != $supplier_currency) {
        display_note(tr("The amount and discount are in the bank account's currency."), 2, 0);
    }
    end_form();
}
Esempio n. 3
0
function check_trans()
{
    global $Refs;
    $input_error = 0;
    if ($_SESSION['pay_items']->count_gl_items() < 1) {
        display_error(_("You must enter at least one payment line."));
        set_focus('code_id');
        $input_error = 1;
    }
    if ($_SESSION['pay_items']->gl_items_total() == 0.0) {
        display_error(_("The total bank amount cannot be 0."));
        set_focus('code_id');
        $input_error = 1;
    }
    $limit = get_bank_account_limit($_POST['bank_account'], $_POST['date_']);
    $amnt_chg = -$_SESSION['pay_items']->gl_items_total() - $_SESSION['pay_items']->original_amount;
    if ($limit !== null && floatcmp($limit, -$amnt_chg) < 0) {
        display_error(sprintf(_("The total bank amount exceeds allowed limit (%s)."), price_format($limit - $_SESSION['pay_items']->original_amount)));
        set_focus('code_id');
        $input_error = 1;
    }
    if ($trans = check_bank_account_history($amnt_chg, $_POST['bank_account'], $_POST['date_'])) {
        display_error(sprintf(_("The bank transaction would result in exceed of authorized overdraft limit for transaction: %s #%s on %s."), $systypes_array[$trans['type']], $trans['trans_no'], sql2date($trans['trans_date'])));
        set_focus('amount');
        $input_error = 1;
    }
    if (!$Refs->is_valid($_POST['ref'])) {
        display_error(_("You must enter a reference."));
        set_focus('ref');
        $input_error = 1;
    } elseif ($_POST['ref'] != $_SESSION['pay_items']->reference && !is_new_reference($_POST['ref'], $_SESSION['pay_items']->trans_type)) {
        display_error(_("The entered reference is already in use."));
        set_focus('ref');
        $input_error = 1;
    }
    if (!is_date($_POST['date_'])) {
        display_error(_("The entered date for the payment is invalid."));
        set_focus('date_');
        $input_error = 1;
    } elseif (!is_date_in_fiscalyear($_POST['date_'])) {
        display_error(_("The entered date is not in fiscal year."));
        set_focus('date_');
        $input_error = 1;
    }
    if (get_post('PayType') == PT_CUSTOMER && (!get_post('person_id') || !get_post('PersonDetailID'))) {
        display_error(_("You have to select customer and customer branch."));
        set_focus('person_id');
        $input_error = 1;
    } elseif (get_post('PayType') == PT_SUPPLIER && !get_post('person_id')) {
        display_error(_("You have to select supplier."));
        set_focus('person_id');
        $input_error = 1;
    }
    if (!db_has_currency_rates(get_bank_account_currency($_POST['bank_account']), $_POST['date_'], true)) {
        $input_error = 1;
    }
    if (isset($_POST['settled_amount']) && in_array(get_post('PayType'), array(PT_SUPPLIER, PT_CUSTOMER)) && input_num('settled_amount') <= 0) {
        display_error(_("Settled amount have to be positive number."));
        set_focus('person_id');
        $input_error = 1;
    }
    return $input_error;
}
Esempio n. 4
0
    display_warning(_("This customer account is on hold."));
}
$display_discount_percent = percent_format($_POST['pymt_discount'] * 100) . "%";
table_section(2);
if (!list_updated('bank_account')) {
    $_POST['bank_account'] = get_default_customer_bank_account($_POST['customer_id']);
}
//Chaitanya : 13-OCT-2011 - Is AJAX call really needed ???
//bank_accounts_list_row(_("Into Bank Account:"), 'bank_account', null, true);
bank_accounts_list_row(_("Into Bank Account:"), 'bank_account', null, false);
text_row(_("Reference:"), 'ref', null, 20, 40);
table_section(3);
date_row(_("Date of Deposit:"), 'DateBanked', '', true, 0, 0, 0, null, true);
$comp_currency = get_company_currency();
$cust_currency = get_customer_currency($_POST['customer_id']);
$bank_currency = get_bank_account_currency($_POST['bank_account']);
if ($cust_currency != $bank_currency) {
    exchange_rate_display($bank_currency, $cust_currency, $_POST['DateBanked'], $bank_currency == $comp_currency);
}
amount_row(_("Bank Charge:"), 'charge');
end_outer_table(1);
if ($cust_currency == $bank_currency) {
    div_start('alloc_tbl');
    show_allocatable(false);
    div_end();
}
start_table(TABLESTYLE, "width=60%");
label_row(_("Customer prompt payment discount :"), $display_discount_percent);
amount_row(_("Amount of Discount:"), 'discount');
amount_row(_("Amount:"), 'amount');
textarea_row(_("Memo:"), 'memo_', null, 22, 4);
read_customer_data();
set_global_customer($_POST['customer_id']);
if (isset($_POST['HoldAccount']) && $_POST['HoldAccount'] != 0) {
    display_warning(_("This customer account is on hold."));
}
$display_discount_percent = percent_format($_POST['pymt_discount'] * 100) . "%";
table_section(2);
date_row(_("Date of Deposit:"), 'DateBanked', '', true, 0, 0, 0, null, true);
ref_row(_("Reference:"), 'ref', '', null, '', ST_CUSTPAYMENT);
table_section(3);
$comp_currency = get_company_currency();
$cust_currency = $_SESSION['alloc']->set_person($_POST['customer_id'], PT_CUSTOMER);
if (!$cust_currency) {
    $cust_currency = $comp_currency;
}
$_SESSION['alloc']->currency = $bank_currency = get_bank_account_currency($_POST['bank_account']);
if ($cust_currency != $bank_currency) {
    amount_row(_("Payment Amount:"), 'bank_amount', null, '', $bank_currency);
}
amount_row(_("Bank Charge:"), 'charge', null, '', $bank_currency);
end_outer_table(1);
div_start('alloc_tbl');
show_allocatable(false);
div_end();
start_table(TABLESTYLE, "width='60%'");
label_row(_("Customer prompt payment discount :"), $display_discount_percent);
amount_row(_("Amount of Discount:"), 'discount', null, '', $cust_currency);
amount_row(_("Amount:"), 'amount', null, '', $cust_currency);
textarea_row(_("Memo:"), 'memo_', null, 22, 4);
end_table(1);
if ($new) {
Esempio n. 6
0
function check_valid_entries()
{
    global $Refs;
    if (!is_date($_POST['DatePaid'])) {
        display_error(_("The entered date is invalid."));
        set_focus('DatePaid');
        return false;
    }
    if (!is_date_in_fiscalyear($_POST['DatePaid'])) {
        display_error(_("The entered date is not in fiscal year."));
        set_focus('DatePaid');
        return false;
    }
    if (!check_num('amount', 0)) {
        display_error(_("The entered amount is invalid or less than zero."));
        set_focus('amount');
        return false;
    }
    if (input_num('amount') == 0) {
        display_error(_("The total bank amount cannot be 0."));
        set_focus('amount');
        return false;
    }
    $limit = get_bank_account_limit($_POST['FromBankAccount'], $_POST['DatePaid']);
    $amnt_tr = input_num('charge') + input_num('amount');
    if ($limit !== null && floatcmp($limit, $amnt_tr) < 0) {
        display_error(sprintf(_("The total bank amount exceeds allowed limit (%s) for source account."), price_format($limit)));
        set_focus('amount');
        return false;
    }
    if ($trans = check_bank_account_history(-$amnt_tr, $_POST['FromBankAccount'], $_POST['DatePaid'])) {
        display_error(sprintf(_("The bank transaction would result in exceed of authorized overdraft limit for transaction: %s #%s on %s."), $systypes_array[$trans['type']], $trans['trans_no'], sql2date($trans['trans_date'])));
        set_focus('amount');
        $input_error = 1;
    }
    if (isset($_POST['charge']) && !check_num('charge', 0)) {
        display_error(_("The entered amount is invalid or less than zero."));
        set_focus('charge');
        return false;
    }
    if (isset($_POST['charge']) && input_num('charge') > 0 && get_company_pref('bank_charge_act') == '') {
        display_error(_("The Bank Charge Account has not been set in System and General GL Setup."));
        set_focus('charge');
        return false;
    }
    if (!$Refs->is_valid($_POST['ref'])) {
        display_error(_("You must enter a reference."));
        set_focus('ref');
        return false;
    }
    if (!is_new_reference($_POST['ref'], ST_BANKTRANSFER)) {
        display_error(_("The entered reference is already in use."));
        set_focus('ref');
        return false;
    }
    if ($_POST['FromBankAccount'] == $_POST['ToBankAccount']) {
        display_error(_("The source and destination bank accouts cannot be the same."));
        set_focus('ToBankAccount');
        return false;
    }
    if (isset($_POST['target_amount']) && !check_num('target_amount', 0)) {
        display_error(_("The entered amount is invalid or less than zero."));
        set_focus('target_amount');
        return false;
    }
    if (isset($_POST['target_amount']) && input_num('target_amount') == 0) {
        display_error(_("The incomming bank amount cannot be 0."));
        set_focus('target_amount');
        return false;
    }
    if (!db_has_currency_rates(get_bank_account_currency($_POST['FromBankAccount']), $_POST['DatePaid'])) {
        return false;
    }
    if (!db_has_currency_rates(get_bank_account_currency($_POST['ToBankAccount']), $_POST['DatePaid'])) {
        return false;
    }
    return true;
}
Esempio n. 7
0
function display_item_form()
{
    global $table_style2;
    start_table($table_style2, 5, 7);
    echo "<tr><td valign=top>";
    // outer table
    echo "<table>";
    if (!isset($_POST['customer_id'])) {
        $_POST['customer_id'] = get_global_customer(false);
    }
    if (!isset($_POST['DateBanked'])) {
        $_POST['DateBanked'] = Today();
        if (!is_date_in_fiscalyear($_POST['DateBanked'])) {
            $_POST['DateBanked'] = end_fiscalyear();
        }
    }
    customer_list_row(tr("From Customer:"), 'customer_id', null, false, true);
    if (db_customer_has_branches($_POST['customer_id'])) {
        customer_branches_list_row(tr("Branch:"), $_POST['customer_id'], 'BranchID', null, false, true, true);
    } else {
        hidden('BranchID', reserved_words::get_any_numeric());
    }
    read_customer_data();
    set_global_customer($_POST['customer_id']);
    if (isset($_POST['HoldAccount']) && $_POST['HoldAccount'] != 0) {
        echo "</table></table>";
        display_note(tr("This customer account is on hold."), 0, 0, "class='redfb'");
    } else {
        $display_discount_percent = percent_format($_POST['pymt_discount'] * 100) . "%";
        amount_row(tr("Amount:"), 'amount');
        amount_row(tr("Amount of Discount:"), 'discount');
        label_row(tr("Customer prompt payment discount :"), $display_discount_percent);
        date_row(tr("Date of Deposit:"), 'DateBanked');
        echo "</table>";
        echo "</td><td valign=top class='tableseparator'>";
        // outer table
        echo "<table>";
        bank_accounts_list_row(tr("Into Bank Account:"), 'bank_account', null, true);
        $cust_currency = get_customer_currency($_POST['customer_id']);
        $bank_currency = get_bank_account_currency($_POST['bank_account']);
        if ($cust_currency != $bank_currency) {
            exchange_rate_display($cust_currency, $bank_currency, $_POST['DateBanked']);
        }
        bank_trans_types_list_row(tr("Type:"), 'ReceiptType', null);
        text_row(tr("Reference:"), 'ref', null, 20, 40);
        textarea_row(tr("Memo:"), 'memo_', null, 22, 4);
        echo "</table>";
        echo "</td></tr>";
        end_table();
        // outer table
        if ($cust_currency != $bank_currency) {
            display_note(tr("Amount and discount are in customer's currency."));
        }
        echo "<br>";
        submit_center('AddPaymentItem', tr("Add Payment"));
    }
    echo "<br>";
}
Esempio n. 8
0
function handle_add_payment()
{
    $supp_currency = get_supplier_currency($_POST['supplier_id']);
    $bank_currency = get_bank_account_currency($_POST['bank_account']);
    $comp_currency = get_company_currency();
    if ($comp_currency != $bank_currency && $bank_currency != $supp_currency) {
        $rate = 0;
    } else {
        $rate = input_num('_ex_rate');
    }
    $payment_id = add_supp_payment($_POST['supplier_id'], $_POST['DatePaid'], $_POST['bank_account'], input_num('amount'), input_num('discount'), $_POST['ref'], $_POST['memo_'], $rate, input_num('charge'));
    new_doc_date($_POST['DatePaid']);
    $_SESSION['alloc']->trans_no = $payment_id;
    $_SESSION['alloc']->write();
    //unset($_POST['supplier_id']);
    unset($_POST['bank_account']);
    unset($_POST['DatePaid']);
    unset($_POST['currency']);
    unset($_POST['memo_']);
    unset($_POST['amount']);
    unset($_POST['discount']);
    unset($_POST['ProcessSuppPayment']);
    meta_forward($_SERVER['PHP_SELF'], "AddedID={$payment_id}&supplier_id=" . $_POST['supplier_id']);
}
Esempio n. 9
0
        $input_error = 1;
    } elseif (!is_date_in_fiscalyear($_POST['date_'])) {
        display_error(_("The entered date is not in fiscal year."));
        set_focus('date_');
        $input_error = 1;
    }
    if (get_post('PayType') == PT_CUSTOMER && (!get_post('person_id') || !get_post('PersonDetailID'))) {
        display_error(_("You have to select customer and customer branch."));
        set_focus('person_id');
        $input_error = 1;
    } elseif (get_post('PayType') == PT_SUPPLIER && !get_post('person_id')) {
        display_error(_("You have to select supplier."));
        set_focus('person_id');
        $input_error = 1;
    }
    if (!db_has_currency_rates(get_bank_account_currency($_POST['bank_account']), $_POST['date_'], true)) {
        $input_error = 1;
    }
    if ($input_error == 1) {
        unset($_POST['Process']);
    }
}
if (isset($_POST['Process'])) {
    begin_transaction();
    $_SESSION['pay_items'] =& $_SESSION['pay_items'];
    $new = $_SESSION['pay_items']->order_id == 0;
    $trans = write_bank_transaction($_SESSION['pay_items']->trans_type, $_SESSION['pay_items']->order_id, $_POST['bank_account'], $_SESSION['pay_items'], $_POST['date_'], $_POST['PayType'], $_POST['person_id'], get_post('PersonDetailID'), $_POST['ref'], $_POST['memo_'], true);
    $trans_type = $trans[0];
    $trans_no = $trans[1];
    new_doc_date($_POST['date_']);
    $_SESSION['pay_items']->clear_items();