{
  "custom": {},
  "params": {
    "configuring": false,
    "equipmentPath": "Enterprise\\El Dorado Hills\\Packaging Area\\Packaging Line 1",
    "title": ""
  },
  "propConfig": {
    "params.configuring": {
      "onChange": {
        "enabled": null,
        "script": "\tviewParams\u003dself.params\n\tconfigParams\u003dself.getChild(\"root\").getChild(\"configuration\").props.params\n\tif currentValue.value:\n\t\tconfigParams.equipmentPathIn \u003d viewParams.equipmentPath\t\n\t\tconfigParams.titleIn \u003d viewParams.title\n\telif previousValue is not None and previousValue.value:\n\t\tviewParams.equipmentPath \u003d configParams.equipmentPathOut\n\t\tviewParams.title \u003d configParams.titleOut "
      },
      "paramDirection": "input",
      "persistent": true
    },
    "params.equipmentPath": {
      "paramDirection": "input",
      "persistent": true
    },
    "params.title": {
      "paramDirection": "input",
      "persistent": true
    }
  },
  "props": {},
  "root": {
    "children": [
      {
        "meta": {
          "name": "Widget Title"
        },
        "propConfig": {
          "meta.visible": {
            "binding": {
              "config": {
                "expression": "!{view.params.configuring}"
              },
              "type": "expr"
            }
          },
          "props.params.text": {
            "binding": {
              "config": {
                "path": "view.params.title"
              },
              "type": "property"
            }
          }
        },
        "props": {
          "path": "Page/Embedded/Widget Title"
        },
        "type": "ia.display.view"
      },
      {
        "children": [
          {
            "meta": {
              "name": "Label"
            },
            "position": {
              "basis": "32px"
            },
            "propConfig": {
              "props.text": {
                "binding": {
                  "config": {
                    "path": "view.params.equipmentPath"
                  },
                  "transforms": [
                    {
                      "code": "\treturn value.split(\u0027\\\\\u0027)[len(value.split(\u0027\\\\\u0027))-1:][0]",
                      "type": "script"
                    }
                  ],
                  "type": "property"
                }
              }
            },
            "props": {
              "textStyle": {
                "fontSize": 20,
                "textAlign": "center"
              }
            },
            "type": "ia.display.label"
          },
          {
            "meta": {
              "name": "lbl_input"
            },
            "props": {
              "text": "Input"
            },
            "type": "ia.display.label"
          },
          {
            "meta": {
              "name": "mos_bottles"
            },
            "position": {
              "grow": 1
            },
            "props": {
              "displayText": "Bottles",
              "includeMaterialDefObjects": true,
              "primaryClassFilter": "Bottles",
              "selectedMESObject": {
                "childCount": 0
              }
            },
            "type": "mes.production.mesObjectSelector"
          },
          {
            "meta": {
              "name": "mos_caps"
            },
            "position": {
              "grow": 1
            },
            "props": {
              "displayText": "Caps",
              "includeMaterialDefObjects": true,
              "primaryClassFilter": "Caps",
              "selectedMESObject": {
                "childCount": 0
              }
            },
            "type": "mes.production.mesObjectSelector"
          },
          {
            "meta": {
              "name": "mos_case"
            },
            "position": {
              "grow": 1
            },
            "props": {
              "displayText": "Cases",
              "includeMaterialDefObjects": true,
              "primaryClassFilter": "Case",
              "selectedMESObject": {
                "childCount": 0
              }
            },
            "type": "mes.production.mesObjectSelector"
          },
          {
            "meta": {
              "name": "lbl_output"
            },
            "position": {
              "grow": 1
            },
            "props": {
              "text": "Output"
            },
            "type": "ia.display.label"
          },
          {
            "meta": {
              "name": "mos_beer"
            },
            "position": {
              "grow": 1
            },
            "props": {
              "displayText": "Beer",
              "includeMaterialDefObjects": true,
              "primaryClassFilter": "Beers",
              "selectedMESObject": {
                "childCount": 0
              }
            },
            "type": "mes.production.mesObjectSelector"
          },
          {
            "meta": {
              "name": "tf_caseQuantity"
            },
            "position": {
              "basis": "40px",
              "grow": 1
            },
            "props": {
              "placeholder": "Total Cases Produced..."
            },
            "type": "ia.input.text-field"
          },
          {
            "meta": {
              "name": "lbl_message"
            },
            "props": {
              "style": {
                "color": "#000000",
                "fontFamily": "Roboto",
                "fontSize": 18,
                "textAlign": "center"
              }
            },
            "type": "ia.display.label"
          },
          {
            "children": [
              {
                "events": {
                  "component": {
                    "onActionPerformed": {
                      "config": {
                        "script": "\n\teqPath \u003d self.view.params.equipmentPath\n\tcase \u003d self.parent.parent.getChild(\"mos_case\").props.selectedMESObject.name\n\tcaseQuantity \u003d int(self.parent.parent.getChild(\"tf_caseQuantity\").props.text)\n\tdata \u003d system.mes.trace.getInventory(equipmentPath\u003deqPath,materialName\u003dcase,includeActiveLots\u003dFalse)\n\tmessage, caseLot \u003d None, None\n\n\tfor lot in data[\u0027lots\u0027]:\n\t\tcaseLot \u003d lot[\u0027LotNumber\u0027]\n\t\tbreak\n\t\t\n\tif caseLot:\n\t\tcaseMultiplier \u003d int(case.split(\u0027 \u0027)[0]) #ex. 6 if 6 Pack\n\telse:\n\t\tcaseMultiplier \u003d 0\n\tbottle \u003d self.parent.parent.getChild(\"mos_bottles\").props.selectedMESObject.name\n\tdata \u003d system.mes.trace.getInventory(equipmentPath\u003deqPath,materialName\u003dbottle,includeActiveLots\u003dFalse)\n\t\n\tfor lot in data[\u0027lots\u0027]:\n\t\tif not lot[\u0027NetQuantity\u0027] \u003e caseQuantity * caseMultiplier or caseLot \u003d\u003d None:\n\t\t\tmessage \u003d \u0027Not enough \u0027 + case + \u0027 inventory\u0027 \n\t\telse:\n\t\t\tbottleLot \u003d lot[\u0027LotNumber\u0027]\n\t\t\tbreak\n\t\n\tcap \u003d self.parent.parent.getChild(\"mos_caps\").props.selectedMESObject.name\n\tdata \u003d system.mes.trace.getInventory(equipmentPath\u003deqPath,materialName\u003dcap,includeActiveLots\u003dFalse)\n\t\n\tfor lot in data[\u0027lots\u0027]:\n\t\tif not lot[\u0027NetQuantity\u0027] \u003e caseQuantity * caseMultiplier:\n\t\t\tmessage \u003d \u0027Not enough \u0027 + cap + \u0027 inventory\u0027 \n\t\telse:\n\t\t\tcapLot \u003d lot[\u0027LotNumber\u0027]\n\t\t\tbreak\n\n\tif not message:\n\t\tquant \u003d caseQuantity * caseMultiplier\n\t\tcaseIn \u003d  system.mes.trace.configureMaterial(name \u003d \u0027Case\u0027, lotNo \u003d caseLot, materialName \u003d case, quantity \u003d caseQuantity, equipmentPath \u003d eqPath)\n\t\tbottleIn \u003dsystem.mes.trace.configureMaterial(name \u003d \u0027Bottles\u0027, lotNo \u003d bottleLot, materialName \u003d bottle, quantity \u003d quant, equipmentPath \u003d eqPath)\n\t\tcapIn \u003d system.mes.trace.configureMaterial(name \u003d \u0027Caps\u0027, lotNo \u003d capLot, materialName \u003d cap, quantity \u003d quant, equipmentPath \u003d eqPath)\n\t\tbeer \u003d self.parent.parent.getChild(\"mos_beer\").props.selectedMESObject.name\n\t\tbeerLotOut \u003d beer + \u0027-\u0027 +str(system.date.toMillis(system.date.now()))\n\t\tbeerOut \u003d system.mes.trace.configureMaterial(name \u003d beer, lotNo \u003d beerLotOut, materialName \u003d beer, quantity \u003d caseQuantity, equipmentPath \u003d eqPath, autoCreateLot\u003dTrue)\n\t\t\n\t\tsystem.mes.trace.recordOperation(name\u003d\u0027Bottle Beer\u0027, equipmentPath\u003deqPath, materialIn\u003d[caseIn,bottleIn,capIn], materialOut\u003d[beerOut])\n\t\tmessage \u003d \u0027Created \u0027 + str(caseQuantity) + \u0027 case(s) of \u0027 + beer\n\t\n\tif message:\n\t\tself.parent.parent.getChild(\"lbl_message\").props.text \u003d message\n\t\tself.parent.parent.getChild(\"lbl_message\").props.visible \u003d True\n\tself.parent.parent.getChild(\"tf_caseQuantity\").props.text \u003d \u0027\u0027\n\t\n\tshared.mes.inventory.updateCurrentInventory(eqPath, \u0027Raw Materials\u0027)"
                      },
                      "scope": "G",
                      "type": "script"
                    }
                  }
                },
                "meta": {
                  "name": "btn_consume"
                },
                "position": {
                  "grow": 1
                },
                "propConfig": {
                  "props.enabled": {
                    "binding": {
                      "config": {
                        "expression": "toInt({.../tf_caseQuantity.props.text},\u0027\u0027)"
                      },
                      "type": "expr"
                    }
                  },
                  "props.textStyle.fontSize": {
                    "binding": {
                      "config": {
                        "path": "page.props.dimensions.screen.width"
                      },
                      "transforms": [
                        {
                          "code": "\tif(value \u003e\u003d600 and value\u003c1300):\n\t\treturn 14\n\telif (value \u003e\u003d1300 and value\u003c\u003d1580):\n\t\treturn 16\n\telif(value \u003e 1580):\n\t\treturn 18\n\telif(value \u003d\u003d 0):\n\t\treturn 18\n\telse:\n\t\treturn 10",
                          "type": "script"
                        }
                      ],
                      "type": "property"
                    }
                  }
                },
                "props": {
                  "style": {
                    "classes": "Buttons/Large_Button",
                    "height": "64px",
                    "width": "100px"
                  },
                  "text": "Consume Materials"
                },
                "type": "ia.input.button"
              }
            ],
            "meta": {
              "name": "flx_submit"
            },
            "position": {
              "basis": "30 px",
              "grow": 1
            },
            "props": {
              "alignContent": "flex-start",
              "justify": "center",
              "style": {
                "marginTop": 10,
                "overflow": "visible"
              }
            },
            "type": "ia.container.flex"
          }
        ],
        "meta": {
          "name": "runtime"
        },
        "position": {
          "basis": "400px",
          "grow": 1,
          "shrink": 0
        },
        "propConfig": {
          "position.display": {
            "binding": {
              "config": {
                "expression": "!{view.params.configuring}"
              },
              "type": "expr"
            }
          }
        },
        "props": {
          "direction": "column",
          "style": {
            "marginLeft": 20,
            "marginRight": 20,
            "overflow": "visible"
          }
        },
        "type": "ia.container.flex"
      },
      {
        "meta": {
          "name": "configuration"
        },
        "propConfig": {
          "position.display": {
            "binding": {
              "config": {
                "path": "view.params.configuring"
              },
              "type": "property"
            }
          }
        },
        "props": {
          "params": {
            "equipmentPathIn": "",
            "equipmentPathOut": "",
            "titleIn": "",
            "titleOut": ""
          },
          "path": "Page/Widgets/Configuration/Equipment Path, Title"
        },
        "type": "ia.display.view"
      }
    ],
    "meta": {
      "name": "root"
    },
    "props": {
      "direction": "column"
    },
    "type": "ia.container.flex"
  }
}