Added Bank Charge field to Customer Payment and Supplier Payment and a new default...
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Fri, 26 Jun 2009 07:27:19 +0000 (07:27 +0000)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Fri, 26 Jun 2009 07:27:19 +0000 (07:27 +0000)
CHANGELOG.txt
admin/db/company_db.inc
admin/gl_setup.php
purchasing/includes/db/supp_payment_db.inc
purchasing/supplier_payment.php
sales/customer_payments.php
sales/includes/db/payment_db.inc
sql/alter2.2.sql
sql/en_US-demo.sql
sql/en_US-new.sql

index 3243c0fbfa61483d3741ced70384abf1dac88cbc..c796017ad6c421bfa64ac530ae3fe09b9348c135 100644 (file)
@@ -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.
index 0e8ddaaf506a78fe7cd55a77bae6bc5e77f60e64..1bb58326d8bacbdefedb7afb4ff14af08bc25b2d 100644 (file)
@@ -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).",
index 6936239e20eacbd32d7887a160ced43ac3259a9c..81de1be779e11516b4831e84bf266c8e753d3ece 100644 (file)
@@ -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']);
index 516dfba1df0afade211ae4c1bebd8238b4417e79..d7c3ccea27eb27ad65410df4492fc16d53d599a0 100644 (file)
@@ -10,7 +10,7 @@
     See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
 ***********************************************************************/
 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 */
index 30cd4bb6b2d8c6dbd91ec718a8c7cb77337c3ef4..fca9417f998dc7371106bb11728e363a72910394 100644 (file)
@@ -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 "</table>";
-       //echo "</td><td valign=top class='tableseparator'>"; // outer table
-       //echo "<table>";
 
     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 "</table>";
+       textarea_row(_("Memo:"), 'memo_', null, 22, 4);
 
-       //echo "</td></tr>";
        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']);
index cd7d7dc3e0bba54de307af84327a0e9a52c0ec36..a184b079d31f70c2d2020174edde60e1a647dcf8 100644 (file)
@@ -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>";
+               br();
 
                submit_center('AddPaymentItem', _("Add Payment"), true, '', 'default');
        }
 
-       echo "<br>";
+       br();
 }
 
 //----------------------------------------------------------------------------------------------
index 3697196915ece047d2597bd1f37566a5cb2ce034..6f079fd7c957ac5ffe321b5fb2dc1b8ce0fd36d7 100644 (file)
@@ -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);       
 
index 3703d0eadfb8c900f327f77baea0f69bba41b6d5..b6c7735a9fe69b16f0ca343d49b7af7bb6137247 100644 (file)
@@ -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`;
index 130df80db898d3b32da8b1d81c3b5bf3ef7689ac..ae1c6ac8b0b1cbf29a96e7a5f462aedee3d8c836 100644 (file)
@@ -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` ###
 
index 9971f5cf6369362bb22978e74c98b2d077aca9f0..79664e89350822fef4a335ce5f104d93a343ff79 100644 (file)
@@ -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` ###