X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=gl%2Faccruals.php;h=3fc2b4270236f5e0c791cd9ff53f53fbc08f8537;hb=da7df35c61205d0b1af47d286be591b8a3194b0c;hp=445e86574aeb43eb908c7c08806f25ba0ea1d2fd;hpb=fe874c11f86ae11cccfb7f4dbc5ad26fff9f618a;p=fa-stable.git diff --git a/gl/accruals.php b/gl/accruals.php index 445e8657..3fc2b427 100644 --- a/gl/accruals.php +++ b/gl/accruals.php @@ -1,4 +1,14 @@ . +***********************************************************************/ /********************************************** Author: Joe Hunt Name: Revenue / Cost Accruals v2.2 @@ -8,16 +18,16 @@ $page_security = 'SA_ACCRUALS'; $path_to_root=".."; include_once($path_to_root . "/includes/session.inc"); -include_once($path_to_root . "/gl/includes/db/gl_db_trans.inc"); +include_once($path_to_root . "/includes/ui/items_cart.inc"); $js = get_js_open_window(800, 500); -if ($use_date_picker) +if (user_use_date_picker()) $js .= get_js_date_picker(); // Begin the UI include_once($path_to_root . "/includes/ui.inc"); -$_SESSION['page_title'] = _($help_context = _("Revenue / Cost Accruals")); +$_SESSION['page_title'] = _($help_context = "Revenue / Cost Accruals"); page($_SESSION['page_title'], false, false,'', $js); //-------------------------------------------------------------------------------------------------- @@ -35,7 +45,7 @@ if (isset($_POST['go']) || isset($_POST['show'])) } elseif (!is_date_in_fiscalyear($_POST['date_'])) { - display_error(_("The entered date is not in fiscal year.")); + display_error(_("The entered date is out of fiscal year or is closed for further data entry.")); set_focus('date_'); $input_error = 1; } @@ -55,13 +65,20 @@ if (isset($_POST['go']) || isset($_POST['show'])) { $periods = input_num('periods'); $per = $periods - 1; - $date_ = get_post('date_'); + $date = $date_ = get_post('date_'); $freq = get_post('freq'); - $lastdate = ($freq== 1?add_days($date_,7*$per):($freq==2?add_days($date_,14*$per): - ($freq==3?add_months($date_,$per):add_months($date_,3*$per)))); + if ($freq == 3 || $freq == 4) { + $date_ = begin_month($date_); // avoid skip on shorter months + $date = end_month($date_); // avoid skip on shorter months + } + + $lastdate = ($freq == 1 ? add_days($date_, 7*$per) : + ($freq == 2 ? add_days($date_, 14*$per) : + ($freq == 3 ? end_month(add_months($date_, $per)) : + end_month(add_months($date_, 3*$per))))); if (!is_date_in_fiscalyears($lastdate, false)) { - display_error(_("Some of the period dates are outside the fiscal year. Create a new fiscal year first!")); + display_error(_("Some of the period dates are outside the fiscal year or are closed for further data entry. Create a new fiscal year first!")); set_focus('date_'); $input_error = 1; } @@ -76,7 +93,7 @@ if (isset($_POST['go']) || isset($_POST['show'])) if (get_post('memo_') != "") $memo = $_POST['memo_']; else - $memo = "Accruals for $amount"; + $memo = sprintf(_("Accruals for %s"), $amount); if (isset($_POST['go'])) begin_transaction(); else @@ -105,35 +122,38 @@ if (isset($_POST['go']) || isset($_POST['show'])) switch($freq) { case 1: - $date_ = add_days($date_, 7); + $date = $date_ = add_days($date_, 7); break; case 2: - $date_ = add_days($date_, 14); + $date = $date_ = add_days($date_, 14); break; case 3: $date_ = add_months($date_, 1); + $date = end_month($date_); break; case 4: $date_ = add_months($date_, 3); + $date = end_month($date_); 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); + $cart = new items_cart(ST_JOURNAL); + $cart->memo_ = $memo; + $cart->reference = $Refs->get_next(ST_JOURNAL, null, $date); + $cart->tran_date = $cart->doc_date = $cart->event_date = $date; + $cart->add_gl_item(get_post('acc_act'), 0, 0, -$am0, $cart->reference); + $cart->add_gl_item(get_post('res_act'), get_post('dimension_id'), + get_post('dimension2_id'), $am0, $cart->reference); + write_journal_entries($cart); + $cart->clear_items(); } else { alt_table_row_color($k); - label_cell($date_); + label_cell($date); label_cell($_POST['acc_act'] . " " . get_gl_account_name($_POST['acc_act'])); if ($dim > 0) label_cell(""); @@ -142,7 +162,7 @@ if (isset($_POST['go']) || isset($_POST['show'])) display_debit_or_credit_cells($am0 * -1); label_cell($memo); alt_table_row_color($k); - label_cell($date_); + 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)); @@ -170,7 +190,7 @@ if (isset($_POST['go']) || isset($_POST['show'])) function frequency_list_row($label, $name, $selected=null) { echo "\n"; - label_cell($label); + label_cell($label, "class='label'"); echo "\n"; $freq = array( '1'=> _("Weekly"), @@ -190,7 +210,8 @@ start_table(TABLESTYLE2); date_row(_("Date"), 'date_', _('First date of Accruals'), true, 0, 0, 0, null, true); start_row(); -gl_all_accounts_list_cells(_("Accrued Balance Account"), 'acc_act', null, true, false, false, true); +label_cell(_("Accrued Balance Account"), "class='label'"); +gl_all_accounts_list_cells(null, 'acc_act', null, true, false, false, true); end_row(); gl_all_accounts_list_row(_("Revenue / Cost Account"), 'res_act', null, true); @@ -215,5 +236,3 @@ submit_js_confirm('go', _("Are you sure you want to post accruals?")); end_form(); end_page(); - -?>