Met de ioi API kun je de volgende ioi-klassen gebruiken:
- ioi Customer,
- ioi Supplier,
- ioi Item,
- ioi Sales Quote,
- ioi Sales Order,
- ioi Sales Delivery,
- ioi Sales Invoice,
- ioi Purchases Price Request,
- ioi Purchases Order,
- ioi Purchases Receipt,
- ioi Purchases Invocie.
→ De Functie werkt volgens hetzelfde principe als de REST API van Frappe: https://frappeframework.com/docs/user/en/api/rest
Authenticatie en machtigingen #
Meegeleverde principes als de REST API van FRAPPE.
→ Voor authenticatie:
- Token-gebaseerde authenticatie,
- Wachtwoord-gebaseerde authenticatie,
- Toegangstoken.
→ Voor machtigingen baseren we ons op de standaard gebruikersmachtigingen per doctype.
Body-structuur #
→ Type: Raw JSON-body.
Voorbeeld:
{
"mandatory_field": "ID",
"my_data":{
""overriding_field": "DATE"
},
"line_detail": [{
"mandatory_field": "ITEM",
"my_data": {
"overriding_field": "PRICE"
}
}
]
}
→ Een van de voordelen van het gebruik van klassen is het profiteren van de populaties van het object.
Voorbeeld: Wanneer de referentie van een klant wordt opgegeven, worden alle gebieden met betrekking tot deze klant ingevuld door de populatie van de klant.
→ Bovendien zullen alle gegevens die zich in het object ‘my_data’ bevinden, de gegevens van de populatie overschrijven.
Voorbeeld: Als we een populatie van de klant hebben, maar toch de waarde van de verkoopvoorwaarde willen afdwingen, moeten we aangeven:
"my_data":{ "sales_condition_id": "NORMAL" }
Het ‘line_detail’-object is een array bedoeld voor de detailregels. Dit heeft alleen betrekking op verkoop- en inkoopdocumenten. Het hierboven uitgelegde principe is hetzelfde voor de detailregels. Samengevat:
- In het ‘main’-object vindt u: de verplichte velden en de velden die een populatie zullen activeren.
- In het ‘my_data’-object vindt u: alle andere velden.
- In de ‘line_detail’-array vindt u: de detailregels.
Overzicht van populaties #
Customer/Supplier #
- full_name
- mode
- postal_code_id
Sales / Purchases documents #
Header : #
- document_date
- period_id
- order_customer_id / order_supplier_id
- order_customer_contact_id order_supplier_contact_id
- delivery_customer_id / delivery_supplier_id
- delivery_customer_contact_id / delivery_supplier_contact_id
- invoice_customer_id / invoice_supplier_id
- invoice_customer_contact_id / invoice_supplier_contact_id
- currency_id
- currency_rate
- currency_rate_inv
- cashdesk_id
Detail : #
- sales_condition_id / purchases_condition_id
- item_id
- manufacter_ref
- unit_id
- unit_price
- fixed_price
- base_discount
- extra_discount
- value_discount
- unit_price_tvac
- account_id
- vat_type
- vat_service
- vat_matching_id
- vat_rate
- vatcode_id
- warehouse_id
CRUD Operations #
Create #
Methode : POST
Query : api/method/silicon_ioi.api.resource/:doctype
ioi Customer #
Query : api/method/silicon_ioi.api.resource/ioi Customer
→ Body :
{
"identification": "ACE",
"ioistatus": 4,
"full_name": "ACE SA",
"my_data":{
"address": "Avenue Louise 222",
"city": "Brussel",
"postal_code": "1010",
"country_id": "FR",
"phone_1": "02\/758.25.69",
"email": "info@ace.be",
"language": "fr",
"currency_id": "EUR",
"family_1_id": "INDUSTRIE",
"payment_term_id": "30,J",
"general_memo": "<!DOCTYPE HTML PUBLIC \"-\/\/W3C\/\/DTD HTML 4.01 Transitional\/\/EN\">\n<html>\n<head>\n<title><\/title>\n<meta http-equiv=\"Content-Type\" content=\"text\/html; charset=iso-8859-1\">\n<\/head>\n\n<body>\n\n<div align=\"left\"><font face=\"Courier new\" size=\"2\" color=\"#000000\"><u><i><b>TEST Rtf<br><\/b><\/i><\/u>\n<\/div>\n<div align=\"center\">je test la conversio du rtf en hml via la dll<\/font><\/div>\n<\/body>\n<\/html>",
"vat_number": "BE432-112-630",
"dimension_type": "N",
"website": "www.ace.be",
"delivery_condition_id": "EXWORKS",
"delivery_copy": 1,
"invoice_copy": 1,
"mode": 2,
"id_ioi": "ACE",
"last_sync_dt_ioi": "2023-04-26T13:25:06.210Z",
"sync_dt_ioi": "2023-04-24T09:36:39.923Z"
}
}
ioi Sales Order #
Query : api/method/silicon_ioi.api.resource/ioi Sales Order
→ Body :
{
"prefix_id": "CMD",
"document_date": "2023-10-12",
"ioistatus": 1,
"order_customer_id": "VOLVO",
"delivery_customer_id": "GARDENANS",
"invoice_customer_id": "GARDENANS",
"currency_id": "EUR",
"my_data":{
"sales_condition_id": "DISTRIB",
"delivery_condition_id": "NORMAL",
"language": "fr",
"external_ref": "TEST external ref",
"shipping_datetime": "2023-10-16 23:00:11.000",
"expected_arrival_on": "2023-10-23",
"responsible_id": "Administrator",
"base_discount": 0,
"extra_discount": 0,
"financial_discount": 0,
"vat_type": "NAT",
"spec_vat_rate": 21,
"wo_vat1": 810,
"wo_vat2": 0,
"wo_vat3": 0,
"wo_vat4": 0,
"wo_vat5": 0,
"base_vat1": 810,
"base_vat2": 0,
"base_vat3": 0,
"base_vat4": 0,
"base_vat5": 0,
"vat_type1": "NAT",
"rate_vat1": 21,
"rate_vat2": 0,
"rate_vat3": 0,
"rate_vat4": 0,
"rate_vat5": 0,
"vat1": 170.1,
"vat2": 0,
"vat3": 0,
"vat4": 0,
"vat5": 0,
"inc_vat1": 980.1,
"inc_vat2": 0,
"inc_vat3": 0,
"inc_vat4": 0,
"inc_vat5": 0,
"sales_agent_id": "ANDRE",
"credit_mode": 0,
"payment_term_id": "FDM,30,J",
"asked_arrival_date": "2015-10-13"
},
"line_detail": [{
"sales_condition_id": "DISTRIB",
"item_id": "B02-LAWNMOWER",
"unit_id": "PCS",
"ordered_qty": 1,
"unit_price": 1350,
"unit_price_tvac": 1633.5,
"base_discount": 10,
"extra_discount": 5,
"value_discount":5,
"vat_type": "NAT",
"vat_service": "G",
"vat_rate": 21,
"my_data": {
"expected_arrival_on": "2023-10-20 12:30:45",
"warehouse_id": "BXL",
"to_execute": 0,
"shipping_datetime": "2023-10-15 18:57:11.000",
"weight": 1000,
"external_ref": 10,
"item_cost": 572.22,
"item_cost_std_stamp": 485.293105,
"value_paid": 810,
"barcode_reference": "1234567001609",
"reserved_qty": 10,
"free_part_qty": 0
}
}
]
}
Read #
Methode : GET
Query : api/method/silicon_ioi.api.resource/:doctype/:name
ioi Customer #
Query : api/method/silicon_ioi.api.resource/silicon_ioi.api.resource/ACE
→ Body :
{
"data": {
"name": "ACE",
"owner": "Administrator",
"creation": "2023-10-25 14:29:39.937475",
"modified": "2023-10-25 14:29:40.216554",
"modified_by": "Administrator",
"docstatus": 0,
"idx": 0,
"is_warning": 0,
"warninfo": "",
"identification": "ACE",
"id_prefix": null,
"id_number": 0,
"lib_ioistatus": "Active",
"full_name": "ACE SA",
"language": "en",
"supplier_id": null,
"mode": "0",
"currency_id": "EUR",
"address": null,
"postal_code_id": null,
"latitude": 0.0,
"postal_code": "1000",
"city": "Brussel",
"longitude": 0.0,
"country_id": "FR",
"contact_title": null,
"contact_lastname": null,
"contact_firstname": null,
"phone_1": "02/758.25.69",
"email": "info@ace.be",
"phone_2": null,
"website": "www.ace.be",
"select_image": null,
"vat_number": "BE432-112-630",
"external_reference": null,
"vat_matching_id": null,
"duns_number": null,
"vat_type": "NAT",
"payment_term_id": "30,J",
"payment_reminder_category_id": null,
"payment_last_reminder_date": null,
"payment_last_reminder_level": 0,
"payment_reminder_last_level": null,
"accounting_collective_account_id": null,
"accounting_default_account_id": null,
"specific_vat_code_id": null,
"financial_discount": 0.0,
"financial_delay": 0,
"financial_discount_mode": "0",
"domiciliation_sign_date": null,
"domiciliation_active": 0,
"domiciliation_id": null,
"domiciliation_type": null,
"sales_catalog_id": "STANDARD",
"sales_condition_id": "NORMAL",
"specific_condition_id": null,
"delivery_condition_id": "EXWORKS",
"delivery_delay": 0,
"base_discount": 0.0,
"extra_discount": 0.0,
"sales_agent_id": null,
"default_order_to": null,
"delivery_flow": "0",
"default_deliver_to": null,
"default_invoice_to": null,
"end_user_id": null,
"not_for_order": 0,
"invoice_mode": "PAPER",
"summary_invoice": 0,
"not_for_delivery": 0,
"invoice_email": null,
"delivery_copy": 1,
"edi_identification": null,
"not_for_invoice": 0,
"invoice_format": "PDF",
"invoice_copy": 1,
"document_calc_mode": "0",
"batch_invoice_grouping_mode": "0",
"batch_invoice_grouping_cadency": 0,
"batch_invoice_grouping_except_bo": 0,
"family_1_id": "INDUSTRIE",
"family_2_id": null,
"marketing_action_disabled": 0,
"activity_summary": "",
"sector_summary": "",
"sla_category_id": null,
"geographic_index_id": null,
"distance": 0,
"visible": 0,
"sale_name": null,
"vweb": null,
"id_nav": null,
"ioistatus": "2",
"imported_data": 1,
"ioiuserstatus": "0",
"lib_ioiuserstatus": null,
"accounting_memo": null,
"general_memo": "\n\n\n<title></title>\n<meta content=\"text/html; charset=iso-8859-1\">\n\n\n\n\n<div align=\"left\"><font color=\"#000000\" face=\"Courier new\" size=\"2\"><u><i><b>TEST Rtf<br></b></i></u>\n</font></div><font color=\"#000000\" face=\"Courier new\" size=\"2\">\n</font><div align=\"center\"><font color=\"#000000\" face=\"Courier new\" size=\"2\">je test la conversio du rtf en hml via la dll</font></div>\n\n",
"reconciliation_number": 0,
"doctype": "ioi Customer",
"bank_detail": [],
"activity_detail": [],
"sector_detail": [],
"preconfigured_imputations": [],
"cust_discount_detail": []
}
}
ioi Sales Order #
Query : api/method/silicon_ioi.api.resource/silicon_ioi.api.resource/ioi Sales Order?filters=[[“order_customer_id”,“=”,“GARDENANS”]]&fields=[“name”, “total_htva”, “currency_id”]
→ Body :
{
"data": [
{
"name": "CMD • 2020000040",
"total_htva": 36000.0,
"currency_id": "EUR"
},
{
"name": "CMD • 2020000055",
"total_htva": 19980.0,
"currency_id": "EUR"
},
{
"name": "CMD • 2020000071",
"total_htva": 600.0,
"currency_id": "EUR"
},
{
"name": "ORD • 2020000027",
"total_htva": 133.88,
"currency_id": "EUR"
},
{
"name": "ORD • 2020000042",
"total_htva": 918.0,
"currency_id": "EUR"
}
]
}
Update #
Methode : PUT
Query : api/method/silicon_ioi.api.resource/:doctype/:name
ioi Customer #
Query : api/method/silicon_ioi.api.resource/ioi Customer/ACE
→ Body :
{
"my_data":
{
"city": "Brussel",
"postal_code": "1000",
"country_id": "BE"
}
}
ioi Sales Order #
Query : api/method/silicon_ioi.api.resource/ioi Sales Order/CMD • 2020000087
→ Body :
{
"document_date": "2050-10-12",
"order_customer_id": "GARDENANS",
"line_detail":[{
"name": "d2c19403c1",
"unit_price": 1400,
"my_data": {
"weight": 1100
}
}
]
}
Delete #
Methode : DELETE
Query : api/method/silicon_ioi.api.resource/:doctype/:name
ioi Customer #
Query : api/method/silicon_ioi.api.resource/ioi Customer/ACE
→ Réponse :
{
"message": "ok"
}
ioi Sales Order #
Query : api/method/silicon_ioi.api.resource/ioi Sales Order/CMD • 2020000087
→ Réponse :
{
"message": "ok"
}
Verandering van status #
Methode : POST
Query : api/method/silicon_ioi.api.resource/:doctype/:name?run_method=change_status
→ Body :
{
"ioistatus": 2
}
Wijziging van gebruikersstatus #
Methode : POST
Query : api/method/silicon_ioi.api.resource/:doctype/:name?run_method= change_user_status
→ Body :
{
"ioiuserstatus": 2
}
Specifieke methoden #
Het is ook mogelijk om een document te creëren op basis van een ander.
Methode : POST
Query : api/method/silicon_ioi.api.resource/:doctype/:name?run_method=method_name
→ Opmerkingen: Normaal gesproken zijn er geen parameters nodig in de body om deze methoden te gebruiken, behalve in twee uitzonderingen voor create_delivery en add_lines_to_delivery, waarin ook de parameter qty_rule moet worden opgegeven (zie voorbeeld). Hieronder staan de geaccepteerde waarden voor qty_rule:
- 1 : Fill limited to site stock,
- 2 : Fill limited to available,
- 3 : Fill limited to scheduled available (par défaut),
- 5 : Fill with order qty.
Creëren van een levering vanuit een bestelling #
Query : api/method/silicon_ioi.api.resource/ioi Sales Order/CMD • 2020000087?run_method=create_delivery
→ Body :
{
"qty_rule": 3
}
Toevoegen van een detailregel aan een levering vanuit een bestelling #
Query : api/method/silicon_ioi.api.resource/ioi Sales Order/CMD • 2020000087?run_method=add_lines_to_delivery
→ Body :
{
"name": "LIV • 2020000054",
"qty_rule": 3
}
Overzicht van specifieke methoden #
ioi Sales/Purchases Quote #
- create_order
- add_lines_to_order
ioi Sales Order #
- create_delivery
- add_lines_to_delivery
- create_invoice
- add_lines_to_invoice
ioi Purchases Order #
- create_receipt
- add_lines_to_receipt
- create_invoice
- add_lines_to_invoice
ioi Sales/Purchases Delivery/Receipt #
- create_invoice
- add_lines_to_invoice
Contrat #
Om een overeenkomst te creëren, moet u het parameter document_type: CONTRACT toevoegen aan het hoofdobject van het doctype ioi Sales Quote.
Methode : POST
Query : api/method/silicon_ioi.api.resource/ioi Sales Quote
→ Body :
{
"prefix_id": "CTC",
"document_date": "2023-10-12",
"ioistatus": 1,
"order_customer_id": "ASMA",
"delivery_customer_id": "ASMA",
"invoice_customer_id": "ASMA",
"currency_id": "EUR",
"document_type": "CONTRACT",
"my_data":{
"sales_condition_id": "NORMAL",
"sales_catalog_id": "STANDARD",
"delivery_condition_id": "NORMAL",
"language": "fr",
"external_ref": "TEST external ref",
"shipping_datetime": "2023-10-16 23:00:11.000",
"expected_arrival_on": "2023-10-23",
"responsible_id": "Administrator",
"base_discount": 0,
"extra_discount": 0,
"financial_discount": 0,
"vat_type": "NAT",
"wo_vat1": 810,
"wo_vat2": 0,
"wo_vat3": 0,
"wo_vat4": 0,
"wo_vat5": 0,
"base_vat1": 810,
"base_vat2": 0,
"base_vat3": 0,
"base_vat4": 0,
"base_vat5": 0,
"vat_type1": "NAT",
"rate_vat1": 21,
"rate_vat2": 0,
"rate_vat3": 0,
"rate_vat4": 0,
"rate_vat5": 0,
"vat1": 170.1,
"vat2": 0,
"vat3": 0,
"vat4": 0,
"vat5": 0,
"inc_vat1": 980.1,
"inc_vat2": 0,
"inc_vat3": 0,
"inc_vat4": 0,
"inc_vat5": 0,
"sales_agent_id": "ANDRE",
"credit_mode": 0,
"payment_term_id": "FDM,30,J",
"asked_arrival_date": "2015-10-13"
},
"line_detail": [{
"item_id": "B02-LAWNMOWER",
"unit_id": "PCS",
"quoted_qty": 5,
"my_data": {
"expected_arrival_on": "2023-10-20 12:30:45",
"warehouse_id": "BXL",
"spec_vat_rate": 21,
"to_execute": 0,
"shipping_datetime": "2023-10-15 18:57:11.000",
"weight": 1000,
"external_ref": 10,
"item_cost": 572.22,
"item_cost_std_stamp": 485.293105,
"value_paid": 810,
"barcode_reference": "1234567001609",
"reserved_qty": 10,
"free_part_qty": 0
}
}
]
}
Credit Note #
Om een creditnota te creëren, moet u het parameter document_type: CNOTE toevoegen aan het hoofdobject van het doctype ioi Sales Invoice.
Methode : POST
Query : api/method/silicon_ioi.api.resource/ioi Sales Invoice
→ Body :
{
"prefix_id": "NDC",
"document_date": "2023-10-12",
"ioistatus": 1,
//"order_customer_id": "VOLVO",
// "delivery_customer_id": "ASMA",
"invoice_customer_id": "ASMA",
"document_type": "CNOTE",
"currency_id": "EUR",
"my_data":{
"sales_condition_id": "DISTRIB",
"sales_catalog_id": "STANDARD",
"delivery_condition_id": "NORMAL",
"language": "fr",
"external_ref": "TEST external ref",
"shipping_datetime": "2023-10-16 23:00:11.000",
"expected_arrival_on": "2023-10-23",
"responsible_id": "Administrator",
"base_discount": 0,
"extra_discount": 0,
"financial_discount": 0,
"vat_type": "NAT",
"wo_vat1": 810,
"wo_vat2": 0,
"wo_vat3": 0,
"wo_vat4": 0,
"wo_vat5": 0,
"base_vat1": 810,
"base_vat2": 0,
"base_vat3": 0,
"base_vat4": 0,
"base_vat5": 0,
"vat_type1": "NAT",
"rate_vat1": 21,
"rate_vat2": 0,
"rate_vat3": 0,
"rate_vat4": 0,
"rate_vat5": 0,
"vat1": 170.1,
"vat2": 0,
"vat3": 0,
"vat4": 0,
"vat5": 0,
"inc_vat1": 980.1,
"inc_vat2": 0,
"inc_vat3": 0,
"inc_vat4": 0,
"inc_vat5": 0,
"sales_agent_id": "ANDRE",
"credit_mode": 0,
"payment_term_id": "FDM,30,J",
"asked_arrival_date": "2015-10-13"
},
"line_detail": [{
"sales_condition_id": "DISTRIB",
"sales_catalog_id": "STANDARD",
"item_id": "B02-LAWNMOWER",
"unit_id": "PCS",
"invoiced_qty": 1,
// "unit_price": 1350,
// "vat_type": "NAT",
"vat_rate": 21,
// "vat_code":
"my_data": {
"expected_arrival_on": "2023-10-20 12:30:45",
"warehouse_id": "BXL",
"spec_vat_rate": 21,
"to_execute": 0,
"shipping_datetime": "2023-10-15 18:57:11.000",
"weight": 1000,
"value_paid": 810,
"barcode_reference": "1234567001609",
"reserved_qty": 0,
"free_part_qty": 0
}
}
]
}