Last active
November 18, 2020 00:29
-
-
Save RobertWaiteREPAY/2bb88b95b527f8a8b87bd6db0b66f5ba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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