Public/ServiceTaxOverrides/New-AspireServiceTaxOverride.ps1

<#
.SYNOPSIS
    Creates a new service tax override in the Aspire API.
.DESCRIPTION
    Uses Invoke-AspireRequest to perform a POST request to the /ServiceTaxOverrides endpoint.
.PARAMETER ServiceID
    The ID of the service (optional).
.PARAMETER StateProvinceCode
    The state/province code (required).
.PARAMETER LaborTaxable
    Whether labor is taxable (optional).
.PARAMETER MaterialTaxable
    Whether material is taxable (optional).
.PARAMETER EquipmentTaxable
    Whether equipment is taxable (optional).
.PARAMETER SubTaxable
    Whether sub is taxable (optional).
.PARAMETER OtherTaxable
    Whether other is taxable (optional).
.OUTPUTS
    The response from the API containing the result.
.EXAMPLE
    New-AspireServiceTaxOverride -StateProvinceCode "CA" -LaborTaxable $true
#>

function New-AspireServiceTaxOverride {
    [CmdletBinding()]
    param(
        [int]$ServiceID = $null,
        [Parameter(Mandatory = $true)]
        [string]$StateProvinceCode,
        [bool]$LaborTaxable = $null,
        [bool]$MaterialTaxable = $null,
        [bool]$EquipmentTaxable = $null,
        [bool]$SubTaxable = $null,
        [bool]$OtherTaxable = $null
    )

    $body = @{
        StateProvinceCode = $StateProvinceCode
    }

    if ($ServiceID) {
        $body.ServiceID = $ServiceID
    }
    if ($LaborTaxable -ne $null) {
        $body.LaborTaxable = $LaborTaxable
    }
    if ($MaterialTaxable -ne $null) {
        $body.MaterialTaxable = $MaterialTaxable
    }
    if ($EquipmentTaxable -ne $null) {
        $body.EquipmentTaxable = $EquipmentTaxable
    }
    if ($SubTaxable -ne $null) {
        $body.SubTaxable = $SubTaxable
    }
    if ($OtherTaxable -ne $null) {
        $body.OtherTaxable = $OtherTaxable
    }

    return Invoke-AspireRequest -Method POST -Path "/ServiceTaxOverrides" -Body $body -ApiVersion $null
}