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?
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.
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