From: Joe Hunt Date: Mon, 19 Jul 2010 00:16:46 +0000 (+0000) Subject: Added Revenue / Cost Accruals to be included in core FA X-Git-Tag: v2.4.2~19^2~788 X-Git-Url: https://delta.frontaccounting.com/gitweb/?p=fa-stable.git;a=commitdiff_plain;h=749eba79a95008edf017d7d6381779fd46d91308 Added Revenue / Cost Accruals to be included in core FA --- diff --git a/CHANGELOG.txt b/CHANGELOG.txt index f22531ce..74cba867 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -19,6 +19,13 @@ Legend: ! -> Note $ -> Affected files +19-Jul-2010 Joe Hunt ++ Added Revenue / Cost Accruals to be included in core FA +$ /applications/generalledger.php + /gl/accruals.php (new file) + /gl/view/accrual_trans.php (new file) + /includes/access_levels.inc + 18-Jul-2010 Janusz Dobrowolski ! Improved key_in_foreign_table to check multiply tables $ /admin/db/company_db.inc diff --git a/applications/generalledger.php b/applications/generalledger.php index ce22dec3..1bbea0d4 100644 --- a/applications/generalledger.php +++ b/applications/generalledger.php @@ -1,17 +1,17 @@ . ***********************************************************************/ -class general_ledger_app extends application +class general_ledger_app extends application { - function general_ledger_app() + function general_ledger_app() { $this->application("GL", _($this->help_context = "&Banking and General Ledger")); @@ -28,7 +28,9 @@ class general_ledger_app extends application "gl/gl_budget.php?", 'SA_BUDGETENTRY'); $this->add_rapp_function(0, _("&Reconcile Bank Account"), "gl/bank_account_reconcile.php?", 'SA_RECONCILE'); - + $this->add_rapp_function(0, _("Revenue / &Costs Accruals"), + "gl/accruals.php?", 'SA_ACCRUALS'); + $this->add_module(_("Inquiries and Reports")); $this->add_lapp_function(1, _("&Journal Inquiry"), "gl/inquiry/journal_inquiry.php?", 'SA_GLANALYTIC'); @@ -44,7 +46,7 @@ class general_ledger_app extends application $this->add_rapp_function(1, _("Balance &Sheet Drilldown"), "gl/inquiry/balance_sheet.php?", 'SA_GLANALYTIC'); $this->add_rapp_function(1, _("&Profit and Loss Drilldown"), - "gl/inquiry/profit_loss.php?", 'SA_GLANALYTIC'); + "gl/inquiry/profit_loss.php?", 'SA_GLANALYTIC'); $this->add_rapp_function(1, _("Banking &Reports"), "reporting/reports_main.php?Class=5", 'SA_BANKREP'); $this->add_rapp_function(1, _("General Ledger &Reports"), diff --git a/gl/accruals.php b/gl/accruals.php new file mode 100644 index 00000000..8636dde9 --- /dev/null +++ b/gl/accruals.php @@ -0,0 +1,218 @@ + 0) + { + switch($freq) + { + case 1: + $date_ = add_days($date_, 7); + break; + case 2: + $date_ = add_days($date_, 14); + break; + case 3: + $date_ = add_months($date_, 1); + break; + case 4: + $date_ = add_months($date_, 3); + break; + } + $am0 = $am; + } + if (isset($_POST['go'])) + { + $id = get_next_trans_no(ST_JOURNAL); + $ref = $Refs->get_next(ST_JOURNAL); + add_gl_trans(ST_JOURNAL, $id, $date_, get_post('acc_act'), 0, + 0, $ref, $am0 * -1); + add_gl_trans(ST_JOURNAL, $id, $date_, get_post('res_act'), get_post('dimension_id'), + get_post('dimension2_id'), $ref, $am0); + add_comments(ST_JOURNAL, $id, $date_, $memo); + $Refs->save(ST_JOURNAL, $id, $ref); + } + else + { + alt_table_row_color($k); + label_cell($date_); + label_cell($_POST['acc_act'] . " " . get_gl_account_name($_POST['acc_act'])); + if ($dim > 0) + label_cell(""); + if ($dim > 1) + label_cell(""); + display_debit_or_credit_cells($am0 * -1); + label_cell($memo); + alt_table_row_color($k); + label_cell($date_); + label_cell($_POST['res_act'] . " " . get_gl_account_name($_POST['res_act'])); + if ($dim > 0) + label_cell(get_dimension_string($_POST['dimension_id'], true)); + if ($dim > 1) + label_cell(get_dimension_string($_POST['dimension2_id'], true)); + display_debit_or_credit_cells($am0); + label_cell($memo); + } + } + if (isset($_POST['go'])) + { + commit_transaction(); + display_notification_centered(_("Revenue / Cost Accruals have been processed.")); + $_POST['date_'] = $_POST['amount'] = $_POST['periods'] = ""; + } + else + { + end_table(1); + display_notification_centered(_("Showing GL Transactions.")); + } + } + } +} + +function frequency_list_row($label, $name, $selected=null) +{ + echo "\n"; + label_cell($label); + echo "\n"; + $freq = array( + '1'=> _("Weekly"), + '2'=> _("Bi-weekly"), + '3' => _("Monthly"), + '4' => _("Quarterly"), + ); + echo array_selector($name, $selected, $freq); + echo "\n"; + echo "= 1) + dimensions_list_row(_("Dimension"), 'dimension_id', null, true, " ", false, 1); +if ($dim > 1) + dimensions_list_row(_("Dimension")." 2", 'dimension2_id', null, true, " ", false, 2); + +$url = "gl/view/accrual_trans.php?act=".get_post('acc_act')."&date=".get_post('date_'); +amount_row(_("Amount"), 'amount', null, null, viewer_link(_("Search Amount"), $url, "", "", ICON_VIEW)); + +frequency_list_row(_("Frequency"), 'freq', null); + +text_row(_("Periods"), 'periods', null, 3, 3); +textarea_row(_("Memo"), 'memo_', null, 35, 3); + +end_table(1); +submit_center_first('show', _("Show GL Rows"));//,true,false,'process',ICON_SUBMIT); +submit_center_last('go', _("Process Accruals"));//,true,false,'process',ICON_SUBMIT); +submit_js_confirm('go', _("Are you sure you want to post accruals?")); + +end_form(); + +end_page(); + +?> diff --git a/gl/view/accrual_trans.php b/gl/view/accrual_trans.php new file mode 100644 index 00000000..6d1d360d --- /dev/null +++ b/gl/view/accrual_trans.php @@ -0,0 +1,108 @@ +. +***********************************************************************/ +$page_security = 'SA_ACCRUALS'; +$path_to_root = "../.."; +include_once($path_to_root . "/includes/session.inc"); + +$_SESSION['page_title'] = _($help_context = _("Search General Ledger Transactions for account: ").$_GET['act']); + +page($_SESSION['page_title'], true); + +include_once($path_to_root . "/includes/date_functions.inc"); +include_once($path_to_root . "/includes/ui.inc"); + +include_once($path_to_root . "/gl/includes/gl_db.inc"); + +$js ="\n\n"; +echo $js; + +if (!isset($_GET['act']) || !isset($_GET['date'])) +{ /*Script was not passed the correct parameters */ + + echo "

