{
	"name": "preference/report/work_in_progress_cost/work_in_progress.json",
	"subtotal": ["pr.product_group"],
	"null_allowed": ["qry_work_self_cost", "qry_material_self_cost_por", "qry_material_self_cost_wme__unit", "qry_subcontract_self_cost"],
	"calculate": [
		{
			"field": "qry_material_self_cost_wme__unit",
			"width": 70,
			"name": "Mat. OK/kpl (var. ohj)",
			"format": ["%'.0f"]
		},
		{
			"field": "calc_material_self_cost_wme",
			"width": 70,
			"name": "cost_wme",
			"format": ["%'.0f"]
		},
		{
			"field": "self_cost_sum",
			"formula": ["+", "qry_work_self_cost_calculated", "qry_subcontract_self_cost_calculated", "calc_material_self_cost_wme", "qry_material_self_cost_por_calculated"]
		}
	],
	"column": [
		{
			"field": "rowNumber",
			"subtotal": "",
			"subtotal_operator": "",
			"width": 30,
			"name": "Rivi",
			"format": ["%'d"]
		},
		{
			"field": "pro.company_id",
			"width": 80,
			"name": "Asiakas"
		},
		{
			"field": "pr.product_group",
			"width": 90,
			"name": "Tuoteryhmä"
		},
		{
			"field": "pro.drawing_number",
			"width": 125,
			"name": "Piirustusnumero"
		},
		{
			"field": "pr.name",
			"width": 218,
			"name": "Nimi"
		},
		{
			"field": "pro.production_order_id",
			"width": 70,
			"name": "Valm. erä"
		},
		{
			"field": "pro.production_order_state",
			"width": 24,
			"name": "Tila"
		},
		{
			"field": "pro.create_time",
			"width": 68,
			"name": "Luontipäivä",
			"format": ["d%d.%m.%Y"],
			"styleXX": "row_data_date"
		},
		{
			"field": "pro.json_data.material_actual_arrival_date",
			"width": 66,
			"name": "RA tot. tulo",
			"format": ["d%d.%m.%Y"]
		},
		{
			"field": "pr.production_type",
			"width": 25,
			"name": "T/V",
			"formula": [
				"replace",
				{
					"0": "T",
					"1": "V"
				}
			],
			"style": {
				"text-align": "center"
			}
		},
		{
			"field": "pro.amount_to_produce",
			"width": 40,
			"name": "Al.",
			"style": {
				"text-align": "center"
			}
		},
		{
			"field": "pro.produced_amount",
			"width": 40,
			"name": "Val.",
			"style": {
				"text-align": "center"
			}
		},
		{
			"field": "pro.remaining_amount",
			"width": 40,
			"name": "Jäl.",
			"style": {
				"text-align": "center"
			}
		},
		{
			"field": "pro.failed_amount",
			"width": 40,
			"name": "Hyl.",
			"style": {
				"text-align": "center"
			}
		},
		{
			"field": "calc_material_self_cost",
			"width": 70,
			"name": "Mat. OK",
			"formula": ["+", "qry_material_self_cost_por_calculated", "calc_material_self_cost_wme"],
			"format": ["%'.0f"],
			"style": {
				"text-align": "right"
			}
		},
		{
			"field": "calc_subcontract_self_cost",
			"width": 70,
			"name": "Alih. OK",
			"formula": ["+", "qry_subcontract_self_cost_calculated"],
			"format": ["%'.0f"],
			"style": {
				"text-align": "right"
			}
		},
		{
			"field": "calc_work_self_cost",
			"width": 70,
			"name": "Työ. OK",
			"format": ["%'.0f"],
			"formula": ["+", "qry_work_self_cost_calculated"],
			"style": {
				"text-align": "right"
			}
		},
		{
			"field": "reduced_self_cost",
			"width": 45,
			"name": "Väh.",
			"formula": ["*", "self_cost_sum", "reduced_self_cost_multiplier", "-1"],
			"format": ["%'.0f"],
			"style": {
				"text-align": "right"
			}
		},
		{
			"field": "calc_self_cost",
			"width": 67,
			"name": "OK yht.",
			"formula": ["*", "self_cost_sum", "self_cost_multiplier"],
			"format": ["%'.0f"],
			"style": {
				"text-align": "right"
			}
		},
		{
			"field": "calc_sales_price",
			"width": 67,
			"name": "MH",
			"formula": ["*", "pro.remaining_amount", "pro.json_data.sales_price__unit"],
			"format": ["%'.0f"],
			"style": {
				"text-align": "right"
			}
		},
		{
			"field": "calc_profit_percent",
			"formula": [
				["/", "calc_self_cost", "calc_sales_price"],
				["*", "100"]
			],
			"width": 45,
			"name": "%",
			"format": ["%.f%%"],
			"style": {
				"text-align": "right"
			}
		}
	],
	"columns_not_in_use": [
		{
			"field": "qry_material_self_cost_por",
			"width": 70,
			"name": "Mat. OK (til. ohj)",
			"format": ["%'.0f"],
			"type": "calculate"
		},
		{
			"field": "qry_material_self_cost_wme__unit",
			"width": 70,
			"name": "Mat. OK/kpl (var. ohj)",
			"format": ["%'.0f"],
			"type": "calculate"
		},
		{
			"field": "qry_material_self_cost_wme__unit",
			"width": 70,
			"name": "Mat. OK/yks",
			"format": ["%'.0f"],
			"style": {
				"text-align": "right"
			}
		}
	]
}
