Public/Receipts/New-AspireReceipt.ps1
|
<#
.SYNOPSIS Creates a new receipt in the Aspire API. .DESCRIPTION Uses Invoke-AspireRequest to perform a POST request to the /Receipts endpoint. .PARAMETER BranchID The ID of the branch (required). .PARAMETER VendorID The ID of the vendor (required). .PARAMETER ReceiptID Optional ID of the receipt. .PARAMETER VendorInvoiceNum Optional vendor invoice number. .PARAMETER VendorInvoiceDate Optional vendor invoice date (DateTime). .PARAMETER WorkTicketID Optional work ticket ID. .PARAMETER ReceiptNote Optional receipt note. .PARAMETER AddressLine1 Optional address line 1. .PARAMETER AddressLine2 Optional address line 2. .PARAMETER City Optional city. .PARAMETER StateProvinceCode Optional state/province code. .PARAMETER ZipCode Optional zip code. .PARAMETER InventoryLocationID Optional inventory location ID. .PARAMETER ReceiptTotalCost Optional total cost of the receipt (double). .PARAMETER ReceiptItems Optional array of receipt items. .PARAMETER ReceiptExtraCosts Optional array of receipt extra costs. .OUTPUTS The response from the API containing the created receipt. .EXAMPLE New-AspireReceipt -BranchID 1 -VendorID 2 -ReceiptTotalCost 100.00 #> function New-AspireReceipt { [CmdletBinding()] param( [Parameter(Mandatory = $true)] [int]$BranchID, [Parameter(Mandatory = $true)] [int]$VendorID, [int]$ReceiptID = $null, [string]$VendorInvoiceNum = $null, [DateTime]$VendorInvoiceDate = $null, [int]$WorkTicketID = $null, [string]$ReceiptNote = $null, [string]$AddressLine1 = $null, [string]$AddressLine2 = $null, [string]$City = $null, [string]$StateProvinceCode = $null, [string]$ZipCode = $null, [int]$InventoryLocationID = $null, [double]$ReceiptTotalCost = $null, [array]$ReceiptItems = $null, [array]$ReceiptExtraCosts = $null ) $body = @{ BranchID = $BranchID VendorID = $VendorID } if ($ReceiptID) { $body.ReceiptID = $ReceiptID } if ($VendorInvoiceNum) { $body.VendorInvoiceNum = $VendorInvoiceNum } if ($VendorInvoiceDate) { $body.VendorInvoiceDate = $VendorInvoiceDate.ToString("o") } if ($WorkTicketID) { $body.WorkTicketID = $WorkTicketID } if ($ReceiptNote) { $body.ReceiptNote = $ReceiptNote } if ($AddressLine1) { $body.AddressLine1 = $AddressLine1 } if ($AddressLine2) { $body.AddressLine2 = $AddressLine2 } if ($City) { $body.City = $City } if ($StateProvinceCode) { $body.StateProvinceCode = $StateProvinceCode } if ($ZipCode) { $body.ZipCode = $ZipCode } if ($InventoryLocationID) { $body.InventoryLocationID = $InventoryLocationID } if ($ReceiptTotalCost) { $body.ReceiptTotalCost = $ReceiptTotalCost } if ($ReceiptItems) { $body.ReceiptItems = $ReceiptItems } if ($ReceiptExtraCosts) { $body.ReceiptExtraCosts = $ReceiptExtraCosts } return Invoke-AspireRequest -Method POST -Path "/Receipts" -Body $body -ApiVersion $null } |