stdnum.vn.mst

MST (Mã số thuế, Vietnam tax number).

This number consists of 10 digits. Branches have a 13 digit number, where the first ten digits are the same as the parent company’s.

The first two digits is the province code where the business was established. If an enterprise relocates its head office from one province to another, the MST will remain unchanged.

The following seven digits are a sequential number from 0000001 to 9999999.

The tenth digit is the check digit for the first nine digits, which is used to verify the number was correctly typed.

The last optional three digits are a sequence from 001 to 999 indicating branches of the enterprise. These digits are usually separated from the first ten digits using a dash (-)

More information:

>>> validate('0100233488')
'0100233488'
>>> validate('0314409058-002')
'0314409058002'
>>> validate('12345')
Traceback (most recent call last):
    ...
InvalidLength: ...
>>> validate('0100233480')
Traceback (most recent call last):
    ...
InvalidChecksum: ...
>>> format('01.00.112.437')
'0100112437'
>>> format('0312 68 78 78 - 001')
'0312687878-001'
stdnum.vn.mst.calc_check_digit(number)

Calculate the check digit.

stdnum.vn.mst.compact(number)

Convert the number to the minimal representation.

This strips the number of any valid separators and removes surrounding whitespace.

stdnum.vn.mst.format(number)

Reformat the number to the standard presentation format.

stdnum.vn.mst.is_valid(number)

Check if the number is a valid Vietnam MST number.

stdnum.vn.mst.validate(number)

Check if the number is a valid Vietnam MST number.

This checks the length, formatting and check digit.