Breadcrumbs

API - Purchase Agreements

Overview

The list page that contains the Receipt Agreements in Wisefish.


Endpoint name

purchaseAgreements

Source table

"WiFi Purchase Agreement Header"

Fixed view

Only shows unposted purchases, i.e. where invoice has not been posted.

Requests allowed

GET, POST, PATCH, DELETE

Primary key

documentType, documentNo

Record ID

systemId

Procedures

release, reopen, createPostingDocument, receiveItems

Data

Field List

Property

Type

Max Len

Description


1

systemId

string uuid


The record ID must be used when reading only one entry or when using procedures on the endpoint.

RECORD ID

2

documentType

string


Options:

  • Receipt - a normal purchase

  • Blanket - an ongoing purchase document.

See Wisefish user manuals for more info.

Primary key

3

documentNo

string

20

The unique id within each “Document Type”

Primary key

4

status

string


Status shows if the agreement is still open or has been released


5

orderDate

date


Order Date


6

vendorOrderNo

string

20

Vendor Order No.


7

buyFromVendorNo

string

20

This field is related to table Vendor.

Mandatory

8

buyFromVendorName

string

100

Vendor information


9

buyFromVendorName2

string

50

Vendor information


10

buyFromAddress

string

100

Vendor information


11

buyFromAddress2

string

50

Vendor information


12

buyFromPostCode

string

20

Vendor information


13

buyFromCity

string

30

Vendor information


14

buyFromCounty

string


Vendor information


15

buyFromCountry

string

10

Vendor information


16

languageCode

string

10



17

locationCode

string

10

After posting, the items will be on this Location


18

stockCenterCode

string

20

After posting, the items will be on this Stock Center


19

externalProducer

string

20



20

placeofLoading

string

10

Fields regarding shipping


21

placeofDischarge

string

10

Fields regarding shipping


22

placeofDelivery

string

10

Fields regarding shipping


23

transporter

string


Fields regarding shipping


24

transportMethodCode

string

10

Fields regarding shipping


25

expectedReceiptDate

date


Fields regarding shipping


26

amount

decimal


The total amount of this purchase


27

currencyCode

string

10



28

postingDate

date


This date will be used for the ledger entries created when this is posted.


29

vendorInvoiceNo

string

20



30

getBCTIInvoice

true/false




31

noOfLines

integer


Number of lines on this agreement


32

noOfTradeItems

decimal


Total number of trade items on this agreement


33

noOfTradeItemsAllocated

decimal




34

noOfTradeItemsReceived

decimal




35

lastModified

date-time UTC


Automatic time stamp of last modification.


Example Object

The response with only the properties from the “Purchase Agreement Header” (not the lines, looks like this);

JSON
{
    "@odata.context": "https://api.businesscentral.dynamics.com/v2.0/b33a6a3b-244c-4295-84b3-0ad90823c736/AB_Test_191125/api/wisefish/base/v1.0/$metadata#companies(1691e98a-6a95-f011-b41a-6045bde126e9)/purchaseAgreements/$entity",
    "@odata.etag": "W/\"JzIwOzExMTg5ODcyMDAwMzUyNTUzMzI0MTswMDsn\"",
    "systemId": "b443a749-239a-f011-b41a-000d3adf9fc2",
    "documentType": "Receipt",
    "documentNo": "RA2000004",
    "status": "Released",
    "orderDate": "2025-09-25",
    "vendorOrderNo": "",
    "buyFromVendorNo": "4203690429",
    "buyFromVendorName": "Þorbjörn hf.",
    "buyFromVendorName2": "",
    "buyFromAddress": "",
    "buyFromAddress2": "",
    "buyFromPostCode": "240",
    "buyFromCity": "GRINDAVÍK",
    "buyFromCounty": "",
    "buyFromCountry": "IS",
    "languageCode": "ISL",
    "locationCode": "",
    "stockCenterCode": "",
    "externalProducer": "",
    "placeofLoading": "",
    "placeofDischarge": "",
    "placeofDelivery": "",
    "transporter": "",
    "transportMethodCode": "",
    "expectedReceiptDate": "2025-09-25",
    "amount": 10000,
    "currencyCode": "",
    "postingDate": "2025-09-25",
    "vendorInvoiceNo": "",
    "getBCTIInvoice": false,
    "noOfLines": 1,
    "noOfTradeItems": 100,
    "noOfTradeItemsAllocated": 0,
    "noOfTradeItemsReceived": 0,
    "lastModified": "2025-09-30T17:14:22.093Z",
}

Usage

Read one agreement with lines

Reading one entry of this table must be done with the record Id which is in this case the systemId.

Lines are shown by adding to the URL $expand=purchaseAgreementLines

GET ... purchaseAgreements([system-id])?$expand=purchaseAgreementLines


Expand to see the example json

An example of a response:

JSON
GET ... purchaseAgreements(b443a749-239a-f011-b41a-000d3adf9fc2)?$expand=purchaseAgreementLines

