The Queue is a functionality added to the Partner API that helps you manage and send documents to ERPLY Books better. This way, a queue for saving documents to ERPLY Books is created and a new save can only be started when the previous one is completed.

The Queue is suitable for solutions where there are many invoices and changes to the invoices are possible (i.e. one invoice can be sent twice in the same second). Queue works in the “send and forget” style.

Base URL: https://api.erplybooks.com/api/invoices/add_to_queue

POST

URL example: https://api.erplybooks.com/api/invoices/add_to_queue.json?token=MY_COOL_TOKEN

JSON: {number:”5343353″,customerName:”Gangster”,date:”2021-05-05″,currencyCode:”CURRENCY_USD”,languageCode:”LANGUAGE_EN”,deadlineDate:”2021-06-28″,sumNoVat:16.5,sumWithVat:16.5,currencyRate:1,typeCode:”DOCUMENT_BUY”,code:”98329″,transactionDate:”2021-03-29″,note:”We need it now”,partnerDocumentId:”KDDK49839″,documentStatusTypeCode:”STATUS_NOT_CONFIRMED”,projectNames:[“Location in the mall”],rows:[{articleName:”Products”,quantity:1,price:16.5,typeCode:”ARTICLE_ROW_BUY”,partnerArticleId:”prod”,partnerTaxRateId:”TAX_0″,vatPercent:0},{articleName:”Transport”,quantity:1,price:0,cogs:88,typeCode:”ARTICLE_ROW_BUY”,partnerArticleId:”tran”,partnerTaxRateId:”TAX_20″,vatPercent:20}],customer:{name:”Gangster”,legalCountryCode:”US”,email:”coolio@gangsters.paradise”,partnerCustomerId:”IAMID”}}

Response

{“id”: 24, “json”: … }

 

The Queue is used only with a Partner API. When using Queue, the url contains “invoices/add_to_queue” instead of “invoices/partner”. When you use this function, a new row is created in the Document_Queue table, which also stores the document sequence number Id, the ID of the organization that sent the document, the status of the document, and the JSON.

 

The Queue has four different document status:

FAIL – if the document doesn’t meet the requirements
PENDING – if the document meets the requirements but has not been saved
REJECTED – a newer version of this document is available in the queue
CONFIRMED – the document is saved

 

The sent document is checked and if it is a document, it will be saved in the DOCUMENT_QUEUE table with a PENDING status. If the document does not meet the requirements, its status is FAIL and the sender of the document receives an error message. The Queue job starts every three minutes. All documents with the ID of one organization with the status PENDING are selected and the uniqueness of the partner Document is checked. If several documents with the same ID are found, the last received version will be saved. Other documents with the same ID will be REJECTED. The usual Partner API document storage process continues. If the saving fails for any reason, the document will remain in a PENDING status and will be retried during the next queue job. If saving a document fails five times, the status of the document will be FAIL. The software sends an error message if you have set up receiving error messages.