Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2012
    Posts
    132
    Plugin Contributions
    0

    Default Adding VAT field to customers table

    ZC 1.5.8,Mariadb,Nginx,Php7.41

    Hi folks and thanks to all of You who have participated to development of ZC. I think this new 1.5.8 is an exellent upgrade.

    But to the point. I did an upgrade from old 1.5.3 to 1.5.8 and noticed the 1.5.8 has a Company field when new user makes an registration which is an very welcomed improvement. But I was also asked to add an company VAT-ID field and thoght that is not too difficult because you just have to put something like:
    Code:
    ALTER TABLE customers ADD customers_VAT varchar(10) NOT NULL default '0';
    to db and make few changes to affected forms. Well I did made an test client regitration which had an company name and it shows on admin pages correctly but strangely I could not find it on a database even though I used search.

    I could of course add the field but I also have an older zc database soon to be moved to new 1.5.8 platform and now I don't even now in where in the new db this info is hidden so I would like to get to bottom of this issue before I alter the old database because of compliance issues when upgrading that.

    All the best,
    Oops

  2. #2
    Join Date
    Mar 2012
    Posts
    132
    Plugin Contributions
    0

    Default Re: Adding VAT field to customers table

    I answer to my own question: Company field which is in registration field is located in orders table in database.

  3. #3
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    9,627
    Plugin Contributions
    123

    Default Re: Adding VAT field to customers table

    Some guidance on adding fields to the customers table:

    https://docs.zen-cart.com/dev/code/add_field_customers/
    That Software Guy. My Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

  4. #4
    Join Date
    Oct 2008
    Location
    Croatia
    Posts
    1,541
    Plugin Contributions
    19

    Default Re: Adding VAT field to customers table

    It's fairly straight-forward, but remember that you still need the VAT field in the orders table as well as customers (I placed it in address_book). In case you're wondering why: if a customer places an order and needs a VAT invoice, the VAT number needs to be stored with the order because you need to have that number with that invoice. If it's stored in the customers table, customer may change it at some point and you n longer have record of which VAT number was used with that order. If the customer is able to download an invoice, they might get 2 of the same invoices with different VAT numbers.
    Why address book and not customers table? Perhaps the customer is ordering for their company today and they need a VAT invoice so their billing address is the company address. Tomorrow, the same customer might be placing a personal order and they don't need their VAT number on the invoice - this is where the secondary address from the address_book kicks in which doesn't have the VAT number.

    As for your alter table sql - I *would* null that field, what's the purpose of having it default to zero?

  5. #5
    Join Date
    Mar 2012
    Posts
    132
    Plugin Contributions
    0

    Default Re: Adding VAT field to customers table

    Hi,

    sorry for my late response, was at the hospital again and Thank you to balihr and Swguy. Balihr great explanation of the process is indeed true and NULL is a proper db field value to use. And all company customers are indeed need of the official Vat invoice number in the bill. EU Taxation rules are also pretty strict and any official bill is in need to have VAT number or company identification number in them (basically the same info in different format) among with product price VAT calculations.

    Regarding that next I have to think a procedure how to alter all the prices to our VAT which is 24% because in old days there were no VAT and VAT is currently 0% in both gross and net price fields in old db so they are showing wrong in customers invoice.

    I know if I multiply current gross price with 0,80645161290322 I get Vat 0% price pretty accurately and then do also sql ROUND with prices not to get too many decimals I think I can make sql statement which does the trick. Long time I have useld Sql and have forgotten all most everything in Sql syntax but luckily we can search easily now a days ...

    I made regarding price alterations a little hack so you can easier also rise zen cart prices but noticed somebody all ready had made it called price increase/decrease plugin. Possibly I try to make also it also to work with product categories selection because it now only uses manufacturers field. If there is all ready a plugin for that, please let me know ;) Somewhow missed all ready that price increase/decrease plugin..

    Thank again though, starting to make alterations to db fields.

 

 

Similar Threads

  1. Adding field to customers table
    By eflat in forum General Questions
    Replies: 4
    Last Post: 27 Oct 2010, 12:58 AM
  2. Adding Custom Field to Customer Table
    By experimenter in forum General Questions
    Replies: 3
    Last Post: 26 Sep 2008, 08:36 PM
  3. Adding field to categories_description table
    By 0101101011 in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 13 Aug 2007, 05:56 PM
  4. Adding field to products_description table
    By IncrediBody in forum General Questions
    Replies: 2
    Last Post: 14 Sep 2006, 05:18 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR