Esempio n. 1
0
def check_dgii(rnc, ncf):  # pragma: no cover
    """Validate the RNC, NCF combination on using the DGII online web service.

    This uses the validation service run by the the Dirección General de
    Impuestos Internos, the Dominican Republic tax department to check
    whether the combination of RNC and NCF is valid.

    Returns a dict with the following structure::

        {
            'name': 'The registered name',
            'proof': 'Source of the information',
            'is_valid': '1',
            'validation_message': '',
            'rnc': '123456789',
            'ncf': 'A020010210100000005'
        }

    Will return None if the number is invalid or unknown."""
    from stdnum.do.rnc import compact as rnc_compact
    from stdnum.do.rnc import dgii_wsdl
    rnc = rnc_compact(rnc)
    ncf = compact(ncf)
    client = get_soap_client(dgii_wsdl)
    result = client.GetNCF(
        RNC=rnc,
        NCF=ncf,
        IMEI='')
    if result == '0':
        return
    return _convert_result(result)
Esempio n. 2
0
def check_dgii(number, timeout=30):  # pragma: no cover
    """Lookup the number using the DGII online web service.

    This uses the validation service run by the the Dirección General de
    Impuestos Internos, the Dominican Republic tax department to lookup
    registration information for the number. The timeout is in seconds.

    Returns a dict with the following structure::

        {
            'rnc': '123456789',     # The requested number
            'name': 'The registered name',
            'commercial_name': 'An additional commercial name',
            'status': '2',          # 1: inactive, 2: active
            'category': '0',        # always 0?
            'payment_regime': '2',  # 1: N/D, 2: NORMAL, 3: PST
        }

    Will return None if the number is invalid or unknown."""
    # this function isn't automatically tested because it would require
    # network access for the tests and unnecessarily load the online service
    number = compact(number)
    client = get_soap_client(dgii_wsdl, timeout)
    result = client.GetContribuyentes(
        value=number,
        patronBusqueda=0,   # search type: 0=by number, 1=by name
        inicioFilas=1,      # start result (1-based)
        filaFilas=1,        # end result
        IMEI='')
    if result and 'GetContribuyentesResult' in result:
        result = result['GetContribuyentesResult']  # PySimpleSOAP only
    if result == '0':
        return
    return _convert_result(result)
Esempio n. 3
0
def check_dgii(number, timeout=30):  # pragma: no cover
    """Lookup the number using the DGII online web service.

    This uses the validation service run by the the Dirección General de
    Impuestos Internos, the Dominican Republic tax department to lookup
    registration information for the number. The timeout is in seconds.

    Returns a dict with the following structure::

        {
            'rnc': '123456789',     # The requested number
            'name': 'The registered name',
            'commercial_name': 'An additional commercial name',
            'status': '2',          # 1: inactive, 2: active
            'category': '0',        # always 0?
            'payment_regime': '2',  # 1: N/D, 2: NORMAL, 3: PST
        }

    Will return None if the number is invalid or unknown."""
    # this function isn't automatically tested because it would require
    # network access for the tests and unnecessarily load the online service
    number = compact(number)
    client = get_soap_client(dgii_wsdl, timeout)
    result = client.GetContribuyentes(
        value=number,
        patronBusqueda=0,   # search type: 0=by number, 1=by name
        inicioFilas=1,      # start result (1-based)
        filaFilas=1,        # end result
        IMEI='')
    if result and 'GetContribuyentesResult' in result:
        result = result['GetContribuyentesResult']  # PySimpleSOAP only
    if result == '0':
        return
    result = [x for x in result.split('@@@')]
    return _convert_result(result[0])
Esempio n. 4
0
def _get_client():  # pragma: no cover (no tests for this function)
    """Get a SOAP client for performing T.C. Kimlik validation."""
    # this function isn't automatically tested because the functions using
    # it are not automatically tested
    global _tckimlik_client
    if _tckimlik_client is None:
        _tckimlik_client = get_soap_client(tckimlik_wsdl)
    return _tckimlik_client
