Progressive invoice number and no invoice for free

  • Posts: 89
  • Thank you received: 1
11 years 10 months ago #84084

Hi,

I have two problems in the issuance of invoice.

The first, as Italian user, I need a number for invoices that starts over every beginning of the year and one that does not have holes numbering.

The second. I have many free products. I do not want no "official" invoice is for these products but only orders, is it possible?


thanks
Fabio


Configuration:
Joomla: 2.5.9
Hikashop: 2.1.1
Hikamarket: 1.1.2

Please Log in or Create an account to join the conversation.

  • Posts: 26151
  • Thank you received: 4027
  • MODERATOR
11 years 10 months ago #84408

Hi,

I have started a patch in HikaShop in order to have a reset system for invoices. The patch should be finished for the next release of HikaShop.
It would add a new option for "invoice number reseting frequency" (every month, every year, never).

For the second point, you mean that, if an order does not have a price (that is a free order), you don't want to generate the invoice number ?

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 89
  • Thank you received: 1
11 years 9 months ago #84505

Hi Jerome

thanks for the reply,
wait for the patch.


For the second point, exactly, I would like for orders equal to zero, there was no emission of invoice

Is it possible?

Thanks
Fabio


Configuration:
Joomla: 2.5.9
Hikashop: 2.1.1
Hikamarket: 1.1.2

Please Log in or Create an account to join the conversation.

  • Posts: 26151
  • Thank you received: 4027
  • MODERATOR
11 years 9 months ago #84581

Hi,

The only way I see for such feature is to include it directly in the HikaShop core. It's not possible to put it in a plugin or to externalize it.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 89
  • Thank you received: 1
11 years 9 months ago #84796

Hi Jerome.

Ok thanks,

Can You do so in the coming features?

Or can I change it in some file? Which one?

Regards
fabio


Configuration:
Joomla: 2.5.9
Hikashop: 2.1.1
Hikamarket: 1.1.2

Please Log in or Create an account to join the conversation.

  • Posts: 26151
  • Thank you received: 4027
  • MODERATOR
11 years 9 months ago #84831

Hi,

There is a simpler solution with some view customisation.
It would possible to hide the "invoice" buttons in the front-end directly in views. Just making a little test on the order full price to know if the button should be displayed or not.
After that, I don't know if there are other points that you want to "forbidden" with your free orders.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 89
  • Thank you received: 1
11 years 9 months ago #84840

Hi,

I do not want to hide the "invoice", but not generate an id of invoice for the zero amounts

is it possible?

Thanks
fabio


Configuration:
Joomla: 2.5.9
Hikashop: 2.1.1
Hikamarket: 1.1.2

Please Log in or Create an account to join the conversation.

  • Posts: 26151
  • Thank you received: 4027
  • MODERATOR
11 years 9 months ago #84857

Hi,

You can update your class order with this code.

	if(!empty($order->order_status) && empty($order->order_invoice_id) && empty($order->old->order_invoice_id) && $order_type == 'sale') {
		$config =& hikashop_config();
		$valid_statuses = explode(',', $config->get('invoice_order_statuses','confirmed,shipped'));
		$excludeFreeOrders = $config->get('invoice_exclude_free_orders', 0);
		if(isset($order->order_full_price))
			$total = $order->order_full_price;
		else
			$total = $order->old->order_full_price;
		if(in_array($order->order_status, $valid_statuses) && ($total > 0 || !$excludeFreeOrders)) {
			$this->database->setQuery('SELECT MAX(a.order_invoice_id)+1 FROM '.hikashop_table('order').' AS a WHERE a.order_type = \'sale\'');
			$order->order_invoice_id = $this->database->loadResult();
			$order->order_invoice_number = hikashop_encode($order, 'invoice');
		}
	}
After that, you have to create an option in the database, named "invoice_exclude_free_orders" and with the value "1".
It would be an advanced option (we have some options which are hidden).

If it's right for you, the patch would be validate and include in the next release of HikaShop.
(And the option would be managed by HikaMarket too).

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: insegnalo

Please Log in or Create an account to join the conversation.

  • Posts: 89
  • Thank you received: 1
11 years 9 months ago #86808

Hi.

What about your last news? Did you finish the patch?

thanks
Fabio


Configuration:
Joomla: 2.5.9
Hikashop: 2.1.1
Hikamarket: 1.1.2

Please Log in or Create an account to join the conversation.

  • Posts: 26151
  • Thank you received: 4027
  • MODERATOR
11 years 9 months ago #86840

Hi,

Does the patch right for you ?

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 89
  • Thank you received: 1
11 years 9 months ago #86917

Hi Jerome,

as you can see at the beginning of this discussion,

we need the invoice number start from zero with each new year.


At The second question of this discussion (not generate an id of invoice for the zero amounts) you answered me so... "You can update your class order with this code..."

which file should I change?

thanks a lot

Fabio


Configuration:
Joomla: 2.5.9
Hikashop: 2.1.1
Hikamarket: 1.1.2

Please Log in or Create an account to join the conversation.

  • Posts: 26151
  • Thank you received: 4027
  • MODERATOR
11 years 9 months ago #86927

Hi,

About your first question, the feature has been implemented in HikaShop and would be include in the next release (2.1.0) which should be publish at the end of the month.

The file is the class order ( administrator/components/com_hikashop/classes/order.php ).
In this file you would find the line

