Skip to content

Instantly share code, notes, and snippets.

@RobertWaiteREPAY
Last active November 18, 2020 00:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RobertWaiteREPAY/2bb88b95b527f8a8b87bd6db0b66f5ba to your computer and use it in GitHub Desktop.
Save RobertWaiteREPAY/2bb88b95b527f8a8b87bd6db0b66f5ba to your computer and use it in GitHub Desktop.
#CSV file is in this format:
#CustomerNbr,Description,Qty,UnitPrice,PaymentMethod
#CUST1,Services for June 2020,1,100,UPSUSD
#CUST2,Services for May 2020,2,200,UPSUSD
#CUST3,Services for April 2020,3,300,UPSUSD
$WebSession = New-Object Microsoft.PowerShell.Commands.WebRequestSession
Login-Acumatica -WebSession $WebSession
$InvoicePayementsToCreate = Import-Csv -Path C:\PathToTheCSVFile\PaymentBlog.csv
foreach($InvPayToCreate in $InvoicePayementsToCreate)
{
$isReadyForPaymentCreation = -not (Check-Invoice -WebSession $WebSession -CustomerNbr $InvPayToCreate.CustomerNbr -DocDesc $Description)
if($isReadyForPaymentCreation)
{
$body = @"
{
`"Customer`": {`"value`": `"$CustomerNbr`"},
`"Description`": {`"value`": `"$Description`"},
`"Details`": [{`"InventoryID`": {`"value`": `"$InventoryID`"},
`"Qty`": {`"value`": $Qty},
`"UnitPrice`": {`"value`": $UnitPrice},
`"UOM`": {`"value`": `"$UOM`"}}]
}
"@
$InvoiceAsPSObject = Create-Invoice -WebSession $WebSession -Body $body -release
$PaymentAsPSObject = Pay-Invoice -WebSession $WebSession -ReferenceNbr $InvoiceAsPSObject.ReferenceNbr.Value
}
}
Logout-Acumatica -WebSession $WebSession
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment