» Tax Rule SDK Documentation

Getting All Tax Rules

Function: admin_tax_rules_get_list()

Purpose

The admin_tax_rules_get_list() function is designed to retrieve a list of tax rules from the system. This function provides an easy way to access all tax rules that have been configured, including their associated details like names, codes, descriptions, and tax zones. It supports efficient management of tax rules across different regions and ensures that businesses are able to review and manage all applicable tax regulations quickly.

Parameters

This function does not require any input parameters.

Use Case

This function is useful for administrators or tax managers who need to view all available tax rules within the system. For example, if a business is reviewing all the tax rules applied across multiple regions, this function can be used to fetch a comprehensive list. It can also be used to check which tax rules are currently active, as well as their associated attributes like tax codes and zones, making it easier to update or review tax settings across various jurisdictions.

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

Response

The function returns a TaxRulesListResponseDTO, which contains a list of TaxRuleDTO objects. Each TaxRuleDTO provides key information about the individual tax rule, including the id, name, associated tax_code, description, default status, and the tax zones it applies to. The response also includes timestamps for when each tax rule was created and last updated. Additionally, the response supports pagination, allowing users to fetch large datasets efficiently.

TaxRulesListResponseDTO(
    taxRules=[
        TaxRuleDTO(
            id=PLACEHOLDER_ID,
            name="PLACEHOLDER_NAME",
            code=TaxCodeDTO(
                id=PLACEHOLDER_ID,
                name="PLACEHOLDER_CODE_NAME",
                isDefault=PLACEHOLDER_IS_DEFAULT
            ),
            description="PLACEHOLDER_DESCRIPTION",
            default=PLACEHOLDER_DEFAULT,
            roundingType="PLACEHOLDER_ROUNDING_TYPE",
            decimalPoint=PLACEHOLDER_DECIMAL_POINT,
            zones=[
                TaxZoneDTO(
                    id=PLACEHOLDER_ZONE_ID,
                    name="PLACEHOLDER_ZONE_NAME",
                    isSystemGenerated=PLACEHOLDER_IS_SYSTEM_GENERATED,
                    isDefault=PLACEHOLDER_IS_DEFAULT
                )
            ],
            createdAt="PLACEHOLDER_CREATED_AT",
            updatedAt="PLACEHOLDER_UPDATED_AT",
            taxProfileId=PLACEHOLDER_TAX_PROFILE_ID
        )
    ],
    pagination=PaginationDTO(
        records=PLACEHOLDER_RECORDS,
        limit=PLACEHOLDER_LIMIT,
        offset=PLACEHOLDER_OFFSET,
        nextPage=PLACEHOLDER_NEXT_PAGE,
        previousPage=PLACEHOLDER_PREVIOUS_PAGE
    )
)

Getting Specific Tax Rule

Function: admin_tax_rules_get_details() 

Purpose

The admin_tax_rules_get_details() function is designed to retrieve detailed information about a specific tax rule by its unique identifier. This function provides comprehensive information about the tax rule, including its name, tax code, associated zones, and metadata such as creation and update timestamps.

Parameters

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

Use Case

This function is useful for administrators who need to review or manage specific tax rules. For instance, if an admin wants to verify the configuration of a particular tax rule applied to a specific region, they can fetch the complete details using this function. This is particularly helpful when troubleshooting tax calculation issues or ensuring compliance with updated tax regulations.

def admin_tax_rules_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 = PLACEHOLDER_ID
        response = webcommander_sdk.admin_tax_rules.details(id=id)
        print(response)
    except WCException as ab:
        print(ab)
        print(ab.get_errors())
        print(ab.raw_response)

Response

The function returns a TaxRulesDetailsResponseDTO object containing a TaxRuleDTO. This object includes detailed information such as the tax rule’s unique identifier, name, associated tax code, applicable zones, and timestamps indicating when the rule was created and last updated. This detailed response allows for in-depth inspection and validation of the tax rule's configuration.

TaxRulesDetailsResponseDTO(
    taxRule=TaxRuleDTO(
        id=PLACEHOLDER_ID,
        name="PLACEHOLDER_NAME",
        code=TaxCodeDTO(
            id=PLACEHOLDER_CODE_ID,
            name="PLACEHOLDER_CODE_NAME",
            isDefault=PLACEHOLDER_IS_DEFAULT
        ),
        description="PLACEHOLDER_DESCRIPTION",
        default=PLACEHOLDER_DEFAULT,
        roundingType="PLACEHOLDER_ROUNDING_TYPE",
        decimalPoint=PLACEHOLDER_DECIMAL_POINT,
        zones=[
            TaxZoneDTO(
                id=PLACEHOLDER_ZONE_ID,
                name="PLACEHOLDER_ZONE_NAME",
                isSystemGenerated=PLACEHOLDER_IS_SYSTEM_GENERATED,
                isDefault=PLACEHOLDER_IS_DEFAULT
            )
        ],
        createdAt="PLACEHOLDER_CREATED_AT",
        updatedAt="PLACEHOLDER_UPDATED_AT",
        taxProfileId=PLACEHOLDER_TAX_PROFILE_ID
    )
)

Creating Specific Tax Rules

Function: admin_create_tax_rules() 

Purpose

The admin_create_tax_rules() function is responsible for creating a new tax rule. It takes the necessary details, such as the tax rule name, description, and associated tax profile, and sends them to the system. This function enables the addition of new tax rules to manage different taxation scenarios.

Parameters

Parameter Type Description
name String The name of the tax rule to be created.
description String A description for the new tax rule.
taxProfileId String The ID of the tax profile under which this rule will be created.

