Public/Get-Earning.ps1

function Get-Earning {
    <#
    .SYNOPSIS
        Retrieves earning entries.
 
    .DESCRIPTION
        Gets one or more earnings from the data store. Can filter by name or ID.
 
    .PARAMETER Name
        Filter earnings by name.
 
    .PARAMETER Id
        Get a specific earning by ID.
 
    .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
        Get-Earning
 
    .EXAMPLE
        Get-Earning -Name "Salary"
 
    .OUTPUTS
        Array of Earning objects
    #>

    [CmdletBinding(DefaultParameterSetName = 'All')]
    param(
        [Parameter(ParameterSetName = 'ByName')]
        [string]$Name,

        [Parameter(ParameterSetName = 'ById')]
        [string]$Id,

        [Parameter()]
        [string]$Budget,

        [Parameter()]
        [string]$DataPath
    )

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

    $earnings = Read-EntityData -EntityType 'Earning' -DataPath $resolvedPath

    if ($PSCmdlet.ParameterSetName -eq 'ByName') {
        $earnings = $earnings | Where-Object { $_.Name -like "*$Name*" }
    }
    elseif ($PSCmdlet.ParameterSetName -eq 'ById') {
        $earnings = $earnings | Where-Object { $_.Id -eq $Id }
    }

    return $earnings
}