X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=admin%2Ffiscalyears.php;h=8874ea7de99dd0a848a5151dd243cdadc111ad89;hb=89e8ca2be9235215ac2e2bf5e58d7eedd2dda84d;hp=b2d2913b9102c8abf3eda152fc1c15ebba3bea3c;hpb=0c07d137e821125e2bbd3034c01ce4cbc376d00b;p=fa-stable.git diff --git a/admin/fiscalyears.php b/admin/fiscalyears.php index b2d2913b..8874ea7d 100644 --- a/admin/fiscalyears.php +++ b/admin/fiscalyears.php @@ -20,7 +20,7 @@ include_once($path_to_root . "/includes/ui.inc"); include_once($path_to_root . "/sales/includes/db/cust_trans_db.inc"); include_once($path_to_root . "/admin/db/maintenance_db.inc"); $js = ""; -if ($use_date_picker) +if (user_use_date_picker()) $js .= get_js_date_picker(); page(_($help_context = "Fiscal Years"), false, false, "", $js); @@ -29,7 +29,7 @@ simple_page_mode(true); function check_data() { - if (!is_date($_POST['from_date']) || is_date_in_fiscalyears($_POST['from_date']) || is_bad_begin_date($_POST['from_date'])) + if (!is_date($_POST['from_date']) || is_date_in_fiscalyears($_POST['from_date'])) { display_error( _("Invalid BEGIN date in fiscal year.")); set_focus('from_date'); @@ -41,6 +41,12 @@ function check_data() set_focus('to_date'); return false; } + if (!check_begin_end_date($_POST['from_date'], $_POST['to_date'])) + { + display_error( _("Invalid BEGIN or END date in fiscal year.")); + set_focus('from_date'); + return false; + } if (date1_greater_date2($_POST['from_date'], $_POST['to_date'])) { display_error( _("BEGIN date bigger than END date.")); @@ -65,6 +71,18 @@ function handle_submit() set_focus('closed'); return false; } + $co = get_company_prefs(); + if (get_gl_account($co['retained_earnings_act']) == false || get_gl_account($co['profit_loss_year_act']) == false) + { + display_error(_("The Retained Earnings Account or the Profit and Loss Year Account has not been set in System and General GL Setup")); + return false; + } + if (!is_account_balancesheet($co['retained_earnings_act']) || is_account_balancesheet($co['profit_loss_year_act'])) + { + display_error(_("The Retained Earnings Account should be a Balance Account or the Profit and Loss Year Account should be an Expense Account (preferred the last one in the Expense Class)")); + return false; + } + $ok = close_year($selected_id); } else @@ -93,7 +111,7 @@ function check_can_delete($selected_id) // PREVENT DELETES IF DEPENDENT RECORDS IN gl_trans if (check_years_before(sql2date($myrow['begin']), true)) { - display_error(_("Cannot delete this fiscal year because thera are fiscal years before.")); + display_error(_("Cannot delete this fiscal year because there are fiscal years before.")); return false; } if ($myrow['closed'] == 0) @@ -196,6 +214,12 @@ function display_fiscalyear_edit($selected_id) } else { + $begin = next_begin_date(); + if ($begin && $Mode != 'ADD_ITEM') + { + $_POST['from_date'] = $begin; + $_POST['to_date'] = end_month(add_months($begin, 11)); + } date_row(_("Fiscal Year Begin:"), 'from_date', '', null, 0, 0, 1001); date_row(_("Fiscal Year End:"), 'to_date', '', null, 0, 0, 1001); } @@ -241,4 +265,3 @@ display_fiscalyear_edit($selected_id); end_page(); -?>