web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :

Apply multiple invoice entries against a payment entry through APIs in D365 Business Central

Mohana Yadav Profile Picture Mohana Yadav 61,214 Super User 2026 Season 1


Step 1: Get the Payment Journal Batch that we want to use in Business Central
We can get Payment Batch details using vendorPaymentJournals API
 
{
  "@odata.context": "https://api.businesscentral.dynamics.com/v2.0/8f0f6868-04b3-4834-8f54-49b21664eb18/Sandbox/api/v2.0/$metadata#companies(e93b67c5-78f1-ea11-bb43-000d3a2e8412)/vendorPaymentJournals",
  "value": [
    {
      "@odata.etag": "W/\"JzQ0O0R2KzNtQjdWREIybjJRRnV5b1hFVG44b3NqNlZqbDVVWVNHUWtQNzZ4L2c9MTswMDsn\"",
      "id": "30e08afa-78f1-ea11-bb43-000d3a2e8412",
      "code": "CASH",
      "displayName": "Cash receipts and payments",
      "balancingAccountId": "00000000-0000-0000-0000-000000000000",
      "balancingAccountNumber": "10100",
      "lastModifiedDateTime": "2020-09-08T02:14:48.853Z"
    },
    {
      "@odata.etag": "W/\"JzQ0O0k4MlhkK29tK0w3STdOVE40dzdZRHhuTHNpSnppVTVJVWcxRTcvdjNSOWs9MTswMDsn\"",
      "id": "32e08afa-78f1-ea11-bb43-000d3a2e8412",
      "code": "GENERAL",
      "displayName": "GENERAL",
      "balancingAccountId": "00000000-0000-0000-0000-000000000000",
      "balancingAccountNumber": "10100",
      "lastModifiedDateTime": "2020-09-08T02:14:48.86Z"
    },
    {
      "@odata.etag": "W/\"JzQ0O3pzQXAxMGt6bFVDN3ZUSlJQY1I0Zk0rOEFBY1NUUVhQM2dqelFqTEZHNEU9MTswMDsn\"",
      "id": "34e08afa-78f1-ea11-bb43-000d3a2e8412",
      "code": "PMT REG",
      "displayName": "Bank Reconciliation",
      "balancingAccountId": "00000000-0000-0000-0000-000000000000",
      "balancingAccountNumber": "CHECKING",
      "lastModifiedDateTime": "2020-09-08T02:14:48.87Z"
    }
  ]
}
I am going to use General Batch from the above list
      "id": "32e08afa-78f1-ea11-bb43-000d3a2e8412",
      "code": "GENERAL",
 
 
Step 2: Create a payment entry in Payment Journal using APIs
We can use vendorPaymentsAPI for this along with vendorPaymentJournals API
 
Body of the Post command
{
  "journalId": "32e08afa-78f1-ea11-bb43-000d3a2e8412",
  "vendorNumber": "10000",
  "documentNumber": "323",
  "externalDocumentNumber": "125",
  "amount": 2000,
  "description": "apply entries"
}
 
Response
 
{
  "@odata.context": "https://api.businesscentral.dynamics.com/v2.0/8f0f6868-04b3-4834-8f54-49b21664eb18/Sandbox/api/v2.0/$metadata#companies(e93b67c5-78f1-ea11-bb43-000d3a2e8412)/vendorPaymentJournals(32e08afa-78f1-ea11-bb43-000d3a2e8412)/vendorPayments/$entity",
  "@odata.etag": "W/\"JzQ0O1ZCVUNIQVVGTnBEM2l4aHVIOUZzczg0a0crNlh2TTlvQVpGbXJoZVBHR1E9MTswMDsn\"",
  "id": "b3897612-e097-ec11-80f1-002248290747",
  "journalId": "32e08afa-78f1-ea11-bb43-000d3a2e8412",
  "journalDisplayName": "GENERAL",
  "lineNumber": 10000,
  "vendorId": "c6ec91f4-78f1-ea11-bb43-000d3a2e8412",
  "vendorNumber": "10000",
  "postingDate": "2022-02-27",
  "documentNumber": "323",
  "externalDocumentNumber": "125",
  "amount": 2000.00,
  "appliesToInvoiceId": "00000000-0000-0000-0000-000000000000",
  "appliesToInvoiceNumber": "",
  "description": "apply entries",
  "comment": "",
  "lastModifiedDateTime": "2022-02-27T15:15:18.987Z"
}
 
 
We can find the Payment entry in Business Central page
 

 
Step 3: Apply the above payment against multiple existing invoices in Business Central
We can get the open Vendor Entries details using applyVendorEntries API along with above VendorPaymentJournals and vendorPayments
 
