From: Joe Hunt Date: Tue, 28 Apr 2009 09:46:01 +0000 (+0000) Subject: Changed so the close of fiscal years also closes the balances and brings forward... X-Git-Tag: v2.4.2~19^2~1428 X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=ac67fd3d7312c358ddec72393538cf4590c66f49;p=fa-stable.git Changed so the close of fiscal years also closes the balances and brings forward retained earnings. --- diff --git a/CHANGELOG.txt b/CHANGELOG.txt index e2dc8b9b..42bdaaee 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -19,6 +19,15 @@ Legend: ! -> Note $ -> Affected files +28-Apr-2009 Joe Hunt +! Changed so the close of fiscal years also closes the balances and brings forward retained earnings. +$ /admin/gl_setup.ph + /admin/fiscalyears.php + /admin/db/company_db.inc + /sql/en_US-new.sql + /sql/en_US-demo.sql + /sql/alter2.2.sql + 25_Apr-2009 Janusz Dobrowolski # Fixed ambigous sql $ /inventory/manage/item_categories.php diff --git a/admin/db/company_db.inc b/admin/db/company_db.inc index 1215229a..c9f416f0 100644 --- a/admin/db/company_db.inc +++ b/admin/db/company_db.inc @@ -10,7 +10,7 @@ See the License here . ***********************************************************************/ -function update_company_gl_setup($debtors_act, $pyt_discount_act, $creditors_act, +function update_company_gl_setup($retained_act, $profit_loss_act, $debtors_act, $pyt_discount_act, $creditors_act, $freight_act, $exchange_diff_act, $default_sales_act, @@ -33,6 +33,7 @@ function update_company_gl_setup($debtors_act, $pyt_discount_act, $creditors_act $default_delivery_required) { $sql = "UPDATE ".TB_PREF."company SET + retained_earnings_act=".db_escape($retained_act).", profit_loss_year_act=".db_escape($profit_loss_act).", debtors_act=".db_escape($debtors_act).", pyt_discount_act=".db_escape($pyt_discount_act).", creditors_act=".db_escape($creditors_act).", freight_act=".db_escape($freight_act).", diff --git a/admin/fiscalyears.php b/admin/fiscalyears.php index 86ebfbda..e5e9c2f7 100644 --- a/admin/fiscalyears.php +++ b/admin/fiscalyears.php @@ -56,13 +56,45 @@ function check_data() return true; } //--------------------------------------------------------------------------------------------- +function close_year($year) +{ + $myrow = get_fiscalyear($year); + $to = $myrow['end']; + // retrieve total balances from balance sheet accounts + $sql = "SELECT SUM(amount) FROM ".TB_PREF."gl_trans INNER JOIN ".TB_PREF."chart_master ON account=account_code + INNER JOIN ".TB_PREF."chart_types ON account_type=id INNER JOIN ".TB_PREF."chart_class ON class_id=cid + WHERE balance_sheet=1 AND tran_date <= '$to'"; + $result = db_query($sql, "The total balance could not be calculated"); + + $row = db_fetch_row($result); + $balance = round2($row[0], user_price_dec()); + if ($balance != 0.0) + { + $co = get_company_prefs(); + $to = sql2date($to); + + begin_transaction(); + $trans_type = systypes::journal_entry(); + $trans_id = get_next_trans_no($trans_type); + + add_gl_trans($trans_type, $trans_id, $to, $co['retained_earnings_act'], + 0, 0, _("Closing Year"), -$balance); + add_gl_trans($trans_type, $trans_id, $to, $co['profit_loss_year_act'], + 0, 0, _("Closing Year"), $balance); + + commit_transaction(); + } +} + function handle_submit() { global $selected_id, $Mode; if ($selected_id != -1) { + if ($_POST['closed'] == 1) + close_year($selected_id); update_fiscalyear($selected_id, $_POST['closed']); display_notification(_('Selected fiscal year has been updated')); } diff --git a/admin/gl_setup.php b/admin/gl_setup.php index 2fa03f36..6936239e 100644 --- a/admin/gl_setup.php +++ b/admin/gl_setup.php @@ -52,7 +52,8 @@ function can_process() if (isset($_POST['submit']) && can_process()) { - update_company_gl_setup($_POST['debtors_act'], $_POST['pyt_discount_act'], + 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['default_sales_act'], @@ -89,6 +90,8 @@ table_section(1); $myrow = get_company_prefs(); +$_POST['retained_earnings_act'] = $myrow["retained_earnings_act"]; +$_POST['profit_loss_year_act'] = $myrow["profit_loss_year_act"]; $_POST['debtors_act'] = $myrow["debtors_act"]; $_POST['creditors_act'] = $myrow["creditors_act"]; $_POST['freight_act'] = $myrow["freight_act"]; @@ -131,6 +134,10 @@ table_section_title(_("General GL")); text_row(_("Past Due Days Interval:"), 'past_due_days', $_POST['past_due_days'], 6, 6, '', "", _("days")); +gl_all_accounts_list_row(_("Retained Earnings:"), 'retained_earnings_act', $_POST['retained_earnings_act']); + +gl_all_accounts_list_row(_("Profit/Loss Year:"), 'profit_loss_year_act', $_POST['profit_loss_year_act']); + gl_all_accounts_list_row(_("Exchange Variances Account:"), 'exchange_diff_act', $_POST['exchange_diff_act']); //--------------- @@ -162,13 +169,13 @@ text_row(_("Delivery Required By:"), 'default_delivery_required', $_POST['defaul //---------------- +table_section(2); + table_section_title(_("Dimension Defaults")); text_row(_("Dimension Required By After:"), 'default_dim_required', $_POST['default_dim_required'], 6, 6, '', "", _("days")); //--------------- -table_section(2); - table_section_title(_("Suppliers and Purchasing")); percent_row(_("Delivery Over-Receive Allowance:"), 'po_over_receive'); diff --git a/sql/alter2.2.sql b/sql/alter2.2.sql index 1965a8dc..0973d87e 100644 --- a/sql/alter2.2.sql +++ b/sql/alter2.2.sql @@ -6,6 +6,10 @@ ALTER TABLE `0_company` DROP COLUMN `custom2_value`; ALTER TABLE `0_company` DROP COLUMN `custom3_value`; ALTER TABLE `0_company` ADD COLUMN `default_delivery_required` SMALLINT(6) NULL DEFAULT '1'; +ALTER TABLE `0_company` ADD COLUMN `version_id` VARCHAR(11) NOT NULL DEFAULT ''; +ALTER TABLE `0_company` CHANGE `purch_exchange_diff_act` `profit_loss_year_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' 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 b402102e..9757d2ae 100644 --- a/sql/en_US-demo.sql +++ b/sql/en_US-demo.sql @@ -233,6 +233,7 @@ INSERT INTO `0_chart_master` VALUES ('6810', '', 'Legal Expenses', '5', '0'); INSERT INTO `0_chart_master` VALUES ('6600', '', 'Repairs and Maintenance Office', '5', '0'); INSERT INTO `0_chart_master` VALUES ('6730', '', 'phone', '5', '0'); INSERT INTO `0_chart_master` VALUES ('8200', '', 'Bank Interest', '52', '0'); +INSERT INTO `0_chart_master` VALUES ('8900', '', 'Profit and Loss this year', '52', '0'); INSERT INTO `0_chart_master` VALUES ('6840', '', 'Credit Control', '5', '0'); INSERT INTO `0_chart_master` VALUES ('7040', '', 'Depreciation Office Equipment', '51', '0'); INSERT INTO `0_chart_master` VALUES ('3800', '', 'Freight Outwards', '5', '0'); @@ -338,7 +339,7 @@ CREATE TABLE `0_company` ( `creditors_act` varchar(11) NOT NULL default '', `grn_act` varchar(11) NOT NULL default '', `exchange_diff_act` varchar(11) NOT NULL default '', - `purch_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 '', `freight_act` varchar(11) NOT NULL default '', `default_sales_act` varchar(11) NOT NULL default '', @@ -367,6 +368,7 @@ CREATE TABLE `0_company` ( `accumulate_shipping` tinyint(1) NOT NULL default '0', `legal_text` tinytext NOT NULL, `default_delivery_required` smallint(6) NOT NULL default '1', + `version_id` varchar(11) NOT NULL default '', PRIMARY KEY (`coy_code`) ) TYPE=MyISAM ; diff --git a/sql/en_US-new.sql b/sql/en_US-new.sql index 5c166546..a95fd791 100644 --- a/sql/en_US-new.sql +++ b/sql/en_US-new.sql @@ -213,6 +213,7 @@ INSERT INTO `0_chart_master` VALUES ('6810', '', 'Legal Expenses', '5', '0'); INSERT INTO `0_chart_master` VALUES ('6600', '', 'Repairs and Maintenance Office', '5', '0'); INSERT INTO `0_chart_master` VALUES ('6730', '', 'phone', '5', '0'); INSERT INTO `0_chart_master` VALUES ('8200', '', 'Bank Interest', '52', '0'); +INSERT INTO `0_chart_master` VALUES ('8900', '', 'Profit and Loss this year', '52', '0'); INSERT INTO `0_chart_master` VALUES ('6840', '', 'Credit Control', '5', '0'); INSERT INTO `0_chart_master` VALUES ('7040', '', 'Depreciation Office Equipment', '51', '0'); INSERT INTO `0_chart_master` VALUES ('3800', '', 'Freight Outwards', '5', '0'); @@ -309,7 +310,7 @@ CREATE TABLE `0_company` ( `creditors_act` varchar(11) NOT NULL default '', `grn_act` varchar(11) NOT NULL default '', `exchange_diff_act` varchar(11) NOT NULL default '', - `purch_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 '', `freight_act` varchar(11) NOT NULL default '', `default_sales_act` varchar(11) NOT NULL default '', @@ -338,6 +339,7 @@ CREATE TABLE `0_company` ( `accumulate_shipping` tinyint(1) NOT NULL default '0', `legal_text` tinytext NOT NULL, `default_delivery_required` smallint(6) NOT NULL default '1', + `version_id` varchar(11) NOT NULL default '', PRIMARY KEY (`coy_code`) ) TYPE=MyISAM ;