" . _("The script must be called with a valid transaction type and transaction number to review the general ledger postings for.") . "

"; + exit; +} + +display_heading($_SESSION['page_title']. " ".get_gl_account_name($_GET['act'])); + +br(); + +start_table(TABLESTYLE); +$dim = get_company_pref('use_dimension'); + +$first_cols = array(_("Type"), "#", _("Date")); +if ($dim == 2) + $dim_cols = array(_("Dimension")." 1", _("Dimension")." 2"); +else if ($dim == 1) + $dim_cols = array(_("Dimension")); +else + $dim_cols = array(); + +$remaining_cols = array(_("Person/Item"), _("Debit"), _("Credit"), _("Memo")); + +$th = array_merge($first_cols, $dim_cols, $remaining_cols); + +table_header($th); +$end = $_GET['date']; +$account = $_GET['act']; +$begin = add_days($end, -30); + +$result = get_gl_transactions($begin, $end, -1, $account, 0, 0, null); +$j = 0; +$k = 1; +while ($myrow = db_fetch($result)) +{ + alt_table_row_color($k); + + $trandate = sql2date($myrow["tran_date"]); + + label_cell($systypes_array[$myrow["type"]]); + $amount = price_format($myrow["amount"]); + $str = "".$myrow['type_no'].""; + label_cell($str); + label_cell($trandate); + + if ($dim >= 1) + label_cell(get_dimension_string($myrow['dimension_id'], true)); + if ($dim > 1) + label_cell(get_dimension_string($myrow['dimension2_id'], true)); + label_cell(payment_person_name($myrow["person_type_id"],$myrow["person_id"])); + display_debit_or_credit_cells($myrow["amount"]); + label_cell($myrow['memo_']); + end_row(); + + $j++; + if ($j == 12) + { + $j = 1; + table_header($th); + } +} +//end of while loop + + +//end of while loop +end_table(1); + +end_page(true); + +?> diff --git a/includes/access_levels.inc b/includes/access_levels.inc index bb84a10a..ee728860 100644 --- a/includes/access_levels.inc +++ b/includes/access_levels.inc @@ -240,6 +240,7 @@ $security_areas =array( 'SA_BANKJOURNAL' => array(SS_GL|11, _("Journal entries to bank related accounts")), 'SA_BUDGETENTRY' => array(SS_GL|9, _("Budget edition")), 'SA_STANDARDCOST' => array(SS_GL|10, _("Item standard costs")), + 'SA_ACCRUALS' => array(SS_GL|12, _("Revenue / Cost Accruals")), 'SA_GLANALYTIC' => array(SS_GL_A|1, _("GL analytical reports and inquiries")), 'SA_TAXREP' => array(SS_GL_A|2, _("Tax reports and inquiries")),