» Tax Zone SDK Documentation

Getting All Tax Zones

Function: admin_tax_zones_get_list()

Purpose

This function retrieves a list of tax zones available within the system for administrative purposes. It is designed to fetch and display tax zone details, including system-generated and custom-defined zones. This helps administrators manage tax configurations by providing insights into the geographical tax zones and their associated metadata.

Parameters

ParameterTypeDescription
limitstringThe number of categories to retrieve per page. If not specified, it fetches the default amount.
offsetintThe starting point for fetching categories. Useful for pagination, specifies the index to begin.
directionstringThe direction to sort the categories.
order_bystringThe field by which to sort the categories.

Use Case

The admin_tax_zones_get_list() function is essential for administrators to monitor and manage tax zones effectively. By fetching a limited list of tax zones, it allows administrators to audit tax regions, verify system-generated zones, and ensure accurate tax application. It is useful in scenarios where tax rules vary by location or need frequent updates to comply with regional regulations.

def admin_tax_zones_get_list():
    SDKConfig.PRINT_REQUEST_DATA = False
    SDKConfig.PRINT_RAW_RESPONSE = False

    webcommander_sdk: WebCommanderSDK = WebCommanderSDK().init_sdk(request_token_dto=CommonData.get_request_token_dto())

    try:
        response = webcommander_sdk.admin_tax_zones.list(limit="limit")
        print(response)
    except WCException as ab:
        print(ab)
        print(ab.get_errors())
        print(ab.raw_response)

Response

TaxZonesListResponseDTO(
    taxZones=[
        TaxZoneDataDTO(
            id='TAX_ZONE_ID_1',
            name='TAX_ZONE_NAME_1',
            isSystemGenerated=False,
            default=False,
            useRadius=False,
            radius=None,
            startLocation=None,
            countries=[
                CountryDataDTO(
                    id='COUNTRY_ID_1',
                    name='COUNTRY_NAME_1',
                    code='COUNTRY_CODE_1'
                )
            ],
            states=[],
            postCode=[['']],
            createdAt='TAX_ZONE_CREATED_AT_1',
            updatedAt='TAX_ZONE_UPDATED_AT_1'
        ),
        TaxZoneDataDTO(
            id='TAX_ZONE_ID_2',
            name='TAX_ZONE_NAME_2',
            isSystemGenerated=True,
            default=True,
            useRadius=False,
            radius=None,
            startLocation=None,
            countries=[
                CountryDataDTO(
                    id='COUNTRY_ID_2',
                    name='COUNTRY_NAME_2',
                    code='COUNTRY_CODE_2'
                )
            ],
            states=[
                {
                    'id': 'STATE_ID_1',
                    'name': 'STATE_NAME_1',
                    'code': 'STATE_CODE_1'
                }
            ],
            postCode=[],
            createdAt='TAX_ZONE_CREATED_AT_2',
            updatedAt='TAX_ZONE_UPDATED_AT_2'
        )
    ],
    pagination=PaginationDTO(
        records='TOTAL_RECORDS',
        limit='PAGE_LIMIT',
        offset='PAGE_OFFSET',
        nextPage='NEXT_PAGE_URL',
        previousPage='PREVIOUS_PAGE_URL'
    )
)

Getting Specific Tax Zone

Function: admin_tax_zones_get_details()

Purpose

This function retrieves the detailed information of a specific tax zone identified by its unique ID. It is used to fetch comprehensive metadata about the tax zone, including geographical details, system generation status, and associated countries and states. This aids administrators in auditing and managing specific tax regions effectively.

Parameters

ParameterTypeDescription
idstringThe unique identifier of the tax zone to retrieve details for.

Use Case

The admin_tax_zones_get_details() function is essential for administrators who need to inspect the configuration of individual tax zones. It is particularly useful for verifying the accuracy of tax settings, regional inclusions, and system-generated zone properties. This helps maintain compliance with regional tax regulations and supports troubleshooting of tax application issues.

