Public/Set-Biller.ps1

function Set-Biller {
    <#
    .SYNOPSIS
        Updates an existing biller entry.
 
    .DESCRIPTION
        Modifies properties of an existing biller identified by ID.
 
    .PARAMETER Id
        The ID of the biller to update.
 
    .PARAMETER Name
        New name for the biller.
 
    .PARAMETER StartDate
        New start date for the biller.
 
    .PARAMETER Frequency
        New frequency for the biller.
 
    .PARAMETER Amount
        New amount for the biller.
 
    .PARAMETER Budget
        Optional budget name to target. Uses active budget if not specified.
 
    .PARAMETER DataPath
        Optional custom path for data storage. Overrides budget-based paths.
 
    .EXAMPLE
        Set-Biller -Id "abc123" -Amount 150.00
 
    .EXAMPLE
        Set-Biller -Id "abc123" -Amount 150.00 -Budget "daily-expenses"
 
    .OUTPUTS
        Updated Biller object
    #>

    [CmdletBinding()]
    param(
        [Parameter(Mandatory, ValueFromPipelineByPropertyName)]
        [string]$Id,

        [Parameter()]
        [string]$Name,

        [Parameter()]
        [datetime]$StartDate,

        [Parameter()]
        [ValidateSet('Daily', 'Weekly', 'BiWeekly', 'Monthly', 'Bimonthly', 'Quarterly', 'Yearly')]
        [string]$Frequency,

        [Parameter()]
        [decimal]$Amount,

        [Parameter()]
        [string]$Budget,

        [Parameter()]
        [string]$DataPath
    )

    process {
        $resolvedPath = Resolve-DataPath -DataPath $DataPath -Budget $Budget
        if (-not $resolvedPath) { return }

        $billers = Read-EntityData -EntityType 'Biller' -DataPath $resolvedPath
        $biller = $billers | Where-Object { $_.Id -eq $Id }

        if (-not $biller) {
            Write-Error "Biller with ID '$Id' not found."
            return
        }

        if ($PSBoundParameters.ContainsKey('Name')) { $biller.Name = $Name }
        if ($PSBoundParameters.ContainsKey('StartDate')) { $biller.StartDate = $StartDate }
        if ($PSBoundParameters.ContainsKey('Frequency')) { $biller.Frequency = $Frequency }
        if ($PSBoundParameters.ContainsKey('Amount')) { $biller.Amount = $Amount }

        if (Write-EntityData -EntityType 'Biller' -Data $billers -DataPath $resolvedPath) {
            Write-Verbose "Updated biller: $($biller.Name)"
            return $biller
        }
    }
}