updateObject.php
SM JSON Object Import Service
Endpoint: UpdateObject.php
This service inserts or updates specific object data from data given in JSON format. It can update address, item, transaction, event, or category data. Only PUT or POST methods are accepted.
Parameters:
user: SM user name for authenticationpassword: SM user password for authenticationobject: the type of object to insert/update. Accepted values:address,item,transaction,event,categorynodatareturn: if specified andobject=transaction, the sent transaction(s) won't be sent back in the data field
Request Body:
A JSON data structure with the following fields must be given:
comparekeys: name one or more keys to decide if the object must be updated or inserted.directimport: iftrue, the transactions are immediately present in the database. If not set, transactions are first uploaded to a buffer table.data: array of objects containing the data to insert with the names of the keys. There shouldn't be primary keys in the data.
List of fields per object:
Address:
- Fields: "Status", "Name1", "Name2", "Title", "Address1", "Address2", "Address3", "Address4", "Address5", "Address6", "DeliveryAddress1", "ContactPerson", "SalutationNr", "AddressTypeNr", "Phone_d", "Phone_p", "Fax", "Modem", "Radio", "eMail", "URL", "Photo", "Bankname", "BankAccount", "BankCode", "IBAN", "BIC", "PostAccount", "AddressInformation", "CustomerNumber", "MinimalOrder", "DeliverInformation", "Sales", "ElectronicOrder", "Protocol", "Name1beforeName2", "AddressActive", "CurrencyNr", "VAT_free", "MaximalAmount", "DiscountNr", "DeliveryDuration", "DeliveryDays", "OrderDate", "ModificationMarks", "FDB_Link1", "FDB_Link2", "LCostAmount", "LCostFactor0", "LCostFactor1", "LCostFactor2", "LCostFactor3", "ParentNr", "AddressGroup", "LanguageNr", "AddressText", "AddressAddon", "AddressDesc", "Sales", "Sales_P1", "Sales_P2", "AddressNumber", "AddressActive", "PurchaseAmount", "ReturnsAmount", "ContactPerson", "ContactInformation", "Time_Stamp", "PricelevelNr", "ElectronicOrder", "ControlID", "VATNr", "PaymentDeadline", "OrderInterval", "DeliveryDuration", "DeliveryDays", "OrderDays"
- Only one address per call can be sent. The branch-specific data will be added/updated for each branch.
Example:
{
"comparekeys": ["CustomerNumber"],
"data": [
{
"Status": "-1",
"Name1": "Vita Reform-Verlag AG",
"Name2": "",
"Title": "",
"Address1": "Bodenackerstrasse 69",
"Address2": "",
"Address3": "4657 Dullikon",
"Address4": "",
"Address5": "",
"Address6": "",
"DeliveryAddress1": "",
"ContactPerson": "",
"SalutationNr": "1",
"AddressTypeNr": "0",
"Phone_d": "",
"Phone_p": "",
"Fax": "",
"Modem": "",
"Radio": "",
"eMail": "",
"URL": "",
"Photo": "",
"Bankname": "",
"BankAccount": "",
"BankCode": "",
"IBAN": "",
"BIC": "",
"PostAccount": "01-2594-3",
"AddressInformation": "",
"CustomerNumber": "965990",
"MinimalOrder": "0",
"DeliverInformation": "",
"Sales": "0",
"ElectronicOrder": "0",
"Protocol": "",
"Name1beforeName2": "-1",
"AddressActive": "-1",
"CurrencyNr": "0",
"VAT_free": "0",
"MaximalAmount": "-6660.5",
"DiscountNr": "1",
"DeliveryDuration": "",
"DeliveryDays": "",
"OrderDate": "",
"ModificationMarks": "0",
"FDB_Link1": "",
"FDB_Link2": "",
"LCostAmount": "",
"LCostFactor0": "",
"LCostFactor1": "",
"LCostFactor2": "",
"LCostFactor3": "",
"ParentNr": "0",
"AddressGroup": "",
"LanguageNr": "",
"AddressText": "",
"AddressAddon": "",
"AddressDesc": "",
"Sales": "",
"Sales_P1": "",
"Sales_P2": "",
"AddressNumber": "",
"AddressActive": "-1",
"PurchaseAmount": "0",
"ReturnsAmount": "0",
"ContactPerson": "",
"ContactInformation": "",
"Time_Stamp": "",
"PricelevelNr": "",
"ElectronicOrder": "0",
"ControlID": "",
"VATNr": "",
"PaymentDeadline": "",
"OrderInterval": "",
"DeliveryDuration": "",
"DeliveryDays": "0",
"OrderDays": "0"
}
]
}
Item:
- Fields: "Barcode", "ItemNumber", "ProductGroupNr", "PackageTypeNr", "Quantity", "UnitNr", "AssortmentNr", "FrontLabelNr", "BackLabelNr", "ProductionQty", "AssignQty", "DeliveryQty", "StockQty", "RequiredQty", "PurchaseAmount", "SalesAmount", "PurchaseQty", "SalesQty", "StartStock", "Status", "Ordered", "Reserved", "SentToTill", "DiscountNr", "StockItem", "MinFillUpQty", "MinSalesPrice", "ModificationMarks", "ItemType", "DaysofSales", "ForcePriceInput", "ForcePriceControl", "NoQtyPreselection", "NoDoublePosition", "NoReturn", "MinSalesQty", "MaxSalesQty", "ForceWeightInput", "Discountable", "strFDB_Link1", "strFDB_Link2", "strFDB_Link3", "lngFDB_Link4", "lngFDB_Link5", "Time_stamp", "GrossWeight", "ShipmentTypeNr", "AmountDaysOutOfStock", "CSFactor", "SaleOnPermission", "FullStockQty", "FullStoreQty", "ActualStockQty", "ActualStoreQty", "MinStockQty", "MinimalStockQty", "BasicPrice", "ActualPrice", "ItemActive", "ShelfLocation", "StockLocation", "SalesAmount", "SalesQty", "PurchaseAmount", "PurchaseQty", "Time_Stamp", "ItemURL", "ItemSpecsURL", "ItemPictureURL", "ItemPictureSmallURL", "ItemPicturePrintURL", "SellingDaysAmount", "NOSFlag", "AmountDaysOS", "ItemName", "ItemAddition1", "ItemAddition2", "ItemAddition3", "Matchcode", "TillName", "LabelName", "ItemShortDescription", "ItemDescription", "VATRateNr", "VATRateNr1", "HPrice1", "HPrice2", "HPrice3gross", "HPrice3", "HPrice1gross", "HPrice2gross", "HQty1", "HQty2", "HQty3", "WCostAmount", "WCostFactor0", "WCostFactor1", "WCostFactor2", "WCostFactor3", "LCostAmount", "LCostFactor0", "LCostFactor1", "LCostFactor2", "LCostFactor3", "ProductionQuantity", "AssignQty", "DeliveryQty", "StockQty", "RequiredQty", "BeginningQty", "SentToTill", "DiscountNr", "IsStockItem", "MinFillUpQty", "MinSalesPrice", "ForcePriceInput", "ForcePriceControl", "NoQtyPreselection", "NoDoublePosition", "NoReturn", "MinSalesQty", "MaxSalesQty", "ForceWeightInput", "Discountable", "ShippingTypeNr", "AmountDaysOutOfStock", "Department", "AvPurchasePrice", "AvSalesPrice"
Example:
{
"comparekeys": ["ItemNumber"],
"data": [
{
"Barcodes": ["98989", "76987897", "9898989"],
"ItemNumber": "3565697",
"ProductGroupNr": "1",
"PackageTypeNr": "0",
"Quantity": "1",
"UnitNr": "27",
"AssortmentNr": "1",
"FrontLabelNr": "",
"BackLabelNr": "35",
"ProductionQty": "0",
"AssignQty": "0",
"DeliveryQty": "0",
"StockQty": "0",
"RequiredQty": "0",
"PurchaseAmount": "0",
"SalesAmount": "24",
"PurchaseQty": "0",
"SalesQty": "17",
"StartStock": "0",
"Status": "-1",
"Ordered": "0",
"Reserved": "0",
"SentToTill": "0",
"DiscountNr": "0",
"StockItem": "0",
"MinFillUpQty": "1",
"MinSalesPrice": "0",
"ModificationMarks": "0",
"ItemType": "0",
"DaysofSales": "0",
"ForcePriceInput": "0",
"ForcePriceControl": "0",
"NoQtyPreselection": "0",
"NoDoublePosition": "0",
"NoReturn": "0",
"MinSalesQty": "0",
"MaxSalesQty": "0",
"ForceWeightInput": "0",
"Discountable": "-1",
"strFDB_Link1": "",
"strFDB_Link2": "",
"strFDB_Link3": "",
"lngFDB_Link4": "0",
"lngFDB_Link5": "0",
"Time_stamp": "",
"GrossWeight": "0",
"ShipmentTypeNr": "",
"AmountDaysOutOfStock": "0",
"CSFactor": "0",
"SaleOnPermission": "0",
"FullStockQty": "100",
"FullStoreQty": "24",
"ActualStockQty": "0",
"ActualStoreQty": "0",
"MinStockQty": "10",
"MinimalStockQty": "-1",
"BasicPrice": "1",
"ActualPrice": "1",
"ItemActive": "-1",
"ShelfLocation": "",
"StockLocation": "",
"SalesAmount": "1054.9054871100002",
"SalesQty": "972",
"PurchaseAmount": "0",
"PurchaseQty": "0",
"Time_Stamp": "2011-09-05 11:09:46",
"ItemURL": "",
"ItemSpecsURL": "",
"ItemPictureURL": "",
"ItemPictureSmallURL": "",
"ItemPicturePrintURL": "",
"SellingDaysAmount": "0",
"NOSFlag": "0",
"AmountDaysOS": "0",
"ItemName": "Kiwi frisch aus Italien",
"ItemAddition1": "",
"ItemAddition2": "",
"ItemAddition3": "",
"Matchcode": "Kiwi frisch aus Italien",
"TillName": "Kiwi frisch aus Italien",
"LabelName": "Kiwi frisch aus Italien",
"ItemShortDescription": "",
"ItemDescription": "",
"VATRateNr": "1",
"VATRateNr1": "2",
"HPrice1": "1",
"HPrice2": "1",
"HPrice3gross": "0",
"HPrice3": "1",
"HPrice1gross": "0",
"HPrice2gross": "0",
"HQty1": "",
"HQty2": "",
"HQty3": "",
"WCostAmount": "",
"WCostFactor0": "",
"WCostFactor1": "",
"WCostFactor2": "",
"WCostFactor3": "",
"LCostAmount": "0",
"LCostFactor0": "1",
"LCostFactor1": "1",
"LCostFactor2": "1",
"LCostFactor3": "1",
"ProductionQuantity": "0",
"AssignQty": "0",
"DeliveryQty": "0",
"StockQty": "0",
"RequiredQty": "0",
"BeginningQty": "0",
"SentToTill": "0",
"DiscountNr": "0",
"IsStockItem": "-1",
"MinFillUpQty": "1",
"MinSalesPrice": "0",
"ForcePriceInput": "0",
"ForcePriceControl": "0",
"NoQtyPreselection": "0",
"NoDoublePosition": "0",
"NoReturn": "0",
"MinSalesQty": "0",
"MaxSalesQty": "0",
"ForceWeightInput": "0",
"Discountable": "-1",
"ShippingTypeNr": "3",
"AmountDaysOutOfStock": "0",
"Department": "",
"AvPurchasePrice": "0",
"AvSalesPrice": "1"
}
]
}
Transaction:
One object and four arrays of objects. Name and field of these objects:
- bill: "BillNr", "BranchNr", "HostNr", "Description", "DeliveryAddress", "AddressNr", "Subject", "Salutation", "Text1", "Text2", "Text3", "VATAmount", "Discount", "Reduction", "Allowance", "Amount", "DiscountFactor", "BillNr", "BDate", "CRMAction1", "CRMAction2", "CRMAction3", "UserNr", "AccountBooked", "SalesBooked", "StockBooked", "Status", "AddressRight", "URef", "IRef", "ReporttoPrint1", "ReporttoPrint2", "PaymentTerm", "AllowanceTerm", "DiscountCombi", "DiscountNr", "BookStockAt", "VATFlag", "VATText", "SettingNr", "EFTTrxNum", "EFTBillText", "ExportedToSM", "ExportedToTps"
- positions: "PositionID", "Pos", "Quantity", "Title", "Option1", "Option2", "PosPrice", "PosDiscount", "PosReduction", "PosAmount", "VATAmount", "ItemNr", "VATRateNr", "Barcode", "UserNr", "Status", "AccountBooked", "SalesBooked", "StockBooked", "Discountable", "DiscountNr"
- finance: "AccountNr", "Amount", "WAmount", "Timestamp", "Status", "FText1", "FText2"
- bookings: "BookingNr", "BranchNr", "HostNr", "DebitAccount", "CreditAccount", "AddressNr", "BookingRuleNr", "TransactionDesc", "Amount", "VatCode", "CurrDate", "TransactDate", "ProcessingDate", "Confirmed", "Payable", "Paid", "PaymentOrder", "Status", "BookingRef", "UserNr"
The value of comparekeys will most likely be ["BillNr"]
Only one transaction can be imported every call (see request body transaction)
Example:
{
"comparekeys": ["BillNumber"],
"data": {
"bill": {
"BillNr": null,
"BranchNr": 28,
"HostNr": 11901,
"Description": null,
"DeliveryAddress": null,
"AddressNr": 0,
"Subject": null,
"Salutation": null,
"Text1": null,
"Text2": null,
"Text3": null,
"VATAmount": 0.0,
"Discount": 0.0,
"Reduction": 0.0,
"Allowance": 0.0,
"Amount": 19.0,
"DiscountFactor": 0.0,
"BillNumber": "B0281190119071500121",
"BDate": "2019-07-15T16:26:43.5891754",
"CRMAction1": null,
"CRMAction2": null,
"CRMAction3": null,
"UserNr": 4855,
"AccountBooked": -1,
"SalesBooked": -1,
"StockBooked": -1,
"Status": 4,
"AddressRight": null,
"URef": null,
"IRef": null,
"ReporttoPrint1": null,
"ReporttoPrint2": null,
"PaymentTerm": null,
"AllowanceTerm": null,
"DiscountCombi": null,
"DiscountNr": null,
"BookStockAt": null,
"VATFlag": null,
"VATText": null,
"SettingNr": null,
"EFTTrxNum": null,
"EFTBillText": null,
"ExportedToSM": null,
"ExportedToTps": null,
"LastUpdate": "2019-07-15T16:26:43.5891754"
},
"positions": [
{
"PositionID": 1,
"BranchNr": 28,
"HostNr": 11901,
"BillNr": null,
"Status": -1,
"Pos": "1",
"Quantity": "1",
"Title": "Alkoholika > 18% Vol.",
"PosPrice": 19.0,
"PosDiscount": null,
"PosReduction": null,
"PosAmount": 19.0,
"VATAmount": 0.0,
"ItemNr": 1,
"VATRateNr": 1,
"Barcode": "2",
"UserNr": 4855,
"PositionStatusNr": 0,
"AccountBooked": -1,
"SalesBooked": -1,
"StockBooked": -1,
"Discountable": -1,
"DiscountNr": 1,
"Option1": null,
"Option2": null,
"IsDeleted": 0,
"IsEnable": 1,
"LastUpdate": "2019-07-15T16:26:43.5941613",
"SortOrder": 1
}
],
"finance": [
{
"BillNr": null,
"BranchNr": 28,
"HostNr": 11901,
"AccountNr": 110,
"Amount": 19.0,
"WAmount": null,
"Timestamp": "2019-07-15 16:26:41",
"Status": -1,
"FText1": null,
"FText2": null,
"LastUpdate": "2019-07-15T16:26:41.5888513"
}
],
"bookings": [
{
"BookingNr": null,
"BranchNr": 28,
"HostNr": 11901,
"CurrDate": "2019-07-15 16:26:43",
"DebitAccount": null,
"CreditAccount": 3520,
"AddressNr": 0,
"BookingRuleNr": null,
"TransactionNumber": "B0281190119071500114",
"TransactionDesc": "receipt",
"Amount": null,
"VatCode": null,
"TransactDate": "2019-07-15 16:26:43",
"ProcessingDate": "2019-07-15 16:26:43",
"Confirmed": 1,
"Payable": null,
"Paid": -1,
"PaymentOrder": null,
"Status": null,
"BookingRef": 2,
"UserNr": 4855,
"LastUpdate": "2019-07-15T16:26:43.8145501"
},
{
"BookingNr": null,
"BranchNr": 28,
"HostNr": 11901,
"CurrDate": "2019-07-15 16:26:43",
"DebitAccount": null,
"CreditAccount": 2220,
"AddressNr": 0,
"BookingRuleNr": null,
"TransactionNumber": "B0281190119071500114",
"TransactionDesc": "receipt VAT",
"Amount": null,
"VatCode": 1,
"TransactDate": "2019-07-15 16:26:43",
"ProcessingDate": "2019-07-15 16:26:43",
"Confirmed": 1,
"Payable": null,
"Paid": -1,
"PaymentOrder": null,
"Status": null,
"BookingRef": 2,
"UserNr": 4855,
"LastUpdate": "2019-07-15T16:26:43.8145501"
},
{
"BookingNr": null,
"BranchNr": 28,
"HostNr": 11901,
"CurrDate": "2019-07-15 16:26:43",
"DebitAccount": 110,
"CreditAccount": null,
"AddressNr": 0,
"BookingRuleNr": null,
"TransactionNumber": "B0281190119071500114",
"TransactionDesc": "receipt",
"Amount": 19.0,
"VatCode": null,
"TransactDate": "2019-07-15 16:26:43",
"ProcessingDate": "2019-07-15 16:26:43",
"Confirmed": 1,
"Payable": null,
"Paid": -1,
"PaymentOrder": null,
"Status": null,
"BookingRef": 2,
"UserNr": 4855,
"LastUpdate": "2019-07-15T16:26:43.8175778"
}
]
}
}
Event:
Array of objects with one object and an array of objects
- event: "BranchNr", "EventNr", "EventName", "EventDescription", "Eventcolor", "Eventfromdate", "Eventtodate", "CalendarNr", "ParentEventNr", "UserNr", "framecolnr", "backcolnr", "frametypenr", "timestamp", "status", "foreignlink", "foreignlinktype", "exclusive", "blocked"
- eventartikel: "ItemNr", "BranchNr", "FullStock", "CurrentStock", "MinStock", "Actualprice", "Status"
The value of comparekeys will most likely be ["EventNr"]
Example:
{
"comparekeys": ["EventNr"],
"data": [
{
"event": {
"BranchNr": "33",
"EventNr": "18475",
"EventName": "Vorlage-Test",
"EventDescription": "This is an event",
"Eventcolor": "0000FF",
"Eventfromdate": "2019-04-18 09:00:00",
"Eventtodate": "2019-04-18 10:00:00",
"CalendarNr": "1",
"ParentEventNr": "0",
"UserNr": "1",
"framecolnr": "0",
"backcolnr": "0",
"frametypenr": "-1",
"timestamp": "2019-04-16 15:38:13",
"status": "-1",
"foreignlink": "B0330012011600001",
"foreignlinktype": "3",
"exclusive": "0",
"blocked": "0"
},
"eventartikel": [
{
"ItemNr": "22387",
"BranchNr": "33",
"FullStock": "150",
"CurrentStock": "15",
"MinStock": "0",
"Actualprice": "90.15",
"Status": "-1"
},
{
"EventNr": "18474",
"ItemNr": "47301",
"BranchNr": "33",
"FullStock": "15",
"CurrentStock": "15",
"MinStock": "0",
"Actualprice": "178",
"Status": "-1"
}
]
}
]
}
Category:
Array of three objects with the following properties
- category: "CatNr", "ParentCatNr", "FromDate", "ToDate", "Status", "DisplayMode", "TimeStamp"
- catcontent: "languageNr", "Title", "SubTitle", "Text1", "Text2", "Pic1", "Pic2", "Text3", "Pic3"
- catitems: array of objects with "branch": integer, branch number on which to add the items and "items", one array of integers representing the item numbers for this branch and category. The items must be completely transmitted per branch. So it is possible to remove items per category and branch.
Example: "catitems"
[
{
"branch": 3,
"items": [1, 2, 3, 4, 5]
},
{
"branch": 4,
"items": [6, 7, 8, 9]
}
]
The value of comparekeys will most likely be ["CatNr"]
Example:
{
"comparekeys": ["CatNr"],
"data": [
{
"category": {
"CatNr": "202",
"ParentCatNr": "10",
"FromDate": "2019-02-12 14:16:14",
"ToDate": "2019-02-12 14:16:15",
"Status": "1",
"DisplayMode": "1",
"TimeStamp": "2019-02-13 11:23:32"
},
"catcontent": [
{
"languageNr": "0",
"Title": "BBB56767",
"SubTitle": "5685",
"Text1": "",
"Text2": "",
"Pic1": "Picture1.jpg",
"Pic2": "Picture2.jpg",
"Text3": "",
"Pic3": ""
},
{
"languageNr": "1",
"Title": "Cat 1.1.1",
"SubTitle": "5685",
"Text1": "555556",
"Text2": "64",
"Pic1": "Picture11.jpg",
"Pic2": "Picture22.jpg",
"Text3": "6",
"Pic3": "Picture33.jpg"
},
{
"languageNr": "2",
"Title": "BBB56767",
"SubTitle": "5685",
"Text1": "",
"Text2": "",
"Pic1": "Picture111.jpg",
"Pic2": "Picture222.jpg",
"Text3": "",
"Pic3": ""
}
],
"catitems": [
{
"branch": 3,
"items": [1, 2, 3, 4, 5]
},
{
"branch": 4,
"items": [6, 7, 8, 9]
}
]
}
]
}
Return values of the JSON structure:
success:trueorfalsestatus: numeric status, see table below for detailsdata: an array containing objects with the keys values of the added/modified objects (the index of the array corresponds to those of the input objects) on success or error message when failed- If
successisfalseand the problem is record-specific, returns one object per failed record, with the three following fields:data: the erroneous record array sent to the serviceerrornr: the number of the error (can also be MySQL error numbers)message: the error message (can also be a MySQL error message)query: the query which threw an error
Remarks:
- The
sm_viewsmust be defined on the server (Database update/Table views or see definitions below) - If there is a NULL value to be sent (especially for empty numeric fields), please use this format:
"field": "NULL"(and not"field": "", etc.) - When an object will be updated and fields are omitted, these won't be updated
- If
object="Transaction":- the uploaded transaction(s) will be returned in the field
data, in the same format as the request - If the
BillNumberstarts with "A", the bill will be moved to the delete tables - If the
BillNumberends with "S", the bill with Number without S (original B) will be set toStatus=11 - If the bill has to be overwritten and its status is 4, 11, 21, 22, 23, 24, 25, 26 or 30, it won't be overwritten and a message with
status 110will be thrown
- the uploaded transaction(s) will be returned in the field
Status codes:
0: Execution of the query ok102: Cannot connect to database103: Authentication failure105: Object name unknown106: No data JSON given107: No comparekeys given108: Error while executing query109: Method is not POST or PUT110: No bill data present111: No positions in the incoming bill112: Bill has not all data on the StoreManager113: Bill cannot be replaced because it is already on the StoreManager
Examples:
- Request: /UpdateObject.php?object=address&user=user&password=password
- Request body address:
Example:
{
"comparekeys": [
"eMail",
"AddressTypeNr"
],
"data": [
{
"LanguageNr": "1",
"FDB_Link2": "xxx",
"AddressNr": null,
"Status": "-1",
"Name1": "Jozef",
"Name2": "Palenik",
"Title": "",
"Address2": "1. m\u00e1ja",
"Address1": "1991-01-01",
"Address3": "",
"Address4": "841 07",
"Address5": "Bratislava",
"Address6": "",
"DeliveryAddress1": "Jozef Palenik\r\n1. m\u00e1ja\r\nBratislava\r\n841 07\r\nSK\r\n",
"ContactPerson": "",
"SalutationNr": "1",
"AddressTypeNr": "15",
"eMail": "jozef.palenik@adega.ch",
"Phone_d": null
}
]
}
Response OK:
{
"success": true,
"status": 0,
"data":
[
{
"AddressNr": 5455
}
]
}