» Tax Profile SDK Documentation

Getting All Tax Profiles

Function: admin_tax_profiles_get_list()

Purpose

The admin_tax_profiles_get_list() function in the SDK is designed to retrieve a list of all tax profiles available in the system. This function allows you to access detailed information about each tax profile, including its ID, name, description, default status, and timestamps for creation and last update. It is useful for managing tax configurations and ensuring compliance with regional tax regulations.

Parameters

This function does not require any input parameters.

Use Case

The function can be used to fetch and display all tax profiles within the system. For example, an e-commerce platform can use this function to view available tax profiles and determine which profile applies to specific products or customer regions. This function is particularly helpful when integrating or managing tax settings programmatically.

def admin_tax_profiles_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_profiles.list()
        print(response)
    except WCException as ab:
        print(ab)
        print(ab.get_errors())
        print(ab.raw_response)

Response

The function returns a structured response containing a list of tax profiles. Each profile includes details such as the id, name, description, whether it is the default profile, and timestamps for creation and updates. The response also includes pagination information, allowing you to manage large datasets efficiently.

TaxProfileListResponseDTO(
    tax_profiles=[
        TaxProfileDTO(
            id=PLACEHOLDER_ID,
            name=PLACEHOLDER_NAME,
            description=PLACEHOLDER_DESCRIPTION,
            default=PLACEHOLDER_DEFAULT,
            created_at=PLACEHOLDER_CREATED_AT,
            updated_at=PLACEHOLDER_UPDATED_AT
        ),
        TaxProfileDTO(
            id=PLACEHOLDER_ID,
            name=PLACEHOLDER_NAME,
            description=PLACEHOLDER_DESCRIPTION,
            default=PLACEHOLDER_DEFAULT,
            created_at=PLACEHOLDER_CREATED_AT,
            updated_at=PLACEHOLDER_UPDATED_AT
        )
    ],
    pagination=PaginationDTO(
        records=PLACEHOLDER_RECORDS,
        limit=PLACEHOLDER_LIMIT,
        offset=PLACEHOLDER_OFFSET,
        next_page=PLACEHOLDER_NEXT_PAGE,
        previous_page=PLACEHOLDER_PREVIOUS_PAGE
    )
)

Getting Specific Tax Profiles

Function: admin_tax_profiles_get_details() 

Purpose

The admin_tax_profiles_get_details() function in the SDK is designed to retrieve detailed information about a specific tax profile by its unique identifier (id). This function provides comprehensive details about a tax profile, including its name, description, default status, and timestamps for creation and last update. It is useful for viewing and verifying the configuration of a particular tax profile.

Parameters

Parameter
Type
Description
id
String
The unique identifier of the tax profile.

Use Case

The function can be used to fetch and inspect the details of a specific tax profile. For instance, an administrator may want to review the characteristics of a tax profile applied to specific regions or products. This function is especially valuable when you need to ensure that tax information is accurate and up-to-date within an automated system.

def admin_tax_profiles_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:
        id='TAX_PROFILE_ID'
        response = webcommander_sdk.admin_tax_profiles.details(id=id)
        print(response)
    except WCException as ab:
        print(ab)
        print(ab.get_errors())
        print(ab.raw_response)

Response

A successful call to the admin_tax_profiles_get_details() function returns a detailed view of the specified tax profile. The response includes attributes such as the id, name, description, whether it is the default profile, and timestamps for creation and updates.

TaxProfileDetailsResponseDTO(
    tax_profile=TaxProfileDTO(
        id=PLACEHOLDER_ID,
        name=PLACEHOLDER_NAME,
        description=PLACEHOLDER_DESCRIPTION,
        default=PLACEHOLDER_DEFAULT,
        created_at=PLACEHOLDER_CREATED_AT,
        updated_at=PLACEHOLDER_UPDATED_AT
    )
)

Creating Specific Tax Profiles

Function: admin_create_tax_profiles() 

Purpose

The admin_create_tax_profiles function is designed to create a new tax profile using the WebCommander SDK. It allows administrators to define essential tax-related information such as the profile name, description, and whether the tax profile is set as the default. This function is useful for adding new tax profiles to the system, which can later be applied to products or orders.

Parameters

Parameter Type Description
name String The name of the tax profile.
description String A short description of the tax profile.
default Boolean Whether this tax profile should be marked as default.

Use Case

