API - MES Adjustment


Overview

The is an API to create an adjustment transaction in the MES transaction queue.

  • This API will create a new entry in table MES Transaction Line

  • The header (MES Transaction) will be created automatically, if it does not already exist

  • Modification or deletion is not allowed. If a wrong entry was created, it must be deleted (with the transactionLines endpoint) and a new one created instead, unless it has already been processed, then it is not possible to delete it.

About Adjustment transactions

  • When an Adjustment is processed by the MES processor, either a positive or a negative adjustment is posted, depending on the sign of the Quantity field.

    • Each Adjustment transaction can have multiple lines, but all the lines must have the same sign on the Quantity field, i.e. either be positive or negative

    • If the lines are negative, the Transaction will be marked as Credit. See snapshot below, which shows both normal and credit adjustments.

  • Location

    • An adjustment entry needs to have a Location, it is given as a parameter. It is the location on the lines that is used for the posting.

    • The transaction’s header will automatically get the location of the first line. Transactions with mixed locations are allowed, therefore the location on the header is only for information. It cannot be empty, because else the transaction will not get through the error checks.

    • When adding lines to a transaction that already has a location in the header, the location parameter can be skipped and the line will get the location of the header by default.

  • Stage

    • With this endpoint, a Stage can only be set on the transaction’s header by default from field Default Stage on the Terminal card.

    • Stage is mandatory for Adjustments (but this it will not have any effect when adjusting standard items.)

  • Stock Center

    • With this endpoint, a Stock Center can be set on the transaction’s header by using the default Terminal card, field Default Stock Center.

    • Stock Center Code is mandatory for Adjustments (but this it will not have any effect when adjusting standard items.)

image-20260507-123623.png
Adjustment transactions


Endpoint name

mesAdjustment

Source table

WiFiAPIs MES Transaction Line

Fixed view/defaults

This endpoint will only create/show transactions with Type = Transfer.

Requests allowed

  • POST is used to create transactions

  • PATCH is not allowed.

  • DELETE is not allowed.

  • GET is possible, but not recommended since this endpoint is specifally designed to insert entries. To view transactions, it is better to use API - MES Transactions

Primary key

The primary key of a transaction line is transactionId + lineNo

Record ID

The record ID is systemId

Procedures

None


Data

Field List

Property

Type

Format

Description


1

systemId

string

uuid

The automatic system ID, which is in GUID format.

record id

non-editable

2

transactionId

integer


The Transaction this line belongs to.

  • Skip this when creating a new transaction.

  • Can be used to add a line to a transaction that already has been created. If used, the transaction with this ID must already exist. It is not possible to use an ID that does not exist.

PRIMARY KEY

OPTIONAL

3

lineNo

integer


The sequence number of this line, within the transaction which has ID = transactionId

This is set automatically as next number..

PRIMARY KEY

non-editable

4

terminal

string

max 10

The terminal will indicate from which manufacturing unit or machine this entry comes from. This could for example be one packing station. This is mandatory, but if there is only one terminal, this can be set up as a default on page API Base Setup.

OPTIONAL

5

externalReference

string

max 10

The sender needs to use their own reference, because every transaction needs to be unique. The same external reference can be used repeatedly in order to add an item line (for example a new package) to a transaction already created.

Mandatory

6

date

string

date

Posting date for the adjustment.

Mandatory

7

location

string

max 10

The current location of the item / trade item.

Mandatory

8

itemNo

string

max 20

Item No. of the item to be adjusted.

Mandatory

9

lot

string

max 10

The lot of the item to be adjusted.

Mandatory

10

quantity

decimal


quantity and unitOfMeasure are mandatory, unless weight is used instead.

Mandatory *

11

unitOfMeasure

string

max 10

The unit of measure that belongs to the quantity field.

This can be skipped if the Terminal is marked with Populate Units Automatically.

Mandatory *

12

weight

decimal


Weight, if used, it is the weight in the base weight unit of Wisefish.

OPTIONAL

13

tradeItemStage

string

max 20

Only for negative adjustments:

