When using the Sage 300 WebApi, is it possible to post several invoices to the same batch in Sage?
When using the Sage 300 WebApi, is it possible to post several invoices to the same batch in Sage?
Hi Benard Muinde your question could mean a few different things but I'll take a guess that your problem is:
Is this correct as it was a common question long before the Web API when integration was done with Sage 300 VB Macros and other methods? Awaiting your clarification. Cheers.
Hi Tim - Accsys Consulting you got it right. That's the issue I'm dealing with. I want all A/R invoices created by the web API integration to go to the same open batch until posted, instead of creating a new batch every time an invoice is pushed.
Yes, you can.
For something like AR Invoice with multiple entries with multiple lines per entry:
{ "BatchDate": "2024-11-15", "BatchStatus": "Open", "Description": "Test Multi Entry", "Invoices": [ { "CustomerNumber": "1400", "DocumentType": "Invoice", "InvoiceType": "Summary", "DocumentDate": "2024-11-15", "DueDate": "2024-11-15", "InvoiceDetails": [ { "DistributionCode": "CACCSE", "ExtendedAmountWithTIP": 200 } ] }, { "CustomerNumber": "1200", "DocumentType": "Invoice", "InvoiceType": "Summary", "DocumentDate": "2024-11-15", "DueDate": "2024-11-15", "InvoiceDetails": [ { "DistributionCode": "CACCSE", "ExtendedAmountWithTIP": 200 }, { "DistributionCode": "ITEM", "ExtendedAmountWithTIP": 300 }, { "DistributionCode": "CACCSE", "ExtendedAmountWithTIP": 400 }, { "DistributionCode": "ITEM", "ExtendedAmountWithTIP": 500 } ] } ] }
Hi SergeB that's cool and will insert multiple invoice entries into the initial batch though what happens when the call is repeated with new sets of invoices throughout the day? I haven't done any testing/dev yet (I will when I get a chance), but will your call above insert those two invoices into the most recent open batch? i.e. if you were to run this call 3 times 30 mins apart, after 90 minutes would you have 3 batches with 2 invoices in each, or one batch with 6 invoices? I think Benard Muinde wants multiple API calls to insert invoices into the most recent open batch until its posted or set 'Ready to Post'. Only then would the next call open a new batch, with subsequent calls populating that batch via the same process until its posted or set ready to post again, so on, so fourth.
If you repeate that POST call, you will create new batches all day long.
If you want to update/add to an existing batch #54:
HTTP PATCH : /Sage300WebApi/v1.0/-/SAMINC/AR/ARInvoiceBatches(54)
Body:
{ "BatchStatus": "Open", "Invoices": [ { "CustomerNumber": "1400", "DocumentType": "Invoice", "InvoiceType": "Summary", "DocumentDate": "2024-11-15", "DueDate": "2024-11-15", "InvoiceDetails": [ { "DistributionCode": "CACCSE", "ExtendedAmountWithTIP": 50 } ] }, { "CustomerNumber": "1200", "DocumentType": "Invoice", "InvoiceType": "Summary", "DocumentDate": "2024-11-15", "DueDate": "2024-11-15", "InvoiceDetails": [ { "DistributionCode": "CACCSE", "ExtendedAmountWithTIP": 50 }, { "DistributionCode": "ITEM", "ExtendedAmountWithTIP": 50 } ] } ] }
^ That will add a new entry to batch 54.
If you want to update an existing entry in that batch, same URL but then you need to specify the EntryNumber.
This payload will update entry #1 by adding another line detail:
{ "BatchStatus": "Open", "Invoices": [ { "EntryNumber": 1, "CustomerNumber": "1400", "DocumentType": "Invoice", "InvoiceType": "Summary", "DocumentDate": "2024-11-15", "DueDate": "2024-11-15", "InvoiceDetails": [ { "DistributionCode": "CACCSE", "ExtendedAmountWithTIP": 50 } ] } ] }
*Community Hub is the new name for Sage City