Page 7 of 7

Re: Invoicenumber(s) not correct according to EU law

Posted: Fri Mar 26, 2010 8:28 pm
by speedingorange
Is this now included in the latest release?

Cheers
James

Re: Invoicenumber(s) not correct according to EU law

Posted: Fri Mar 26, 2010 8:31 pm
by Daniel
yes

Re: Invoicenumber(s) not correct according to EU law

Posted: Fri Mar 26, 2010 8:38 pm
by speedingorange
Cheers, I better upgrade then.

Re: Invoicenumber(s) not correct according to EU law

Posted: Fri Mar 26, 2010 10:16 pm
by i2Paq
speedingorange wrote:Is this now included in the latest release?

Cheers
James
This is not released yet!

Re: Invoicenumber(s) not correct according to EU law

Posted: Sun Mar 28, 2010 1:30 am
by Daniel
i have just finished it. going to release the next version tonight after I get some food.

Re: Invoicenumber(s) not correct according to EU law

Posted: Sun Mar 28, 2010 1:45 am
by i2Paq
Daniel wrote: after I get some food.
Image

There your go! ;D

Re: Invoicenumber(s) not correct according to EU law

Posted: Fri Jun 25, 2010 5:30 pm
by sonicsam
Hi,

Sorry to reopen this thread however I am trying to work out of OpenCart will provide a suitable platform for a client project.

Firstly my client is Italian and so like has been mentioned there are some very specific requirements for invoicing which are -

1. Sequential Numbering with no missing invoice numbers (Canceling an order should not delete a created invoice).
2. Starting from 1 each year (A simple way to do this which we use in WHMCS is to have a "next invoice number" field in admin so we have 2010-01345 and next year we would simply change the next invoice field to 2011-00001).

Can OpenCart support the Italian requirements?

Regards

Sam M
www.servwise.com - Hosting Windows & Linux italia

Re: Invoicenumber(s) not correct according to EU law

Posted: Fri Jun 25, 2010 7:22 pm
by SteveSherry
sonicsam wrote: Can OpenCart support the Italian requirements?
Yes

Re: Invoicenumber(s) not correct according to EU law

Posted: Fri Jun 25, 2010 7:24 pm
by Xsecrets
well you can do sequential and you can set the initial start number, but I'm not sure if you can reset it to start over at 1 each year.

Re: Invoicenumber(s) not correct according to EU law

Posted: Fri Jun 25, 2010 8:17 pm
by i2Paq
Xsecrets wrote:well you can do sequential and you can set the initial start number, but I'm not sure if you can reset it to start over at 1 each year.

You can, by running a query via phpMyAdmin at the beginning of each year.

Thats how i do it with osCommerce and this should work with OpenCart as well.

Re: Invoicenumber(s) not correct according to EU law

Posted: Fri Jun 25, 2010 11:10 pm
by JAY6390
Or just have the current invoice prefix (the year) in a config variable and check it every time an order goes through against date('Y'). If they're not equal, bump it up to the next year, reset the invoice counter and carry on :)

Re: Invoicenumber(s) not correct according to EU law

Posted: Wed Jul 14, 2010 7:23 am
by Maaris
i2Paq wrote:You can, by running a query via phpMyAdmin at the beginning of each year.
What query it should be? Like setting all invoice id's to "0"??? I think there might be some problems for users when they view order history from account page and when I need to print an old invoice.

Re: Invoicenumber(s) not correct according to EU law

Posted: Sat Jul 17, 2010 3:35 am
by Maaris
Here's a thing that I tried for myself. And it seems to be working.

Modification:

In a file "admin/model/sale/order.php" I found where it says:

Code: Select all

$query = $this->db->query("SELECT MAX(invoice_id) AS invoice_id FROM `" . DB_PREFIX . "order`");
and replaced it with:

Code: Select all

$query = $this->db->query("SELECT MAX(invoice_id) AS invoice_id FROM `" . DB_PREFIX . "order` WHERE invoice_prefix = '" . $this->db->escape($this->config->get('config_invoice_prefix')) . "'");
Effect:
Now you don't need to reset invoice counter when year starts. Just change the Invoice prefix when new year (month or whatever) and the counter will be re-set automatically. And you won't have to lose previously saved invoice numbers to reset counter.

Explanation:
Thing is that originally core file searches in DB for highest invoice number and adds +1. After this modification core file searches for highest invoice number in DB only in rows that use current invoice prefix (set at BackOffice settings). In this way, when you set a prefix that was never used before (like when changing from INV2009 to INV2010 whne a new year starts) invoice id automatically sets to 0+1 = 1

Disclaimer:
Edit this file at your own risk. I am not a coder. Just edited this file for my own shop (which is not even jet launched) and I might not be aware of harm it might cause.