Esempio n. 5
0
def _get_client():  # pragma: no cover (no tests for this function)
    """Get a SOAP client for performing VIES requests."""
    # this function isn't automatically tested because the functions using
    # it are not automatically tested
    global _vies_client
    if _vies_client is None:
        _vies_client = get_soap_client(vies_wsdl)
    return _vies_client
Esempio n. 6
0
def _get_client():  # pragma: no cover (no tests for this function)
    """Get a SOAP client for performing VIES requests."""
    # this function isn't automatically tested because the functions using
    # it are not automatically tested
    global _vies_client
    if _vies_client is None:
        _vies_client = get_soap_client(vies_wsdl)
    return _vies_client
Esempio n. 7
0
def check_vies(number):  # pragma: no cover (not part of normal test suite)
    """Query the online European Commission VAT Information Exchange System
    (VIES) for validity of the provided number. Note that the service has
    usage limitations (see the VIES website for details). This returns a
    dict-like object."""
    # this function isn't automatically tested because it would require
    # network access for the tests and unnecessarily load the VIES website
    number = compact(number)
    client = get_soap_client(vies_wsdl)
    return client.checkVat(number[:2], number[2:])
Esempio n. 8
0
def check_vies(number, timeout=30):  # pragma: no cover (not part of normal test suite)
    """Query the online European Commission VAT Information Exchange System
    (VIES) for validity of the provided number. Note that the service has
    usage limitations (see the VIES website for details). The timeout is in
    seconds. This returns a dict-like object."""
    # this function isn't automatically tested because it would require
    # network access for the tests and unnecessarily load the VIES website
    number = compact(number)
    client = get_soap_client(vies_wsdl, timeout)
    return client.checkVat(number[:2], number[2:])
Esempio n. 9
0
def check_vies_approx(number, requester):  # pragma: no cover
    """Query the online European Commission VAT Information Exchange System
    (VIES) for validity of the provided number, providing a validity
    certificate as proof. You will need to give your own VAT number for this
    to work. Note that the service has usage limitations (see the VIES
    website for details). This returns a dict-like object."""
    # this function isn't automatically tested because it would require
    # network access for the tests and unnecessarily load the VIES website
    number = compact(number)
    requester = compact(requester)
    client = get_soap_client(vies_wsdl)
    return client.checkVatApprox(
        countryCode=number[:2], vatNumber=number[2:],
        requesterCountryCode=requester[:2], requesterVatNumber=requester[2:])
Esempio n. 10
0
def check_kps(number, name, surname, birth_year, timeout):  # pragma: no cover
    """Query the online T.C. Kimlik validation service run by the Directorate
    of Population and Citizenship Affairs. The timeout is in seconds. This
    returns a boolean but may raise a SOAP exception for missing or invalid
    values."""
    # this function isn't automatically tested because it would require
    # network access for the tests and unnecessarily load the online service
    number = compact(number)
    client = get_soap_client(tckimlik_wsdl, timeout)
    result = client.TCKimlikNoDogrula(
        TCKimlikNo=number, Ad=name, Soyad=surname, DogumYili=birth_year)
    if hasattr(result, 'get'):
        return result.get('TCKimlikNoDogrulaResult')
    return result
def check_kps(number, name, surname, birth_year, timeout):  # pragma: no cover
    """Query the online T.C. Kimlik validation service run by the Directorate
    of Population and Citizenship Affairs. The timeout is in seconds. This
    returns a boolean but may raise a SOAP exception for missing or invalid
    values."""
    # this function isn't automatically tested because it would require
    # network access for the tests and unnecessarily load the online service
    number = compact(number)
    client = get_soap_client(tckimlik_wsdl, timeout)
    result = client.TCKimlikNoDogrula(
        TCKimlikNo=number, Ad=name, Soyad=surname, DogumYili=birth_year)
    if hasattr(result, 'get'):
        return result.get('TCKimlikNoDogrulaResult')
    return result
