function can_process() { global $Refs; if (!get_post('customer_id')) { display_error(_("There is no customer selected.")); set_focus('customer_id'); return false; } if (!get_post('BranchID')) { display_error(_("This customer has no branch defined.")); set_focus('BranchID'); return false; } if (!isset($_POST['DateBanked']) || !is_date($_POST['DateBanked'])) { display_error(_("The entered date is invalid. Please enter a valid date for the payment.")); set_focus('DateBanked'); return false; } elseif (!is_date_in_fiscalyear($_POST['DateBanked'])) { display_error(_("The entered date is not in fiscal year.")); set_focus('DateBanked'); return false; } if (!$Refs->is_valid($_POST['ref'])) { display_error(_("You must enter a reference.")); set_focus('ref'); return false; } //Chaitanya : 13-OCT-2011 - To support Edit feature if (isset($_POST['trans_no']) && $_POST['trans_no'] == 0 && !is_new_reference($_POST['ref'], ST_CUSTPAYMENT)) { display_error(_("The entered reference is already in use.")); set_focus('ref'); return false; } elseif ($_POST['ref'] != $_POST['old_ref'] && !is_new_reference($_POST['ref'], ST_CUSTPAYMENT)) { display_error(_("The entered reference is already in use.")); set_focus('ref'); return false; } if (!check_num('amount', 0)) { display_error(_("The entered amount is invalid or negative and cannot be processed.")); set_focus('amount'); return false; } if (isset($_POST['charge']) && !check_num('charge', 0)) { display_error(_("The entered amount is invalid or negative and cannot be processed.")); 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 (isset($_POST['_ex_rate']) && !check_num('_ex_rate', 1.0E-6)) { display_error(_("The exchange rate must be numeric and greater than zero.")); set_focus('_ex_rate'); return false; } if ($_POST['discount'] == "") { $_POST['discount'] = 0; } if (!check_num('discount')) { display_error(_("The entered discount is not a valid number.")); set_focus('discount'); return false; } //if ((input_num('amount') - input_num('discount') <= 0)) { if (input_num('amount') <= 0) { display_error(_("The balance of the amount and discout is zero or negative. Please enter valid amounts.")); set_focus('discount'); return false; } if (!db_has_currency_rates(get_customer_currency($_POST['customer_id']), $_POST['DateBanked'], true)) { return false; } $_SESSION['alloc']->amount = input_num('amount'); if (isset($_POST["TotalNumberOfAllocs"])) { return check_allocations(); } else { return true; } }
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 can_process() { global $Refs, $SysPrefs; copy_to_cart(); if (!get_post('customer_id')) { display_error(_("There is no customer selected.")); set_focus('customer_id'); return false; } if (!get_post('branch_id')) { display_error(_("This customer has no branch defined.")); set_focus('branch_id'); return false; } if (!is_date($_POST['OrderDate'])) { display_error(_("The entered date is invalid.")); set_focus('OrderDate'); return false; } if ($_SESSION['Items']->trans_type != ST_SALESORDER && $_SESSION['Items']->trans_type != ST_SALESQUOTE && !is_date_in_fiscalyear($_POST['OrderDate'])) { display_error(_("The entered date is not in fiscal year")); set_focus('OrderDate'); return false; } if (count($_SESSION['Items']->line_items) == 0) { display_error(_("You must enter at least one non empty item line.")); set_focus('AddItem'); return false; } if (!$SysPrefs->allow_negative_stock() && ($low_stock = $_SESSION['Items']->check_qoh())) { display_error(_("This document cannot be processed because there is insufficient quantity for items marked.")); return false; } if ($_SESSION['Items']->payment_terms['cash_sale'] == 0) { if (strlen($_POST['deliver_to']) <= 1) { display_error(_("You must enter the person or company to whom delivery should be made to.")); set_focus('deliver_to'); return false; } if ($_SESSION['Items']->trans_type != ST_SALESQUOTE && strlen($_POST['delivery_address']) <= 1) { display_error(_("You should enter the street address in the box provided. Orders cannot be accepted without a valid street address.")); set_focus('delivery_address'); return false; } if ($_POST['freight_cost'] == "") { $_POST['freight_cost'] = price_format(0); } if (!check_num('freight_cost', 0)) { display_error(_("The shipping cost entered is expected to be numeric.")); set_focus('freight_cost'); return false; } if (!is_date($_POST['delivery_date'])) { if ($_SESSION['Items']->trans_type == ST_SALESQUOTE) { display_error(_("The Valid date is invalid.")); } else { display_error(_("The delivery date is invalid.")); } set_focus('delivery_date'); return false; } if (date1_greater_date2($_POST['OrderDate'], $_POST['delivery_date'])) { if ($_SESSION['Items']->trans_type == ST_SALESQUOTE) { display_error(_("The requested valid date is before the date of the quotation.")); } else { display_error(_("The requested delivery date is before the date of the order.")); } set_focus('delivery_date'); return false; } } else { if (!db_has_cash_accounts()) { display_error(_("You need to define a cash account for your Sales Point.")); return false; } } if (!$Refs->is_valid($_POST['ref'])) { display_error(_("You must enter a reference.")); set_focus('ref'); return false; } if (!db_has_currency_rates($_SESSION['Items']->customer_currency, $_POST['OrderDate'])) { return false; } if ($_SESSION['Items']->get_items_total() < 0) { display_error("Invoice total amount cannot be less than zero."); return false; } 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; }
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 can_commit() { global $Refs; if (!get_post('supplier_id')) { display_error(_("There is no supplier selected.")); set_focus('supplier_id'); return false; } if (!is_date($_POST['OrderDate'])) { display_error(_("The entered order date is invalid.")); set_focus('OrderDate'); return false; } if ($_SESSION['PO']->trans_type != ST_PURCHORDER && !is_date_in_fiscalyear($_POST['OrderDate'])) { display_error(_("The entered date is not in fiscal year")); set_focus('OrderDate'); return false; } if ($_SESSION['PO']->trans_type == ST_SUPPINVOICE && !is_date($_POST['due_date'])) { display_error(_("The entered due date is invalid.")); set_focus('due_date'); return false; } if (!$_SESSION['PO']->order_no) { if (!$Refs->is_valid(get_post('ref'))) { display_error(_("There is no reference entered for this purchase order.")); set_focus('ref'); return false; } if (!is_new_reference(get_post('ref'), $_SESSION['PO']->trans_type)) { display_error(_("The entered reference is already in use.")); set_focus('ref'); return false; } } if ($_SESSION['PO']->trans_type == ST_SUPPINVOICE && !$Refs->is_valid(get_post('supp_ref'))) { display_error(_("You must enter a supplier's invoice reference.")); set_focus('supp_ref'); return false; } if ($_SESSION['PO']->trans_type == ST_SUPPINVOICE && is_reference_already_there($_SESSION['PO']->supplier_id, get_post('supp_ref'), $_SESSION['PO']->order_no)) { display_error(_("This invoice number has already been entered. It cannot be entered again.") . " (" . get_post('supp_ref') . ")"); set_focus('supp_ref'); return false; } if ($_SESSION['PO']->trans_type == ST_PURCHORDER && get_post('delivery_address') == '') { display_error(_("There is no delivery address specified.")); set_focus('delivery_address'); return false; } if (get_post('StkLocation') == '') { display_error(_("There is no location specified to move any items into.")); set_focus('StkLocation'); return false; } if (!db_has_currency_rates($_SESSION['PO']->curr_code, $_POST['OrderDate'])) { return false; } if ($_SESSION['PO']->order_has_items() == false) { display_error(_("The order cannot be placed because there are no lines entered on this order.")); return false; } return true; }
$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();