def admin_tax_zones_get_details():
    SDKConfig.PRINT_REQUEST_DATA = False
    SDKConfig.PRINT_RAW_RESPONSE = False

    webcommander_sdk: WebCommanderSDK = WebCommanderSDK().init_sdk(request_token_dto=CommonData.get_request_token_dto())

    try:
        response = webcommander_sdk.admin_tax_zones.details(id=id)
        print(response)
    except WCException as ab:
        print(ab)
        print(ab.get_errors())
        print(ab.raw_response)

Response

TaxZonesDetailsResponseDTO(
    taxZone=TaxZoneDataDTO(
        id='TAX_ZONE_ID',
        name='TAX_ZONE_NAME',
        isSystemGenerated=True,
        default=True,
        useRadius=False,
        radius=None,
        startLocation=None,
        countries=[
            CountryDataDTO(
                id='COUNTRY_ID',
                name='COUNTRY_NAME',
                code='COUNTRY_CODE'
            )
        ],
        states=[
            {
                'id': 'STATE_ID',
                'name': 'STATE_NAME',
                'code': 'STATE_CODE'
            }
        ],
        postCode=[],
        createdAt='TAX_ZONE_CREATED_AT',
        updatedAt='TAX_ZONE_UPDATED_AT'
    )
)

Creating Tax Zone

Function: admin_create_tax_zones()

Purpose

This function retrieves the detailed information of a specific tax zone identified by its unique ID. It is used to fetch comprehensive metadata about the tax zone, including geographical details, system generation status, and associated countries and states. This aids administrators in auditing and managing specific tax regions effectively.

Parameters

ParameterTypeDescription
namestringThe name of the tax zone.
isSystemGeneratedbooleanIndicates if the zone is system-generated.
defaultbooleanSpecifies if this is the default tax zone.
useRadiusbooleanIndicates whether the tax zone uses a radius.
radiusfloatThe radius value if useRadius is True.
startLocationstringThe starting location for radius-based zones.
countrieslistA list of countries included in the tax zone with their IDs, names, and codes.
stateslistA list of states included in the tax zone.
createdAtstringTimestamp when the tax zone was created.
updatedAtstringTimestamp when the tax zone was last updated.

Use Case

The admin_create_tax_zones() function is essential for administrators who need to inspect the configuration of individual tax zones. It is particularly useful for verifying the accuracy of tax settings, regional inclusions, and system-generated zone properties. This helps maintain compliance with regional tax regulations and supports troubleshooting of tax application issues.

def admin_create_tax_zones():
    SDKConfig.PRINT_REQUEST_DATA = False
    SDKConfig.PRINT_RAW_RESPONSE = False

    webcommander_sdk: WebCommanderSDK = WebCommanderSDK().init_sdk(request_token_dto=CommonData.get_request_token_dto())

    try:
        request_data = TaxZonesDetailsRequestDTO(
            taxZone=TaxZoneDataDTO(
                name="TAX_ZONE_NAME",
                isSystemGenerated=False,
                default=False,
                useRadius=False,
                radius=1.2,
                startLocation="START_LOCATION",
                countries=[
                    CountryDataDTO(
                        id='COUNTRY_ID',
                        name="COUNTRY_NAME",
                        code="COUNTRY_CODE"
                    )
                ],
                states=[],
                createdAt="TAX_ZONE_CREATED_AT",
                updatedAt="TAX_ZONE_UPDATED_AT"
            )
        )
        response = webcommander_sdk.admin_tax_zones.create_tax_zones(request_data=request_data)
        print(response)
    except WCException as e:
        print(e)
        print(e.get_errors())
        print(e.raw_response)

Response

TaxZonesDetailsResponseDTO(
    taxZone=TaxZoneDataDTO(
        id='TAX_ZONE_ID',
        name='TAX_ZONE_NAME',
        isSystemGenerated=False,
        default=False,
        useRadius=False,
        radius=None,
        startLocation=None,
        countries=[
            CountryDataDTO(
                id='COUNTRY_ID',
                name='COUNTRY_NAME',
                code='COUNTRY_CODE'
            )
        ],
        states=[],
        postCode=[],
        createdAt='TAX_ZONE_CREATED_AT',
        updatedAt='TAX_ZONE_UPDATED_AT'
    )
)

