{
  "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"
  ],
  "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"
    }
  ],
  "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"
       ]
     }
  ],
  "columns": [
    {
      "field": "rowNumber",
			"subtotal": "",
			"subtotal_operator": "",
      "width": 30,
      "name": "Rivi",
      "format": [
        "%'d"
      ]
    },
    {
      "field": "wo_company_id",
      "width": 80,
      "name": "Asiakas"
    },
    {
      "field": "pr_product_group",
      "width": 90,
      "name": "Tuoteryhmä"
    },
    {
      "field": "wo_drawing_number",
      "width": 125,
      "name": "Piirustusnumero"
    },
    {
      "field": "pr_name",
      "width": 220,
      "name": "Nimi"
    },
    {
      "field": "wo_production_lot",
      "width": 70,
      "name": "Valm. erä"
    },
    {
      "field": "wo_state",
      "width": 25,
      "name": "Tila"
    },
    {
      "field": "wo_creation_date",
      "width": 64,
      "name": "Luontipäivä",
      "format": [
        "d%d.%m.%Y"
      ]
    },
    {
      "field": "wo_material_act_arrival_date",
      "width": 64,
      "name": "RA tot. tulo",
      "format": [
        "d%d.%m.%Y"
      ]
    },
    {
      "field": "pr_production_control_type",
      "width": 25,
      "name": "T/V",
      "formula": [
        "replace",
        {
          "0": "T",
          "1": "V"
        }
      ],
      "style":{
    		"horizontal_align": "center"
      }
    },
    {
      "field": "wo_started_amount",
      "width": 40,
      "name": "Al.",
      "style":{
    		"horizontal_align": "center"
      }
    },
    {
      "field": "wo_produced_amount",
      "width": 40,
      "name": "Val.",
      "style":{
    		"horizontal_align": "center"
      }
    },
    {
      "field": "wo_remaining_amount",
      "width": 40,
      "name": "Jäl.",
      "style":{
    		"horizontal_align": "center"
      }
    },
    {
      "field": "wo_failed_amount",
      "width": 40,
      "name": "Hyl.",
      "style":{
    		"horizontal_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":{
    		"horizontal_align": "right"
      }
    },
    {
      "field": "calc_subcontract_self_cost",
      "width": 70,
      "name": "Alih. OK",
      "formula": [
        "+",
        "qry_subcontract_self_cost_calculated"
      ],
      "format": [
        "%'.0f"
      ],
      "style":{
    		"horizontal_align": "right"
      }
    },
    {
      "field": "calc_work_self_cost",
      "width": 70,
      "name": "Työ. OK",
      "format": [
        "%'.0f"
      ],
      "formula": [
        "+",
        "qry_work_self_cost_calculated"
      ],
      "style":{
    		"horizontal_align": "right"
      }
    },
    {
      "field": "reduced_self_cost",
      "width": 55,
      "name": "Väh.",
      "formula": [
        "*",
        "self_cost_sum",
        "reduced_self_cost_multiplier",
        "-1"
      ],
      "format": [
        "%'.0f"
      ],
      "style":{
    		"horizontal_align": "right"
      }
    },
    {
      "field": "calc_self_cost",
      "width": 67,
      "name": "OK yht.",
      "formula": [
        "*",
        "self_cost_sum",
        "self_cost_multiplier"
      ],
      "format": [
        "%'.0f"
      ],
      "style":{
    		"horizontal_align": "right"
      }
    },
    {
      "field": "calc_sales_price",
      "width": 67,
      "name": "MH",
      "formula": [
        "*",
        "wo_remaining_amount",
        "wo_sales_price__unit"
      ],
      "format": [
        "%'.0f"
      ],
      "style":{
    		"horizontal_align": "right"
      }
    },
    {
      "field": "calc_profit_percent",
      "formula": [
        [
          "/",
          "calc_self_cost",
          "calc_sales_price"
        ],
        [
          "*",
          "100"
        ]
      ],
      "width": 45,
      "name": "%",
      "format": [
        "%.f%%"
      ],
      "style":{
    		"horizontal_align": "right"
      }
    }
  ]
}