Use Case

The function can be used when an administrator needs to define a new tax rule for a specific tax profile. For example, it can be used to create region-specific tax rules or add custom taxation requirements. This is particularly useful for maintaining compliance across multiple geographic areas and handling complex tax regulations.

def admin_create_tax_rules():
    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 = TaxRulesDetailsRequestDTO(
            taxRule=TaxRuleDTO(
                name="PLACEHOLDER_NAME",
                description="PLACEHOLDER_DESCRIPTION",
                taxProfileId="PLACEHOLDER_TAX_PROFILE_ID"
            )
        )
        response = webcommander_sdk.admin_tax_rules.create_tax_rules(request_data=request_data)
        print(response)
    except WCException as ab:
        print(ab)
        print(ab.get_errors())
        print(ab.raw_response)

Response

The function returns a TaxRulesDetailsResponseDTO object containing a TaxRuleDTO object. This object includes the newly created tax rule's details, such as its unique identifier (id), name, description, tax profile association, and timestamps. If the creation fails, an error message is returned.

TaxRulesDetailsResponseDTO(
    taxRule=TaxRuleDTO(
        id=PLACEHOLDER_ID,
        name="PLACEHOLDER_NAME",
        code=TaxCodeDTO(
            id=PLACEHOLDER_CODE_ID,
            name="PLACEHOLDER_CODE_NAME",
            isDefault=PLACEHOLDER_IS_DEFAULT
        ),
        description="PLACEHOLDER_DESCRIPTION",
        default=PLACEHOLDER_DEFAULT,
        roundingType="PLACEHOLDER_ROUNDING_TYPE",
        decimalPoint=PLACEHOLDER_DECIMAL_POINT,
        zones=[
            TaxZoneDTO(
                id=PLACEHOLDER_ZONE_ID,
                name="PLACEHOLDER_ZONE_NAME",
                isSystemGenerated=PLACEHOLDER_IS_SYSTEM_GENERATED,
                isDefault=PLACEHOLDER_IS_DEFAULT
            )
        ],
        createdAt="PLACEHOLDER_CREATED_AT",
        updatedAt="PLACEHOLDER_UPDATED_AT",
        taxProfileId=PLACEHOLDER_TAX_PROFILE_ID
    )
)

Updating Specific Tax Rules

Function: admin_update_tax_rules() 

Purpose

The admin_update_tax_rules function updates an existing tax rule by modifying its properties, such as the name and description. This function allows administrators to change the attributes of a specific tax rule based on the provided id. It is useful for keeping tax rules current and aligned with legal and business requirements.

Parameters

Parameter Type Description
id String The ID of the tax rule to be updated.
name String The new name for the tax rule.
description String The updated description for the tax rule.

Use Case

The function can be used when an administrator needs to update the details of an existing tax rule. For instance, if the tax rule name or description requires modification due to regulatory changes or internal policy updates, this function provides a reliable way to make those changes.

def admin_update_tax_rules():
    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 = TaxRulesDetailsRequestDTO(
            taxRule=TaxRuleDTO(
                name="PLACEHOLDER_NAME",
                description="PLACEHOLDER_DESCRIPTION"
            )
        )
        id = "PLACEHOLDER_ID"
        response = webcommander_sdk.admin_tax_rules.update_tax_rules(id=id, request_data=request_data)
        print(response)
    except WCException as ab:
        print(ab)
        print(ab.get_errors())
        print(ab.raw_response)

Response

The function returns a TaxRulesDetailsResponseDTO object containing the updated TaxRuleDTO. This object includes information about the modified tax rule, such as its id, updated name, updated description, and timestamps for when the rule was created and updated. If the update fails, an error message is returned.

TaxRulesDetailsResponseDTO(
    taxRule=TaxRuleDTO(
        id=PLACEHOLDER_ID,
        name="PLACEHOLDER_NAME",
        code=TaxCodeDTO(
            id=PLACEHOLDER_CODE_ID,
            name="PLACEHOLDER_CODE_NAME",
            isDefault=PLACEHOLDER_IS_DEFAULT
        ),
        description="PLACEHOLDER_DESCRIPTION",
        default=PLACEHOLDER_DEFAULT,
        roundingType="PLACEHOLDER_ROUNDING_TYPE",
        decimalPoint=PLACEHOLDER_DECIMAL_POINT,
        zones=[
            TaxZoneDTO(
                id=PLACEHOLDER_ZONE_ID,
                name="PLACEHOLDER_ZONE_NAME",
                isSystemGenerated=PLACEHOLDER_IS_SYSTEM_GENERATED,
                isDefault=PLACEHOLDER_IS_DEFAULT
            )
        ],
        createdAt="PLACEHOLDER_CREATED_AT",
        updatedAt="PLACEHOLDER_UPDATED_AT",
        taxProfileId=PLACEHOLDER_TAX_PROFILE_ID
    )
)

Deleting Tax Rules

Function: admin_tax_rules_delete()

Purpose

This function permanently removes a specific tax rule from the system using its unique identifier. This function is critical for maintaining clean tax rule sets by allowing administrators to remove obsolete or incorrect tax configurations.

Parameters

ParameterTypeDescription
idStringThe unique identifier of the tax rule to be deleted

Use Case

This function permanently deletes tax rules, typically during tax law updates or system cleanups. It removes obsolete or incorrect regulations to maintain accurate tax calculations.

def admin_tax_rules_delete():
    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_RULE_ID'
        response = webcommander_sdk.admin_tax_rules.tax_rules_delete(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 rule has been successfully deleted and there is no additional response body.