{
  "@odata.context": "https://api.businesscentral.dynamics.com/v2.0/8f0f6868-04b3-4834-8f54-49b21664eb18/Sandbox/api/v2.0/$metadata#companies(e93b67c5-78f1-ea11-bb43-000d3a2e8412)/vendorPaymentJournals(32e08afa-78f1-ea11-bb43-000d3a2e8412)/vendorPayments(b3897612-e097-ec11-80f1-002248290747)/applyVendorEntries",
  "value": [
    {
      "@odata.etag": "W/\"JzQ0O0FuSldSUCt1NHhvY044aThWZjhicUI5T2RmYWxuYmhDNFhDVE9zdnZzSm89MTswMDsn\"",
      "id": "ce27de32-4514-eb11-bbf7-000d3a9b9997",
      "applied": false,
      "appliesToId": "",
      "postingDate": "2020-04-06",
      "documentType": "Invoice",
      "documentNumber": "108211",
      "externalDocumentNumber": "107215",
      "vendorNumber": "10000",
      "vendorName": "",
      "description": "Invoice 107215",
      "remainingAmount": -1069
    },
    {
      "@odata.etag": "W/\"JzQ0O29NSkJma2tXQWNPOUdBd2RtVExLZHVxdXRaMjQ0c1JabEJaeE1rM0NqNjg9MTswMDsn\"",
      "id": "d7dd2968-5514-eb11-bbf7-000d3a9b9997",
      "applied": false,
      "appliesToId": "",
      "postingDate": "2020-04-06",
      "documentType": "Invoice",
      "documentNumber": "108212",
      "externalDocumentNumber": "107216",
      "vendorNumber": "10000",
      "vendorName": "",
      "description": "Invoice 107216",
      "remainingAmount": -690
    },
    {
      "@odata.etag": "W/\"JzQ0OzcvcU1pSDZMRkZjR1BqbjNOdDllSnhSY1lMOXAyS2w1TlBudzU1T1FCd0E9MTswMDsn\"",
      "id": "a4145e6f-5514-eb11-bbf7-000d3a9b9997",
      "applied": false,
      "appliesToId": "",
      "postingDate": "2020-04-06",
      "documentType": "Invoice",
      "documentNumber": "108213",
      "externalDocumentNumber": "107217",
      "vendorNumber": "10000",
      "vendorName": "",
      "description": "Invoice 107217",
      "remainingAmount": -460
    },
    {
      "@odata.etag": "W/\"JzQ0OzFmdG5obUdMOFhzV1NOSjFpaS9zR1psM2ZuRUxTNncxbnJCaVVDYkQrR1k9MTswMDsn\"",
      "id": "3a6bed91-8714-eb11-bbf7-000d3a9b9997",
      "applied": false,
      "appliesToId": "",
      "postingDate": "2020-04-06",
      "documentType": "Invoice",
      "documentNumber": "108214",
      "externalDocumentNumber": "107218",
      "vendorNumber": "10000",
      "vendorName": "",
      "description": "Invoice 107218",
      "remainingAmount": -230
    },
    {
      "@odata.etag": "W/\"JzQ0O1pEOWpLU0JFS3k5SnEwdzc3Z0VOL21ZTEZub1BRRTlZZStOT0g1aTJmRTQ9MTswMDsn\"",
      "id": "15c60da4-8714-eb11-bbf7-000d3a9b9997",
      "applied": false,
      "appliesToId": "",
      "postingDate": "2020-04-06",
      "documentType": "Invoice",
      "documentNumber": "108215",
      "externalDocumentNumber": "107219",
      "vendorNumber": "10000",
      "vendorName": "",
      "description": "Invoice 107219",
      "remainingAmount": -230
    },
    {
      "@odata.etag": "W/\"JzQ0O21VcEpndldlenZRdG1teXllbi9OcGRUQnFSWmVldlBwVDBFejlBVFkrYnc9MTswMDsn\"",
      "id": "d6366f3e-8a14-eb11-bbf7-000d3a9b9997",
      "applied": false,
      "appliesToId": "",
      "postingDate": "2020-04-06",
      "documentType": "Invoice",
      "documentNumber": "108216",
      "externalDocumentNumber": "107220",
      "vendorNumber": "10000",
      "vendorName": "",
      "description": "Invoice 107220",
      "remainingAmount": -230
    },
    {
      "@odata.etag": "W/\"JzQ0O1hzNHhuSWdFU2U5NHI3dXd5dEJZdzg5VXh0MmM1QnRrajg4Qm5SQlluMDQ9MTswMDsn\"",
      "id": "a8e34451-8a14-eb11-bbf7-000d3a9b9997",
      "applied": false,
      "appliesToId": "",
      "postingDate": "2020-04-06",
      "documentType": "Invoice",
      "documentNumber": "108217",
      "externalDocumentNumber": "107221",
      "vendorNumber": "10000",
      "vendorName": "",
      "description": "Invoice 107221",
      "remainingAmount": -230
    }
  ]
}
 
