Customers Creation
New customers are created using customers API with provided specific information about this customer. More generic information such as posting groups is assigned from Customer Template. Customer Template is assigned according to templates defined in E-Invoice Setup:
The template is automatically selected according to country defined in API request.
Default dimensions can be assigned to customer at the same request as they are created together with $expand=defaultDimensions method (if customer/vendor template does not contain that default dimension).
Vendors Creation
New vendors are created using vendors API with provided specific information about vendor. The same way as with customers, you can enable setup in E-Invoice setup to assign Vendor Templates for each of the vendor. With vendors you can make analogical requests as with customers. In addition to that, together with vendors creation Vendor Bank Accounts can be created with vendorBankAccount API.
Sales Documents Creation
Sales Invoices are created using salesInvoices API. It is useful to use expand method in order to minimize the number of requests. Most of the information (fields that start with billTo, shipTo, sellTo) are filled automatically from customer table, so only these fields could be filled on request only when their values differ from those defined in customer table.
apiTotalAmountExclVAT and apiTotalAmountInclVAT are required to be added to request to check amounts between integrating system and Business Central. Rounding and total amount calculation can differ between different systems, so it is crucial to check if amounts align, and correct if needed.
Expand methods could include:
salesInvoiceLines API, to provide document lines for a document.
documentAttachments API, if additional documents need to be provided, i.e. Sales Contract. Document Attachment content can be provided through separated PATCH request.
For more specific example of this API usage, please refer to provided Json Collection.
Sales Credit Memos are created using salesCreditMemos API. Recommended expand methods include:
salesCreditMemoLines API.
documentAttachments API.
Purchase Documents Creation
Purchase Invoices are created using purchaseInvoices API.
Related expand methods are:
FAQ
Customers/Vendors API.
How can we use templates if we have more than 3 customer or vendor templates defined?
In this case, “Assign Default Template“ checkbox in “E-Invoice Setup“ table should be unmarked. Additionally, customerTemplateCode value in customers API request should be filled in by template code value. For vendors, vendorTemplateCode in vendors API request should be filled.
How can I assign payment terms for each customer/vendor?
Payment terms can be defined using paymentTermsCode or paymentTermsId fields. You can see all Payment Terms using GET request on paymentTerms API. I you have multiple companies using the same paymentTerms codes, then paymentTermsCode could be more effective to use. Once payments terms code is assigned for customer, this payment term is assigned automatically to sales documents and due date is calculated accordingly.
How default dimensions should be assigned?
defaultDimensions API should be used. You can assign it at the same request with a master table using $expand method or with a separated request as defined in documentation. The required fields are:
dimensionCode - a dimension code that you want to use.
dimensionValueId - dimensionValueCode cannot be added directly, because it is Read-Only field. In order to get a dimensionValueId for a value code, you need to make a request to dimensionValues API and filter by dimensionCode and code (which would be value code) - then you could take id field value for dimensionValueId field.
Where I could store additional information from integrating system to BC?
If you need to store customer/vendor number defined in other system or direct link to this system in BC, you can add this information using customerLink and vendorLink fields.
Sales Documents:
How can I take Sales Invoice printout from Business Central?
You can use a separated GET request using pdfDocument request. Printout report and layout is selected using Report Selections setup for each document type. If there are more than 1 report defined, the first report in sequence is selected.
If you need a specific example, please refer to Json Collection.
Could I post Sales Invoice Lines on a separated requests?
It is possible, although we recommend using expand requests in order to reduce the number of requests and post whole document to BC once you have a final version of the document in other platform.
Can I assign dimensions to the document lines directly on the same request?
Regarding dimensions, it is important to decide where your master data would be - in Business Central or in other platform. If you assign default dimensions for customer, vendor, G/L Accounts and Items then changing them in document lines could be problematic - you’ll need to make additional PATCH requests to change default values. For example, if your company is selling services and in sales invoice lines those services are issued to the same G/L Account(type = “G/L Account“) and it has different dimensions, then no default dimensions should be assigned.
If no default values are assigned, then it is possible to add dimensions to salesInvoiceLines directly using expand method with dimensionSetLines API at the same request.
Important: keep in mind that if request has many lines and expand methods it becomes more complex and takes longer to process. If your invoice only contains few lines, then you can use expand methods both to salesInvoiceLines and then to dimensionSetLines. If your invoice contains hundreds of lines, it would be better to pass dimensions on a separated $batch request to avoid complexity.