Jump to content

Different Invoice Number according to Blling address


Bro Code

Recommended Posts

Hello to everyone !!!!

I am using PrestaShop for the first time and I have a problem with the Invoices numbers. I want to have different prefix in invoice number according to the billing address of customer

More precisely, if a customer has inserted Company and VAT number in billing address, I want the invoice to be labeled with a different prefix than the one that hasn't inserted those values.

I guessed, I could hardcode a simple condition that changes the prefix somewhere in order,php file, but then another problem occurs:
The numbers will not be sequenced!

For example I may have invoices like these:

-------------------------------------------------

Invoice 1 ------>  prefix1_001

Invoice 2 ------>  prefix1_002

Invoice 3 ------>  prefix2_003

Invoice 4 ------>  prefix1_004

Invoice 5 ------>  prefix2_005

-------------------------------------------------

But the desired result is this one:

-------------------------------------------------

Invoice 1 ------>  prefix1_001

Invoice 2 ------>  prefix1_002

Invoice 3 ------>  prefix2_001

Invoice 4 ------>  prefix1_003

Invoice 5 ------>  prefix2_002

-------------------------------------------------

After days of searching all I found was modules and partially fixes when using multistore. Nothing similar to my problem

I would appreciate any help you could give me!!

Thank you in advance!!!

 

Link to comment
Share on other sites

First you should said your Prestashop version

 

not sure on 1.7 but on 1.6

 

you can override the order class and change the function generateReference just do a check of address to got you prefix and after on database to got your number

 

 

Link to comment
Share on other sites

Thank you very much for your response jgamio !

I am sorry you are right, the version I use is : 1.6.1.18

I found the function generateReference you mentioned:

public static function generateReference(){
        return strtoupper(Tools::passwdGen(9, 'NO_NUMERIC'));
 }

Yet I am not sure how to modify it. This is the last function that return prefix + number ?

About the number in database, you mean to keep it in different entry on database in order to increment it accordingly ?

Link to comment
Share on other sites

If you dont know how modify I will recomend you to got some one can do it for you

 

The best practice should the an override of the class just with these function

 

(I havent try just is a reference)

Here you should check the adreess and make the check of the increment to generate the number

 

Becasuse is a static function dont sure you have the information before generate the order I havent check

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...