{
	"name": "plugin/nc-calc-server/column/product-need-weekly.json",
	"option": {
		"grid_option": {
			"cell_class_rules": {
				"red": "data.error && data.error.substring(0, 5) !== 'note:' && colDef.field === 'idx'",
				"brown": "colDef.field === 'date' && data.before_today",
				"darkred nc-bold": "data.highlight && colDef.field === 'scope' && data.scope_visible === 0",
				"dimmed": "!data.highlight && colDef.field === 'scope' && !data.scope_visible"
			},
			"row_class_rules": {
				"grey": "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": [
		{
			"icon": "nc-link-icon",
			"link_field": "record_id",
			"name": "Row",
			"table": "product",
			"record_type": "",
			"variable": "idx"
		},
		{
			"variable": "highlight",
			"hide": true
		},
		{
			"variable": "show_cell_error",
			"hide": true
		},
		{
			"variable": "calc.level",
			"name": "↓",
			"width": 30,
			"pinned": "left"
		},
		{
			"variable": "scope",
			"name": "Scope",
			"width": 65,
			"pinned": "left"
		},
		{
			"variable": "from_row",
			"name": "From",
			"width": 58,
			"pinned": "left"
		},
		{
			"name": "db",
			"name_fi": "tk",
			"variable": "calc.from_db",
			"width": 43,
			"pinned": "left"
		},
		{
			"field": "calc.product_id",
			"width": 220,
			"name": "Product",
			"pinned": "left"
		},
		{
			"field": "calc.name",
			"name": "Name",
			"column_span": 4,
			"width": 220
		},
		{
			"variable": "calc.balance",
			"width": 75,
			"name": "Balance",
			"format": "%'.-2f",
			"cell_class_rules": {
				"grey": "x === 0",
				"red": "x < 0",
				"black": "x > 0"
			}
		},
		{
			"field": "pr.coming_amount",
			"width": 140,
			"name": "Coming",
			"format": "%'.-2f",
			"cell_class_rules": {
				"white": "x === 0",
				"darkred": "x < 0"
			}
		},
		{
			"field": "pr.going_amount",
			"width": 140,
			"name": "Going",
			"format": "%'.-2f",
			"cell_class_rules": {
				"white": "x === 0",
				"darkred": "x < 0"
			}
		},
		{
			"field": "pr.free_amount",
			"width": 140,
			"name": "Free",
			"format": "%'.-2f",
			"cell_class": ["border-right-color-lightgray"],
			"cell_class_rules": {
				"white": "x === 0",
				"darkred": "x < 0"
			}
		},
		{
			"variable": "date",
			"name": "Critical date",
			"type": "date",
			"width": 100
		},
		{
			"field": "order_amount",
			"width": 85,
			"name": "Amount",
			"format": "%'.2f",
			"editable": true,
			"cell_class_rules": {
				"nc-cell-error": "data.show_cell_error && (!x || x <= 0)",
				"blue": "x > 0",
				"white": "x <= 0 && !data.show_cell_error"
			}
		},
		{
			"field": "pr.stock_unit",
			"width": 55,
			"name": "Unit"
		},
		{
			"field": "pr.work_number_id",
			"name": "Work",
			"width": 80
		},
		{
			"field": "company_id",
			"width": 100,
			"name": "Supplier",
			"editable": true,
			"cell_class_rules": {
				"nc-cell-error": "data.show_cell_error && !x",
				"blue": "x && x != ''"
			}
		},
		{
			"field": "co-supplier.name",
			"name": "Name",
			"width": 220,
			"cell_class": ["border-right-color-dimgray"]
		},
		{
			"field": "pr.product_group",
			"width": 100,
			"name": "Group"
		},
		{
			"field": "pr.subgroup",
			"width": 120,
			"name": "Subgroup"
		},
		{
			"field": "pr.quality",
			"width": 100,
			"name": "Quality"
		},
		{
			"field": "calc.production_type",
			"width": 55,
			"name": "Type",
			"cell_class": ["border-right-color-dimgray"],
			"value_formatter": {
				"default": "",
				"convert": [{ "from": 1, "to": "stock" }]
			}
		},
		{
			"variable": "week0need",
			"width": 90,
			"name": "Before -",
			"format": "%'.-1f",
			"cell_class": ["border-right-color-lightgray", "nc-grid-align-right"],
			"cell_class_rules": {
				"darkred": "x && (x < 0 || x.toString().charAt(0) === '-')"
			}
		},
		{
			"variable": "week0coming",
			"width": 110,
			"name": "Before +",
			"cell_class": ["border-right-color-dimgray", "nc-grid-align-right"],
			"cell_class_rules": {
				"darkred": "x && (x < 0 || x.toString().charAt(0) === '-')"
			}
		},
		{
			"variable": "calc.estimate_need",
			"width": 100,
			"name": "Est. need",
			"cell_class": ["nc-grid-align-center"],
			"column_span": 2
		},
		{
			"field": "pr.minimum_stock",
			"width": 75,
			"name": "Min. stock",
			"format": "%'.-2f",
			"cell_class_rules": {
				"white": "x <= 0"
			}
		},
		{
			"field": "pr.json_data.action_limit",
			"width": 75,
			"name": "Act. limit",
			"format": "%'.-2f",
			"cell_class_rules": {
				"white": "x <= 0"
			}
		},
		{
			"field": "pr.minimum_order_amount",
			"width": 75,
			"name": "Min. ord.",
			"format": "%'.-2f",
			"cell_class_rules": {
				"white": "x <= 0"
			}
		},
		{
			"variable": "amount",
			"width": 75,
			"name": "Need",
			"info": "Calculated order need",
			"format": "%'.2f",
			"cell_class": ["border-right-color-dimgray"],
			"cell_class_rules": {
				"red": "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": 800
		},
		{
			"hide": true,
			"variable": "record_id",
			"name": "Record id",
			"width": 650
		}
	],
	"column-not-in-use": [
		{
			"hide": true,
			"field": "waiting_for_delivery",
			"width": 180,
			"name": "Need",
			"name2": "Project need",
			"format": "%'.-2f",
			"cell_class_rules-": {
				"grey": "x == 0",
				"blue": "x > 0"
			},
			"cellEditorParamsXX": {
				"values": "popup.product",
				"popup_field": "value",
				"set_popup_show_field": "sor_explanation"
			}
		},
		{
			"hide": true,
			"variable": "ordered_amount",
			"width": 160,
			"name": "Ordered",
			"name2": "Ordered to project",
			"format": "%'.-2f"
		},
		{
			"hide": true,
			"variable": "arrived_amount",
			"width": 160,
			"name": "Arrived",
			"name2": "Arrived to project",
			"format": "%'.-2f"
		},
		{
			"hide": true,
			"variable": "coming_amount",
			"width": 160,
			"name": "Coming",
			"name2": "Coming to project",
			"format": "%'.-2f"
		}
	]
}
