Master2023 PDO Error when saving new invoice

SimpleInvoices Group Forum Forums Fearless359 SimpleInvoices Discussion Group Master2023 PDO Error when saving new invoice

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #2107
    ppmt
    Participant

    Hello,
    I have been using SI for a long time now but have been stuck on a old version since I was happy with it.

    I decided to install the last Maste2023 from scratch to avoid update issue. All seems good except when I try to create an invoice. When I press save I get this error:

    Fatal error: Uncaught PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'invoice-1-0-1' for key 'PRIMARY' in /var/www/html/simpleinvoices-master_2023/Inc/Claz/PdoDb.php:1291 Stack trace: #0 /var/www/html/simpleinvoices-master_2023/Inc/Claz/PdoDb.php(1291): PDOStatement->execute() #1 /var/www/html/simpleinvoices-master_2023/Inc/Claz/PdoDb.php(1246): Inc\Claz\PdoDb->query() #2 /var/www/html/simpleinvoices-master_2023/Inc/Claz/Index.php(39): Inc\Claz\PdoDb->request() #3 /var/www/html/simpleinvoices-master_2023/Inc/Claz/Invoice.php(665): Inc\Claz\Index::increment() #4 /var/www/html/simpleinvoices-master_2023/modules/invoices/save.php(55): Inc\Claz\Invoice::insert() #5 /var/www/html/simpleinvoices-master_2023/index.php(441): include('...') #6 {main} thrown in /var/www/html/simpleinvoices-master_2023/Inc/Claz/PdoDb.php on line 1291

    The invoice is created but it has none of the product added to the invoice and if I edit there are no row for the product and I can’t add a row. It says there are no row to clone.

    Checking phpmyadmin I see that the si_invoices is populated but the si_invoice_items is empty

    #2108
    ppmt
    Participant

    I tried as well by installing the sample data and the issue is the same.

    Question: Am I meant to be using that version?

    #2113
    RRowley
    Participant

    When you say you tried this loading sample data, does this mean you started with an empty database, letting SI load default configuration data and then letting SI install sample data? If this is the case, the issue if perplexing indeed.

    What version of SI are you trying to upgrade from? What version of PHP are you on?

    If error persists, zip the tmp/log/php.log file and attach it to your response.

    • This reply was modified 1 month ago by RRowley.
    #2118
    ppmt
    Participant

    Thank you for the reply.

    I am using PHP version 8.1.31 . The database is MariaDB version 10
    It is installed on a Debian 12 with Apache2 as the server.

    I am installing a version from scratch so no upgrade. I tried to update in the past and I never got it to work.

    So here is what I did.
    1/ I created a new database and updated the custom.config.ini with the correct credentials
    2/ I opened the website and it ask me to confirm to install the database.
    3/ Then it asked me to install the essential data
    4/ I declined to install the sample data and instead created a biller, a customer and a few products.

    All seemed good so I created an invoice. When I pressed saved I got the message above.

    I also tried to do it again after emptying the database and this time installing the sample data. It gave me the same error while it was doing that.

    The php.log attached is from a fresh install.

    After installing the sample data I got this error:

    
    Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 2014 Cannot execute queries while there are pending result sets. Consider unsetting the previous PDOStatement or calling PDOStatement::closeCursor() in /var/www/html/simpleinvoices-master_2023/Inc/Claz/PdoDb.php:713 Stack trace: #0 /var/www/html/simpleinvoices-master_2023/Inc/Claz/PdoDb.php(713): PDOStatement->execute() #1 /var/www/html/simpleinvoices-master_2023/Inc/Claz/PdoDb.php(1310): Inc\Claz\PdoDb->lastInsertId() #2 /var/www/html/simpleinvoices-master_2023/modules/install/sample_data.php(20): Inc\Claz\PdoDb->query() #3 /var/www/html/simpleinvoices-master_2023/index.php(441): include('...') #4 {main} thrown in /var/www/html/simpleinvoices-master_2023/Inc/Claz/PdoDb.php on line 713

    This was the url listed in the browser at the time:

    http://192.168.0.140/simpleinvoices-master_2023/index.php?module=install&view=sample_data

    Hopefully this will be useful for you

    Attachments:
    #2120
    RRowley
    Participant

    Concerning latest message, SI with empty database. You need to let SI install essential data. Without it, you don’t have required information to use SI. After that step you can choose to install the test biller, customer, product info. Or you can enter these records for yourself with your data. In order to add an invoice, you must have a biller (you), a customer (the one the invoice is for) and at least one product to add to the invoice.

    Now, back to your original problem. The reason 2019.2 is a required upgrade, it because that was the last version that maintained the same database changes that were required to bring original SI versions up to the fearless359 SI version, as the development of fearless359 SI diverged from previous SI versions on the maintenance path (the projects were physically separated on GITHUB.

    Here is a possible way to move forward. I can make a PHP program that will simply apply the patches 2019.2 is trying to apply. However, trying to resolve any issues this program encounters becomes tricky by us having to communicate issues back and forth. If is easier if I had your data to convert. If you are up for that, I would need a full SQL extract of your starting database structure and your data. To protect your data, you can send it to me via email, in an encrypted, password protected zip file. The password could then be texted to my phone. If you are up for that, you can email it to me at admin@simpleinvoices.group. Include your email address along with the attached file and I will then send my cell number for the password to be texted to.

    #2121
    ppmt
    Participant

    Again thanks for your time.

    I did install the Essential Data. I actually think you can’t move forward without doing it.

    So if I understand you well it is not possible to install the Master2023 as a new install? and instead I must upgrade from 2019.2?

    I so I will try to install 2019.2 from scratch and then update it to the Master2023.

    The issue with my existing install is that it is very old.

    version.update_date = 20181012
    version.name

    I have never been able to find a successful upgrade path and sort of gave up.

    I am not too bothered about porting the database over and don’t mind starting from fresh.

    Of course if you think you can upgrade it and you don’t mind spending the time doing it I can send you the files.

    #2122
    RRowley
    Participant

    If you start with an empty database, the structure is created using the most current structure version and then installs essential data required to start using SI. The only reason to insert sample data is if you don’t want to use the database for live purposes; just testing it out.

    Once the essential data has been installed, you can begin using SI. Just create a biller, a customer and a product. The you can enter an invoice.

    This is the approach to take if you are starting from scratch. On the other hand, if you need to preserve your current version’s data, you follow the upgrade path through master_2019.2. This however appears to be having problems for you. That is why I suggested letting me try and convert your current data from your historic SI to the most current level.

    From what you say about your PHP version and such, you should be able to run the most current master_2023 version. However you want to proceed, let me know.

    #2138
    ppmt
    Participant

    Sorry for the late answer.

    I did try to start from scratch. I installed the latest software and created an empty database and let the install do its job but for me it doesn’t work. Each time I try to create an invoice it fails when I try to save it.

    I am not sure why it is not working for me.

    At this stage I would like to install a brand new “virgin” version of SI but I can’t

    #2139
    RRowley
    Participant

    If SI allowed you to select install database, then any errors would be in the tmp/log/php.log file. If that file is empty, then you should be able to collect data in the tmp/log/si.log file. Make sure you enabled DEBUG level logging. This is found in the custom_confi.ini file. You don’t need to start from scratch. Just enable logging, delete the old log file if it exists. Then run SI for the install. Then zip to si.log file and attach to a new message. That should help me figure out what is going on.

    #2142
    ppmt
    Participant

    Ok so I did a fresh install with an empty database and since it is a test server I also installed the sample data.
    As soon as I did that I got the same PDO error:

    
    Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 2014 Cannot execute queries while there are pending result sets. Consider unsetting the previous PDOStatement or calling PDOStatement::closeCursor() in /var/www/html/simpleinvoices-master_2023/Inc/Claz/PdoDb.php:713 Stack trace: #0 /var/www/html/simpleinvoices-master_2023/Inc/Claz/PdoDb.php(713): PDOStatement->execute() #1 /var/www/html/simpleinvoices-master_2023/Inc/Claz/PdoDb.php(1310): Inc\Claz\PdoDb->lastInsertId() #2 /var/www/html/simpleinvoices-master_2023/modules/install/sample_data.php(20): Inc\Claz\PdoDb->query() #3 /var/www/html/simpleinvoices-master_2023/index.php(441): include('...') #4 {main} thrown in /var/www/html/simpleinvoices-master_2023/Inc/Claz/PdoDb.php on line 713

    I have attached a zip file containing the php.log and the si.log.
    I hope it will help you

    Attachments:
    #2145
    RRowley
    Participant

    Not sure why you are getting this error, but have attached files to see if you can get past it using a database I generated from a fresh install. This database should be at the point where you will need to enter customer, biller and product. Then you can add invoices. Just delete all tables from your existing database, the upload the SQL file contained in the attached zip file. Let me know if this helps.

    Attachments:
    #2158
    ppmt
    Participant

    Thanks for the file. I installed it abut I am starting to think my install is cursed.

    Here is the error message I get now 🙁

    Fatal error: Uncaught Error: Class "NumberFormatter" not found in /var/www/html/simpleinvoices-master_2023/Inc/Claz/Taxes.php:123 Stack trace: #0 /var/www/html/simpleinvoices-master_2023/Inc/Claz/Taxes.php(30): Inc\Claz\Taxes::getTaxes() #1 /var/www/html/simpleinvoices-master_2023/modules/index/index.php(24): Inc\Claz\Taxes::getAll() #2 /var/www/html/simpleinvoices-master_2023/index.php(441): include('...') #3 {main} thrown in /var/www/html/simpleinvoices-master_2023/Inc/Claz/Taxes.php on line 123

    #2159
    RRowley
    Participant

    The NumberFormatter class is part of the Intl extension. You need to uncomment this extension in the php.ini file and then restart your Apache server.

    #2160
    ppmt
    Participant

    Thank you so much!!! It turns out I needed to also install php-intl as well !

    But I am not out of the wood yet.

    I can now add an invoice but when I save it I get the following error

    
    Fatal error: Uncaught TypeError: Inc\Claz\PaymentWarehouse::getOne(): Argument #1 ($id) must be of type string|int, null given, called in /var/www/html/simpleinvoices-master_2023/Inc/Claz/Invoice.php on line 398 and defined in /var/www/html/simpleinvoices-master_2023/Inc/Claz/PaymentWarehouse.php:21 Stack trace: #0 /var/www/html/simpleinvoices-master_2023/Inc/Claz/Invoice.php(398): Inc\Claz\PaymentWarehouse::getOne() #1 /var/www/html/simpleinvoices-master_2023/Inc/Claz/Invoice.php(47): Inc\Claz\Invoice::getInvoices() #2 /var/www/html/simpleinvoices-master_2023/modules/invoices/quickView.php(36): Inc\Claz\Invoice::getOne() #3 /var/www/html/simpleinvoices-master_2023/index.php(441): include('...') #4 {main} thrown in /var/www/html/simpleinvoices-master_2023/Inc/Claz/PaymentWarehouse.php on line 21

    Not sure what paymentwarehouse are but I added one and now the new invoice I created after is working.

    will need to read on paymentwarehouse.

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