This function is used when there is a need to create a new tax profile with unique identification and specific tax parameters. It is particularly useful for expanding tax configurations, setting up location-specific tax policies, or adding new taxation rules to comply with legal and business requirements. Since the name field must be unique, attempts to create a tax profile with a duplicate name will result in an error.

def admin_create_tax_profiles():
    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 = TaxProfileRequestDTO(
            tax_profile=TaxProfileDTO(
                name=PLACEHOLDER_NAME,
                description=PLACEHOLDER_DESCRIPTION,
                default=PLACEHOLDER_DEFAULT
            )
        )
        response = webcommander_sdk.admin_tax_profiles.create_tax_profiles(request_data=request_data)
        print(response)
    except WCException as ab:
        print(ab)
        print(ab.get_errors())
        print(ab.raw_response)

Response

If the request is successful, the function returns a TaxProfileDetailsResponseDTO object containing the newly created TaxProfileDTO. This object provides detailed information about the created tax profile, including the unique identifier, name, description, and timestamps for creation and updates.

TaxProfileDetailsResponseDTO(
    tax_profile=TaxProfileDTO(
        id=PLACEHOLDER_ID,
        name=PLACEHOLDER_NAME,
        description=PLACEHOLDER_DESCRIPTION,
        default=PLACEHOLDER_DEFAULT,
        created_at=PLACEHOLDER_CREATED_AT,
        updated_at=PLACEHOLDER_UPDATED_AT
    )
)

Updating Specific Tax Profile

Function: admin_update_tax_profiles() 

Purpose

The admin_update_tax_profiles function updates an existing tax profile by modifying its attributes such as name, description, and default status. This function ensures that tax profile information remains accurate and up-to-date in the system. It requires providing the id of the tax profile to be updated along with the updated values.

Parameters

Parameter Type Description
id String The unique identifier of the tax profile to update.
name String The new or updated name for the tax profile.
description String A description describing the tax profile.
default Boolean Whether this profile should be marked as the default one.

Use Case

When you need to change details of an existing tax profile (e.g., updating the profile name, description, or marking it as default), this function allows you to perform those updates. For instance, if a tax regulation changes, you can use this function to update the corresponding tax profile without creating a new one. The function requires a valid tax profile id and a unique name to successfully update the profile.

def admin_update_tax_profiles():
    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 = PLACEHOLDER_ID
        request_data = TaxProfileRequestDTO(
            tax_profile=TaxProfileDTO(
                name=PLACEHOLDER_NAME,
                description=PLACEHOLDER_DESCRIPTION,
                default=PLACEHOLDER_DEFAULT
            )
        )
        response = webcommander_sdk.admin_tax_profiles.update_tax_profiles(id=id, request_data=request_data)
        print(response)
    except WCException as ab:
        print(ab)
        print(ab.get_errors())
        print(ab.raw_response)

Response

Upon successful execution, the function returns an updated TaxProfileDetailsResponseDTO containing the modified tax profile information. This includes the tax profile's unique id, updated name, description, and whether it is set as the default. Additionally, it provides timestamps indicating when the profile was initially created and last updated. This response allows verification that the update was successfully applied and provides a consistent record of the tax profile's state.

TaxProfileDetailsResponseDTO(
    tax_profile=TaxProfileDTO(
        id=PLACEHOLDER_ID,
        name=PLACEHOLDER_NAME,
        description=PLACEHOLDER_DESCRIPTION,
        default=PLACEHOLDER_DEFAULT,
        created_at=PLACEHOLDER_CREATED_AT,
        updated_at=PLACEHOLDER_UPDATED_AT
    )
)

Deleting Tax Profile

Function: admin_delete_tax_profiles()

Purpose

This function permanently removes tax profile configurations from the system. It's typically used during tax system maintenance or reorganizing tax structures to comply with new regulations. The deletion is irreversible and should be used with caution.

Parameters

ParameterTypeDescription
idStringThe unique identifier of the tax profile to be deleted

Use Case

This operation is essential when tax laws change and old profiles become invalid. It's also useful for removing test profiles or consolidating duplicate configurations. Before deletion, ensure the profile isn't referenced by any active tax rules or product categories.

def admin_delete_tax_profiles():
    SDKConfig.PRINT_REQUEST_DATA = True
    SDKConfig.PRINT_RAW_RESPONSE = True

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

    try:
        id='TAX_PROFILE_ID'
        response = webcommander_sdk.admin_tax_profiles.delete_tax_profiles(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 tax profile has been successfully deleted and there is no additional response body.