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; }
function check_inputs() { global $Refs; if (!get_post('supplier_id')) { display_error(_("There is no supplier selected.")); set_focus('supplier_id'); return false; } if (@$_POST['amount'] == "") { $_POST['amount'] = price_format(0); } if (!check_num('amount', 0)) { display_error(_("The entered amount is invalid or less than zero.")); set_focus('amount'); return false; } 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) { $charge_acct = get_company_pref('bank_charge_act'); if (get_gl_account($charge_acct) == false) { display_error(_("The Bank Charge Account has not been set in System and General GL Setup.")); set_focus('charge'); return false; } } if (@$_POST['discount'] == "") { $_POST['discount'] = 0; } if (!check_num('discount', 0)) { display_error(_("The entered discount is invalid or less than zero.")); set_focus('amount'); return false; } //if (input_num('amount') - input_num('discount') <= 0) if (input_num('amount') <= 0) { display_error(_("The total of the amount and the discount is zero or negative. Please enter positive values.")); set_focus('amount'); return false; } if (isset($_POST['bank_amount']) && input_num('bank_amount') <= 0) { display_error(_("The entered bank amount is zero or negative.")); set_focus('bank_amount'); return false; } if (!is_date($_POST['DatePaid'])) { display_error(_("The entered date is invalid.")); set_focus('DatePaid'); return false; } elseif (!is_date_in_fiscalyear($_POST['DatePaid'])) { display_error(_("The entered date is out of fiscal year or is closed for further data entry.")); set_focus('DatePaid'); return false; } $limit = get_bank_account_limit($_POST['bank_account'], $_POST['DatePaid']); if ($limit !== null && floatcmp($limit, input_num('amount')) < 0) { display_error(sprintf(_("The total bank amount exceeds allowed limit (%s)."), price_format($limit))); set_focus('amount'); 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_SUPPAYMENT)) { display_error(_("The entered reference is already in use.")); set_focus('ref'); return false; } if (!db_has_currency_rates(get_supplier_currency($_POST['supplier_id']), $_POST['DatePaid'], true)) { return false; } $_SESSION['alloc']->amount = -input_num('amount'); if (isset($_POST["TotalNumberOfAllocs"])) { return check_allocations(); } else { return true; } }
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; }
$_SESSION['pay_items'] =& $cart; } //----------------------------------------------------------------------------------------------- if (isset($_POST['Process'])) { $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 && $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;