A relation to the adjusted Trade Item can be given with tradeItemStageand tradeItemLineNo

OPTIONAL

14

tradeItemLineNo

number


Only for negative adjustments:

A relation to the adjusted Trade Item can be given with tradeItemStageand tradeItemLineNo

OPTIONAL

15

tradeItemBarcode

string

max 22

Only for negative adjustments:

A relation to the adjusted Trade Item can be given with it’s barcode.

OPTIONAL

16

lastModified

string

date-time

Timestamp.

non-editable


Example Object

Expand to see the example json

An example of one object :

JSON
{
    "@odata.etag": "W/\"JzIwOzEwMDc1MTQ5Mzg0NjI5NDU1NjE3MTswMDsn\"",
    "systemId": "d5322078-5d49-f111-b032-ccc8a446a9f5",
    "transactionId": 431,
    "lineNo": 1,
    "terminal": "INNOVA",
    "externalReference": "06-MAY-A3",
    "date": "2026-05-06",
    "location": "OSLO",
    "itemNo": "SALMON",
    "lot": "OR-00001",
    "quantity": 10,
    "unitOfMeasure": "KG",
    "weight": 0,
    "tradeItemStage": "",
    "tradeItemLineNo": 0,
    "tradeItemBarcode": "",
    "lastModified": "2026-05-06T15:08:43.137Z"
}


Default Values

This is explained in more details in document MES Inbound - Error Handling & Validation but the main defaults and automatic population is as follows:

  • Creation of the Transaction:

    • Type will be Adjustment

    • Activity Date will be the value of property dateor if not given, it will be set as today

    • For this API there is no property for Stock Center or Location, these values should get their default value from any of the following tables:

      • Terminal table

      • User Profile

  • Creation of the Transaction Line:

    • Line No. is set automatically


Usage - TODO

Adjust one item lot by 20 KG

In this example a raw material is being adjusted:

JSON
POST
.../mesAdjustment

Body:

{   
    "externalReference": "08-may-a5",
    "itemNo": "SALMON",
    "lot": "SAL0805",
    "location": "BERGEN",
    "quantity": 20,
    "unitOfMeasure": "KG"
}

The response has all properties of the endpoint:

JSON
{
    "@odata.etag": "W/\"JzIwOzE3NDUxOTE5MDgwMjA0MjMwMzMxMTswMDsn\"",
    "systemId": "06dfda4e-c94a-f111-b032-f84273c39f63",
    "transactionId": 469,
    "lineNo": 1,
    "terminal": "INNOVA",
    "externalReference": "08-MAY-A5",
    "date": "2026-05-08",
    "location": "BERGEN",
    "itemNo": "SALMON",
    "lot": "SAL0805",
    "quantity": 20,
    "unitOfMeasure": "KG",
    "weight": 0,
    "tradeItemStage": "",
    "tradeItemLineNo": 0,
    "tradeItemBarcode": "",
    "lastModified": "2026-05-08T10:33:10.71Z"
}


Adjust a standard item stock

When using standard items, it works in the same way, except stock centers and stages are not used, even though they will appear on the Transactions.

POST
.../mesAdjustment

Body:

{   
    "externalReference": "08-may-std",
    "itemNo": "70074",
    "location": "OSLO",
    "quantity": 5,
    "unitOfMeasure": "STK"
}

Response:

JSON
{
    "@odata.etag": "W/\"JzIwOzE3OTUxMTE3MjgwNzg5Nzk2Nzc1MTswMDsn\"",
    "systemId": "07bf4b21-ca4a-f111-b032-f84273c39f63",
    "transactionId": 470,
    "lineNo": 1,
    "terminal": "INNOVA",
    "externalReference": "08-MAY-STD",
    "date": "2026-05-08",
    "location": "OSLO",
    "itemNo": "70074",
    "lot": "",
    "quantity": 5,
    "unitOfMeasure": "STK",
    "weight": 0,
    "tradeItemStage": "",
    "tradeItemLineNo": 0,
    "tradeItemBarcode": "",
    "lastModified": "2026-05-08T10:39:03.77Z"
}