Recurring invoices

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1310
    jorge
    Participant

    First of all, thank you for your efforts to keep this software alive. It’s a great job.

    I have recently updated to 2019 version (because I can’t install php 7,4 in my server) from a very old version and finally I’ve made nearly everything work (I had problems with Spanish accents in names in the manage tables script, btw).

    Then, my question now is that I want to establish a recurring invoice but when cron runs is gives me an error:

    <array> <cron_message>Cron started</cron_message> <cron_message_2>Cron ID: 2 - Cron for Factura 20098 with start date of 2021-01-10 and no end date that runs each 1 day, was run today :: Info diff=1</cron_message_2> <email_message>One or more required fields is missing</email_message> </array>

    It seems as it was looking somewhere for the e-mail body content. Is it? In that case, Where can I set the e-mail body for a recurring invoice? Also, do the recurring invoices generate a new “normal” invoice with it’s new invoice number and dates?

    I have tested the email with pdf attach delivery and it works. What it doesn’t is the recurring one.ç

    #1311
    RRowley
    Participant

    The email body is automatically set by the code. I don’t think that is the problem. However, I don’t know which field is empty. I’ve made a modified version of the Email.php file that will put info in the tmp/log/php.log (aka error log) file indicating which email field is empty.

    Extract the Email.php file from the zip file and save it in your Inc/Claz folder over the version that is there. If you run cron, you can see what it puts in the error log and let me know.

    Attachments:
    #1313
    jorge
    Participant

    Hmmm, it looks like there is something more.
    I have tried to create a new invoice to do the recurring, as I realized that I had done the testing with an imported one, but it doesn’t work.
    So I’m going to see what else is going on and I’ll keep you updated. Thanks.

    #1314
    jorge
    Participant

    This is what the logs are saying:

    
    [12-Jan-2021 20:09:13 Europe/Madrid] PHP Notice:  Undefined index: tax_id in /var/www/vhosts/mydomain.es/httpdocs/fact2/Inc/Claz/Invoice.php on line 1344
    [12-Jan-2021 20:09:13 Europe/Madrid] PHP Warning:  explode() expects parameter 2 to be string, array given in /var/www/vhosts/mydomain.es/httpdocs/fact2/Inc/Claz/Email.php on line 424
    [12-Jan-2021 20:09:13 Europe/Madrid] PHP Warning:  array_filter() expects parameter 1 to be array, null given in /var/www/vhosts/mydomain.es/httpdocs/fact2/Inc/Claz/Email.php on line 424
    [12-Jan-2021 20:09:13 Europe/Madrid] PHP Notice:  Array to string conversion in /var/www/vhosts/mydomain.es/httpdocs/fact2/Inc/Claz/Email.php on line 435
    [12-Jan-2021 20:09:13 Europe/Madrid] Email::setTo() - Invalid TO address[Array]
    [12-Jan-2021 20:09:13 Europe/Madrid] to is empty
    [12-Jan-2021 20:09:13 Europe/Madrid] Email::send() - One or more required fields is missing

    the “To” field should not be empty, as there is an e-mail in the e-mail field of the client. My mail has a “.es” domain (Not sure if could be related).

    #1315
    RRowley
    Participant

    The “to” field is set to the customer and/or the biller email depending on the option to send to either one or both in the recurrence record.

    The error for the tax_id field is a bug in the code. I’ve attached new Email.zip file that contains updated Email.php and Invoice.php files. The first removes the debug statements I added in the previous change, but the Invoice.php contains a fix for the tax_id issue. Extract both of these to the Inc/Claz directory.

    At this point, I’m not able to test that changes, so I ask that you do and let me know the result so I can hopefully at them to the next version of 2019.2

    • This reply was modified 3 years, 11 months ago by RRowley.
    Attachments:
    #1322
    jorge
    Participant

    Hello, I managed to make it work:

    In Inc/Claz/Email.php

    function setTo($to)

    is assuming that $to is a string, but it has already been converted to array in previous function at Cron.php (getEmailSendAddresses).

    To make it work I added $to = implode(“;”, $to); to the begining of setTo function:

     public function setTo($to)
        {
             $to = implode(";", $to);
    
    #1323
    jorge
    Participant

    I’ve made another fix, as this led to break the “normal” invoice e-mail functionality. So now I check that the $to variable is an array before converting it:

     public function setTo($to)
        {
            if (is_array ($to)){
             $to = implode(";", $to);
            }
    ...
    
    #1333
    RRowley
    Participant

    Sorry it took so long. I had to complete work I was doing on master_2020 to get back to master_2019.2. Anyway, I’ve attached a zip file with three files that go in your Inc/Claz directory. I took a different approach than you did but I believe it implements the changes needed. If you could test this and let me know how it works.

    Attachments:
Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.