if(!empty($order->order_status) && empty($order->order_invoice_id) && empty($order->old->order_invoice_id) && $order_type == 'sale') {
And that's this block content which require an update.
But, like I said, if the patch working fine for you, we could include it for the next release, just need your validation before.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: insegnalo

Please Log in or Create an account to join the conversation.

  • Posts: 89
  • Thank you received: 1
11 years 9 months ago #87073

Hi Jerome

I made ​​the changes that I've written.

As you can see from the attached pictures I changed the order.php file

and I added the entry invoice_exclude_free_orders in the table _hikashop_order

But also the invoice is generated for zero amounts

where went I wrong?

Thanks
Fabio


Configuration:
Joomla: 2.5.9
Hikashop: 2.1.1
Hikamarket: 1.1.2
Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 26151
  • Thank you received: 4027
  • MODERATOR
11 years 9 months ago #87079

Hi,

You need to add a line in the database. You have create a new column.


In the database, make an "insert" and set:
config_namekey: invoice_exclude_free_orders
config_value: 1
config_default: 0

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 89
  • Thank you received: 1
11 years 9 months ago #87092

Ok it works! :-)

on the table _hikashop_order not entered any invoice number for free orders.

Although, however, in order always appears Invoice button with the order number.

A doubt, the PDF plugin what invoice send to the buyer ?

Thanks
Fabio


Configuration:
Joomla: 2.5.9
Hikashop: 2.1.1
Hikamarket: 1.1.2

Please Log in or Create an account to join the conversation.

  • Posts: 26151
  • Thank you received: 4027
  • MODERATOR
11 years 9 months ago #87224

Hi,

I have to check about the "invoice" button. It is mainly a translation of the word "order/invoice" and it could be modified with view overrides.
The PDF plugin use a view too, so you can override his content too.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 89
  • Thank you received: 1
11 years 9 months ago #87605

Hi Jerome

I would like the PDF plugin not send any file if it is not generated invoice,

with the changes you told me now is no longer generated invoice for orders equal to zero, however, the pdf file is sent

What should I do in order not to send this file?

Thanks
Fabio


Configuration:
Joomla: 2.5.9
Hikashop: 2.1.1
Hikamarket: 1.1.2

Please Log in or Create an account to join the conversation.

  • Posts: 26151
  • Thank you received: 4027
  • MODERATOR
11 years 9 months ago #87787

Hi,

You can update the "attachinvoice" plugin in order to do not generate the invoice if the invoice number is not generated.
In the function "onBeforeMailSend" you would found the lines:

		if(!class_exists('HTML2PDF')) include(dirname(__FILE__).DS.'attachinvoice'.DS.'html2pdf.class.php');

		$orderId = $data->data->order_id;
		// Add this text block
		if(empty($data->data->order_invoice_id)) {
			return;
		}

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: insegnalo

Please Log in or Create an account to join the conversation.

  • Posts: 104
  • Thank you received: 0
11 years 5 months ago #103012

Hi Jerome,

I have a question. In administrator/components/com_hikashop/classes/order.php I can see the code

if(!empty($order->order_status) && empty($order->order_invoice_id) && empty($order->old->order_invoice_id) && $order_type == 'sale') {
				$config =& hikashop_config();
				$valid_statuses = explode(',', $config->get('invoice_order_statuses','confirmed,shipped'));
				$excludeFreeOrders = $config->get('invoice_exclude_free_orders', 0);
				if(isset($order->order_full_price))
					$total = $order->order_full_price;
				else
					$total = $order->old->order_full_price;
				if(in_array($order->order_status, $valid_statuses) && ($total > 0 || !$excludeFreeOrders)) {
					$query = 'SELECT MAX(a.order_invoice_id)+1 FROM '.hikashop_table('order').' AS a WHERE a.order_type = \'sale\'';
					$resetFrequency = $config->get('invoice_reset_frequency', '');
					if(!empty($resetFrequency)) {
						$y = (int)date('Y');
						$m = 1;
						$d = 1;
						if($resetFrequency == 'month')
							$m = (int)date('m');

						if(strpos($resetFrequency, '/') !== false) {
							list($d,$m) = explode('/', $resetFrequency, 2);
							if($d == '*')
								$d = (int)date('d');
							else
								$d = (int)$d;

							if($m == '*')
								$m = (int)date('m');
							else
								$m = (int)$m;

							if($d <= 0) $d = 1;
							if($m <= 0) $m = 1;
						}
I should replace it with this one?
if(!empty($order->order_status) && empty($order->order_invoice_id) && empty($order->old->order_invoice_id) && $order_type == 'sale') {
		$config =& hikashop_config();
		$valid_statuses = explode(',', $config->get('invoice_order_statuses','confirmed,shipped'));
		$excludeFreeOrders = $config->get('invoice_exclude_free_orders', 0);
		if(isset($order->order_full_price))
			$total = $order->order_full_price;
		else
			$total = $order->old->order_full_price;
		if(in_array($order->order_status, $valid_statuses) && ($total > 0 || !$excludeFreeOrders)) {
			$this->database->setQuery('SELECT MAX(a.order_invoice_id)+1 FROM '.hikashop_table('order').' AS a WHERE a.order_type = \'sale\'');
			$order->order_invoice_id = $this->database->loadResult();
			$order->order_invoice_number = hikashop_encode($order, 'invoice');
		}
	}

And then create the option in de database.

Please Log in or Create an account to join the conversation.

  • Posts: 26151
  • Thank you received: 4027
  • MODERATOR
11 years 5 months ago #103014

Hi,

The latest version of HikaShop already includes the patch which read the option

$excludeFreeOrders = $config->get('invoice_exclude_free_orders', 0);
So you just need to create the option in the database. No view modification is required.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

Time to create page: 0.070 seconds
Powered by Kunena Forum