{
    "@odata.context": "https://api.businesscentral.dynamics.com/v2.0/b33a6a3b-244c-4295-84b3-0ad90823c736/AB_Test_191125/api/wisefish/base/v1.0/$metadata#companies(1691e98a-6a95-f011-b41a-6045bde126e9)/purchaseAgreements/$entity",
    "@odata.etag": "W/\"JzIwOzExMTg5ODcyMDAwMzUyNTUzMzI0MTswMDsn\"",
    "systemId": "b443a749-239a-f011-b41a-000d3adf9fc2",
    "documentType": "Receipt",
    "documentNo": "RA2000004",
    "status": "Released",
    "orderDate": "2025-09-25",
    "vendorOrderNo": "",
    "buyFromVendorNo": "4203690429",
    "buyFromVendorName": "Þorbjörn hf.",
    "buyFromVendorName2": "",
    "buyFromAddress": "",
    "buyFromAddress2": "",
    "buyFromPostCode": "240",
    "buyFromCity": "GRINDAVÍK",
    "buyFromCounty": "",
    "buyFromCountry": "IS",
    "languageCode": "ISL",
    "locationCode": "",
    "stockCenterCode": "",
    "externalProducer": "",
    "placeofLoading": "",
    "placeofDischarge": "",
    "placeofDelivery": "",
    "transporter": "",
    "transportMethodCode": "",
    "expectedReceiptDate": "2025-09-25",
    "amount": 10000,
    "currencyCode": "",
    "postingDate": "2025-09-25",
    "vendorInvoiceNo": "",
    "getBCTIInvoice": false,
    "noOfLines": 1,
    "noOfTradeItems": 100,
    "noOfTradeItemsAllocated": 0,
    "noOfTradeItemsReceived": 0,
    "lastModified": "2025-09-30T17:14:22.093Z",
    "purchaseAgreementLines": [
        {
            "@odata.etag": "W/\"JzIwOzE3MjI2NDI3NTI4MzQ1MzA1NzY2MTswMDsn\"",
            "systemId": "2559e15b-239a-f011-b41a-000d3adf9fc2",
            "documentType": "Receipt",
            "documentNo": "RA2000004",
            "lineNo": 10000,
            "type": "Item",
            "itemNo": "ZZZ1003",
            "description": "Lifur - lánað til Lýsi",
            "tradeItems": 100,
            "tIUoM": "KG",
            "quantityBase": 100,
            "quantity": 100,
            "unitOfMeasureCode": "KG",
            "directUnitCost": 100,
            "unitCost": 100,
            "lineAmount": 10000,
            "lineDiscount": 0,
            "lineDiscountAmount": 0,
            "amount": 10000,
            "vat": 11,
            "amountIncludingVAT": 11100,
            "originalProducer": "",
            "productionDate": "2025-09-25",
            "netWeight": 0,
            "netWeightBWU": 100,
            "lastModified": "2025-10-02T13:18:31.53Z"
        }
    ]
}


Create an agreement with lines

JSON
POST .../purchaseAgreements?$expand=purchaseAgreementLines

Body:

{
    "orderDate": "2025-12-02",
    "buyFromVendorNo": "4203690429",
    "locationCode": "001",
    "vendorInvoiceNo": "AFH-001",
    "purchaseAgreementLines": [
        {
            "itemNo": "ZZZ1003",
            "tradeItems": 300,
            "tradeItemUnitOfMeasure": "KG",
            "productionDate": "2025-12-02"
        }
    ]
}

The response contains the the new entry, both header and lines.


Procedures

Service-enabled procedures are the following, see below.

If there is anything important to say about these procedures

If the request is successful, the response is 200 OK and could also possibly contain something in the value property:

JSON
{
    "@odata.context": "https://api.businesscentral.dynamics.com/v2.0/b33a6a3b-244c-4295-84b3-0ad90823c736/AB_Test_191125/api/wisefish/base/v1.0/$metadata#Edm.String",
    "value": "Success"
}


Release

This will release the agreement, same as clicking on the Release button within BC.

Usage

JSON
POST
[server]/api/wisefish/wiFiEP/v1.0/companies([CompanyGUID])/purchaseAgreements([record-id])/Microsoft.NAV.release

(no parameters)

After a successful request:

  • The Status becomes Released.


Reopen

If an already released agreement needs to be reopened, in order to do some changes.

Usage

JSON
POST
[server]/api/wisefish/wiFiEP/v1.0/companies([CompanyGUID])/purchaseAgreements([record-id])/Microsoft.NAV.reopen

(no parameters)

After a successful request:

  • The Status becomes Open.


Create Posting Document

When all lines have been registered on the purchase agreement, the posting document can be created, i.e. either a Purchase Order or a Purchase Invoice.
Before this is run, the agreement must be released.

Usage

JSON
POST
[server]/api/wisefish/wiFiEP/v1.0/companies([CompanyGUID])/purchaseAgreements([record-id])/Microsoft.NAV.createPostingDocument

(no parameters)

After a successful request:

  • A purchase document (Purchase Order or Purchase Invoice, depends on settings) has been created for the agreement.


Receive Items

This method can be used if the API user is allowed to both created the posting document and then immediately post the items into inventory.

Usage

JSON
POST
[server]/api/wisefish/wiFiEP/v1.0/companies([CompanyGUID])/purchaseAgreements([record-id])/Microsoft.NAV.receiveItems

(no parameters)

This method does both:

  • Creates a a Purchase Order for the agreement.

  • The purchase order is posted with the “receipt” option, which means that items are in stock, and the order waits for the invoice to be created later.