#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