Now, I would like to apply the above payment against invoices 108211 and 108212 which have remaining about as 1069 and 690 respectively.
 
Before that let’s check the apply entries page in Business Central
 


Now call the below Patch APIs
 
Don’t forget to add header “If-Match” as *
 


Body as
{
  "applied": true
}
Response:
{
  "@odata.context": "https://api.businesscentral.dynamics.com/v2.0/8f0f6868-04b3-4834-8f54-49b21664eb18/Sandbox/api/v2.0/$metadata#companies(e93b67c5-78f1-ea11-bb43-000d3a2e8412)/vendorPaymentJournals(32e08afa-78f1-ea11-bb43-000d3a2e8412)/vendorPayments(b3897612-e097-ec11-80f1-002248290747)/applyVendorEntries/$entity",
  "@odata.etag": "W/\"JzQ0O2szUE5KRGVUeXZ3VVQzK0U5RE5KaFFlN3BobGFBL0YyRmVmSlBmR3lLcTA9MTswMDsn\"",
  "id": "ce27de32-4514-eb11-bbf7-000d3a9b9997",
  "applied": true,
  "appliesToId": "323",
  "postingDate": "2020-04-06",
  "documentType": "Invoice",
  "documentNumber": "108211",
  "externalDocumentNumber": "107215",
  "vendorNumber": "10000",
  "vendorName": "",
  "description": "Invoice 107215",
  "remainingAmount": -1069
}
 
Now verify in Business Central
Applies-to ID field will have Payment Document No. field


Execute 2ndAPI call with 2nd Invoice
 
Response:
{
  "@odata.context": "https://api.businesscentral.dynamics.com/v2.0/8f0f6868-04b3-4834-8f54-49b21664eb18/Sandbox/api/v2.0/$metadata#companies(e93b67c5-78f1-ea11-bb43-000d3a2e8412)/vendorPaymentJournals(32e08afa-78f1-ea11-bb43-000d3a2e8412)/vendorPayments(b3897612-e097-ec11-80f1-002248290747)/applyVendorEntries/$entity",
  "@odata.etag": "W/\"JzQ0O2x2eGF3aFBCeTl3WjlSZ1RrbUQrc09GSGVVZEZ6RmozM0NoL3pvQk11YlU9MTswMDsn\"",
  "id": "d7dd2968-5514-eb11-bbf7-000d3a9b9997",
  "applied": true,
  "appliesToId": "323",
  "postingDate": "2020-04-06",
  "documentType": "Invoice",
  "documentNumber": "108212",
  "externalDocumentNumber": "107216",
  "vendorNumber": "10000",
  "vendorName": "",
  "description": "Invoice 107216",
  "remainingAmount": -690
}
 
Verify in Business Central.


Second invoice line also has Applies-to ID as payment document no.
 
Step 4: Post the payment journal in Business Central
 


 
Go to Vendor Ledger Entries and verify the application
Payment Entry


Click on Applied Entries
 


Notice that 2 invoices are applied to the payment
 


 

This was originally posted here.

Comments

*This post is locked for comments