#4292 (Lino should validate the vat_id field)
by Luc Saffre · in Developers · assigned to Sharif Mehedi
Kurzbeschreibung
Kinder
Kommentare
- 5 Jahre, 2 Monate ago von Luc Saffre about #4292 (Lino should validate the vat_id field) : Oops, it was because I didn't pull tera.
- 5 Jahre, 2 Monate ago von Luc Saffre about #4292 (Lino should validate the vat_id field) : But strangely, the issue doesn't seem to occur on GitLab. Here are my lines 95...99 of mentioned file: obj = Company( name="Tough Thorough Thought Therapies", country_id="BE", vat_id="BE12 3456 7890") yield obj settings.SITE.site_config.update(site_company=obj)
- 5 Jahre, 2 Monate ago von Luc Saffre about #4292 (Lino should validate the vat_id field) : The failure is obvious and caused because tera/lino_tera/lib/tera/fixtures/demo.py tries to save an invalid VAT number. But strange, didn't you fix that already? Please have a look at it. Simply "go lydia" and "pm prep" to reproduce the issue.
- 5 Jahre, 2 Monate ago von Luc Saffre about #4292 (Lino should validate the vat_id field) : I am still having an issue when doing "pm prep" in lydia: Failed to save Company(country='BE',vat_id='BE12 3456 7890',name='Tough Thorough Thought Therapies') from manual fixture: django.core.exceptions.ValidationError: ['Modulo 97 check failed for VAT identification number in BE']
- 5 Jahre, 2 Monate ago von Luc Saffre about #4292 (Lino should validate the vat_id field) : Done. Good work, Sharif!
- 5 Jahre, 2 Monate ago von Sharif Mehedi about #4292 (Lino should validate the vat_id field) : Correction to my last comment: the vat_id(s) in the demo fixtures are actually valid and the have a length = 9 but the vat_id_length dictionary had it set to 10 and was detecting them as invalid.
- 5 Jahre, 2 Monate ago von Sharif Mehedi about #4292 (Lino should validate the vat_id field) : In many demo fixtures, there are some hard coded vat_id numbers that does not match valid vat_id format. I am thinking whether to replace them also with VatNumberChecker.generate_vid() method (a VAT id auto generation method).
- 5 Jahre, 2 Monate ago von Luc Saffre about #4292 (Lino should validate the vat_id field) : For a Belgian partner, Lino should accept a string "404484654 " in vat_id, and the full_clean should change this to "BE 0404.484.654" (i.e. upper case country code + space + 9999.999.999"). For other countries there will be something similar.
- 5 Jahre, 2 Monate ago von Luc Saffre about #4292 (Lino should validate the vat_id field) : It turns out that pyvat does only online checking. But online checking would slow down the submit of a partner record. And Yvonne actually just wants the modulo 97 check, as it is being used in TIM. Next steps: write a data checker for pyvat checks and do pyvat check only there. In the full_clean me...
- 5 Jahre, 2 Monate ago von Sharif Mehedi about #4292 (Lino should validate the vat_id field) : lino_xl.lib.vat.fixtures.demo creates some random vat_id(s) and vat_id validator is marking them as invalid and raising ValidationError. So, even the `pm prep` command is failing for project that has vat plugin installed.
- 5 Jahre, 2 Monate ago von Sharif Mehedi about #4292 (Lino should validate the vat_id field) : This was actually not a lot of work. just three-four lines of code!
- 5 Jahre, 2 Monate ago von Luc Saffre about #4292 (Lino should validate the vat_id field) : Sharif you can now go for it and add vat id verification for Belgian partners (by extending the VatSubjectable mixin). You should add the new dependency to [url pyvat.readthedocs.io/en/latest/ pyvat] in the vat plugin by overriding Plugin.get_requirements(). Also update the requirements-install.txt ...
- 5 Jahre, 2 Monate ago von Luc Saffre about #4292 (Lino should validate the vat_id field) : Done converting vat_id and vat_regime to a VatSubjectable model mixin. (The last failure was because min9 redefined a field vat_id, which was rather a bug). 6 changes in the book test suite confirm that it works.
- 5 Jahre, 2 Monate ago von Luc Saffre about #4292 (Lino should validate the vat_id field) : There is yet another subtle inheritance problem after my change (in min9): django.core.exceptions.FieldError: Local field 'vat_id' in class 'Company' clashes with field of the same name from base class 'Partner'.
- 5 Jahre, 2 Monate ago von Luc Saffre about #4292 (Lino should validate the vat_id field) : I wrote the new model mixin VatSubjectable to replace the inject_field(). This mixin is inherited from contacts.Partner. And it is a no-op when vat is not installed. So the result should be the same (i will wait the outcome of the local test run before pushing). It was a bit tricky because of circul...
- 5 Jahre, 2 Monate ago von Luc Saffre about #4292 (Lino should validate the vat_id field) : We will probably use only the Python side. [url pyvat.readthedocs.io/en/latest/ pyvat] module. Before starting on this, get active_fields supported on react (#4293).
- 5 Jahre, 2 Monate ago von Luc Saffre about #4292 (Lino should validate the vat_id field) : The main question is: should we check on the client side or on the server side? Maybe both. Here is a JS code example: [url formvalidation.io/guide/validators/vat/belgian-vat-number/]. I want a solution that uses the same JS code snippet for both ExtJS and React.
- 5 Jahre, 2 Monate ago von Luc Saffre about #4292 (Lino should validate the vat_id field) : I plan to replace the inject_field() calls for vat_id and vat_regime by a model mixin VatSubjectable. And then add a validator, which of course will depend on the partner's country.