Topic: The deferred income GL posting could not be inserted

I am wondering why I am seeing this error/warning. I have a deferred income account (liability). The setup shows that account in the setup window for deferred income. 
-I placed an order and set the payment to a prepayment "prepay to next fiscal" .
-I then did invoice prepaid orders. The dates on the sales order and the payments are today's date. 
-I did a delivery and set the date to the first day of the next fiscal. The sales item is a membership fee and no product is transferred. 
-When I look at the Trial balances for the defered income account it show that message.
What am I doing wrong?

Re: The deferred income GL posting could not be inserted

Turn debug to 2 in config.php and execute the transaction and post the results.

Re: The deferred income GL posting could not be inserted

This is the only error that showed up (site name changed for security):

Undefined array key 9 in file: /home/admin/web/mysite.com/public_html/reporting/includes/pdf_report.inc at line 758
/home/admin/web/mysite.com/public_html/reporting/rep112.php:197:    (FrontReport Object)->TextCol('1','9','Purchases for your Service Dog is Tax Deductible. Keep this Receipt','-2')
/home/admin/web/mysite.com/public_html/reporting/rep112.php:29:    print_receipts()
/home/admin/web/mysite.com/public_html/reporting/prn_redirect.php:58:    require('/home/admin/web/mysite.com/public_html/reporting/rep112.php')

Re: The deferred income GL posting could not be inserted

Which version of PHP and MySQL are you using? Looks like a PHP 8 issue where arguments for functions with default values are generally pushed to the end.

Re: The deferred income GL posting could not be inserted

I am using php 8. 11.2.4-MariaDB. But does that error even have anything to do with the "The deferred income GL posting could not be inserted" that is shown in the memo of all deferred income payments.

Re: The deferred income GL posting could not be inserted

Try to do the same transaction in a fresh install of FA in PHP 5.x and MySQL 5.1 and you will note that NULL implementation and argument order may expose causes.

Lines 756-759 in reporting/includes/pdf_report.inc are:

    function TextCol($c, $n, $txt, $corr=0, $r=0, $border=0, $fill=0, $link=NULL, $stretch=1)
    {
        return $this->TextWrap($this->cols[$c], $this->row - $r, $this->cols[$n] - $this->cols[$c] + $corr, $txt, $this->aligns[$c], $border, $fill, $link, $stretch);
    }

The above function has not changed in 15 years.
However in 2 places in the said file certain PHP 8.1 issues caused a change 2 years ago for the likes of:

$str = ($str != NULL ? strtr($str, array("\r"=>'')) : "");

which may have to be revisited.

The function / method TextWrap is also defined in the same file (changed for PHP 8.1, 2 years ago) whilst the function / method addTextWrap called therefrom is defined in the file reporting/includes/class.pdf.inc.

Check if there are any PHP version related changes between PHP 5 and 8.1 that cause this situation.

@joe: any clues?

Re: The deferred income GL posting could not be inserted

Hard to tell. It has to be investigated. The $go_debug variabel should give us some clues. Please continue.

Joe

8 (edited by baxterdmutt 08/16/2024 05:07:42 pm)

Re: The deferred income GL posting could not be inserted

This doesn't make any sense to me.  There are no errors unless I do a report and I rarely need to do one. I don't even know what "The deferred income GL posting could not be inserted" means in the memo area of the deferred income account.  Does nobody know why that message would be inserted into the memo area of all prepayments.
I guess I'm also having trouble understanding how the prepayment and deferred income works.  When I look at the trial balances after the prepayments, I see the items in the deferred income, and also in the sales revenue account that the sales related to. But how does the deferred income know what year it is deferred to. I would have thought that it was the delivery date. And if so, why is it still sitting in the deferred income account. Do I need to move it around manually???

EDIT: OOPS!, so I do see that the prepayment did set the Delivery date correct (I marked it as delivered on the first day of the next fiscal). And the income account does show the items going into the revenue account on the date I set (first day of the next fiscal). So that all seems to be working (I think). I'm just not understanding why I would see that message in the memo field.  Could it be designed to do that and it is working properly??? I'm not a developer and so I can't really debug this on my own.

Re: The deferred income GL posting could not be inserted

joe wrote:

Hard to tell. It has to be investigated. The $go_debug variabel should give us some clues. Please continue.

Joe

That variable was set and that's how I got the error that I posted just before your message.

Re: The deferred income GL posting could not be inserted

The code seems to be"
if ($delivery->is_prepaid())
        {
                $deferred_act = get_company_pref('deferred_income_act');
                add_gl_trans(ST_CUSTDELIVERY, $delivery_no, $delivery->document_date, $deferred_act, 0, 0,
                        "The deferred income GL posting could not be inserted",
                        -$total, null, PT_CUSTOMER, $delivery->customer_id);
        }

and to me that looks like this is just what gets entered into all prepaid items. So it's part of normal behaviour.
I would still like to know why it's worded like that. When one reads that it feels like it's an error.