From: Joe Hunt Date: Fri, 26 Jun 2009 07:27:19 +0000 (+0000) Subject: Added Bank Charge field to Customer Payment and Supplier Payment and a new default... X-Git-Tag: v2.4.2~19^2~1359 X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=f20f229779b9db77c3f978fac90dfcb571bd551c;p=fa-stable.git Added Bank Charge field to Customer Payment and Supplier Payment and a new default bank charge account in gl_setup. --- diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 3243c0fb..c796017a 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -19,6 +19,18 @@ Legend: ! -> Note $ -> Affected files +26-Jun-2009 Joe Hunt ++ Added Bank Charge field to Customer Payment and Supplier Payment and a new default bank charge account in gl_setup. +$ /admin/gl_setup.php + /admin/db/company_db.inc + /purchasing/supplier_payment.php + /purchasing/includes/db/supp_payment_db.inc + /sales/customer_payment.php + /sales/includes/db/payment_db.inc + /sql/alter2.2.sql + /sql/en_US-demo.sql + /sql/en_US-new.sql + 25-Jun-2009 Joe Hunt ! Changed balance_sheet field in account class to ctype and fixed class editing. # Parse error in ui_lists.inc. Masked include_once(/validation.inc) in main.inc. diff --git a/admin/db/company_db.inc b/admin/db/company_db.inc index 0e8ddaaf..1bb58326 100644 --- a/admin/db/company_db.inc +++ b/admin/db/company_db.inc @@ -13,6 +13,7 @@ function update_company_gl_setup($retained_act, $profit_loss_act, $debtors_act, $pyt_discount_act, $creditors_act, $freight_act, $exchange_diff_act, + $bank_charge_act, $default_sales_act, $default_sales_discount_act, $default_prompt_payment_act, @@ -38,6 +39,7 @@ function update_company_gl_setup($retained_act, $profit_loss_act, $debtors_act, creditors_act=".db_escape($creditors_act).", freight_act=".db_escape($freight_act).", exchange_diff_act=".db_escape($exchange_diff_act).", + bank_charge_act=".db_escape($bank_charge_act).", default_sales_act=".db_escape($default_sales_act).", default_sales_discount_act=".db_escape($default_sales_discount_act).", default_prompt_payment_act=".db_escape($default_prompt_payment_act).", diff --git a/admin/gl_setup.php b/admin/gl_setup.php index 6936239e..81de1be7 100644 --- a/admin/gl_setup.php +++ b/admin/gl_setup.php @@ -55,7 +55,7 @@ if (isset($_POST['submit']) && can_process()) update_company_gl_setup($_POST['retained_earnings_act'], $_POST['profit_loss_year_act'], $_POST['debtors_act'], $_POST['pyt_discount_act'], $_POST['creditors_act'], $_POST['freight_act'], - $_POST['exchange_diff_act'], + $_POST['exchange_diff_act'], $_POST['bank_charge_act'], $_POST['default_sales_act'], $_POST['default_sales_discount_act'], $_POST['default_prompt_payment_act'], @@ -98,6 +98,7 @@ $_POST['freight_act'] = $myrow["freight_act"]; $_POST['pyt_discount_act'] = $myrow["pyt_discount_act"]; $_POST['exchange_diff_act'] = $myrow["exchange_diff_act"]; +$_POST['bank_charge_act'] = $myrow["bank_charge_act"]; $_POST['default_sales_act'] = $myrow["default_sales_act"]; $_POST['default_sales_discount_act'] = $myrow["default_sales_discount_act"]; $_POST['default_prompt_payment_act'] = $myrow["default_prompt_payment_act"]; @@ -140,6 +141,8 @@ gl_all_accounts_list_row(_("Profit/Loss Year:"), 'profit_loss_year_act', $_POST[ gl_all_accounts_list_row(_("Exchange Variances Account:"), 'exchange_diff_act', $_POST['exchange_diff_act']); +gl_all_accounts_list_row(_("Bank Charges Account:"), 'bank_charge_act', $_POST['bank_charge_act']); + //--------------- table_section_title(_("Customers and Sales")); @@ -182,11 +185,6 @@ percent_row(_("Delivery Over-Receive Allowance:"), 'po_over_receive'); percent_row(_("Invoice Over-Charge Allowance:"), 'po_over_charge'); -// Not used in FA2.0. -//gl_all_accounts_list_row(_("Purchases Exchange Variances Account:"), 'purch_exchange_diff_act', $_POST['purch_exchange_diff_act']); -// Not used in FA2.0. -//gl_all_accounts_list_row(_("Goods Received Clearing Account:"), 'grn_act', $_POST['grn_act']); - table_section_title(_("Suppliers and Purchasing Defaults")); gl_all_accounts_list_row(_("Payable Account:"), 'creditors_act', $_POST['creditors_act']); diff --git a/purchasing/includes/db/supp_payment_db.inc b/purchasing/includes/db/supp_payment_db.inc index 516dfba1..d7c3ccea 100644 --- a/purchasing/includes/db/supp_payment_db.inc +++ b/purchasing/includes/db/supp_payment_db.inc @@ -10,7 +10,7 @@ See the License here . ***********************************************************************/ function add_supp_payment($supplier_id, $date_, $bank_account, - $amount, $discount, $ref, $memo_, $rate=0) + $amount, $discount, $ref, $memo_, $rate=0, $charge=0) { begin_transaction(); @@ -22,11 +22,13 @@ function add_supp_payment($supplier_id, $date_, $bank_account, { $supp_amount = exchange_from_to($amount, $bank_account_currency, $supplier_currency, $date_); $supp_discount = exchange_from_to($discount, $bank_account_currency, $supplier_currency, $date_); + $supp_charge = exchange_from_to($charge, $bank_account_currency, $supplier_currency, $date_); } else { $supp_amount = round($amount / $rate, user_price_dec()); $supp_discount = round($discount / $rate, user_price_dec()); + $supp_charge = round($charge / $rate, user_price_dec()); } @@ -51,10 +53,17 @@ function add_supp_payment($supplier_id, $date_, $bank_account, -$supp_discount, $supplier_id, "", $rate); } + if ($supp_charge != 0) + { + $charge_act = get_company_pref('bank_charge_act'); + $total += add_gl_trans_supplier($trans_type, $payment_id, $date_, $charge_act, 0, 0, + $supp_charge, $supplier_id, "", $rate); + } + if ($supp_amount != 0) { $total += add_gl_trans_supplier($trans_type, $payment_id, $date_, $bank_gl_account, 0, 0, - -$supp_amount, $supplier_id, "", $rate); + -($supp_amount + $supp_charge), $supplier_id, "", $rate); } /*Post a balance post if $total != 0 */ diff --git a/purchasing/supplier_payment.php b/purchasing/supplier_payment.php index 30cd4bb6..fca9417f 100644 --- a/purchasing/supplier_payment.php +++ b/purchasing/supplier_payment.php @@ -94,13 +94,11 @@ function display_controls() amount_row(_("Amount of Payment:"), 'amount'); amount_row(_("Amount of Discount:"), 'discount'); + amount_row(_("Bank Charge:"), 'charge'); date_row(_("Date Paid") . ":", 'DatePaid', '', true, 0, 0, 0, null, true); table_section(2); - //echo ""; - //echo ""; // outer table - //echo ""; supplier_list_row(_("Payment To:"), 'supplier_id', null, false, true); @@ -115,11 +113,8 @@ function display_controls() ref_row(_("Reference:"), 'ref', '', references::get_next(22)); - text_row(_("Memo:"), 'memo_', null, 52,50); - - //echo "
"; + textarea_row(_("Memo:"), 'memo_', null, 22, 4); - //echo ""; end_outer_table(1); // outer table submit_center('ProcessSuppPayment',_("Enter Payment"), true, '', 'default'); @@ -148,6 +143,12 @@ function check_inputs() 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['_ex_rate']) && !check_num('_ex_rate', 0.000001)) { display_error(_("The exchange rate must be numeric and greater than zero.")); @@ -217,7 +218,7 @@ function handle_add_payment() $payment_id = add_supp_payment($_POST['supplier_id'], $_POST['DatePaid'], $_POST['bank_account'], input_num('amount'), input_num('discount'), - $_POST['ref'], $_POST['memo_'], $rate); + $_POST['ref'], $_POST['memo_'], $rate, input_num('charge')); new_doc_date($_POST['DatePaid']); //unset($_POST['supplier_id']); unset($_POST['bank_account']); diff --git a/sales/customer_payments.php b/sales/customer_payments.php index cd7d7dc3..a184b079 100644 --- a/sales/customer_payments.php +++ b/sales/customer_payments.php @@ -93,6 +93,12 @@ function can_process() 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['_ex_rate']) && !check_num('_ex_rate', 0.000001)) { display_error(_("The exchange rate must be numeric and greater than zero.")); @@ -152,7 +158,7 @@ if (isset($_POST['AddPaymentItem'])) { $payment_no = write_customer_payment(0, $_POST['customer_id'], $_POST['BranchID'], $_POST['bank_account'], $_POST['DateBanked'], $_POST['ref'], - input_num('amount'), input_num('discount'), $_POST['memo_'], $rate); + input_num('amount'), input_num('discount'), $_POST['memo_'], $rate, input_num('charge')); meta_forward($_SERVER['PHP_SELF'], "AddedID=$payment_no"); } @@ -214,10 +220,12 @@ function display_item_form() label_row(_("Customer prompt payment discount :"), $display_discount_percent); - date_row(_("Date of Deposit:"), 'DateBanked', '', true, 0, 0, 0, null, true); + amount_row(_("Bank Charge:"), 'charge'); table_section(2); + date_row(_("Date of Deposit:"), 'DateBanked', '', true, 0, 0, 0, null, true); + bank_accounts_list_row(_("Into Bank Account:"), 'bank_account', null, true); $cust_currency = get_customer_currency($_POST['customer_id']); @@ -236,12 +244,12 @@ function display_item_form() if ($cust_currency != $bank_currency) display_note(_("Amount and discount are in customer's currency.")); - echo"
"; + br(); submit_center('AddPaymentItem', _("Add Payment"), true, '', 'default'); } - echo "
"; + br(); } //---------------------------------------------------------------------------------------------- diff --git a/sales/includes/db/payment_db.inc b/sales/includes/db/payment_db.inc index 36971969..6f079fd7 100644 --- a/sales/includes/db/payment_db.inc +++ b/sales/includes/db/payment_db.inc @@ -13,7 +13,7 @@ Write/update customer payment. */ function write_customer_payment($trans_no, $customer_id, $branch_id, $bank_account, - $date_, $ref, $amount, $discount, $memo_, $rate=0) + $date_, $ref, $amount, $discount, $memo_, $rate=0, $charge=0) { begin_transaction(); @@ -33,7 +33,7 @@ function write_customer_payment($trans_no, $customer_id, $branch_id, $bank_accou $total = 0; /* Bank account entry first */ $total += add_gl_trans_customer(12, $payment_no, $date_, - $bank_gl_account, 0, 0, $amount, $customer_id, + $bank_gl_account, 0, 0, $amount - $charge, $customer_id, "Cannot insert a GL transaction for the bank account debit", $rate); if ($branch_id != reserved_words::get_any_numeric()) { @@ -61,6 +61,13 @@ function write_customer_payment($trans_no, $customer_id, $branch_id, $bank_accou "Cannot insert a GL transaction for the payment discount debit", $rate); } + if ($charge != 0) { + /* Now Debit bank charge account with charges */ + $charge_act = get_company_pref('bank_charge_act'); + $total += add_gl_trans_customer(12, $payment_no, $date_, + $charge_act, 0, 0, $charge, $customer_id, + "Cannot insert a GL transaction for the payment bank charge debit", $rate); + } /*Post a balance post if $total != 0 */ add_gl_balance(12, $payment_no, $date_, -$total, payment_person_types::customer(), $customer_id); diff --git a/sql/alter2.2.sql b/sql/alter2.2.sql index 3703d0ea..b6c7735a 100644 --- a/sql/alter2.2.sql +++ b/sql/alter2.2.sql @@ -10,8 +10,9 @@ ALTER TABLE `0_company` ADD COLUMN `version_id` VARCHAR(11) NOT NULL DEFAULT ''; ALTER TABLE `0_company` DROP COLUMN `purch_exchange_diff_act`; ALTER TABLE `0_company` ADD COLUMN`profit_loss_year_act` VARCHAR(11) NOT NULL DEFAULT '' AFTER `exchange_diff_act`; ALTER TABLE `0_company` ADD COLUMN `time_zone` TINYINT(1) NOT NULL DEFAULT '0'; +ALTER TABLE `0_company` CHANGE `grn_act` `bank_charge_act` VARCHAR(11) NOT NULL DEFAULT ''; #INSERT INTO `0_chart_master` VALUES ('8900', '', 'Profit and Loss this year', '52', '0'); -UPDATE `0_company` SET `profit_loss_year_act`='8900', `version_id`='2.2' WHERE `coy_code`=1; +UPDATE `0_company` SET `profit_loss_year_act`='9990', `version_id`='2.2' WHERE `coy_code`=1; ALTER TABLE `0_stock_category` DROP COLUMN `stock_act`; ALTER TABLE `0_stock_category` DROP COLUMN `cogs_act`; diff --git a/sql/en_US-demo.sql b/sql/en_US-demo.sql index 130df80d..ae1c6ac8 100644 --- a/sql/en_US-demo.sql +++ b/sql/en_US-demo.sql @@ -374,7 +374,7 @@ CREATE TABLE `0_company` ( `debtors_act` varchar(11) NOT NULL default '', `pyt_discount_act` varchar(11) NOT NULL default '', `creditors_act` varchar(11) NOT NULL default '', - `grn_act` varchar(11) NOT NULL default '', + `bank_charge_act` varchar(11) NOT NULL default '', `exchange_diff_act` varchar(11) NOT NULL default '', `profit_loss_year_act` varchar(11) NOT NULL default '', `retained_earnings_act` varchar(11) NOT NULL default '', @@ -412,7 +412,7 @@ CREATE TABLE `0_company` ( ### Data of table `0_company` ### -INSERT INTO `0_company` VALUES ('1', 'Training Co.', '9876543', '123456789', '1', '1', 'Address 1\r\nAddress 2\r\nAddress 3', '(222) 111.222.333', '', 'delta@delta.com', 'logo_frontaccounting.jpg', '', 'USD', '1200', '5060', '2100', '1430', '4450', '9990', '3590', '4430', '4010', '4510', '4500', '1510', '5010', '5040', '4010', '1530', '5000', '0', '10', '10', '1000', '20', '20', '30', '1', '2', '0', '0', '0', '1', '0', '0', '', '1', '2.2', '0'); +INSERT INTO `0_company` VALUES ('1', 'Training Co.', '9876543', '123456789', '1', '1', 'Address 1\r\nAddress 2\r\nAddress 3', '(222) 111.222.333', '', 'delta@delta.com', 'logo_frontaccounting.jpg', '', 'USD', '1200', '5060', '2100', '5690', '4450', '9990', '3590', '4430', '4010', '4510', '4500', '1510', '5010', '5040', '4010', '1530', '5000', '0', '10', '10', '1000', '20', '20', '30', '1', '2', '0', '0', '0', '1', '0', '0', '', '1', '2.2', '0'); ### Structure of table `0_credit_status` ### diff --git a/sql/en_US-new.sql b/sql/en_US-new.sql index 9971f5cf..79664e89 100644 --- a/sql/en_US-new.sql +++ b/sql/en_US-new.sql @@ -357,7 +357,7 @@ CREATE TABLE `0_company` ( `debtors_act` varchar(11) NOT NULL default '', `pyt_discount_act` varchar(11) NOT NULL default '', `creditors_act` varchar(11) NOT NULL default '', - `grn_act` varchar(11) NOT NULL default '', + `bank_charge_act` varchar(11) NOT NULL default '', `exchange_diff_act` varchar(11) NOT NULL default '', `profit_loss_year_act` varchar(11) NOT NULL default '', `retained_earnings_act` varchar(11) NOT NULL default '', @@ -396,7 +396,7 @@ CREATE TABLE `0_company` ( ### Data of table `0_company` ### -INSERT INTO `0_company` VALUES ('1', 'Company name', '', '', '1', '1', 'N/A', '', '', '', '', '', 'USD', '1200', '5060', '2100', '1430', '4450', '9990', '3590', '4430', '4010', '4510', '4500', '1510', '5010', '5040', '4010', '1530', '5000', '0', '10', '10', '1000', '20', '20', '30', '1', '1', '0', '0', '0', '1', '0', '0', '', '1', '2.2', '0'); +INSERT INTO `0_company` VALUES ('1', 'Company name', '', '', '1', '1', 'N/A', '', '', '', '', '', 'USD', '1200', '5060', '2100', '5690', '4450', '9990', '3590', '4430', '4010', '4510', '4500', '1510', '5010', '5040', '4010', '1530', '5000', '0', '10', '10', '1000', '20', '20', '30', '1', '1', '0', '0', '0', '1', '0', '0', '', '1', '2.2', '0'); ### Structure of table `0_credit_status` ###