{
	"name": "plugin/nc-calc-server/column/product-need.json",
	"option": {
		"grid_option": {
			"cell_class_rules": {
				"semi-bold": "data.from === 0",
				"semi-bold underline": "data.last_row === true && colDef.field === 'balance'",
				"grey": "colDef.field === 'date' && data.before_today && !data.first_row",
				"brown": "colDef.field === 'date' && data.before_today && data.first_row",
				"darkgrey": "colDef.field === 'name' || colDef.field === 'amount' && data.from === 5",
				"blue": "colDef.field === 'date' && data.first_row === true && data.date !== 0",
				"darkred": "!data.last_row && data.balance < 0 && colDef.field === 'balance'",
				"green nc-bold": "colDef.field === 'production_order_id' && data.from !== 0 && data.production_order_id && data.production_order_id.substring(0, 2) !== 'V-'",
				"red": "(data.last_row && data.balance < 0 && colDef.field === 'balance') || (colDef.field === 'idx' && data.error && data.error.substring(0, 5) !== 'note:')",
				"darkred nc-bold": "data.highlight && colDef.field === 'scope' && data.scope_visible === 0",
				"dimmed": "!data.highlight && colDef.field === 'scope' && !data.scope_visible"
			},
			"row_class_rules": {
				"brown": "data.virtual && data.order_type !== 'VM'",
				"lightbrown": "data.order_type === 'VM'",
				"teal": "data.from === 5",
				"nc-not-in-use": "data.need_calculation_in_use === 0 || data.pr?.json_data?.need_calculation_in_use === 0",
				"nc-highlight-upper": "data.highlight === 'upper'",
				"nc-highlight-lower": "data.highlight === 'lower'",
				"nc-highlight-no-info": "data.highlight === 'no-info'"
			}
		}
	},
	"column": [
		{
			"link_field": "pr.record_id",
			"name": "Row",
			"table": "product",
			"record_type": "",
			"variable": "idx"
		},
		{
			"variable": "highlight",
			"hide": true
		},
		{
			"variable": "level",
			"name": "↓",
			"width": 30,
			"sum": false,
			"pinned": "left"
		},
		{
			"variable": "scope",
			"name": "Scope",
			"width": 75,
			"pinned": "left"
		},
		{
			"variable": "from_row",
			"name": "From",
			"width": 58,
			"sum": false,
			"pinned": "left"
		},
		{
			"variable": "product_row",
			"name": "Row",
			"width": 50,
			"pinned": "left"
		},
		{
			"variable": "product_id_show",
			"name": "Product",
			"type": "text",
			"width": 220,
			"pinned": "left"
		},
		{
			"variable": "name",
			"name": "Name",
			"width": 120,
			"column_span": 12
		},
		{
			"variable": "order_id",
			"name": "Order",
			"width": 80
		},
		{
			"variable": "order_row",
			"name": "Row",
			"cell_class_rules": {
				"white": "x == 0"
			},
			"width": 50
		},
		{
			"name": "db",
			"name_fi": "tk",
			"variable": "from_db",
			"width": 43
		},
		{
			"variable": "production_order_id",
			"name": "Work / prod. lot",
			"width": 130,
			"column_span": 12
		},
		{
			"variable": "json_data.parent_production_lot",
			"name": "Parent prod. lot",
			"width": 130,
			"column_span": 12
		},
		{
			"variable": "delivery_date",
			"name": "Delivery",
			"type": "date",
			"width": 90
		},
		{
			"variable": "date",
			"name": "Date",
			"type": "timestamp",
			"width": 160
		},
		{
			"variable": "week",
			"name": "Week",
			"width": 65
		},
		{
			"variable": "origin",
			"name": "Origin",
			"width": 90
		},
		{
			"variable": "order_type",
			"name": "Ord. type",
			"width": 80
		},
		{
			"variable": "date_type",
			"name": "Date type",
			"width": 85
		},
		{
			"variable": "amount",
			"width": 75,
			"name": "Amount",
			"format": "%'.2f",
			"cell_class_rules": {
				"white": "x === 0",
				"black": "x > 0",
				"darkred": "x < 0"
			}
		},
		{
			"variable": "balance",
			"name": "Balance",
			"format": "%'.2f",
			"cell_class_rules-": {
				"grey": "x === 0",
				"black": "x < 0 || x > 0"
			},
			"width": 85
		},
		{
			"variable": "stock_unit",
			"name": "Unit",
			"width": 55
		},
		{
			"variable": "need_down",
			"name": "Need ⇣",
			"format": "%'.-2f",
			"cell_class_rules": {
				"blue": "x > 0",
				"white": "x <= 0"
			},
			"width": 70
		},
		{
			"variable": "need_down_info",
			"name": "Info ⇣",
			"column_span": 2,
			"width": 80
		},
		{
			"variable": "estimate_need",
			"name": "Est. need",
			"column_span": 2,
			"width": 110
		},
		{
			"field": "production_type",
			"width": 55,
			"name": "Stock",
			"value_formatter": {
				"default": "",
				"convert": [{ "from": 1, "to": "stock" }]
			}
		},
		{
			"variable": "company_id",
			"name": "Company",
			"width": 100
		},
		{
			"field": "pr.product_group",
			"width": 100,
			"name": "Group"
		},
		{
			"field": "pr.subgroup",
			"width": 120,
			"name": "Subgroup"
		},
		{
			"field": "pr.quality",
			"width": 100,
			"name": "Quality"
		},
		{
			"field": "pr.minimum_stock",
			"width": 90,
			"name": "Min. stock",
			"format": "%'.-2f",
			"cell_class_rules": {
				"white": "x <= 0"
			}
		},
		{
			"field": "action_limit",
			"width": 85,
			"name": "Act. limit",
			"format": "%'.-2f",
			"cell_class_rules": {
				"white": "x <= 0"
			}
		},
		{
			"field": "pr.minimum_order_amount",
			"width": 85,
			"name": "Min. ord.",
			"format": "%'.-2f",
			"cell_class_rules": {
				"white": "x <= 0"
			}
		},
		{
			"variable": "from_row_text",
			"name": "Need from row",
			"width": 120
		},
		{
			"field": "pr.json_data.coming_amount",
			"width": 75,
			"name": "Coming",
			"format": "%'.-2f",
			"cell_class_rules": {
				"white": "x === 0",
				"darkred": "x < 0"
			}
		},
		{
			"field": "pr.json_data.going_amount",
			"width": 75,
			"name": "Going",
			"format": "%'.-2f",
			"cell_class_rules": {
				"white": "x === 0",
				"darkred": "x < 0"
			}
		},
		{
			"field": "pr.json_data.free_amount",
			"width": 75,
			"name": "Free",
			"format": "%'.-2f",
			"cell_class_rules": {
				"white": "x === 0",
				"darkred": "x < 0"
			}
		},
		{
			"field": "pr.json_data.true_free_amount",
			"width": 85,
			"name": "True free",
			"format": "%'.-2f",
			"cell_class_rules": {
				"white": "x === 0",
				"darkred": "x < 0"
			}
		},
		{
			"field": "pr.coming_amount",
			"width": 85,
			"name": "Coming 2",
			"format": "%'.-2f",
			"cell_class_rules": {
				"white": "x === 0",
				"darkred": "x < 0"
			}
		},
		{
			"field": "pr.going_amount",
			"width": 75,
			"name": "Going 2",
			"format": "%'.-2f",
			"cell_class_rules": {
				"white": "x === 0",
				"darkred": "x < 0"
			}
		},
		{
			"field": "pr.json_data.true_going_amount",
			"width": 90,
			"name": "True going",
			"format": "%'.-2f",
			"cell_class_rules": {
				"white": "x === 0",
				"darkred": "x < 0"
			}
		},
		{
			"field": "pr.free_amount",
			"width": 75,
			"name": "Free 2",
			"format": "%'.-2f",
			"cell_class_rules": {
				"white": "x === 0",
				"darkred": "x < 0"
			}
		},
		{
			"field": "pr.stock_type",
			"width": 75,
			"name": "Storable"
		},
		{
			"variable": "error",
			"name": "Error",
			"cell_class_rules": {
				"green": "typeof x === 'string' && x.substring(0, 5) === 'note:'",
				"red": "typeof x === 'string' && x.substring(0, 5) !== 'note:'"
			},
			"width": 1300
		},
		{
			"variable": "phase_key",
			"name": "Phase",
			"width": 290
		},
		{
			"variable": "parent_phase_key",
			"name": "Parent phase",
			"width": 290
		},
		{
			"hide": true,
			"variable": "record_id",
			"name": "Record id",
			"width": 400
		}
	],
	"column-": [
		{
			"variable": "from",
			"name": "From",
			"width": 90,
			"value_formatter": {
				"default": "error",
				"convert": [
					{ "from": 0, "to": "" },
					{ "from": 1, "to": "production" },
					{ "from": 2, "to": "purchase" },
					{ "from": 3, "to": "sales" },
					{ "from": 4, "to": "material" },
					{ "from": 5, "to": "avg need" },
					{ "from": 6, "to": "action limit" },
					{ "from": 7, "to": "act. limit -" },
					{ "from": 8, "to": "neg. balance" },
					{ "from": 9, "to": "neg. bal. -" }
				]
			}
		},
		{
			"variable": "pr.calc.need_down_material_count",
			"name": "⇣",
			"width": 80
		},
		{
			"variable": "pr.calc.material_count",
			"name": "⇣ tot.",
			"width": 80
		},
		{
			"variable": "info",
			"name": "Info",
			"width": 1600
		},
		{
			"variable": "co.name",
			"name": "As. nimi",
			"width": 120
		},
		{
			"variable": "ord.vat_price",
			"name": "Alv",
			"width": 100
		}
	]
}
