Opened 12 years ago

Closed 10 years ago

#10756 closed Bug (fixed)

Correct PLNIPField

Reported by: remik Owned by: nobody
Component: contrib.localflavor Version: dev
Severity: Normal Keywords:
Cc: michal.modzelewski@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Valid forms are: XXX-XXX-YY-YY or XXX-XX-YY-YYY.


Attachments (2)

ticket10756.diff (3.1 KB) - added by Michał Modzelewski 10 years ago.
patch that changes the accepted formats, details in the comments
ticket10756-2.diff (3.1 KB) - added by Claude Paroz 10 years ago.
Updated to current trunk

Download all attachments as: .zip

Change History (8)

comment:1 Changed 12 years ago by Jarek Zgoda

Polish law does not specify any particular form of tax ID number, the only requirement is 10 digits. These formats are only enforced by paper forms and may vary. To be fair with current law, we should use a regex that allows any grouping (with no grouping as special case).

comment:2 Changed 12 years ago by Alex Gaynor

Triage Stage: UnreviewedAccepted

comment:3 Changed 10 years ago by Chris Beaven

Severity: Normal
Type: Bug

Changed 10 years ago by Michał Modzelewski

Attachment: ticket10756.diff added

patch that changes the accepted formats, details in the comments

comment:4 Changed 10 years ago by Michał Modzelewski

Cc: michal.modzelewski@… added
Easy pickings: unset
Has patch: set
Version: 1.0SVN

I've added a patch to fix this.
New accepted formats are XXX-XXX-XX-XX, XXX-XX-XX-XXX and XXXXXXXXXX based on, the historical wikipedia entry and some Polish legal forums that discussed the matter of validation.

Some translations from the wikipedia article:

Prefiks - trzy pierwsze cyfry każdego NIP oznaczają kod urzędu skarbowego, który nadał dany numer.

Prefix - the first three digits in each NIP signify the tax office that assigned the number.

W przeszłości NIP zwyczajowo zapisywało się, oddzielając grupy cyfr łącznikiem. Obecnie nadawany jest bez znaków łącznika.

In the past a NIP was commonly writen with dashes separating the digit groups. Currently numbers are assigned without dashes.

Translated excerpt from the historical artical:

Zwyczajowo NIP zapisuje się, oddzielając grupy cyfr łącznikiem. Dla osób fizycznych numer dzielony jest na grupy 123-456-78-90, a dla osób prawnych, bądź ułomnych osób prawnych, na grupy 123-45-67-890.

Commonly a NIP is written with dashes separating the digits into groups. For individuals the number is split into groups 123-456-78-90, and for legal personalities and restricted legal personalities into groups 123-45-67-890.

From the note on prefixes we can see that the previous accepted format of XX-XX-XXX-XXX was incorrect so I have removed it.
Apropos the comment by zgoda, since the current accepted format is without dashes, we only need to accept the current format and the two historical formats posted in the bug report by remik, and in the historical wikipedia entry.

We don't need to support the previously accepted format for backwards compatibility since the fields clean method stripped the dashes.

Last edited 10 years ago by Michał Modzelewski (previous) (diff)

Changed 10 years ago by Claude Paroz

Attachment: ticket10756-2.diff added

Updated to current trunk

comment:5 Changed 10 years ago by Claude Paroz

Triage Stage: AcceptedReady for checkin
UI/UX: unset

comment:6 Changed 10 years ago by Aymeric Augustin

Resolution: fixed
Status: newclosed

In [17346]:

Fixed #10756 -- Error in the formats accepted by PLNIPField. Thanks remik for the report, michalm for the patch and claudep for the review.

Note: See TracTickets for help on using tickets.
Back to Top