{
	"name": "form/nc/erp-sync/cxml/save/order-sales-import.json",
	"organization_id": "4d",
	"save": [
		{
			"record_type": ["sales"],
			"table": "order",
			"all_fields": false,
			"on_conflict": "update",
			"row_table": [{ "table": "order_row", "all_fields": false, "on_conflict": "update" }],
			"row_number_field": [
				{
					"field": "ordr.row_number",
					"start_value": 1
				}
			]
		}
	],
	"parameter": {
		"show_sql": true
	},
	"default_value": {
		"order": {
			"copy_value": {
				"delivery_company_id": "company_id",
				"invoicing_company_id": "company_id"
			},
			"static": {
				"order_type": "order",
				"order_state": "open"
			}
		}
	},
	"run_script": [
		{
			"table": "order_row",
			"init_new_record": true,
			"find_linked_record": ["ordr.order_id"],
			"info": "script_field fields are first save, then script run, then restored to imported values",
			"script_field": ["ordr.product_id", "ordr.order_amount", "ordr.delivery_date"],
			"script_field-": ["ordr.price_without_vat", "ordr.vat_price", "ordr.unit_price"]
		},
		{
			"table": "order",
			"init_new_record": true,
			"up_calculate": 1,
			"info": "script_field fields are first save, then script run, then restored to imported values",
			"script_field": ["ord.company_id", "ord.company_reference_number", "ord.your_reference"]
		}
	]
}