Updating Tax Zone

Function: admin_update_tax_zones()

Purpose

This function updates an existing tax zone with new parameters such as the zone name, radius, geographical location, and associated countries and states. It is useful for modifying tax regions and applying updated tax rules in an e-commerce environment.

Parameters

ParameterTypeDescription
idstringThe unique identifier of the tax zone to be updated.
namestringThe updated name of the tax zone.
isSystemGeneratedbooleanIndicates if the zone is system-generated.
defaultbooleanSpecifies if this is the default tax zone.
useRadiusbooleanIndicates whether the tax zone uses a radius.
radiusfloatThe radius value if useRadius is True.
startLocationstringThe starting location for radius-based zones.
countrieslistA list of countries included in the tax zone with their IDs, names, and codes.
stateslistA list of states included in the tax zone.
createdAtstringTimestamp when the tax zone was created.
updatedAtstringTimestamp when the tax zone was last updated.

Use Case

The admin_update_tax_zones() function is essential for administrators who need to modify existing tax regions. This is particularly useful when adjusting geographical coverage or tax rules due to policy changes or business expansion.

def admin_update_tax_zones():
    SDKConfig.PRINT_REQUEST_DATA = False
    SDKConfig.PRINT_RAW_RESPONSE = False

    webcommander_sdk: WebCommanderSDK = WebCommanderSDK().init_sdk(request_token_dto=CommonData.get_request_token_dto())

    try:
        id = 'TAX_ZONE_ID'
        request_data = TaxZonesDetailsRequestDTO(
            taxZone=TaxZoneDataDTO(
                name="UPDATED_TAX_ZONE_NAME",
                isSystemGenerated=False,
                default=False,
                useRadius=False,
                radius=1.2,
                startLocation="UPDATED_START_LOCATION",
                countries=[
                    CountryDataDTO(
                        id='COUNTRY_ID',
                        name="COUNTRY_NAME",
                        code="COUNTRY_CODE"
                    )
                ],
                states=[],
                createdAt="TAX_ZONE_CREATED_AT",
                updatedAt="TAX_ZONE_UPDATED_AT"
            )
        )
        response = webcommander_sdk.admin_tax_zones.update_tax_zones(id=id, request_data=request_data)
        print(response)
    except WCException as error:
        print(error)
        print(error.get_errors())
        print(error.raw_response)

Response

{
  "taxZone": {
    "id": TAX_ZONE_ID,
    "name": "TAX_ZONE_NAME",
    "isSystemGenerated": IS_SYSTEM_GENERATED,
    "default": IS_DEFAULT,
    "useRadius": USE_RADIUS,
    "radius": RADIUS_VALUE,
    "startLocation": START_LOCATION,
    "countries": [
      {
        "id": COUNTRY_ID,
        "name": "COUNTRY_NAME",
        "code": "COUNTRY_CODE"
      }
    ],
    "states": [],
    "postCode": [],
    "createdAt": "CREATED_AT_TIMESTAMP",
    "updatedAt": "UPDATED_AT_TIMESTAMP"
  }
}

Deleting Tax Zone

Function: admin_delete_tax_zones()

Purpose

This function deletes an existing tax zone identified by its unique ID. It is useful for removing obsolete or incorrect tax zones from the system.

Parameters

ParameterTypeDescription
idstrThe unique identifier of the tax zone to be deleted.

Use Case

The admin_delete_tax_zones() function is essential for administrators who need to clean up or manage tax zones. This ensures the system reflects accurate tax region information.

def admin_delete_tax_zones():
    SDKConfig.PRINT_REQUEST_DATA = False
    SDKConfig.PRINT_RAW_RESPONSE = False

    webcommander_sdk: WebCommanderSDK = WebCommanderSDK().init_sdk(request_token_dto=CommonData.get_request_token_dto())

    try:
        response = webcommander_sdk.admin_tax_zones.delete_tax_zones(id="id")
        print(response)
    except WCException as ab:
        print(ab)
        print(ab.get_errors())
        print(ab.raw_response)

Response

This function returns an HTTP 204 No Content status, indicating that the blog post has been successfully deleted and there is no additional response body.