# 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:

- https://vi.wikipedia.org/wiki/Thuế_Việt_Nam#Mã_số_thuế_(MST)_của_doanh_nghiệp

- https://easyinvoice.vn/ma-so-thue/

- https://ub.com.vn/threads/huong-dan-tra-cuu-ma-so-thue-doanh-nghiep-moi-nhat.261393/

    >>> 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: str) → str

  Calculate the check digit.

stdnum.vn.mst.compact(number: str) → str

  Convert the number to the minimal representation.

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

stdnum.vn.mst.format(number: str) → str

  Reformat the number to the standard presentation format.

stdnum.vn.mst.is_valid(number: str) → bool

  Check if the number is a valid Vietnam MST number.

stdnum.vn.mst.validate(number: str) → str

  Check if the number is a valid Vietnam MST number.

  This checks the length, formatting and check digit.