» Tax Code SDK Documentation

Getting All Tax Code

Function: admin_tax_code_get_list()

Purpose

The admin_tax_code_get_list() function retrieves a list of tax codes with optional parameters for pagination and sorting. It is useful for fetching tax code details in an e-commerce system to manage tax rules.

Parameters

ParameterTypeDescription
limitStringThe number of tax codes to retrieve per page. If not specified, fetches the default amount.
offsetIntegerThe starting point for fetching tax codes. Useful for pagination.
directionStringThe direction to sort the tax codes (e.g., ASC or DESC).
order_byStringThe field by which to sort the tax codes.

Use Case

The function is essential for administrators who need to fetch tax codes. It helps in managing tax rules, rates, and descriptions, which is crucial for compliance and accurate taxation.

def admin_tax_code_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_codes.list(limit="TAX_CODE_LIMIT")
        print(response)
    except WCException as ab:
        print(ab)
        print(ab.get_errors())
        print(ab.raw_response)

Response

TaxCodesListResponseDTO(
    taxCodes=[
        TaxCodeDataDTO(
            id="TAX_CODE_ID",
            name="TAX_CODE_NAME",
            label="TAX_CODE_LABEL",
            method=None,
            description="TAX_CODE_DESCRIPTION",
            rate="TAX_CODE_RATE",
            resolverType="TAX_CODE_RESOLVER_TYPE",
            priority="TAX_CODE_PRIORITY",
            isDefault="TAX_CODE_IS_DEFAULT"
        )
    ],
    pagination=PaginationDTO(
        records="TOTAL_RECORDS",
        limit="PAGE_LIMIT",
        offset="PAGE_OFFSET",
        nextPage="NEXT_PAGE_URL",
        previousPage="PREVIOUS_PAGE_URL"
    )
)

Getting Specific Tax Code

Function: admin_tax_code_get_details()

Purpose

The admin_tax_code_get_details() function fetches the details of a specific tax code by its unique identifier. It is useful for viewing detailed information about a particular tax code in an e-commerce system.

Parameters

ParameterTypeDescription
idStringThe unique identifier of the tax code to retrieve.

Use Case

Administrators can use this function to retrieve detailed information about a specific tax code, including its rate, description, and priority. This is essential for verifying tax rule configurations.

def admin_tax_code_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_codes.details(id="id")
        print(response)
    except WCException as ab:
        print(ab)
        print(ab.get_errors())
        print(ab.raw_response)

Response

TaxCodesDetailsResponseDTO(
    taxCode=TaxCodeDataDTO(
        id="TAX_CODE_ID",
        name="TAX_CODE_NAME",
        label="TAX_CODE_LABEL",
        method=None,
        description="TAX_CODE_DESCRIPTION",
        rate="TAX_CODE_RATE",
        resolverType="TAX_CODE_RESOLVER_TYPE",
        priority="TAX_CODE_PRIORITY",
        isDefault="TAX_CODE_IS_DEFAULT"
    )
)

Creating Tax Code

Function: admin_create_tax_code()

Purpose

The admin_create_tax_code() function allows administrators to create a new tax code with attributes like name, description, label, method, rate, and default status. It is useful for configuring tax rules in an e-commerce system.

Parameters

ParameterTypeDescription
nameStringThe name of the tax code.
descriptionStringBrief description of the tax code.
labelStringLabel describing the tax code.
methodStringThe method used for tax calculation.
rateFloatThe rate of tax to be applied.
isDefaultBooleanIndicates whether this tax code is the default.

Use Case

Administrators use this function to create tax codes needed for different products or services. This is essential for maintaining tax compliance and ensuring correct taxation across transactions.

def admin_create_tax_code():
    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 = TaxCodesDetailsRequestDTO(
            taxCode=TaxCodeDataDTO(
                name="TAX_CODE_NAME",
                description="TAX_CODE_DESCRIPTION",
                label="TAX_CODE_LABEL",
                method="TAX_CODE_METHOD",
                rate="TAX_CODE_RATE",
                isDefault="TAX_CODE_IS_DEFAULT"
            )
        )
        response = webcommander_sdk.admin_tax_codes.create_tax_codes(request_data=request_data)
        print(response)
    except WCException as ab:
        print(ab)
        print(ab.get_errors())
        print(ab.raw_response)

Response

TaxCodesCreationDetailsResponseDTO(
    taxCode=TaxCodeDataDTO(
        id="TAX_CODE_ID",
        name="TAX_CODE_NAME",
        label="TAX_CODE_LABEL",
        method="TAX_CODE_METHOD",
        description="TAX_CODE_DESCRIPTION",
        rate="TAX_CODE_RATE",
        resolverType="TAX_CODE_RESOLVER_TYPE",
        priority="TAX_CODE_PRIORITY",
        isDefault="TAX_CODE_IS_DEFAULT"
    )
)

Updating Tax Code

Function: admin_update_tax_code()

Purpose

The admin_update_tax_code() function updates the details of an existing tax code identified by its unique ID. It is useful for modifying tax rules, rates, and descriptions in an e-commerce system.

Parameters

Parameter Type Description
id String The unique identifier of the tax code to update.
name String The updated name of the tax code.
label String The updated label for the tax code.
description String A brief description of the tax code.
method String The method of tax calculation (e.g., FLAT_RATE).
rate Float The updated tax rate percentage.
isDefault Boolean Indicates whether this is the default tax code.

Use Case

This function is essential for maintaining accurate tax configurations. Administrators can modify tax details to reflect changes in tax laws or organizational policies.

def admin_update_tax_code():
    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_CODE_ID"
        request_data = TaxCodesDetailsRequestDTO(
            taxCode=TaxCodeDataDTO(
                name="TAX_CODE_NAME_UPDATED",
                label="TAX_CODE_LABEL_UPDATED",
                description="TAX_CODE_DESCRIPTION_UPDATED",
                method="TAX_CODE_METHOD",
                rate="TAX_CODE_RATE",
                isDefault="TAX_CODE_IS_DEFAULT"
            )
        )
        response = webcommander_sdk.admin_tax_codes.update_tax_codes(id=id, request_data=request_data)
        print(response)
    except WCException as ab:
        print(ab)
        print(ab.get_errors())
        print(ab.raw_response)

Response

TaxCodesCreationDetailsResponseDTO(
    taxCode=TaxCodeDataDTO(
        id="TAX_CODE_ID",
        name="TAX_CODE_NAME_UPDATED",
        label="TAX_CODE_LABEL_UPDATED",
        method="TAX_CODE_METHOD",
        description="TAX_CODE_DESCRIPTION_UPDATED",
        rate="TAX_CODE_RATE",
        resolverType="TAX_CODE_RESOLVER_TYPE",
        priority="TAX_CODE_PRIORITY",
        isDefault="TAX_CODE_IS_DEFAULT"
    )
)

Deleting Tax  Code

Function: admin_delete_tax_code()

Purpose

The admin_delete_tax_code() function deletes a specified tax code by its unique identifier. It is useful for removing outdated or incorrect tax codes from the system.

Parameters

ParameterTypeDescription
idStringThe unique identifier of the tax code to delete.

Use Case

Administrators can use this function to delete a tax code when it is no longer needed or was created incorrectly. It helps maintain accurate and up-to-date tax code records.

def admin_delete_tax_code():
    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_CODE_ID"
        response = webcommander_sdk.admin_tax_codes.delete_tax_code(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.