Public/Receipts/Invoke-AspireReceiptApprove.ps1

<#
.SYNOPSIS
    Approves a receipt in the Aspire API.
.DESCRIPTION
    Uses Invoke-AspireRequest to perform a POST request to the /Receipts/Approve endpoint.
.PARAMETER ReceiptID
    The ID of the receipt to approve (required).
.PARAMETER Receive
    Optional boolean indicating whether to receive the receipt.
.PARAMETER VendorInvoiceNum
    Optional vendor invoice number (max 50 characters).
.PARAMETER VendorInvoiceDate
    Optional vendor invoice date (DateTime).
.OUTPUTS
    The response from the API (boolean).
.EXAMPLE
    Invoke-AspireReceiptApprove -ReceiptID 123 -Receive $true
#>

function Invoke-AspireReceiptApprove {
    [CmdletBinding()]
    param(
        [Parameter(Mandatory = $true)]
        [int]$ReceiptID,
        [bool]$Receive = $null,
        [string]$VendorInvoiceNum = $null,
        [DateTime]$VendorInvoiceDate = $null
    )

    $body = @{
        ReceiptID = $ReceiptID
    }

    if ($PSBoundParameters.ContainsKey('Receive')) { $body.Receive = $Receive }
    if ($VendorInvoiceNum) { $body.VendorInvoiceNum = $VendorInvoiceNum }
    if ($VendorInvoiceDate) { $body.VendorInvoiceDate = $VendorInvoiceDate.ToString("o") }

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