1 (edited by MacKenzie 02/01/2023 12:00:35 am)

Topic: The entered date is out of fiscal year (oh, no sir, it's not!)

******************************************************************************************************************************************************
Longer Subject:  The entered date is out of fiscal year (oh, no sir, it's not!) so you're Journal Entry ain't gonna happen (wanna bet?)
******************************************************************************************************************************************************
supportingDocs: https://imgflip.com/i/79hs43 (Images probably too small to be useful to anyone).

I hit another anomaly and  It's a bit of an issue.  An accountant needs to be unfettered when setting up a new company.  That person might be working on 2021 in 2023 - trying to enter a T/B to carry forward, etc.  Lots of reasons.  I can't apparently provide attachments to this post, but I have a 2021 fiscal year selected, and set up in the Company as active.  Under fiscal years it is also set up, and it should be good to go.  Now mind you, I'm doing this work in 2023, but FOR 2021.  This is real world stuff.  So I wanted to establish in 2021 accounts the "activity" - - profit and loss, with an entry to would encapsulate all activity for 2021.  Then the plan was to close this out, and roll into 2022 and basically do the same thing.  Even though 2021 was the ONLY active year set up, FA would not let me make the entry.    The offending code is found in gl_journal.php as follows:

// Would not let me post a journal entry in 2021, even though it was all set up for that.
        elseif (!is_date_in_fiscalyear($_POST['date_']))
        {
              display_error(_("The entered date is out of fiscal year or is closed for further data entry."));
              set_focus('date_');
              $input_error = 1;
        }
This, as I'm sure you know, calls the date_functions.inc and keys off of this code:

function is_date_in_fiscalyear($date, $convert=false)
{
        global $path_to_root;
        include_once($path_to_root . "/admin/db/fiscalyears_db.inc");

        if ($convert)
                $date2 = sql2date($date);
        else
                $date2 = $date;

        if (is_date_closed($date2))
                return 0;

        if (user_check_access('SA_MULTIFISCALYEARS')) // allow all open years for this one
                return is_date_in_fiscalyears($date2, false);

        $myrow = get_current_fiscalyear();
        $begin = sql2date($myrow['begin']);
        $end = sql2date($myrow['end']);
        if (date1_greater_date2($begin, $date2) || date1_greater_date2($date2, $end))
        {
                return 0;
        }
        return 1;
}

Not being able to post a 2021 entry to basically mimic the activity, albeit in summary, would render FA useless to me.  To get around this I simply commented out the function (last one I presented above) and ran the journal entry, and of course it worked fine once the digital hand-cuffs were removed.

My question is WHY DID THIS HAPPEN?  Trust me when I tell you everything in FA pointed to 2021 as the active year.  I have screen shots to back this up, but again I can't share them here.

Anyway, I just copy the original file (e.g., gl_journal.php -> gl_journal_original.php) and then make modifications to the gl_journal.php file.  Like I said, to comment out the handcuffs.  Once completed I just copy the original php code back into the directory.  This is a PITA so I'm hoping there is a reason for this.  If not, then it's definitely a bug.

Thanks.
Mac

Re: The entered date is out of fiscal year (oh, no sir, it's not!)

setup->Company Setup->choose 2021 fiscal year. Bottom of screen press Update.
Now you will be able to enter data in that year.

Re: The entered date is out of fiscal year (oh, no sir, it's not!)

@MacKensie

Did you forget to set the current fiscal year as @rafat advised?

I cannot reproduce this error with the correct fiscal year set on the company.

Joe

4 (edited by MacKenzie 02/01/2023 08:27:30 pm)

Re: The entered date is out of fiscal year (oh, no sir, it's not!)

No sir.  Trust me when I tell you everything in FA pointed to 2021 as the active year.  Not my first rodeo.  Weird, I know.  I have screen shots to back this up, but again I can't share them here.

I did a work around for this and this issue is now in my rear view mirror.  Not exactly sure why it happened, but since it DID happen (perhaps an anomaly) I needed a quick fix.

Anybody can do this, but I would NOT recommend it unless you know what you're doing.

Before you do anything LOG OUT of FA and then copy the gl_journal.php to to a safe place in another directory!

1.  Create a status.txt file in the gl directory.

2. Edit the status.txt file so it reads "Super Super Admin is turned off". (no quotes in the file).

3. copy file gl_journal.php to reg_gl_journal.php

4. copy file gl_journal.php to ssa_gl_journal.php

5. edit ssa_gl_journal.php and comment out (not delete) 6 lines:

        //elseif (!is_date_in_fiscalyear($_POST['date_'])) 
        //{
        //      display_error(_("The entered date is out of fiscal year or is closed for further data entry."));
        //      set_focus('date_');
        //      $input_error = 1;
        //}

5. Save the edited file as ssa_gl_journal.php (ssa = super super admin)

6.  Create a bash script named "ssa_cpa.sh" (or whatever you want)  as follows:

#!/bin/bash
read -p "Do you wish to be in Super Admin Mode? " USER_INPUT

if [[ $USER_INPUT = "yes" ]]; then
        cp ssa_gl_journal.php gl_journal.php
        sed -i 's/off/on/' status.txt
        echo "status.txt file will reflect super admin status."

elif [[ $USER_INPUT = "no" ]]; then
        cp reg_gl_journal.php gl_journal.php
        sed -i 's/on/off/' status.txt
        echo "status.txt file will reflect regular admin status."
else
        echo "Make up your mind please."

fi


7.  Save the bash script.

8.  Change rights to your bash file as:

9.  sudo chmod +x ssa_cpa.sh

10.  Just use FA as needed with your regular rights.  If you MUST have access to multi-year and can not do this through the UI, and it's an emergency then invoke the bash script.  In linux this is done as follows:

10: sudo bash ssa_cpa.sh

11. Answer the question as "yes" or "no" (no quotes, lower case response).  Anything else just ends it.   If you answer "yes" then status will be : "Super Admin is turned On."  Opposite if you answer "no".

12.  LOG BACK INTO FA

13.  When you are finished with your multi-year general journal entry, LOG OUT OF FA and immediately run the bash script again, and this time answer "no" to the question.  This will put everything back as it was, and you can then LOG BACK INTO FA.


If you ever forget what admin status you are in [keyboard] type:  cat status.txt and it will report on your terminal.  Note, all of the above requires you to be in command line in the /frontaccount/gl directory.

***DO NOT TRY THIS UNLESS YOU KNOW WHAT YOU'RE DOING.  IT'S A VERY SIMPLE WORK AROUND, BUT IT'S EASY TO FAT FINGER THIS FIX. DON'T DO IT UNLESS YOU ARE COMFORTABLE.***

***NO WARRANTIES WHATSOEVER - - USE AT YOUR OWN RISK***

:-)

Re: The entered date is out of fiscal year (oh, no sir, it's not!)

@MacKensie

Please avoid all these technical descriptions when reporting. It will make most users confused.

1. Set the $go_debug variable in file config.php to 2. It will then report if there are php errors in the code.

2. If you want to make entries in all non closed fiscal years, then check that you are 'Super administrator' and set the 'Allow entry on non closed fiscal years' in 'Banking & GL configuration', 'Access Setup', 'Setup' tab.

3. Use the 'Help' menu if you need information and tips on your current operations. The Help is Context Sensitive.

As I told before, we can't reproduce your reported error and during the years with these operations noone has reported any errors.

Joe

6 (edited by MacKenzie 02/02/2023 07:43:37 pm)

Re: The entered date is out of fiscal year (oh, no sir, it's not!)

MacKenzie, not Mackensie.  I appreciate it.

Re: The entered date is out of fiscal year (oh, no sir, it's not!)

Of course your name is @MacKenzie. Sorry. Thanks for your contributions.

Joe

Re: The entered date is out of fiscal year (oh, no sir, it's not!)

No problem. I like FA and will continue to be involved.

Re: The entered date is out of fiscal year (oh, no sir, it's not!)

@MacKenzie
Did you investigate this with debug on?