Documentation to Support Usage Scenarios
To support the various managed usage scenarios, some use cases are provided as examples.
Although the use of services allows for implementations different from those specified, it is reminded that the supported functionalities are those described in the indicated Use Cases.
General Master Data
Default 'ditta' field in data transfer objects (DTO)
In POST requests to insert new records or documents, it is possible to specify the 'ditta' or 'dittaCg18' field.
A practical example: You want to insert a document with document type C-DDT for customer 1 and for company 1000.
Until version 202403000, The 'ditta' field had to be defined for each property of the body, so it was necessary to populate the 'ditta' or 'dittaCg18' field as shown in the JSON example below::
{
"ditta": '1000',
"valutaCg08": "EURO",
"anagraficaDocumentoDitta": {
"dittaCg18": '1000',
"codDocumMg36": "C-DDT",
"indStaperMg36": 1.0
},
"customerSupplierMG": {
"dittaCg18": '1000',
"tipocfCg40": 1,
"cliFor": 1
},
"sezdoc": "00",
"storageWH": {
"dittaCg18": '1000',
"codDep": "00"
},
"righe": [
{
"ditta": '1000',
"progrRiga": 1.0,
"codartMg66": "ART001",
"descart": "Descrizione articolo",
"qta1": 15.000
}
]
}
From version 202501000 a default logic for the 'ditta' field in Data Transfer Objects (DTO) has been introduced, so if the value of the 'ditta' field of the "root" entity is not provided or is null, it is automatically populated with the company code retrieved from the current user session (parameter 'company'). This operation propagates to all associated 'external' and 'internal' entities.
Consequently, considering the example above, the user always has the same POST request.:
{{webapi_base_url}}/api/v1/{{scope}}/MG/Documento?company=1000
but in the body properties, it is no longer necessary to define the 'ditta' or 'dittaCg18' field, as shown in the JSON example below:
{
"valutaCg08": "EURO",
"anagraficaDocumentoDitta": {
"codDocumMg36": "C-DDT",
"indStaperMg36": 1.0
},
"customerSupplierMG": {
"tipocfCg40": 1,
"cliFor": 1
},
"sezdoc": "00",
"storageWH": {
"codDep": "00"
},
"righe": [
{
"progrRiga": 1.0,
"codartMg66": "ART001",
"descart": "Descrizione articolo",
"qta1": 15.000
}
]
}
Note: If the 'ditta' field is defined in a body property, it must be defined in all properties that make up the body.
Minimal Insertion of General Master Data
Insertion of general master data as a Natural Person:
{
"codfiscale": "MRARSS13S08H501H",
"partiva": null,
"flgAnagval": 1.0,
"ragSoAnag": "Mario Rossi & C",
"statofiscCg07" : 86.0, // Country ITALY
"sesso": 0.0, // 0 = M 1 = F
"addresses": [
{
"cap": 47838,
"citta": "Rimini",
"numciv": "12",
"via": "Draghi 9",
"addressesType": [
{
"tipo": 1 // Business location
}
],
"statoEst": {
"codice": 86.0 // Country ITALY
}
}
]
}
Minimal Insertion of a Customer/Supplier
To insert a customer or supplier, it is necessary to have previously inserted the common master data and, when inserting a customer, indicate the corresponding common master data code, as shown in the example below:
{
"flgAttivo": 1.0,
"tipocf": 0.0,
"generalMasterDataCO": {
"codice": 774
},
"paymentTermCO": {
"codPag": "301",
"descPag": "NR.01 RD A VISTA",
"id": 50
},
"extensionData": []
}
Search for a Customer/Supplier by Tax Code and/or VAT Number
Using the call
{{webapi_base_url}}/api/v1/{{scope}}/CO/lookup/CustomerSupplierCO?metadata=true&company={{defaultCompany}}&_op=search
it is possible to search for a customer by VAT Number or Tax Code or by Company Name.
{
"filters":
{
"items":
[
{
"comparer": 0,
"propertyName": "CustomerSupplierCO_Tipocf",
"value": "0"
},
{
"operator": 1,
"items":
[
{
"propertyName": "CustomerSupplierCO_GeneralMasterDataCO_Partiva",
"comparer": 0,
"value": "25052733463"
},
{
"operator": 2,
"propertyName": "CustomerSupplierCO_GeneralMasterDataCO_Codfiscale",
"comparer": 30,
"value": "MRARSS13S08H501H"
},
{
"operator": 2,
"propertyName": "CustomerSupplierCO_GeneralMasterDataCO_RagSoAnag",
"comparer": 20,
"value": "ROSSI"
}
]
}
]
},
"pageSize": 5,
"pageNumber": 0
}
Minimal Insertion of an Item Code
Through the POST call
{{webapi_base_url}}/api/v1/{{scope}}/WH/ItemWH?company={{defaultCompany}}
it is possible to insert a new item code.
Below is an example of inserting an item code with the minimum data:
{
"codiceArticoloMG": "ARTDOC",
"currentDescription": "Articolo Prova creato tramite WEBAPI",
"ditta": {{defaultCompany}},
"divprez": 0.0,
"dtcreaz": "2025-01-01T00:00:00",
"dtultagganag": "2021-01-01T00:00:00",
"fattconv": 2.00000,
"flgAlter": 1,
"flgArtfor": 1,
"flgRicgiac": 1,
"flgRicgiacCosti": 1,
"flgStgior": 1,
"flgStinv": 1,
"flgVarart": 1,
"flgVariato": 1,
"indcalcpre1": 99,
"indcalcpre2": 99,
"indcalcqta1": 3,
"indcalcqta2": 1,
"inddecqta": 1,
"indfatconv": 1,
"indtotart": 1,
"indum2": 1,
"opzioneMg5e": "",
"regprov": 99.0,
"um1": "KG ",
"um2": "MT ",
"vatCodeCO": {
"codice": "22",
"idprov": 25.0,
"perciva": 22.00,
"rowVersion": "AAAAAAAZpXw=",
"tipologia": 1.0,
"verslynfa": "2018.00.04",
"idExtendedAttributeEntity": 61,
"idExtendedAttributeSubEntity": 63
},
"indicatoreFittizio": {
"descr": "No",
"indFittizio": 0
},
"datoDescrizione": [
{
"codArtMg66": "ARTDOC",
"descart": "Articolo Prova creato tramite WEBAPI [lingua]",
"descartest": "",
"dittaCg18":{{defaultCompany}},
"linguaMg52": "",
"opzioneMg5e": ""
}
],
"itemStatusWH": {
"descr": "In uso",
"indStato": 50.0
}
}
Reading service for Item Barcode
The article barcode reading service allows you to read the barcodes of all articles. For example
{{webapi_base_url}}/{{api}}/v1/{{scope}}/WH/ItemBarCodeWH/search?company={{defaultCompany}}
This is the body of Search service:
{
"filters": {
"operator": 0,
"items": [
{
"propertyName": "codArtMG66",
"value":"BICICLETTA"
}
]
}
}
This is the response:
{
"totalCount": 0,
"pageSize": 1,
"pageNumber": 0,
"data": [
{
"codArtMg66": "BICICLETTA",
"codBarcode": "1234567891 ",
"dittaCg18": 1000.0,
"flgCheckdig": 1.0,
"flgInviocas": 1.0,
"flgStampa": 1.0,
"idmediaCg99": null,
"indProven": 0.0,
"indTipogest": 0.0,
"lastchange": "2025-04-01T15:23:03.44",
"numdec": null,
"numpzconf": 1.000,
"opzioneMg5e": "",
"progA": null,
"progDa": null,
"tipobarcodeMg4b": 0.0,
"extensionData": [],
"additionalData": {},
"pluginData": {}
}
],
"extensionData": [],
"additionalData": {},
"pluginData": {}
}
Reading and Searching ItemStatusWH
The ItemStatusWH service allows you to read and search for standard item statuses. For example
{{webapi_base_url}}/{{api}}/v1/{{scope}}/WH/ItemStatusWH/search?company={{defaultCompany}}
This is the body of Search service:
{
"filters": {
"items": [
{
"operator": 1,
"propertyName": "indStato",
"comparer": 0,
"value": 10
}
]
},
"pageSize": 0,
"pageNumber": 0
}
This is the response:
{
"totalCount": 0,
"pageSize": 1,
"pageNumber": 0,
"data": [
{
"descr": "In progettazione",
"indStato": 10.0,
"extensionData": [],
"additionalData": {},
"pluginData": {}
}
],
"extensionData": [],
"additionalData": {},
"pluginData": {}
}
Management of parametric states on customers-suppliers, items and documents
The StateManagementService service allows user to view the Current State of an object, based on the identifying guid, and allows user to change the current state to one of its available states.
The Current State is managed for the following entities:
- CustomerSupplierMG (GET only)
- CustomerSupplierCO
- DocumentoCorpoMG
- DocumentoTestataMG
- ItemWH
User can view and/or modify the Current State of an object if a predefined Flow has been defined for the entity in question and based on the permissions related to the user being used.
Through a simple GET call, user can view the Current State and the Available States for a specific user in the response. For example, if user wants to check the current state of the item code SW6 for the admin user, the GET call should be structured as follows:
GET {{webapi_base_url}}/{{api}}/v1/{{scope}}/WH/ItemWH/SW6?company={{defaultCompany}}&user=admin
and the response will show the state of the item code under consideration and the available states for the admin user.
"statoAttualeCO": {
"statoCorrente": {
"idStato": 4,
"seq": -1,
"indTipoStato": 0,
"extensionData": [],
"additionalData": {}
},
"statiDisponibili": [
{
"idStato": 3,
"seq": 3,
"indTipoStato": 0,
"extensionData": [],
"additionalData": {}
},
{
"idStato": 4,
"seq": 4,
"indTipoStato": 0,
"extensionData": [],
"additionalData": {}
},
{
"idStato": 5,
"seq": 5,
"indTipoStato": 0,
"extensionData": [],
"additionalData": {}
},
{
"idStato": 6,
"seq": 6,
"indTipoStato": 0,
"extensionData": [],
"additionalData": {}
}
}
If user runs the same GET call but specifies another user (who does not have the same permissions as the 'admin' user mentioned above), the response will always show the same Current State but will only show the available states for the other user.
Through the PUT or PATCH call, user can modify the value of the Current State of the entity under consideration, so for example, considering the item code SW6, the PATCH call should be structured as follows:
PATCH {{webapi_base_url}}/{{api}}/v1/{{scope}}/WH/ItemWH/SW6?company={{defaultCompany}}&user=admin
and in the body, user must indicate a new stateId among those available:
{
"statoAttualeCO": {
"statoCorrente": {
"idStato": 5,
"seq":5,
"indTipoStato": 0,
"extensionData": [],
"additionalData": {}
}
}
}
Through the StateManagementService service and through the related GUID, it is possible to view the currentState (which corresponds to the CurrentState) existing for the object under consideration, and as well as the availableStates (which corresponds to the list of available States). For example, always considering the item code 'SW6' for the admin user, a GET call is made, specifying the corresponding GUID of the aforementioned item code:
GET {{webapi_base_url}}/{{api}}/v1/{{scope}}/CO/StateManagementService/{000-000-000-000}?company={{defaultCompany}}&user=admin
And the response will be as follows:
{
"currentState": {
"idStato": 4,
"description": "In uso",
"seq": -1,
"indTipoStato": 0,
"extensionData": [],
"additionalData": {}
},
"availableStates": [
{
"idStato": 3,
"description": "Rilasciato",
"seq": 3,
"indTipoStato": 0,
"extensionData": [],
"additionalData": {}
},
{
"idStato": 4,
"description": "In uso",
"seq": 4,
"indTipoStato": 0,
"extensionData": [],
"additionalData": {}
},
{
"idStato": 5,
"description": "In esaurimento",
"seq": 5,
"indTipoStato": 0,
"extensionData": [],
"additionalData": {}
},
{
"idStato": 6,
"description": "Dismesso",
"seq": 6,
"indTipoStato": 0,
"extensionData": [],
"additionalData": {}
}
]
}
Or
For example, if you want to check the CurrentState of a document, you make a GET call (as shown), specifying the corresponding GUID of the DocumentHeader:
GET {{webapi_base_url}}/{{api}}/v1/{{scope}}/CO/StateManagementService/{{guidTestataDocumento}}?company={{defaultCompany}}&user=admin
And the response will show the CurrentState (or currentState) of the document and any AvailableStates (or availableStates), so it will be as follows:
{
"currentState": {
"idStato": 41,
"description": "Confermato",
"seq": -1,
"indTipoStato": 0,
"extensionData": [],
"additionalData": {}
},
"availableStates": [
{
"idStato": 40,
"description": "Acquisito",
"seq": 1,
"indTipoStato": 0,
"extensionData": [],
"additionalData": {}
},
{
"idStato": 41,
"description": "Confermato",
"seq": 2,
"indTipoStato": 0,
"extensionData": [],
"additionalData": {}
},
{
"idStato": 42,
"description": "Bloccato",
"seq": 3,
"indTipoStato": 0,
"extensionData": [],
"additionalData": {}
},
{
"idStato": 43,
"description": "In spedizione",
"seq": 4,
"indTipoStato": 0,
"extensionData": [],
"additionalData": {}
},
{
"idStato": 44,
"description": "Evaso",
"seq": 5,
"indTipoStato": 0,
"extensionData": [],
"additionalData": {}
}
]
}
Or if you want to check the CurrentState of a row within the document under consideration, with a simple GET on the document, you retrieve the corresponding GUID identifying the said row and then execute the following GET call for the StateManagementCO service:
GET {{webapi_base_url}}/{{api}}/v1/{{scope}}/CO/StateManagementService/{{guidRigaDocumento}}?company={{defaultCompany}}&user=admin
And the response will show the CurrentState (or currentState) of the document row and any AvailableStates (or availableStates), so it will be as follows:
{
"currentState": {
"idStato": 46,
"description": "In evasione",
"seq": -1,
"indTipoStato": 0,
"extensionData": [],
"additionalData": {}
},
"availableStates": [
{
"idStato": 45,
"description": "Da evadere",
"seq": 1,
"indTipoStato": 0,
"extensionData": [],
"additionalData": {}
},
{
"idStato": 46,
"description": "In evasione",
"seq": 2,
"indTipoStato": 0,
"extensionData": [],
"additionalData": {}
},
{
"idStato": 47,
"description": "Evasa",
"seq": 3,
"indTipoStato": 0,
"extensionData": [],
"additionalData": {}
},
{
"idStato": 48,
"description": "Bloccata",
"seq": 4,
"indTipoStato": 0,
"extensionData": [],
"additionalData": {}
},
{
"idStato": 49,
"description": "Annullata",
"seq": 5,
"indTipoStato": 0,
"extensionData": [],
"additionalData": {}
}
]
}
Through the StateManagementService and the setstate action, it is also possible to advance the existing 'currentState' for an object, always using the relevant GUID, by specifying a new 'idState' from those available for the user being used. In this case, the following POST call is executed:
POST {{webapi_base_url}}/{{api}}/v1/{{scope}}/CO/StateManagementService/setstate?company={{defaultCompany}}&user=admin
and in the body, you specify the GUID of the object in question and the new idState, specifying it in the "newState" field:
{
"guidObject": "{000-000-000-000}",
"newState": 5,
"entityCodeForDefault": null
}
For example, considering a specific customer in the 'Codified' state (idState=7), after the appropriate administrative checks, you want to advance the customer's state from 'Codified' to 'In Use' (idState=8). To do this, you execute the POST call, specifying the customer's GUID in the body:
POST {{webapi_base_url}}/{{api}}/v1/{{scope}}/CO/StateManagementService/setstate?company={{defaultCompany}}&user=admin
And in the body, you specify the GUID of the object in question (in this case, the Customer) and the new idState, specifying it in the "newState" field:
{
"guidObject": "{{guidCliente}}",
"newState": 8,
"entityCodeForDefault": null
}
User can also verify the case where a predefined Flow has not been specified, so when creating an item code, for example, the code 'AW1', the CurrentStateCO is NULL. Later, from the Interface, user indicates a flow as 'Default' for the Items entity. At this point, through the 'setstate' action, user can set the value of the 'Default' state belonging to the corresponding 'Default Flow' for the Items entity.
So user runs the same POST call, setting the "newState" parameter to null and "entityCodeForDefault": 6, specifying the guid of the object under consideration (therefore the guid of the item code under consideration AW1)
{
"guidObject": "{000-000-000-000}",
"newState": null,
"entityCodeForDefault": 6
}
The response will show the currentState and the availableStates, as shown below:
{
"currentState": {
"idStato": 10002,
"description": "item inserted",
"seq": -1,
"indTipoStato": 0,
"extensionData": [],
"additionalData": {}
},
"availableStates": [
{
"idStato": 10002,
"description": "item inserted",
"seq": 1,
"indTipoStato": 0,
"extensionData": [],
"additionalData": {}
},
{
"idStato": 10003,
"description": "item confirmed",
"seq": 2,
"indTipoStato": 0,
"extensionData": [],
"additionalData": {}
}
]
}
Through the StateManagementService and the history action, user can also view the various state advancements of the object under consideration, always through the corresponding guid. User performs a GET call structured as follows:
GET {{webapi_base_url}}/{{api}}/v1/{{scope}}/CO/StateManagementService/history/{000-000-000-000}?company={{defaultCompany}}&user=admin
and the response will show the "currentState" and the "statusOperationHistory" with various information:
{
"currentState": {
"idStato": 10003,
"description": "item confirmed",
"seq": -1,
"indTipoStato": 0,
"extensionData": [],
"additionalData": {}
},
"statusOperationHistory": [
{
"idHistory": 135,
"idStatus": 10002,
"validityDate": "2025-03-10T00:00:00",
"updateDate": "2025-03-10T15:00:54.713",
"historyAuto": 0,
"statusDescription": "item inserted",
"flowDescription": "Test Flow",
"userDescription": "Admin user",
"historyDelete": 1
},
{
"idHistory": 136,
"idStatus": 10003,
"validityDate": "2025-03-21T00:00:00",
"updateDate": "2025-03-21T15:03:39.033",
"historyAuto": 0,
"statusDescription": "item confirmed",
"flowDescription": "Test Flow",
"userDescription": "Admin user",
"historyDelete": 0
}
],
}
Documents
The "Document" resource can be used to insert/delete/modify a document in TSE. The resource can be used to insert any type of document, simply by changing the document code in the call.
In order for the information sent to the WebAPI via the corresponding DTO to be correctly received and stored, it is essential that the document code wizard used also handles it properly on the user interface.
Therefore, during the solution design phase, it is necessary to always perform a double check: verify that a document manually entered through the user interface, with the same information sent via WebAPI, is correctly registered and managed by the system.
The insertion of a document can occur synchronously with the POST method.
Please note that to insert a document, it is not necessary to populate all the properties of the complex DTO that represents it. The minimal insertion of the document is done by indicating:
"company" or "companyCg18" (the working company code): property in DocumentHeader.
Note: From version 202501000, a default logic for the company field in Data Transfer Objects (DTO) has been introduced. If the value of the company field of the "root" entity is not provided or is null, it is automatically populated with the company code derived from the current user session (parameter company). This operation propagates to all associated external and internal entities.
"companyDocumentMasterData": property of type CompanyDocumentMasterDataMGDTO that represents the document code to be used for the document insertion. In TSE, each document refers to a document code previously activated for the working company. To insert a document, it is mandatory to indicate the document code to be used, a code to which behaviors and parameterizations with the related functionalities of the management system (Document Customization / Company Document Customization) are associated, and specify whether the document code is standard or customized. A possible value for the companyDocumentMasterData property could be:
{
"companyDocumentMasterData": {
"codDocumMg36": "C-ORDINE",
"indStaperMg36": 1
}
}
In this way, a document with the document code "C-ORDINE" customized (indStaperMg36 = 1, while for standard document codes indStaperMg36 = 0) activated on company 100 is inserted.
"customerSupplierMG": property of type customerSupplierMGDTO that represents the customer or supplier to whom the document is addressed. For example, to address the document to the customer with code 123, it is necessary to set the 'customerSupplierMG' property as follows:
{
"customerSupplierMG": {
"tipocfCg40": 0,
"cliFor": 123
}
}
Note that cliFor is the customer (or supplier for supplier-type documents) code and not its ID present in the CG44_CLIFOR table. Finally, remember that if the document code requires the customer or supplier, it is necessary to define the 'tipocfCg40' indicator with the possible values of the CG44_TIPOCF field of the CG44_CLIFOR table, which are:
0 for customers 1 for suppliers
"sezdoc": the section of the document numbering (e.g., "sezdoc": "00")
"storageWH": the property of type StorageWHDTO that represents the warehouse to be moved. For example, working on company 100, to order goods in warehouse "00", it is necessary to set the storageWH property as follows:
{
"storageWH": {
"codDep": "00"
}
}
"lines": the array of lines to be inserted in the document; it is an array of objects of type DocumentLineMGDTO. The types of lines currently managed in the document body are as follows:
- Item (indtiporiga = 0)
- Manual Item (indtiporiga = 1)
- Descriptive (indtiporiga = 2)
- Expense (indtiporiga = 4)
- Fixed Text (indtiporiga = 6)
- Node (indtiporiga = 15)
- Activity (indtiporiga = 16)
- Project Expense (indtiporiga = 17)
Other types usable from the direct document issuance interface are not supported.
Depending on the type of line to be inserted in the document, a different "indtiporiga" must be specified, as described above. For each document line, at least the line number, code, and quantity must be indicated.
- For item lines, at least the line number, item code, item description, and quantity must be indicated. The indtiporiga property takes the default value of 0 if not set.
{
"progrRiga": 1.0,
"codartMg66": "ART001",
"descart": "Item description ART001",
"qta1": 1.000
}
Note: If item lines are inserted and an item code provides for the automatic explosion of additional lines, the progrRiga is automatically recalculated by the procedure.
- For miscellaneous expense lines, at least indtiporiga, line number, quantity (normally unitary), and expense code, an object of type MiscellaneousExpenseMGDTO, must be indicated, as in the following example:
{
"indtiporiga": 4,
"progrRiga": 4.0,
"qta1": 1.000,
"miscellaneousExpenseMG": {
"code": "SP1"
}
}
Note on Document Customization: Document customizations are managed only in the document header through "extensionData" and "additionalData" and cannot be managed in the document lines. Therefore, to manage document customizations in the document body, it is necessary to use the CustomizedLine (DO35_DOCCORPOPERS) and ExtendedLine (DO36_DOCCORPOEST) fields.
Price retrieval when inserting lines If the prices and discounts of warehouse items inserted in the document body are passed with a value of zero, the business logic values them based on the price retrieval configuration set on the document code parameterization used.
If the price and discounts passed in the DTO are different from zero, the values proposed by the price retrieval logic from the configuration will be overwritten with the values passed in the DTO.
Note on Document Customization: Document customizations are managed only in the document header through "extensionData" and "additionalData" and cannot be managed in the document lines. Therefore, to manage document customizations in the document body, it is necessary to use the CustomizedLine (DO35_DOCCORPOPERS) and ExtendedLine (DO36_DOCCORPOEST) fields.
Price retrieval when inserting lines If the prices and discounts of warehouse items inserted in the document body are passed with a value of zero, the business logic values them based on the price retrieval configuration set on the document code parameterization used.
If the price and discounts passed in the DTO are different from zero, the values proposed by the price retrieval logic from the configuration will be overwritten with the values passed in the DTO.
Regarding Document scenarios, some examples are made available directly within the POST (Create) call of the IntegrationMG\Documento module in the swagger:

Using the Try it out feature, it will be possible to automatically execute the call, replacing the placeholders indicated in the examples with the appropriate data.
Available Document examples on Swagger:
Default (complete): shows the complete call body; Min required: Minimal mandatory header information; Order: example of an order-type document body; Delivery Note: example of a delivery note-type document body; Invoice: example of an invoice-type document body; Transfer warehouses: example of a warehouse transfer-type document body.
callOptions Property
The callOptions property allows grouping all call options/parameters that are not actual fields of the entity.
Currently, the following options are available:
flgSpbolliForceZero(default false): set to true if you want to force the value = 0 of the stamp duty expenses flag;flgSpincasForceZero(default false): set to true if you want to force the value = 0 of the collection expenses flag;esclusioneAgentiMultipli(default false): set to true to exclude the loading of multiple agents in the header;esclusioneIvaTestata(default false): set to true to force the VAT code of the document header to Null;flgLockOnDocExist(default false): set to true to block the insertion of an already existing document;disableLetterOfIntent(default false): set to true to disable letters of intent;esclusioneSpeseTestiCliFor(default false): set to true to exclude the proposal of default expense and fixed text lines of the Customer.
WARNING: the parameters esclusioneAgentiMultipli, esclusioneIvaTestata, flgLockOnDocExist already present in the document header entity remain to ensure compatibility with previous versions; it is recommended not to use them as they have been deprecated, and the [Obsolete] attribute is used in the swagger.
Management of the Preferred Agent
It is possible to manage the preferred agent when saving a customer (CustomerSupplierCO). Any agent associated with the customer is inserted into the multiple agents as the preferred agent. It is also possible to define additional multiple agents for the customer.
When inserting a document, the multiple agents stored in the customer registry are retrieved.
However, if different agents are specified in DocumentoTestataAgentiMG property during document insertion, these will replace those retrieved from the customer registry.
Through the callOptions property, it is possible to include or exclude multiple agents.
EsclusioneAgentiMultipli = false (with callOptions property or parameter=0 on version 8)
- If the
DocumentoTestataAgentiMGproperty is not set in the DTO, the system will populate theDO29_DOCTESAGENTItable with the agents linked to the customer and retrieved using the usual logic employed by the management software when inserting the document from the interface. - If the
DocumentoTestataAgentiMGproperty is set in the DTO, the system will populate theDO29_DOCTESAGENTItable with the agents mentioned in the previous point and with the agents passed inDocumentoTestataAgentiMG(the two sets of agents are merged).
EsclusioneAgentiMultipli = true (with callOptions property or parameter=1 on version 8)
- The system will populate the
DO29_DOCTESAGENTItable only with any agents passed inDocumentoTestataAgentiMG, ignoring those that would be proposed by the customer configuration.
Price Search from Priority Price Lists
Retrieving Prices When Inserting Rows from Priority Price Lists: PricePriorityLI Service The service allows you to perform a price search from priority price lists through the PricePriorityLI service.
The attached example shows the price of the priority price lists processed based on the Priority Table defined on TSE, used to generate the PricePriorityLI, and displays it in the Result ("RowElaboratePriceList") if the parameter "ResultElaboratePriceList" is set to true.
Parameters
- Price Type (typeSalePurchaseProd):
Decimal(DO11_TIPOCF_CG44/2)
0 = Sales (default)
1 = Purchases
2 = Production - Item Code (CodartMg66):
String(DO30_CODART_MG66) — mandatory - Customer/Supplier Code:
Decimal(DO11_CLIFOR_CG44) - Registration Date:
Datetime(DateElab) — mandatory - Quantity 1 (of row) (qty1):
Decimal(DO30_QTA1) - Price List Number (numPriceList):
Decimal(DO11_LISTMAG) - Warehouse Code (codDepMg58):
String(DO30_CODDEP_MG58) - Enable display of processed price list (resultElaboratePriceList): if set =
true
Example
{
"typeSalePurchaseProd": 0,
"codArtMg66": "ART_LI",
"cliforCg44": 1,
"dateElab": "2024-06-14 00:00:00",
"qty1": 0,
"numPriceList": 1,
"codDepMg58": "00",
"resultElaboratePriceList": true
}
Price Search from Parametric Price Lists
Retrieving prices when inserting rows from parametric price lists: PriceParametricLI service The PriceParametricLI service allows you to determine the price based on parametric price lists starting from the priority code defined in the Priority Table on TSE.
This service requires the "PriceParametricParameters" and calls the stored procedure SPLP_QUOTPROBELIST to retrieve the current price with any discounts in "PriceParametricLI".
A parameter is also provided to request the detail of the outcome of the parametric price list processing, which allows you to understand how the price was formed based on the priority table and the providers used.
WARNING!: Currently, the stored procedure also manages commercial conditions and commissions for document footer, which are not handled in this initial phase (the fixed parameter @RIGA_PIEDE=0 is passed to the stored procedure).
Parameters
- ResultElab bool (default false) Parameter to activate the outcome of the parametric price list processing. If activated, it is necessary to pass to the stored procedure the name of a temporary table where all the price rows found to generate the final price are stored.
- dataReg - Registration date --- mandatory
- CodTabPriority int64 (ID_TABPRIORITA) --- mandatory Through the code, the IdTabPriority to be passed to the stored procedure is derived.
- tipocfCg44 - Customer/Supplier Type Decimal (DO11_TIPOCF_CG44) WARNING: Document type conversion: customer= 0 --> becomes 1 and supplier=1 becomes 2 to be passed to the stored procedure.
- cliforCg44 - Customer/Supplier Code Decimal (DO11_CLIFOR_CG44) All customer/supplier fields are read automatically.
- codartMg66 - String (DO30_CODART_MG66) --- mandatory
- documentData - Document date Datetime (DATADOC) If not set, it is valued with the registration date
Example
{
"resultElab": false,
"dataReg": "2023-06-22T13:34:35.125Z",
"CodTabPriority": "TVEN",
"tipocfCg44": 0,
"cliforCg44": 2,
"codartMg66": "2",
"documentData": {
"qta1": 10,
"documMg36": "CLI-FATIMM"
}
}
Print Documents Service: generating document print to PDF
To enable the PDF printing of a document, it is possible to retrieve the streamPDF of a document with a GET request using the Print command. This streamPDF must then be decoded and converted into a PDF using any conversion program.
Example of GET request to generate the streamPDF:
webapi_base_url/api/v1/{{scope}}/MG/Documento/<NumeroDocumento>/print?company={{defaultCompany}}
The service returns the following Json:
{
"streamPDF": "JVBERi0xLjMgCiXi48/ …………………………………….. ",
"error": ""
}
The content of the streamPDF must be copied and inserted into any conversion program to proceed with decoding and converting it into a PDF.
Warning - in case of archived and valid print: in the case of archived and valid print, it is necessary to re-export, and the program retrieves the archived PDF from the disk.
Extension of PDF Printing Functionality
The PDF printing service has been extended: in addition to generating the standard document via streamPDF, it is now possible to print custom reports associated with the document type Example of GET request to generate the streamPDF:
{{webapi_base_url}}/api/v1/{{scope}}/mg/documento/{{numreg}}/print?user=admin&company={{azienda}}&reportname=CRMG_STINTINV_SINT.rpt
The service returns the following Json:
{
"streamPDF": "JVBERi0xLjMgCiXi48/ …………………………………….. ",
"error": ""
}
The reportName field allows dynamic selection of the desired print layout, either Crystal or Jasper, making the system more flexible and adaptable to specific requirements.
KIT management
It is possible to search, insert, modify, and delete a kit and consequently use it within appropriately configured documents (General Document Parameters - Customization) with the related explosion of components in the document rows.
Using the Master KitWH and Detail KitLinkWH entities, it is possible to create simple kits by defining only the item and quantity
{
"codProductMg66": "BICI",
"dittaCg18": {{azienda}},
"exclusionChild1Mg82": null,
"exclusionChild2Mg82": null,
"exclusionChild3Mg82": null,
"exclusionChild4Mg82": null,
"exclusionFather1Mg82": "OR",
"exclusionFather2Mg82": "BO",
"exclusionFather3Mg82": "FA",
"exclusionFather4Mg82": "PR",
"optionProductMg5e": "",
"kitLinkWH": [
{
"codComponentMg66": "BICI2",
"optionComponentMg5e": "",
"qtyComponent1": 10.000000
},
{
"codComponentMg66": "MSE003",
"qtyComponent1": 15.000000
}
]
}
or create complete kits, where it is possible to set additional properties:
{
"codProductMg66": "MSE002",
"dittaCg18": {{azienda}},
"exclusionChild1Mg82": null,
"exclusionChild2Mg82": "BO",
"exclusionChild3Mg82": "PR",
"exclusionChild4Mg82": null,
"exclusionFather1Mg82": "OR",
"exclusionFather2Mg82": "BO",
"exclusionFather3Mg82": "FA",
"exclusionFather4Mg82": "PR",
"optionProductMg5e": "",
"kitLinkWH": [
{
"codComponentMg66": "BICI2",
"optionComponentMg5e": "",
"StartingDate": "2024-01-15T00:00:00",
"endingDate": "2024-12-31T00:00:00",
"qtyComponent1": 13.000000,
"qtyComponent2": 10.000000,
"fixedQta": 1,
"typeBomLink": 3,
"typeOptionalLink": 1,
"typeVal": 2,
"costComponent": 10.0000
},
{
"codComponentMg66": "BICI",
"optionComponentMg5e": "",
"StartingDate": "2024-01-15T00:00:00",
"edningDate": "2024-06-31T00:00:00",
"qtyComponent1": 25.000000,
"qtyComponent2": 33.000000,
"fixedQta": 1,
"typeBomLink": 3,
"typeOptionalLink": 0,
"typeVal": 3,
"costComponent": 150.0000
}
]
}
KIT Components That Are Themselves KITs
When managing a KIT, the IdKitNode property allows you to determine whether a component is a raw material or another KIT. This can be seen in the following sample request:
GET {{webapi_base_url}}/{{api}}/v1/{{scope}}/WH/KitWH/{{idKit}}?company={{defaultCompany}}&utente=admin
The response contains two KIT rows. In one case, the idKitNode value is null, indicating that the component is a raw material. In the other case, the value is a non-null number, which corresponds to the ID of a child KIT—meaning it is not a raw material but another KIT.
The sample response is:
{
"codProductMg66": "KSE001",
"codTypeBom": "",
"dittaCg18": 2.0,
...
"kitLinkWH": [
{
"codComponentMg66": "KSE002",
...
"idKitNode": 31.0, // child KIT ID
...
},
{
"codComponentMg66": "00003",
...
"idKitNode": null, // raw material
...
}
],
...
}
Inserting Document with Kit Type Item Code
Through a standard document insertion call, it is possible to include a Kit type item code among the document rows. The explosion of the related components and the explosion mode must be predefined by the ERP in General Document Parameters, Document Customization, or Company Document Customization, depending on the company's needs.
The following example involves the insertion of a DDT using the customized document type 'C-DDT', which includes two document rows:
- One with a normal item code.
- The other with a Kit type item code.
This document type provides for the explosion of the Kit components, with each component being listed on the document as a descriptive row.
{
"valutaCg08": "EURO",
"anagraficaDocumentoDitta": {
"codDocumMg36": "C-DDT",
"indStaperMg36": 1.0
},
"customerSupplierMG": {
"tipocfCg40": 1,
"cliFor": 1
},
"sezdoc": "00",
"storageWH": {
"codDep": "00"
},
"righe": [
{
"progrRiga": 1.0,
"codartMg66": "ART001",
"descart": "Articolo ordinario",
"qta1": 15.000
},
{
"progrRiga": 1.0,
"codartMg66": "MSE002",
"descart": "Articolo kit",
"qta1": 15.000
}
]
}
Automatic Generation of Kit Product Loading Documents and Kit Component Unloading Documents
If the sales or customer commitment document contains Kit item lines, but the document type used does not provide for the generation of Kit Product Loading and Kit Component Unloading, or if a Kit Product Loading document is entered without component explosion, it is possible to perform this at a later time using the KitDocumentService.
The service includes two actions:
- unloadcomp which allows the unloading of Kit components at the first level, based on the existing Kit Product Loading documents;
- loadkit which allows the creation of the Kit Product Loading document and the Kit Component Unloading document, based on the sales or customer commitment documents considered.
Batch Generation for Kit Product Loading and Component Unloading For the correct generation of the documents in question, it is noted that the batch movement for the Product Loading document must be defined in the Batch Console for "Single Item", while for the Component Unloading document it must be defined for "Multiple Items".
Generation of Kit Component Unloading Documents
The KitDocumentService, through the unloadcomp action, allows the unloading of Kit components at the first level, based on the entered Kit Product Loading documents for which the component explosion and the corresponding component unloading have not been performed. If there are also Semi-finished products, a loading document for the Semi-finished product and an unloading document for the components of the Semi-finished product are generated.
Here is a practical example: The item code KIT is composed of item code (component1) 00001 and item code (component2) 00002. A Kit Product Loading document is entered with two item lines, both referring to the item code KIT but with different quantities and prices. Document number 40 dated 08/07/2025 is generated, and the component explosion is not performed.
To generate the Kit Component Unloading document at a later time, the following call must be executed:
webapi_base_url/api/v1/{{scope}}/MG/KitDocumentService/unloadcomp?company={{defaultCompany}}
In the body of the call, you must specify the necessary parameters to generate the new document (unloadComponentKitParameter) and define the necessary parameters for a sort of selection/search at the document header level (headLoadDocumentsFilter) and/or at the document line level (rowLoadDocumentsFilter), where you define the details of the Kit Product Loading document under consideration and/or the Kit item code. These parameters are mandatory (as per the interface):
{
"loadDocumentCodeFilter": "INT-CARKIT",
"unloadComponentKitParameter": {
"documentCode": "INT-SCARKIT",
"postingDate": "2025-07-08",
"documentDate": "2025-07-08",
"documentSectional": "00",
"documentNumber": 0,
"storageCode": "00",
"indExplosionLevel": "0",
"numberLevel": 1,
"indSemiFinishedProducts": "0",
"recalculateCostKitProduct": false,
"includeBOMComponents": false
},
"headLoadDocumentsFilter": {
"filters": {
"items": [
{
"propertyName": "datadoc",
"comparer": 0,
"value": "2025-07-08"
},
{
"operator": 1,
"propertyName": "numdoc",
"comparer": 0,
"value": 40
}
]
}
},
"rowLoadDocumentsFilter": {
"filters": {
"items": [
{
"propertyName": "codartMg66",
"comparer": 0,
"value": "KIT"
}
]
}
}
}
The response lists the generated documents based on the item lines highlighted in the above search.
{
{
"numRegLoadProductKit": [],
"numRegUnloadComp": [
"202500000897",
"202500000898"
]
}
}
Simultaneous Generation of Kit Product Loading Documents and Kit Component Unloading Documents
The KitDocumentService, through the loadkit action, allows the generation of Kit Product Loading Documents based on the entered sales documents. For each Kit Product Loading Document, it is also possible to simultaneously generate the corresponding Kit Component Unloading Documents
Here is a practical example: We always consider the item code KIT, composed of item code (component1) 00001 and item code (component2) 00002. A sales document is entered with a KIT item line with document number 408 dated 08/07/2025, and the components are not exploded.
To generate the Kit Loading Document and the Kit Component Unloading Document, the following call must be executed:
webapi_base_url/api/v1/{{scope}}/MG/KitDocumentService/loadkit?company={{defaultCompany}}
In the body of the call, you must specify the necessary parameters to generate the new Kit Product Loading Document (loadProductKitParameter) and the parameters for the new Kit Component Unloading Document (unloadComponentKitParameter). In the body, it is also possible to apply search filters at the document header level, using the parameters (headLoadDocumentsFilter) and/or at the line level (rowLoadDocumentsFilter). In this case, you specify the details of the relevant sales document and/or the Kit item code under consideration:
{
{
"loadProductKitParameter": {
"documentCode": "INT-CARKIT",
"postingDate": "2025-07-08",
"documentDate": "2025-07-08",
"documentSectional": "00",
"documentNumber": 100
},
"unloadComponentKitParameter": {
"documentCode": "INT-SCARKIT",
"postingDate": "2025-07-08",
"documentDate": "2025-07-08",
"documentSectional": "00",
"documentNumber": 101,
"storageCode": "00",
"indExplosionLevel": "0",
"numberLevel": 1,
"indSemiFinishedProducts": "0",
"recalculateCostKitProduct": false,
"includeBOMComponents": false
},
"headUnloadDocumentsFilter": {
"filters": {
"items": [
{
"propertyName": "datadoc",
"comparer": 0,
"value": "2025-07-08"
},
{
"operator": 1,
"propertyName": "numdoc",
"comparer": 0,
"value": 408
}
]
}
},
"rowUnloadDocumentsFilter": {
"filters": {
"items": [
{
"propertyName": "codartMg66",
"comparer": 0,
"value": "KIT"
}
]
}
}
}
}
The response lists the documents corresponding to the Kit Product Loading (numRegLoadProductKit) and the documents related to the Kit Component Unloading (numRegUnloadComp), based on the item lines under consideration.
{
{
"numRegLoadProductKit": [
"202500000904"
],
"numRegUnloadComp": [
"202500000905"
]
}
}
Balancing check of batches quantity
The balancing check is performed on the quantity of the batches, both when is active the "Balancing check for document", and when is active the "Balancing check for movement". In the second case, the check on the front-end is performed by the batch entry program for each item line indicated in the document.
In the case of non-balancing batch control, for example an item line of 10 pcs and a batch line with a quantity of 3 pcs, an error or a warning is reported based on the "Balancing check for document" parameter defined in the Batch parameters console:
-
A Warning will be reported if the parameter = "Ask whether to continue document registration" has been selected
-
An Error will be reported if, instead, the parameter = "Block document registration" has been selected
Both error or warning reports can be forced by adding the base url &force=16099
Example of a message with incorrect quantities item details and warning report:
{
"items": [
{
"message": "Check balancing by document:\r\n Reg: 202500000578 \r\n - Item: 1_KIT_LOTTO qty1: 5 (Type mov.: LOT qty1: 0)\r\n Reg: 202500000579 \r\n - Item: 1_KIT_LOT2/42 W qty1: 10 (Type mov.: LOT qty1: 0)\r\n(Source: CMD_GENERACAR_ButtonClick)",
"warningCode": 16099,
"isWarning": true,
"isError": false,
"dtoName": null,
"dtoPropertyName": null,
"entityPropertyPath": null
}
],
"extensionData": [],
"additionalData": {},
"pluginData": {}
}
Transfer Document Between Warehouses
It is possible to issue an outbound warehouse DDT, automatically generating a new inbound warehouse DDT.
In the JSON for the Header part, the storageWH properties for the originating warehouse must be filled out
{
"storageWH": {
"codDep": "00"
}
}
and storageWHCollegato for the destination warehouse
{
"storageWHCollegato": {
"codDep": "01",
"descrdep": "Deposito secondario",
}
}
If within a document the user wants to define a row warehouse different from the header warehouse, in the JSON file, in the document rows section, coddepcolMg58 and coddepMg58 must be filled out :
{
"coddepcolMg58": "01",
"coddepMg58": "00",
}
where the first indicates the destination warehouse and the second indicates the originating warehouse.
Document service
DocumentService contains a set of processing services to complement the CRUD part of the documents, such as transformation, fulfillment, order portfolio fulfillability check, and bulk insertion of synchronous and asynchronous document types.
Document Transformation 1-to-1 and Fulfillment Status Check
The attached example presents the ERP-B2C interaction scenario that involves the insertion of a Customer Order with:
- Minimal mandatory header information
- Item type row, with item code and quantity (price retrieved from the price list in the BO)
Regarding Document Transformation (transform), with the following call:
webapi_base_url/api/v1/{{scope}}/MG/DocumentService/transform?company={{defaultCompany}}&force=24368,89522
The document is transformed into an invoice by specifying the registration number of the source order document and the related transformation model. The response includes the registration number of the generated invoice.
The service retrieves the parameters from "DocumentTransformationParameterDTO," which contains the transformation model defined on the ERP and the list of registration numbers of the source documents. It returns in "DocumentTransformationMGDTO" the list of registration numbers of the generated documents.
DocumentTransformationParameterDTO
{
"[NumRegOrigin]" - obbligatorio (Numero di registrazione che si vuole trasformare/evadere)
"CodModelTransfDoc" - obbligatorio (Codice modello per la trasformazione documento)
}
DocumentTransformationResponseDTO
{
"<NumRegDestination>" - (Elenco dei numero di registrazione creati)
}
In case of warning messages it is possible to override them with the following parameters:
&force=24368: in the Presence of Blocked Article Notifications; &force=29074: in the Presence of Notifications for Articles and Batches Transformed Understock.
The following Lookups are also available to trace transformation models and their composition, as well as Lookups that query beyond the already existing entities:
- ModelTrasformationCompanyMG: with details in ModelTrasformationCompanyDetMG
- ModelTrasformationMG: with details in ModelTrasformationDetMG
These contain the source and destination document codes used by the transformation model:
- General Transformation Models Lookup: View all models (general archive) detailed with source and destination documents
webapi_base_url/api/v1/{{scope}}/MG/Lookup/ModelTrasformationMG
- **General Transformation Models Details Lookup**: View All Model Details (general archive)
webapi_base_url/api/v1/{{scope}}/MG/Lookup/ModelTrasformationDetMG
- **General Transformation Models Lookup**: View Activated Models by Company (Without Details)
webapi_base_url/api/v1/{{scope}}/MG/Lookup/ModelTrasformationCompanyMG
- **Transformation Models Lookup with Document Details**: View Activated Models by Company or General Archive with details of actual source and destination documents. The property **ModelTrasformationCompanyMG.IndEvasmult** is retrieved from the ERP. If set to 99, the documents from the general archive are used. If set to 1, the company's documents are used instead.
webapi_base_url/api/v1/{{scope}}/MG/Lookup/ModelTrasformationCompanyDetMG
webapi_base_url/api/v1/{{scope}}/MG/Lookup/ModelTrasformationCompanyWithCodeDoc