Esempio n. 12
0
def check_vies_approx(number, requester, timeout=30):  # pragma: no cover
    """Query the online European Commission VAT Information Exchange System
    (VIES) for validity of the provided number, providing a validity
    certificate as proof. You will need to give your own VAT number for this
    to work. Note that the service has usage limitations (see the VIES
    website for details). The timeout is in seconds. This returns a dict-like
    object."""
    # this function isn't automatically tested because it would require
    # network access for the tests and unnecessarily load the VIES website
    number = compact(number)
    requester = compact(requester)
    client = get_soap_client(vies_wsdl, timeout)
    return client.checkVatApprox(
        countryCode=number[:2], vatNumber=number[2:],
        requesterCountryCode=requester[:2], requesterVatNumber=requester[2:])
Esempio n. 13
0
def search_dgii(keyword,
                end_at=10,
                start_at=1,
                timeout=30):  # pragma: no cover
    """Search the DGII online web service using the keyword.

    This uses the validation service run by the the Dirección General de
    Impuestos Internos, the Dominican Republic tax department to search the
    registration information using the keyword.

    The number of entries returned can be tuned with the `end_at` and
    `start_at` arguments. The timeout is in seconds.

    Returns a list of dicts with the following structure::

        [
            {
                'rnc': '123456789',     # The found number
                'name': 'The registered name',
                'commercial_name': 'An additional commercial name',
                'status': '2',          # 1: inactive, 2: active
                'category': '0',        # always 0?
                'payment_regime': '2',  # 1: N/D, 2: NORMAL, 3: PST
                'result_number': '1',   # index of the result
            },
            ...
        ]

    Will return an empty list if the number is invalid or unknown."""
    # this function isn't automatically tested because it would require
    # network access for the tests and unnecessarily load the online service
    client = get_soap_client(dgii_wsdl, timeout)
    results = client.GetContribuyentes(
        value=keyword,
        patronBusqueda=1,  # search type: 0=by number, 1=by name
        inicioFilas=start_at,  # start result (1-based)
        filaFilas=end_at,  # end result
        IMEI='')
    if results and 'GetContribuyentesResult' in results:
        results = results['GetContribuyentesResult']  # PySimpleSOAP only
    if results == '0':
        return []
    return [_convert_result(result) for result in results.split('@@@')]
Esempio n. 14
0
def search_dgii(keyword, end_at=10, start_at=1, timeout=30):  # pragma: no cover
    """Search the DGII online web service using the keyword.

    This uses the validation service run by the the Dirección General de
    Impuestos Internos, the Dominican Republic tax department to search the
    registration information using the keyword.

    The number of entries returned can be tuned with the `end_at` and
    `start_at` arguments. The timeout is in seconds.

    Returns a list of dicts with the following structure::

        [
            {
                'rnc': '123456789',     # The found number
                'name': 'The registered name',
                'commercial_name': 'An additional commercial name',
                'status': '2',          # 1: inactive, 2: active
                'category': '0',        # always 0?
                'payment_regime': '2',  # 1: N/D, 2: NORMAL, 3: PST
                'result_number': '1',   # index of the result
            },
            ...
        ]

    Will return an empty list if the number is invalid or unknown."""
    # this function isn't automatically tested because it would require
    # network access for the tests and unnecessarily load the online service
    client = get_soap_client(dgii_wsdl, timeout)
    results = client.GetContribuyentes(
        value=keyword,
        patronBusqueda=1,       # search type: 0=by number, 1=by name
        inicioFilas=start_at,   # start result (1-based)
        filaFilas=end_at,       # end result
        IMEI='')
    if results and 'GetContribuyentesResult' in results:
        results = results['GetContribuyentesResult']  # PySimpleSOAP only
    if results == '0':
        return []
    return [_convert_result(result) for result in results.split('@@@')]