Public/Remove-Biller.ps1
|
function Remove-Biller { <# .SYNOPSIS Removes a biller entry. .DESCRIPTION Deletes a biller from the data store by ID. .PARAMETER Id The ID of the biller to remove. .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 Remove-Biller -Id "abc123" .EXAMPLE Remove-Biller -Id "abc123" -Budget "daily-expenses" .OUTPUTS None #> [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')] param( [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [string]$Id, [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 ($PSCmdlet.ShouldProcess($biller.Name, "Remove biller")) { $updatedBillers = @($billers | Where-Object { $_.Id -ne $Id }) if (Write-EntityData -EntityType 'Biller' -Data $updatedBillers -DataPath $resolvedPath) { Write-Verbose "Removed biller: $($biller.Name)" } } } } |