{
  "eventsAndFunctions": [
    {
      "algorithm": {
        "parameters": [],
        "statements": [
          {
            "command": "ReadModel",
            "modelVariableName": "plan",
            "variableName": "plan"
          },
          {
            "command": "Load",
            "expression": "Select(GetFrequencies(),[code,name])",
            "widgetName": "cboControlFrequency"
          },
          {
            "command": "Load",
            "expression": "Select(GetFrequencies(),[code,name])",
            "widgetName": "cboPartialFrequency"
          },
          {
            "command": "Load",
            "expression": "Select(ExtStrategicPlanMng.DomainsList(),[id,name])",
            "widgetName": "cboDomain"
          },
          {
            "command": "Load",
            "expression": "Select(GetTimeFrequencies(),[code,name])",
            "widgetName": "cboFrequency"
          }
        ],
        "typeReturn": "any",
        "variables": [
          {
            "name": "plan",
            "type": "ExtStrategicPlanMng.Plan"
          }
        ]
      },
      "name": "main_init"
    },
    {
      "algorithm": {
        "parameters": [],
        "statements": [
          {
            "command": "ReadModel",
            "modelVariableName": "plan",
            "variableName": "plan"
          },
          {
            "command": "Set",
            "expression": "true",
            "variableName": "isValid"
          },
          {
            "command": "Set",
            "expression": "[]",
            "variableName": "validations"
          },
          {
            "command": "GetValue",
            "variableName": "domain",
            "widgetName": "cboDomain"
          },
          {
            "command": "WriteModel",
            "expression": "^domain",
            "modelVariableName": "domain"
          },
          {
            "command": "GetValue",
            "variableName": "plan.name",
            "widgetName": "txtName"
          },
          {
            "command": "GetValue",
            "variableName": "from",
            "widgetName": "dtFrom"
          },
          {
            "command": "GetValue",
            "variableName": "to",
            "widgetName": "dtTo"
          },
          {
            "command": "GetValue",
            "variableName": "plan.controlFrequency",
            "widgetName": "cboControlFrequency"
          },
          {
            "command": "GetValue",
            "variableName": "plan.partialFrequency",
            "widgetName": "cboPartialFrequency"
          },
          {
            "command": "Set",
            "expression": "false",
            "variableName": "isValid"
          },
          {
            "children": [
              {
                "command": "Set",
                "expression": "{header: ^plan.name, list: []}",
                "variableName": "validation"
              },
              {
                "command": "Push",
                "expressionItem": "{severity:\"error\",message: \"[[ErrorPlanInvalidDates]]\"}",
                "variableNameList": "validation.list"
              },
              {
                "command": "Push",
                "expressionItem": "^validation",
                "variableNameList": "validations"
              }
            ],
            "command": "If",
            "expression": "^from >= ^to"
          },
          {
            "command": "Set",
            "expression": "{header: ^plan.name, list: []}",
            "variableName": "validation"
          },
          {
            "command": "Switch",
            "expression": "^plan.controlFrequency"
          },
          {
            "children": [
              {
                "children": [
                  {
                    "command": "Push",
                    "expressionItem": "{severity:\"error\",message: \"[[ErrorPartialFrequency]]\"}",
                    "variableNameList": "validation.list"
                  }
                ],
                "command": "If",
                "expression": "Contains(^plan.partialFrequency, \"annual\")"
              }
            ],
            "command": "Case",
            "expression": "\"semester\""
          },
          {
            "children": [
              {
                "children": [
                  {
                    "command": "Push",
                    "expressionItem": "{severity:\"error\",message: \"[[ErrorPartialFrequency]]\"}",
                    "variableNameList": "validation.list"
                  }
                ],
                "command": "If",
                "expression": "Contains(^plan.partialFrequency, \"annual\") || Contains(^plan.partialFrequency, \"semester\")"
              }
            ],
            "command": "Case",
            "expression": "\"quarter\""
          },
          {
            "children": [
              {
                "children": [
                  {
                    "command": "Push",
                    "expressionItem": "{severity:\"error\",message: \"[[ErrorPartialFrequency]]\"}",
                    "variableNameList": "validation.list"
                  }
                ],
                "command": "If",
                "expression": "Contains(^plan.partialFrequency, \"annual\") || Contains(^plan.partialFrequency, \"semester\") || Contains(^plan.partialFrequency, \"quarter\")"
              }
            ],
            "command": "Case",
            "expression": "\"bimester\""
          },
          {
            "children": [
              {
                "children": [
                  {
                    "command": "Push",
                    "expressionItem": "{severity:\"error\",message: \"[[ErrorPartialFrequency]]\"}",
                    "variableNameList": "validation.list"
                  }
                ],
                "command": "If",
                "expression": "Contains(^plan.partialFrequency, \"annual\") || Contains(^plan.partialFrequency, \"semester\") || Contains(^plan.partialFrequency, \"quarter\") || Contains(^plan.partialFrequency, \"bimester\")"
              }
            ],
            "command": "Case",
            "expression": "\"monthly\""
          },
          {
            "children": [
              {
                "children": [
                  {
                    "command": "Push",
                    "expressionItem": "{severity:\"error\",message: \"[[ErrorPartialFrequency]]\"}",
                    "variableNameList": "validation.list"
                  }
                ],
                "command": "If",
                "expression": "!Contains(^plan.partialFrequency, \"weekly\")"
              }
            ],
            "command": "Case",
            "expression": "\"weekly\""
          },
          {
            "children": [
              {
                "command": "Push",
                "expressionItem": "^validation",
                "variableNameList": "validations"
              }
            ],
            "command": "If",
            "expression": "Count(^validation.list) > 0"
          },
          {
            "children": [
              {
                "command": "Throw",
                "errorName": "Error",
                "expressionData": "GetValidationsTemplate(^validations)",
                "expressionInnerError": "\"[[ErrorCustom]]\""
              }
            ],
            "command": "If",
            "expression": "Count(^validations) > 0"
          }
        ],
        "typeReturn": "any",
        "variables": [
          {
            "name": "from",
            "type": "date"
          },
          {
            "name": "to",
            "type": "date"
          },
          {
            "name": "validation",
            "type": "any"
          },
          {
            "name": "validations",
            "type": "any"
          },
          {
            "name": "isValid",
            "type": "boolean"
          },
          {
            "name": "domain",
            "type": "string"
          },
          {
            "name": "plan",
            "type": "ExtStrategicPlanMng.Plan"
          }
        ]
      },
      "name": "main_submit"
    }
  ],
  "model": [
    {
      "name": "plan",
      "required": false,
      "type": "ExtStrategicPlanMng.SimplePlan"
    },
    {
      "name": "domain",
      "required": false,
      "type": "string"
    }
  ],
  "root": {
    "children": [
      {
        "children": [
          {
            "binding": "plan.name",
            "label": "[[Name]]",
            "last": true,
            "name": "txtName",
            "size": 2,
            "widget": "TextBox"
          },
          {
            "binding": "plan.description",
            "label": "[[Description]]",
            "last": true,
            "name": "txtDescription",
            "size": 2,
            "widget": "TextBox"
          },
          {
            "binding": "plan.fromDate",
            "label": "[[From]]",
            "mandatory": true,
            "name": "dtFrom",
            "widget": "DateBox"
          },
          {
            "binding": "plan.toDate",
            "label": "[[To]]",
            "last": true,
            "mandatory": true,
            "name": "dtTo",
            "widget": "DateBox"
          },
          {
            "binding": "plan.domain.id",
            "dataFormat": "KeyValueList",
            "label": "[[Domain]]",
            "last": true,
            "mandatory": true,
            "name": "cboDomain",
            "size": 2,
            "widget": "ComboBox"
          },
          {
            "binding": "plan.controlFrequency",
            "dataFormat": "KeyValueList",
            "label": "[[ControlFrequency]]",
            "last": true,
            "mandatory": true,
            "name": "cboControlFrequency",
            "size": 2,
            "widget": "ComboBox"
          },
          {
            "binding": "plan.partialFrequency",
            "dataFormat": "KeyValueList",
            "label": "[[PartialFrequency]]",
            "last": true,
            "name": "cboPartialFrequency",
            "size": 2,
            "widget": "ComboBox"
          },
          {
            "binding": "plan.snapshotFrequency",
            "label": "[[SnapshotFrequency]]",
            "name": "txtSnapshotFrequency",
            "widget": "NumericBox"
          },
          {
            "dataFormat": "KeyValueList",
            "label": "[[Frequency]]",
            "last": true,
            "name": "cboFrequency",
            "widget": "ComboBox"
          }
        ],
        "layout": "form"
      }
    ],
    "layout": "responsive"
  },
  "routing": {
    "path": "/sf-plan/editor"
  },
  "unused": []
}