[
  {
    "ts": "2018-07-24T16:33:20.083+00:00",
    "entity_name": "demo:LineItem",
    "attribute_name": "amount",
    "prop1": null,
    "prop2": null,
    "prop3": null,
    "prop4": "javascript",
    "prop5": null,
    "rule_text1": "if (row.qty_ordered <= 6)  // discount (using conditional JavaScript logic)\n   return row.product_price * row.qty_ordered;\nelse\n   return row.product_price * row.qty_ordered * 0.8;\n",
    "rule_text2": null,
    "rule_text3": null,
    "rule_text4": null,
    "rule_text5": null,
    "predicate": null,
    "name": "formula_amount",
    "title": "Discounted price*qty",
    "is_auto_title": false,
    "verbs": null,
    "comments": "Reactive Logic is expressed in JavaScript, so you use...\n- conditional logic (as above),\n- standard JavaScript services (e.g., moment date functions - enable in Project > Libraries),\n- SQL / external services.... whatever is required.",
    "active": true,
    "sqlable": false,
    "jit": false,
    "ruletype_ident": 3,
    "default_name": "formula_amount",
    "default_title": "amount = if (row.qty_ordered <= 6)  // discount (using conditional JavaScript logic)",
    "@metadata": {
      "href": "http://localhost:8080/rest/abl/admin/v2/admin:rules/2115",
      "checksum": "A:aea8457211be6fab"
    }
  },
  {
    "ts": "2018-07-24T16:33:20.363+00:00",
    "entity_name": "demo:LineItem",
    "attribute_name": "product_price",
    "prop1": null,
    "prop2": null,
    "prop3": null,
    "prop4": null,
    "prop5": null,
    "rule_text1": "product",
    "rule_text2": "price",
    "rule_text3": null,
    "rule_text4": null,
    "rule_text5": null,
    "predicate": null,
    "name": "parentCopy_product_price",
    "title": "product_price = parentcopy(product.price)",
    "is_auto_title": true,
    "verbs": null,
    "comments": "Parent copy means order unaffected by product price changes",
    "active": true,
    "sqlable": false,
    "jit": false,
    "ruletype_ident": 4,
    "default_name": "parentCopy_product_price",
    "default_title": "product_price = parentcopy(product.price)",
    "@metadata": {
      "href": "http://localhost:8080/rest/abl/admin/v2/admin:rules/2116",
      "checksum": "A:8c4256ca842834cf"
    }
  },
  {
    "ts": "2018-07-24T16:33:20.365+00:00",
    "entity_name": "demo:PurchaseOrder",
    "attribute_name": null,
    "prop1": null,
    "prop2": null,
    "prop3": null,
    "prop4": "javascript",
    "prop5": null,
    "rule_text1": "if (row.amount_total != oldRow.amount_total) {\n  var newPurchaseorder_audit = logicContext.createPersistentBean(\"demo:purchaseorder_audit\");\n  newPurchaseorder_audit.amount_total = oldRow.amount_total;  // set attributes from old values\n  newPurchaseorder_audit.paid = oldRow.paid;\n  newPurchaseorder_audit.customer_name = oldRow.customer_name;\n  newPurchaseorder_audit.order_number = oldRow.order_number;  // set the foreign key\n  logicContext.insert(newPurchaseorder_audit);                // saves (fires logic)\n}\n// better: re-use alternative using Loadable Libraries\n// if (row.amount_total != oldRow.amount_total)\n//   SysLogic.insertChildFrom(\"purchaseorder_audit\", logicContext);\n",
    "rule_text2": null,
    "rule_text3": null,
    "rule_text4": null,
    "rule_text5": null,
    "predicate": null,
    "name": "event_audit_amount",
    "title": "Audit Purchase Order amount changes",
    "is_auto_title": false,
    "verbs": "UPDATE",
    "comments": "row, logicContext passed in from engine; initialVerb is *client* action (e.g., POST), irrespective of subsequent updates (e.g., from item adjustments)\nearly events execute before reactive expressions, events execute after reactive expressions, commit events execute after all rows are processed",
    "active": true,
    "sqlable": false,
    "jit": false,
    "ruletype_ident": 7,
    "default_name": "event_2117",
    "default_title": "Event: if (row.amount_total != oldRow.amount_total) {",
    "@metadata": {
      "href": "http://localhost:8080/rest/abl/admin/v2/admin:rules/2117",
      "checksum": "A:3a851203d2730c59"
    }
  },
  {
    "ts": "2018-07-24T16:33:20.404+00:00",
    "entity_name": "demo:PurchaseOrder",
    "attribute_name": "amount_total",
    "prop1": null,
    "prop2": null,
    "prop3": null,
    "prop4": null,
    "prop5": null,
    "rule_text1": "LineItemList",
    "rule_text2": null,
    "rule_text3": "amount",
    "rule_text4": null,
    "rule_text5": null,
    "predicate": null,
    "name": "sum_amount_total",
    "title": "amount_total = sum(LineItemList.amount)",
    "is_auto_title": true,
    "verbs": null,
    "comments": "sum of line item amounts",
    "active": true,
    "sqlable": false,
    "jit": false,
    "ruletype_ident": 1,
    "default_name": "sum_amount_total",
    "default_title": "amount_total = sum(LineItemList.amount)",
    "@metadata": {
      "href": "http://localhost:8080/rest/abl/admin/v2/admin:rules/2118",
      "checksum": "A:811bc7751b20df62"
    }
  },
  {
    "ts": "2018-07-24T16:33:20.406+00:00",
    "entity_name": "demo:customer",
    "attribute_name": null,
    "prop1": null,
    "prop2": null,
    "prop3": null,
    "prop4": "javascript",
    "prop5": null,
    "rule_text1": "return row.balance <= row.credit_limit;\n",
    "rule_text2": "Customer {name}'s balance: {balance|#,##0.00} exceeds their credit limit: {credit_limit|#,##0.00}",
    "rule_text3": null,
    "rule_text4": null,
    "rule_text5": null,
    "predicate": null,
    "name": "validation_balance",
    "title": "Validation: return row.balance <= row.credit_limit;",
    "is_auto_title": true,
    "verbs": null,
    "comments": "balance cannot exceed credit limit, else throw exception",
    "active": true,
    "sqlable": false,
    "jit": false,
    "ruletype_ident": 5,
    "default_name": "validation_2119",
    "default_title": "Validation: return row.balance <= row.credit_limit;",
    "@metadata": {
      "href": "http://localhost:8080/rest/abl/admin/v2/admin:rules/2119",
      "checksum": "A:6b627120554654fd"
    }
  },
  {
    "ts": "2018-07-24T16:33:20.408+00:00",
    "entity_name": "demo:customer",
    "attribute_name": null,
    "prop1": null,
    "prop2": null,
    "prop3": null,
    "prop4": "javascript",
    "prop5": null,
    "rule_text1": "var detail = {\n        filter: \"{_id: \\\"32751\\\"}\" ,\n        order: \"\",\n        pagesize: 30,\n        offset: 0,\n        verbose: false\n};\n\nvar response =  SysUtility.getResource('zipcodes', detail);\nlog.debug(JSON.stringify(response,null,2));\nlog.debug(response[0].state);\nlog.debug(response[0].city);\n//log.debug(response[0].loc);\n",
    "rule_text2": null,
    "rule_text3": null,
    "rule_text4": null,
    "rule_text5": null,
    "predicate": null,
    "name": "event_citylookup",
    "title": "Lookup city and state from zip code",
    "is_auto_title": false,
    "verbs": "INSERT,UPDATE",
    "comments": null,
    "active": false,
    "sqlable": false,
    "jit": false,
    "ruletype_ident": 7,
    "default_name": "event_2120",
    "default_title": "Event: var detail = {",
    "@metadata": {
      "href": "http://localhost:8080/rest/abl/admin/v2/admin:rules/2120",
      "checksum": "A:fca48d603a45ff6d"
    }
  },
  {
    "ts": "2018-07-24T16:33:20.41+00:00",
    "entity_name": "demo:customer",
    "attribute_name": "balance",
    "prop1": null,
    "prop2": null,
    "prop3": null,
    "prop4": null,
    "prop5": null,
    "rule_text1": "PurchaseOrderList",
    "rule_text2": "paid = false",
    "rule_text3": "amount_total",
    "rule_text4": null,
    "rule_text5": null,
    "predicate": null,
    "name": "sum_balance",
    "title": "balance = sum(PurchaseOrderList.amount_total where paid = false)",
    "is_auto_title": true,
    "verbs": null,
    "comments": "A rule is like a spreadsheet cell formula... it *reacts\" to changes in referenced data...\n* increased when order placed\n* decreased when order deleted... or paid\n* adjusted when order changed... or assigned to a new customer",
    "active": true,
    "sqlable": false,
    "jit": false,
    "ruletype_ident": 1,
    "default_name": "sum_balance",
    "default_title": "balance = sum(PurchaseOrderList.amount_total where paid = false)",
    "@metadata": {
      "href": "http://localhost:8080/rest/abl/admin/v2/admin:rules/2121",
      "checksum": "A:737cc50d15aab417"
    }
  }
]