{
	"name": "form/nc/nc-work-center/save/product_work-actual.json",
	"organization_id": "",
	"save": [
		{
			"record_type": "",
			"table": "production_order",
			"on_conflict": "update"
		},
		{
			"record_type": "actual",
			"table": "product_work"
		}
	],
	"parameter": {
		"combine_save": ["product_work-actual", "production_order"],
		"finished_state": true,
		"show_sql": true
	},
	"query-": [["pro.json_data.state", "<>", "finished_state"]],
	"default_value": {
		"production_order": {
			"static-": {
				"production_order_state": "started"
			},
			"copy_value-": {
				"product_id": "pr.product_id"
			},
			"copy_value": {
				"remaining_amount": "pro.amount_to_produce"
			},
			"code_update": [
				{
					"function": "concatWith",
					"result": "produced_amount",
					"parameter": [
						" + ",
						{
							"value": "production_order.produced_amount"
						},
						{
							"tag": "pro.new_produced_amount"
						}
					]
				},
				{
					"function": "concatWith",
					"result": "failed_amount",
					"parameter": [
						" + ",
						{
							"value": "production_order.failed_amount"
						},
						{
							"tag": "pro.new_failed_amount"
						}
					]
				},
				{
					"function": "concatWith",
					"result": "remaining_amount",
					"parameter": [
						" - ",
						{
							"value": "production_order.amount_to_produce"
						},
						{
							"value": "production_order.produced_amount"
						},
						{
							"tag": "pro.new_produced_amount"
						}
					]
				}
			]
		},
		"product_work-": {
			"code-": [
				{
					"function": "currentUtcString",
					"result": "event_time"
				}
			],
			"code_update": [
				{
					"function": "concatWith",
					"result": "work_hours",
					"parameter": [
						" + ",
						{
							"value": "product_work.work_hours"
						},
						{
							"tag": "prwo.work_hours"
						}
					]
				},
				{
					"function": "concatWith",
					"result": "setup_hours",
					"parameter": [
						" + ",
						{
							"value": "product_work.setup_hours"
						},
						{
							"tag": "prwo.setup_hours"
						}
					]
				},
				{
					"function": "concatWith",
					"result": "machine_hours",
					"parameter": [
						" + ",
						{
							"value": "product_work.machine_hours"
						},
						{
							"tag": "prwo.machine_hours"
						}
					]
				}
			]
		}
	}
}
