src/Private/Resolve-SkuPrice.ps1
|
function Resolve-SkuPrice { <# .SYNOPSIS Resolves a SKU GUID to its friendly name, part number, and monthly list price. .DESCRIPTION Looks the SKU up in the loaded price-list hashtable. Unknown SKUs return a record with the raw GUID as the name and a zero price so they are surfaced (counted, flagged "price unknown") rather than silently dropped from the report. #> [CmdletBinding()] param( [Parameter(Mandatory)] [string] $SkuId, [Parameter(Mandatory)] [hashtable] $PriceList, [string] $PartNumberHint ) $key = $SkuId.ToLowerInvariant() if ($PriceList.ContainsKey($key)) { return $PriceList[$key] } $displayName = if ($PartNumberHint) { "$PartNumberHint (price unknown)" } else { "$SkuId (unrecognized SKU)" } return [pscustomobject]@{ SkuId = $SkuId PartNumber = $PartNumberHint Name = $displayName MonthlyListUsd = 0.0 PriceKnown = $false } } |