{
  "format": "pricekit-template",
  "schemaVersion": "1.0",
  "engineVersion": "1",
  "createdWithVersion": "1.0.0",
  "template": {
    "templateId": "8ccaaefe-bd68-42a8-bd5c-652d5a4a9e3a",
    "templateVersion": "1.0"
  },
  "calculator": {
    "name": "بلاط وأرضيات",
    "description": "سعر التبليط حسب المساحة والنوع ومن يورّد المواد، مع الهالك والأعمال الإضافية.",
    "currency": "USD",
    "calculatorVersion": 1,
    "moneyDecimals": 2,
    "allowNegativeTotal": false,
    "fields": [
      {
        "key": "area",
        "label": "مساحة الأرضية",
        "type": "number",
        "required": true,
        "defaultValue": {
          "type": "number",
          "value": 60
        },
        "constraints": {
          "min": 5,
          "max": 5000
        },
        "unit": "م²",
        "visibleByDefault": true,
        "enabledByDefault": true,
        "customerVisible": true
      },
      {
        "key": "supply",
        "label": "توريد البلاط",
        "type": "singleChoice",
        "required": true,
        "options": [
          {
            "key": "option_1",
            "label": "نحن نورّد البلاط"
          },
          {
            "key": "option_2",
            "label": "العميل يورّد البلاط"
          }
        ],
        "visibleByDefault": true,
        "enabledByDefault": true,
        "customerVisible": true
      },
      {
        "key": "floor_type",
        "label": "نوع البلاط",
        "description": "سعر المادة لكل متر مربع.",
        "type": "singleChoice",
        "required": true,
        "options": [
          {
            "key": "option_1",
            "label": "سيراميك"
          },
          {
            "key": "option_2",
            "label": "بورسلان"
          },
          {
            "key": "option_3",
            "label": "باركيه"
          },
          {
            "key": "option_4",
            "label": "رخام"
          }
        ],
        "visibleByDefault": false,
        "enabledByDefault": true,
        "customerVisible": true
      },
      {
        "key": "removal",
        "label": "إزالة البلاط القديم",
        "type": "boolean",
        "required": false,
        "defaultValue": {
          "type": "boolean",
          "value": false
        },
        "visibleByDefault": true,
        "enabledByDefault": true,
        "customerVisible": true
      },
      {
        "key": "leveling",
        "label": "تسوية الأرضية",
        "type": "boolean",
        "required": false,
        "defaultValue": {
          "type": "boolean",
          "value": false
        },
        "visibleByDefault": true,
        "enabledByDefault": true,
        "customerVisible": true
      },
      {
        "key": "skirting",
        "label": "نعلات جانبية",
        "type": "number",
        "required": true,
        "defaultValue": {
          "type": "number",
          "value": 0
        },
        "constraints": {
          "min": 0,
          "max": 1000
        },
        "unit": "متر طولي",
        "visibleByDefault": true,
        "enabledByDefault": true,
        "customerVisible": true
      }
    ],
    "rules": [
      {
        "key": "show_floor_type",
        "name": "نوع البلاط",
        "enabled": true,
        "when": {
          "mode": "any",
          "items": [
            {
              "type": "condition",
              "subject": {
                "kind": "field",
                "key": "supply"
              },
              "operator": "equals",
              "operand": {
                "type": "choice",
                "option": "option_1"
              }
            }
          ]
        },
        "then": [
          {
            "action": "showField",
            "target": "floor_type"
          }
        ]
      },
      {
        "key": "when_floor_type_option_1",
        "name": "نوع البلاط: سيراميك",
        "enabled": true,
        "when": {
          "mode": "all",
          "items": [
            {
              "type": "condition",
              "subject": {
                "kind": "field",
                "key": "floor_type"
              },
              "operator": "equals",
              "operand": {
                "type": "choice",
                "option": "option_1"
              }
            }
          ]
        },
        "then": [
          {
            "action": "activateComponent",
            "target": "floor_type_option_1"
          }
        ]
      },
      {
        "key": "when_floor_type_option_2",
        "name": "نوع البلاط: بورسلان",
        "enabled": true,
        "when": {
          "mode": "all",
          "items": [
            {
              "type": "condition",
              "subject": {
                "kind": "field",
                "key": "floor_type"
              },
              "operator": "equals",
              "operand": {
                "type": "choice",
                "option": "option_2"
              }
            }
          ]
        },
        "then": [
          {
            "action": "activateComponent",
            "target": "floor_type_option_2"
          }
        ]
      },
      {
        "key": "when_floor_type_option_3",
        "name": "نوع البلاط: باركيه",
        "enabled": true,
        "when": {
          "mode": "all",
          "items": [
            {
              "type": "condition",
              "subject": {
                "kind": "field",
                "key": "floor_type"
              },
              "operator": "equals",
              "operand": {
                "type": "choice",
                "option": "option_3"
              }
            }
          ]
        },
        "then": [
          {
            "action": "activateComponent",
            "target": "floor_type_option_3"
          }
        ]
      },
      {
        "key": "when_floor_type_option_4",
        "name": "نوع البلاط: رخام",
        "enabled": true,
        "when": {
          "mode": "all",
          "items": [
            {
              "type": "condition",
              "subject": {
                "kind": "field",
                "key": "floor_type"
              },
              "operator": "equals",
              "operand": {
                "type": "choice",
                "option": "option_4"
              }
            }
          ]
        },
        "then": [
          {
            "action": "activateComponent",
            "target": "floor_type_option_4"
          }
        ]
      },
      {
        "key": "when_removal",
        "name": "إزالة البلاط القديم",
        "enabled": true,
        "when": {
          "mode": "all",
          "items": [
            {
              "type": "condition",
              "subject": {
                "kind": "field",
                "key": "removal"
              },
              "operator": "equals",
              "operand": {
                "type": "boolean",
                "value": true
              }
            }
          ]
        },
        "then": [
          {
            "action": "activateComponent",
            "target": "removal_price"
          }
        ]
      },
      {
        "key": "when_leveling",
        "name": "تسوية الأرضية",
        "enabled": true,
        "when": {
          "mode": "all",
          "items": [
            {
              "type": "condition",
              "subject": {
                "kind": "field",
                "key": "leveling"
              },
              "operator": "equals",
              "operand": {
                "type": "boolean",
                "value": true
              }
            }
          ]
        },
        "then": [
          {
            "action": "activateComponent",
            "target": "leveling_price"
          }
        ]
      }
    ],
    "components": [
      {
        "key": "supply_price",
        "label": "توريد البلاط",
        "stage": "base",
        "pricing": {
          "type": "singleChoice",
          "field": "supply",
          "options": [
            {
              "option": "option_1",
              "amount": 0
            },
            {
              "option": "option_2",
              "amount": 0
            }
          ]
        },
        "activeByDefault": true,
        "customerVisible": true
      },
      {
        "key": "floor_type_option_1",
        "label": "نوع البلاط: سيراميك",
        "stage": "base",
        "pricing": {
          "type": "unitRate",
          "quantity": {
            "kind": "derived",
            "key": "calc_area_with_waste"
          },
          "rate": 12
        },
        "activeByDefault": false,
        "customerVisible": true
      },
      {
        "key": "floor_type_option_2",
        "label": "نوع البلاط: بورسلان",
        "stage": "base",
        "pricing": {
          "type": "unitRate",
          "quantity": {
            "kind": "derived",
            "key": "calc_area_with_waste"
          },
          "rate": 20
        },
        "activeByDefault": false,
        "customerVisible": true
      },
      {
        "key": "floor_type_option_3",
        "label": "نوع البلاط: باركيه",
        "stage": "base",
        "pricing": {
          "type": "unitRate",
          "quantity": {
            "kind": "derived",
            "key": "calc_area_with_waste"
          },
          "rate": 24
        },
        "activeByDefault": false,
        "customerVisible": true
      },
      {
        "key": "floor_type_option_4",
        "label": "نوع البلاط: رخام",
        "stage": "base",
        "pricing": {
          "type": "unitRate",
          "quantity": {
            "kind": "derived",
            "key": "calc_area_with_waste"
          },
          "rate": 40
        },
        "activeByDefault": false,
        "customerVisible": true
      },
      {
        "key": "removal_price",
        "label": "إزالة البلاط القديم",
        "stage": "base",
        "pricing": {
          "type": "unitRate",
          "quantity": {
            "kind": "field",
            "key": "area"
          },
          "rate": 7
        },
        "activeByDefault": false,
        "customerVisible": true
      },
      {
        "key": "leveling_price",
        "label": "تسوية الأرضية",
        "stage": "base",
        "pricing": {
          "type": "unitRate",
          "quantity": {
            "kind": "field",
            "key": "area"
          },
          "rate": 8
        },
        "activeByDefault": false,
        "customerVisible": true
      },
      {
        "key": "skirting_price",
        "label": "نعلات جانبية",
        "stage": "base",
        "pricing": {
          "type": "unitRate",
          "quantity": {
            "kind": "field",
            "key": "skirting"
          },
          "rate": 5
        },
        "activeByDefault": true,
        "customerVisible": true
      },
      {
        "key": "extra_price",
        "label": "أجرة التركيب",
        "stage": "base",
        "pricing": {
          "type": "unitRate",
          "quantity": {
            "kind": "field",
            "key": "area"
          },
          "rate": 10
        },
        "activeByDefault": true,
        "customerVisible": true
      },
      {
        "key": "minimum_order",
        "label": "الحد الأدنى للعمل",
        "stage": "adjustment",
        "pricing": {
          "type": "minimumCharge",
          "minimum": 400,
          "basis": "beforeTax"
        },
        "activeByDefault": true,
        "customerVisible": true
      }
    ],
    "derivedValues": [
      {
        "key": "calc_area_with_waste",
        "label": "المساحة مع الهالك 10%",
        "type": "number",
        "phase": "prePricing",
        "expression": {
          "type": "function",
          "name": "ceiling",
          "arguments": [
            {
              "type": "arithmetic",
              "operator": "multiply",
              "left": {
                "type": "ref",
                "ref": {
                  "kind": "field",
                  "key": "area"
                }
              },
              "right": {
                "type": "literal",
                "value": {
                  "type": "number",
                  "value": 1.1
                }
              }
            }
          ]
        }
      }
    ],
    "outputs": [
      {
        "key": "out_calc_area_with_waste",
        "label": "المساحة مع الهالك 10%",
        "source": {
          "kind": "derived",
          "key": "calc_area_with_waste"
        },
        "operatorVisible": true,
        "customerVisible": true
      }
    ]
  }
}