Public/PayCodes/New-AspirePayCode.ps1

<#
.SYNOPSIS
    Creates a new pay code in the Aspire API.
.DESCRIPTION
    Uses Invoke-AspireRequest to perform a POST request to the /PayCodes endpoint.
.PARAMETER PayCodeName
    The name of the pay code (required, max 60 characters).
.PARAMETER PremiumDollars
    Optional premium dollars amount.
.PARAMETER PremiumPercent
    Optional premium percentage.
.PARAMETER FixedRate
    Optional fixed rate.
.PARAMETER ExcludeFromOT
    Optional boolean indicating if excluded from overtime.
.PARAMETER PayCode
    Optional pay code string (max 10 characters).
.PARAMETER OTPaycode
    Optional boolean indicating if it's an OT pay code.
.PARAMETER Active
    Optional boolean indicating if active (default: true).
.PARAMETER PayCodeType
    Optional pay code type.
.OUTPUTS
    The response from the API containing the pay code details.
.EXAMPLE
    New-AspirePayCode -PayCodeName "Regular Pay" -Active $true
#>

function New-AspirePayCode {
    [CmdletBinding()]
    param(
        [Parameter(Mandatory = $true)]
        [string]$PayCodeName,
        [decimal]$PremiumDollars = $null,
        [decimal]$PremiumPercent = $null,
        [decimal]$FixedRate = $null,
        [bool]$ExcludeFromOT = $null,
        [string]$PayCode = $null,
        [bool]$OTPaycode = $null,
        [bool]$Active = $true,
        [string]$PayCodeType = $null
    )

    $body = @{
        PayCodeName = $PayCodeName
        Active = $Active
    }

    if ($PremiumDollars) {
        $body.PremiumDollars = $PremiumDollars
    }
    if ($PremiumPercent) {
        $body.PremiumPercent = $PremiumPercent
    }
    if ($FixedRate) {
        $body.FixedRate = $FixedRate
    }
    if ($ExcludeFromOT -ne $null) {
        $body.ExcludeFromOT = $ExcludeFromOT
    }
    if ($PayCode) {
        $body.PayCode = $PayCode
    }
    if ($OTPaycode -ne $null) {
        $body.OTPaycode = $OTPaycode
    }
    if ($PayCodeType) {
        $body.PayCodeType = $PayCodeType
    }

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