Repository navigation
Expand file tree
/
Copy pathexample-rules-backup.js
More file actions
302 lines (298 loc) · 13.5 KB
/
Copy pathexample-rules-backup.js
File metadata and controls
302 lines (298 loc) · 13.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
/**
* Example rules for the Blockly Rule Editor with action blocks
* This file contains predefined rules that can be loaded into the editor
*/
// Example rule definitions in XML format
const exampleRules = {
// Rule: afstand tot bestemming 01 (using assignment action)
distance_init_example: `
<xml xmlns="https://developers.google.com/blockly/xml">
<block type="business_rule" id="ruleDistanceInit" x="20" y="20">
<field name="RULE_NAME">afstand tot bestemming 01</field>
<field name="RULE_ID">distance-init-01</field>
<field name="VALID_FROM">2018</field>
<field name="VALID_UNTIL"></field>
<value name="ACTION">
<block type="assignment_action" id="actionDistanceInit">
<value name="TARGET">
<block type="fact_reference" id="targetDistance">
<field name="OBJECT_TYPE">VLUCHT</field>
<value name="ATTRIBUTE">
<block type="attribute" id="attrDistance">
<field name="ATTRIBUTE_NAME">AFSTAND_TOT_BESTEMMING</field>
</block>
</value>
</block>
</value>
<value name="SOURCE">
<block type="literal" id="literalZero">
<field name="VALUE">0</field>
<field name="UNIT">KM</field>
</block>
</value>
</block>
</value>
</block>
</xml>
`,
// Rule: belasting op basis van afstand 02 (using assignment action with complex expression)
tax_calculation_example: `
<xml xmlns="https://developers.google.com/blockly/xml">
<block type="business_rule" id="ruleTaxCalc" x="20" y="20">
<field name="RULE_NAME">belasting op basis van afstand 02</field>
<field name="RULE_ID">distance-tax-02</field>
<field name="VALID_FROM">2018</field>
<field name="VALID_UNTIL"></field>
<value name="ACTION">
<block type="assignment_action" id="actionTaxCalc">
<value name="TARGET">
<block type="fact_reference" id="targetTax">
<field name="OBJECT_TYPE">NATUURLIJK_PERSOON</field>
<value name="ATTRIBUTE">
<block type="attribute" id="attrTax">
<field name="ATTRIBUTE_NAME">BELASTING_OP_BASIS_VAN_AFSTAND</field>
</block>
</value>
<statement name="ROLES">
<block type="role" id="roleLowTaxRate">
<field name="ROLE_NAME">PASSAGIER</field>
</block>
</statement>
</block>
</value>
<value name="SOURCE">
<block type="expression" id="exprCalcTax">
<field name="FUNCTION_NAME">CALCULATE_AS</field>
<statement name="PARAMETERS">
<block type="math_operation" id="mathSubtract">
<field name="OPERATOR">MINUS</field>
<value name="LEFT">
<block type="parameter_reference" id="paramBasicRate">
<field name="PARAMETER_NAME">LAGE_BASISTARIEF_EERSTE_SCHIJF</field>
</block>
</value>
<value name="RIGHT">
<block type="math_operation" id="mathMultiply">
<field name="OPERATOR">MULTIPLIED BY</field>
<value name="LEFT">
<block type="parameter_reference" id="paramReduction">
<field name="PARAMETER_NAME">LAGE_TARIEF_VERMINDERING_EERSTE_SCHIJF</field>
</block>
</value>
<value name="RIGHT">
<block type="fact_reference" id="factDistance">
<field name="OBJECT_TYPE">VLUCHT</field>
<value name="ATTRIBUTE">
<block type="attribute" id="attrTripDistance">
<field name="ATTRIBUTE_NAME">AFSTAND_TOT_BESTEMMING</field>
</block>
</value>
<statement name="ROLES">
<block type="role" id="roleTrip">
<field name="ROLE_NAME">REIS</field>
</block>
</statement>
</block>
</value>
</block>
</value>
</block>
</statement>
</block>
</value>
</block>
</value>
<statement name="CONDITIONS">
<block type="complex_condition" id="complexCond">
<field name="MULTIPLICITY">ALL</field>
<statement name="CONDITIONS">
<block type="simple_condition" id="condTaxed">
<value name="LEFT">
<block type="fact_reference" id="factTaxedTrip">
<field name="OBJECT_TYPE">VLUCHT</field>
<value name="ATTRIBUTE">
<block type="characteristic" id="charTaxed">
<field name="CHARACTERISTIC_NAME">BELASTE_REIS</field>
</block>
</value>
<statement name="ROLES">
<block type="role" id="roleTripTaxed">
<field name="ROLE_NAME">REIS</field>
</block>
</statement>
</block>
</value>
<field name="OPERATOR">IS EQUAL TO</field>
<value name="RIGHT">
<block type="boolean_literal" id="boolTrue1">
<field name="VALUE">TRUE</field>
</block>
</value>
<next>
<block type="simple_condition" id="condRoundTrip">
<value name="LEFT">
<block type="fact_reference" id="factRoundTrip">
<field name="OBJECT_TYPE">VLUCHT</field>
<value name="ATTRIBUTE">
<block type="characteristic" id="charRoundTrip">
<field name="CHARACTERISTIC_NAME">RONDVLUCHT</field>
</block>
</value>
<statement name="ROLES">
<block type="role" id="roleTripRound">
<field name="ROLE_NAME">REIS</field>
</block>
</statement>
</block>
</value>
<field name="OPERATOR">IS NOT EQUAL TO</field>
<value name="RIGHT">
<block type="boolean_literal" id="boolTrue2">
<field name="VALUE">TRUE</field>
</block>
</value>
<next>
<block type="simple_condition" id="condDistanceGt0">
<value name="LEFT">
<block type="fact_reference" id="factDistanceGt0">
<field name="OBJECT_TYPE">VLUCHT</field>
<value name="ATTRIBUTE">
<block type="attribute" id="attrDistanceGt0">
<field name="ATTRIBUTE_NAME">AFSTAND_TOT_BESTEMMING</field>
</block>
</value>
<statement name="ROLES">
<block type="role" id="roleTripDistGt0">
<field name="ROLE_NAME">REIS</field>
</block>
</statement>
</block>
</value>
<field name="OPERATOR">IS GREATER THAN</field>
<value name="RIGHT">
<block type="literal" id="literalZeroKm">
<field name="VALUE">0</field>
<field name="UNIT">KM</field>
</block>
</value>
<next>
<block type="simple_condition" id="condDistanceLte">
<value name="LEFT">
<block type="fact_reference" id="factDistanceLte">
<field name="OBJECT_TYPE">VLUCHT</field>
<value name="ATTRIBUTE">
<block type="attribute" id="attrDistanceLte">
<field name="ATTRIBUTE_NAME">AFSTAND_TOT_BESTEMMING</field>
</block>
</value>
<statement name="ROLES">
<block type="role" id="roleTripDistLte">
<field name="ROLE_NAME">REIS</field>
</block>
</statement>
</block>
</value>
<field name="OPERATOR">IS LESS THAN OR EQUAL TO</field>
<value name="RIGHT">
<block type="parameter_reference" id="paramUpperLimit">
<field name="PARAMETER_NAME">BOVENGRENS_AFSTAND_EERSTE_SCHIJF</field>
</block>
</value>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
</statement>
</block>
</xml>
`,
// Rule: te betalen belasting 01 (using compliance action)
compliance_rule_example: `
<xml xmlns="https://developers.google.com/blockly/xml">
<block type="business_rule" id="ruleCompliance" x="20" y="20">
<field name="RULE_NAME">te betalen belasting 01</field>
<field name="RULE_ID">tax-payment-01</field>
<field name="VALID_FROM">2018</field>
<field name="VALID_UNTIL"></field>
<value name="ACTION">
<block type="compliance_action" id="actionCompliance">
<value name="TARGET">
<block type="fact_reference" id="targetPayableTax">
<field name="OBJECT_TYPE">NATUURLIJK_PERSOON</field>
<value name="ATTRIBUTE">
<block type="attribute" id="attrPayableTax">
<field name="ATTRIBUTE_NAME">TE_BETALEN_BELASTING</field>
</block>
</value>
</block>
</value>
<field name="COMPARISON">GREATER THAN OR EQUAL TO</field>
<value name="SOURCE">
<block type="literal" id="literalZeroEur">
<field name="VALUE">0</field>
<field name="UNIT">EUR</field>
</block>
</value>
</block>
</value>
<statement name="CONDITIONS">
<block type="complex_condition" id="complexCondAny">
<field name="MULTIPLICITY">ANY</field>
<statement name="CONDITIONS">
<block type="simple_condition" id="condClimateNeutral">
<value name="LEFT">
<block type="fact_reference" id="factClimateNeutral">
<field name="OBJECT_TYPE">VLUCHT</field>
<value name="ATTRIBUTE">
<block type="characteristic" id="charClimateNeutral">
<field name="CHARACTERISTIC_NAME">KLIMAATNEUTRAAL</field>
</block>
</value>
<statement name="ROLES">
<block type="role" id="roleTripClimate">
<field name="ROLE_NAME">REIS</field>
</block>
</statement>
</block>
</value>
<field name="OPERATOR">IS EQUAL TO</field>
<value name="RIGHT">
<block type="boolean_literal" id="boolTrueClimate">
<field name="VALUE">TRUE</field>
</block>
</value>
<next>
<block type="simple_condition" id="condDiscount">
<value name="LEFT">
<block type="fact_reference" id="factDiscount">
<field name="OBJECT_TYPE">NATUURLIJK_PERSOON</field>
<value name="ATTRIBUTE">
<block type="characteristic" id="charDiscount">
<field name="CHARACTERISTIC_NAME">RECHT_OP_DUURZAAMHEIDSKORTING</field>
</block>
</value>
</block>
</value>
<field name="OPERATOR">IS EQUAL TO</field>
<value name="RIGHT">
<block type="boolean_literal" id="boolTrueDiscount">
<field name="VALUE">TRUE</field>
</block>
</value>
</block>
</next>
</block>
</statement>
</block>
</statement>
</block>
</xml>
`,
};
// Export the examples
window.exampleRulesBackup = exampleRules;