kumi 0.0.31 → 0.0.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -1
- data/README.md +31 -99
- data/data/kernels/ruby/core/arithmetic.yaml +2 -2
- data/docs/COMPOSED_SCHEMAS.md +137 -0
- data/docs/SCHEMA_IMPORTS.md +275 -0
- data/docs/SYNTAX.md +48 -0
- data/golden/array_element/expected/schema_ruby.rb +2 -27
- data/golden/array_index/expected/nast.txt +6 -6
- data/golden/array_index/expected/schema_ruby.rb +4 -31
- data/golden/array_operations/expected/lir_06_const_prop.txt +4 -8
- data/golden/array_operations/expected/schema_javascript.mjs +4 -8
- data/golden/array_operations/expected/schema_ruby.rb +10 -43
- data/golden/cascade_logic/expected/lir_06_const_prop.txt +7 -14
- data/golden/cascade_logic/expected/schema_javascript.mjs +7 -14
- data/golden/cascade_logic/expected/schema_ruby.rb +11 -45
- data/golden/chained_fusion/expected/lir_06_const_prop.txt +8 -18
- data/golden/chained_fusion/expected/schema_javascript.mjs +8 -18
- data/golden/chained_fusion/expected/schema_ruby.rb +14 -53
- data/golden/decimal_explicit/expected/schema_ruby.rb +4 -31
- data/golden/element_arrays/expected/lir_06_const_prop.txt +5 -11
- data/golden/element_arrays/expected/schema_javascript.mjs +5 -11
- data/golden/element_arrays/expected/schema_ruby.rb +13 -50
- data/golden/empty_and_null_inputs/expected/schema_ruby.rb +4 -31
- data/golden/example_xpto/expected/ast.txt +23 -0
- data/golden/example_xpto/expected/input_plan.txt +1 -0
- data/golden/example_xpto/expected/lir_00_unoptimized.txt +16 -0
- data/golden/example_xpto/expected/lir_01_hoist_scalar_references.txt +16 -0
- data/golden/example_xpto/expected/lir_02_inlined.txt +16 -0
- data/golden/example_xpto/expected/lir_03_cse.txt +16 -0
- data/golden/example_xpto/expected/lir_04_1_loop_fusion.txt +16 -0
- data/golden/example_xpto/expected/lir_04_loop_invcm.txt +16 -0
- data/golden/example_xpto/expected/lir_06_const_prop.txt +13 -0
- data/golden/example_xpto/expected/nast.txt +17 -0
- data/golden/example_xpto/expected/schema_javascript.mjs +13 -0
- data/golden/example_xpto/expected/schema_ruby.rb +13 -0
- data/golden/example_xpto/expected/snast.txt +17 -0
- data/golden/example_xpto/expected.json +4 -0
- data/golden/example_xpto/input.json +3 -0
- data/golden/example_xpto/schema.kumi +8 -0
- data/golden/function_overload/expected/schema_ruby.rb +2 -27
- data/golden/game_of_life/expected/lir_06_const_prop.txt +236 -287
- data/golden/game_of_life/expected/schema_javascript.mjs +32 -39
- data/golden/game_of_life/expected/schema_ruby.rb +34 -66
- data/golden/hash_keys/expected/lir_06_const_prop.txt +4 -10
- data/golden/hash_keys/expected/schema_javascript.mjs +6 -12
- data/golden/hash_keys/expected/schema_ruby.rb +8 -39
- data/golden/hash_value/expected/lir_06_const_prop.txt +3 -6
- data/golden/hash_value/expected/schema_javascript.mjs +3 -6
- data/golden/hash_value/expected/schema_ruby.rb +7 -37
- data/golden/hierarchical_complex/expected/lir_06_const_prop.txt +9 -18
- data/golden/hierarchical_complex/expected/schema_javascript.mjs +9 -18
- data/golden/hierarchical_complex/expected/schema_ruby.rb +14 -51
- data/golden/inline_rename_scope_leak/expected/lir_06_const_prop.txt +2 -6
- data/golden/inline_rename_scope_leak/expected/schema_javascript.mjs +2 -6
- data/golden/inline_rename_scope_leak/expected/schema_ruby.rb +7 -39
- data/golden/input_reference/expected/schema_ruby.rb +6 -35
- data/golden/interleaved_fusion/expected/lir_06_const_prop.txt +6 -14
- data/golden/interleaved_fusion/expected/schema_javascript.mjs +6 -14
- data/golden/interleaved_fusion/expected/schema_ruby.rb +11 -47
- data/golden/let_inline/expected/lir_06_const_prop.txt +1 -2
- data/golden/let_inline/expected/schema_javascript.mjs +1 -2
- data/golden/let_inline/expected/schema_ruby.rb +3 -29
- data/golden/loop_fusion/expected/lir_06_const_prop.txt +4 -10
- data/golden/loop_fusion/expected/schema_javascript.mjs +4 -10
- data/golden/loop_fusion/expected/schema_ruby.rb +8 -41
- data/golden/min_reduce_scope/expected/lir_06_const_prop.txt +3 -6
- data/golden/min_reduce_scope/expected/schema_javascript.mjs +3 -6
- data/golden/min_reduce_scope/expected/schema_ruby.rb +8 -39
- data/golden/mixed_dimensions/expected/lir_06_const_prop.txt +1 -2
- data/golden/mixed_dimensions/expected/schema_javascript.mjs +1 -2
- data/golden/mixed_dimensions/expected/schema_ruby.rb +5 -33
- data/golden/multirank_hoisting/expected/lir_06_const_prop.txt +9 -18
- data/golden/multirank_hoisting/expected/schema_javascript.mjs +9 -18
- data/golden/multirank_hoisting/expected/schema_ruby.rb +16 -55
- data/golden/nested_hash/expected/lir_06_const_prop.txt +1 -2
- data/golden/nested_hash/expected/schema_javascript.mjs +1 -2
- data/golden/nested_hash/expected/schema_ruby.rb +3 -29
- data/golden/reduction_broadcast/expected/schema_ruby.rb +5 -33
- data/golden/roll/expected/lir_06_const_prop.txt +8 -15
- data/golden/roll/expected/schema_javascript.mjs +8 -15
- data/golden/roll/expected/schema_ruby.rb +13 -48
- data/golden/schema_imports_broadcasting_with_imports/expected/ast.txt +26 -0
- data/golden/schema_imports_broadcasting_with_imports/expected/input_plan.txt +5 -0
- data/golden/schema_imports_broadcasting_with_imports/expected/lir_00_unoptimized.txt +20 -0
- data/golden/schema_imports_broadcasting_with_imports/expected/lir_01_hoist_scalar_references.txt +20 -0
- data/golden/schema_imports_broadcasting_with_imports/expected/lir_02_inlined.txt +22 -0
- data/golden/schema_imports_broadcasting_with_imports/expected/lir_03_cse.txt +21 -0
- data/golden/schema_imports_broadcasting_with_imports/expected/lir_04_1_loop_fusion.txt +21 -0
- data/golden/schema_imports_broadcasting_with_imports/expected/lir_04_loop_invcm.txt +21 -0
- data/golden/schema_imports_broadcasting_with_imports/expected/lir_06_const_prop.txt +21 -0
- data/golden/schema_imports_broadcasting_with_imports/expected/nast.txt +12 -0
- data/golden/schema_imports_broadcasting_with_imports/expected/schema_javascript.mjs +22 -0
- data/golden/schema_imports_broadcasting_with_imports/expected/schema_ruby.rb +24 -0
- data/golden/schema_imports_broadcasting_with_imports/expected/snast.txt +12 -0
- data/golden/schema_imports_broadcasting_with_imports/expected.json +4 -0
- data/golden/schema_imports_broadcasting_with_imports/input.json +7 -0
- data/golden/schema_imports_broadcasting_with_imports/schema.kumi +14 -0
- data/golden/schema_imports_complex_order_calc/expected/ast.txt +82 -0
- data/golden/schema_imports_complex_order_calc/expected/input_plan.txt +16 -0
- data/golden/schema_imports_complex_order_calc/expected/lir_00_unoptimized.txt +94 -0
- data/golden/schema_imports_complex_order_calc/expected/lir_01_hoist_scalar_references.txt +94 -0
- data/golden/schema_imports_complex_order_calc/expected/lir_02_inlined.txt +187 -0
- data/golden/schema_imports_complex_order_calc/expected/lir_03_cse.txt +131 -0
- data/golden/schema_imports_complex_order_calc/expected/lir_04_1_loop_fusion.txt +131 -0
- data/golden/schema_imports_complex_order_calc/expected/lir_04_loop_invcm.txt +131 -0
- data/golden/schema_imports_complex_order_calc/expected/lir_06_const_prop.txt +131 -0
- data/golden/schema_imports_complex_order_calc/expected/nast.txt +56 -0
- data/golden/schema_imports_complex_order_calc/expected/schema_javascript.mjs +147 -0
- data/golden/schema_imports_complex_order_calc/expected/schema_ruby.rb +149 -0
- data/golden/schema_imports_complex_order_calc/expected/snast.txt +56 -0
- data/golden/schema_imports_complex_order_calc/expected.json +12 -0
- data/golden/schema_imports_complex_order_calc/input.json +20 -0
- data/golden/schema_imports_complex_order_calc/schema.kumi +33 -0
- data/golden/schema_imports_composed_order/expected/ast.txt +33 -0
- data/golden/schema_imports_composed_order/expected/input_plan.txt +3 -0
- data/golden/schema_imports_composed_order/expected/lir_00_unoptimized.txt +25 -0
- data/golden/schema_imports_composed_order/expected/lir_01_hoist_scalar_references.txt +25 -0
- data/golden/schema_imports_composed_order/expected/lir_02_inlined.txt +33 -0
- data/golden/schema_imports_composed_order/expected/lir_03_cse.txt +33 -0
- data/golden/schema_imports_composed_order/expected/lir_04_1_loop_fusion.txt +33 -0
- data/golden/schema_imports_composed_order/expected/lir_04_loop_invcm.txt +33 -0
- data/golden/schema_imports_composed_order/expected/lir_06_const_prop.txt +33 -0
- data/golden/schema_imports_composed_order/expected/nast.txt +25 -0
- data/golden/schema_imports_composed_order/expected/schema_javascript.mjs +35 -0
- data/golden/schema_imports_composed_order/expected/schema_ruby.rb +33 -0
- data/golden/schema_imports_composed_order/expected/snast.txt +25 -0
- data/golden/schema_imports_composed_order/expected.json +6 -0
- data/golden/schema_imports_composed_order/input.json +5 -0
- data/golden/schema_imports_composed_order/schema.kumi +15 -0
- data/golden/schema_imports_discount_with_tax/expected/ast.txt +37 -0
- data/golden/schema_imports_discount_with_tax/expected/input_plan.txt +2 -0
- data/golden/schema_imports_discount_with_tax/expected/lir_00_unoptimized.txt +30 -0
- data/golden/schema_imports_discount_with_tax/expected/lir_01_hoist_scalar_references.txt +30 -0
- data/golden/schema_imports_discount_with_tax/expected/lir_02_inlined.txt +37 -0
- data/golden/schema_imports_discount_with_tax/expected/lir_03_cse.txt +34 -0
- data/golden/schema_imports_discount_with_tax/expected/lir_04_1_loop_fusion.txt +34 -0
- data/golden/schema_imports_discount_with_tax/expected/lir_04_loop_invcm.txt +34 -0
- data/golden/schema_imports_discount_with_tax/expected/lir_06_const_prop.txt +34 -0
- data/golden/schema_imports_discount_with_tax/expected/nast.txt +30 -0
- data/golden/schema_imports_discount_with_tax/expected/schema_javascript.mjs +37 -0
- data/golden/schema_imports_discount_with_tax/expected/schema_ruby.rb +34 -0
- data/golden/schema_imports_discount_with_tax/expected/snast.txt +30 -0
- data/golden/schema_imports_discount_with_tax/expected.json +7 -0
- data/golden/schema_imports_discount_with_tax/input.json +4 -0
- data/golden/schema_imports_discount_with_tax/schema.kumi +15 -0
- data/golden/schema_imports_line_items/expected/ast.txt +35 -0
- data/golden/schema_imports_line_items/expected/input_plan.txt +8 -0
- data/golden/schema_imports_line_items/expected/lir_00_unoptimized.txt +19 -0
- data/golden/schema_imports_line_items/expected/lir_01_hoist_scalar_references.txt +19 -0
- data/golden/schema_imports_line_items/expected/lir_02_inlined.txt +24 -0
- data/golden/schema_imports_line_items/expected/lir_03_cse.txt +22 -0
- data/golden/schema_imports_line_items/expected/lir_04_1_loop_fusion.txt +22 -0
- data/golden/schema_imports_line_items/expected/lir_04_loop_invcm.txt +22 -0
- data/golden/schema_imports_line_items/expected/lir_06_const_prop.txt +22 -0
- data/golden/schema_imports_line_items/expected/nast.txt +19 -0
- data/golden/schema_imports_line_items/expected/schema_javascript.mjs +23 -0
- data/golden/schema_imports_line_items/expected/schema_ruby.rb +22 -0
- data/golden/schema_imports_line_items/expected/snast.txt +19 -0
- data/golden/schema_imports_line_items/expected.json +5 -0
- data/golden/schema_imports_line_items/input.json +13 -0
- data/golden/schema_imports_line_items/schema.kumi +17 -0
- data/golden/schema_imports_multiple/expected/ast.txt +35 -0
- data/golden/schema_imports_multiple/expected/input_plan.txt +2 -0
- data/golden/schema_imports_multiple/expected/lir_00_unoptimized.txt +29 -0
- data/golden/schema_imports_multiple/expected/lir_01_hoist_scalar_references.txt +29 -0
- data/golden/schema_imports_multiple/expected/lir_02_inlined.txt +41 -0
- data/golden/schema_imports_multiple/expected/lir_03_cse.txt +37 -0
- data/golden/schema_imports_multiple/expected/lir_04_1_loop_fusion.txt +37 -0
- data/golden/schema_imports_multiple/expected/lir_04_loop_invcm.txt +37 -0
- data/golden/schema_imports_multiple/expected/lir_06_const_prop.txt +37 -0
- data/golden/schema_imports_multiple/expected/nast.txt +28 -0
- data/golden/schema_imports_multiple/expected/schema_javascript.mjs +40 -0
- data/golden/schema_imports_multiple/expected/schema_ruby.rb +37 -0
- data/golden/schema_imports_multiple/expected/snast.txt +28 -0
- data/golden/schema_imports_multiple/expected.json +7 -0
- data/golden/schema_imports_multiple/input.json +4 -0
- data/golden/schema_imports_multiple/schema.kumi +15 -0
- data/golden/schema_imports_nested_expressions/expected/ast.txt +31 -0
- data/golden/schema_imports_nested_expressions/expected/input_plan.txt +3 -0
- data/golden/schema_imports_nested_expressions/expected/lir_00_unoptimized.txt +22 -0
- data/golden/schema_imports_nested_expressions/expected/lir_01_hoist_scalar_references.txt +22 -0
- data/golden/schema_imports_nested_expressions/expected/lir_02_inlined.txt +32 -0
- data/golden/schema_imports_nested_expressions/expected/lir_03_cse.txt +32 -0
- data/golden/schema_imports_nested_expressions/expected/lir_04_1_loop_fusion.txt +32 -0
- data/golden/schema_imports_nested_expressions/expected/lir_04_loop_invcm.txt +32 -0
- data/golden/schema_imports_nested_expressions/expected/lir_06_const_prop.txt +28 -0
- data/golden/schema_imports_nested_expressions/expected/nast.txt +23 -0
- data/golden/schema_imports_nested_expressions/expected/schema_javascript.mjs +29 -0
- data/golden/schema_imports_nested_expressions/expected/schema_ruby.rb +28 -0
- data/golden/schema_imports_nested_expressions/expected/snast.txt +23 -0
- data/golden/schema_imports_nested_expressions/expected.json +5 -0
- data/golden/schema_imports_nested_expressions/input.json +5 -0
- data/golden/schema_imports_nested_expressions/schema.kumi +13 -0
- data/golden/schema_imports_nested_with_reductions/expected/ast.txt +47 -0
- data/golden/schema_imports_nested_with_reductions/expected/input_plan.txt +12 -0
- data/golden/schema_imports_nested_with_reductions/expected/lir_00_unoptimized.txt +31 -0
- data/golden/schema_imports_nested_with_reductions/expected/lir_01_hoist_scalar_references.txt +31 -0
- data/golden/schema_imports_nested_with_reductions/expected/lir_02_inlined.txt +58 -0
- data/golden/schema_imports_nested_with_reductions/expected/lir_03_cse.txt +49 -0
- data/golden/schema_imports_nested_with_reductions/expected/lir_04_1_loop_fusion.txt +51 -0
- data/golden/schema_imports_nested_with_reductions/expected/lir_04_loop_invcm.txt +49 -0
- data/golden/schema_imports_nested_with_reductions/expected/lir_06_const_prop.txt +49 -0
- data/golden/schema_imports_nested_with_reductions/expected/nast.txt +23 -0
- data/golden/schema_imports_nested_with_reductions/expected/schema_javascript.mjs +49 -0
- data/golden/schema_imports_nested_with_reductions/expected/schema_ruby.rb +52 -0
- data/golden/schema_imports_nested_with_reductions/expected/snast.txt +23 -0
- data/golden/schema_imports_nested_with_reductions/expected.json +6 -0
- data/golden/schema_imports_nested_with_reductions/input.json +16 -0
- data/golden/schema_imports_nested_with_reductions/schema.kumi +23 -0
- data/golden/schema_imports_with_imports/expected/ast.txt +19 -0
- data/golden/schema_imports_with_imports/expected/input_plan.txt +1 -0
- data/golden/schema_imports_with_imports/expected/lir_00_unoptimized.txt +13 -0
- data/golden/schema_imports_with_imports/expected/lir_01_hoist_scalar_references.txt +13 -0
- data/golden/schema_imports_with_imports/expected/lir_02_inlined.txt +14 -0
- data/golden/schema_imports_with_imports/expected/lir_03_cse.txt +13 -0
- data/golden/schema_imports_with_imports/expected/lir_04_1_loop_fusion.txt +13 -0
- data/golden/schema_imports_with_imports/expected/lir_04_loop_invcm.txt +13 -0
- data/golden/schema_imports_with_imports/expected/lir_06_const_prop.txt +13 -0
- data/golden/schema_imports_with_imports/expected/nast.txt +13 -0
- data/golden/schema_imports_with_imports/expected/schema_javascript.mjs +13 -0
- data/golden/schema_imports_with_imports/expected/schema_ruby.rb +13 -0
- data/golden/schema_imports_with_imports/expected/snast.txt +13 -0
- data/golden/schema_imports_with_imports/expected.json +4 -0
- data/golden/schema_imports_with_imports/input.json +3 -0
- data/golden/schema_imports_with_imports/schema.kumi +10 -0
- data/golden/shift/expected/lir_06_const_prop.txt +18 -30
- data/golden/shift/expected/schema_javascript.mjs +18 -30
- data/golden/shift/expected/schema_ruby.rb +25 -67
- data/golden/shift_2d/expected/lir_06_const_prop.txt +36 -60
- data/golden/shift_2d/expected/schema_javascript.mjs +36 -60
- data/golden/shift_2d/expected/schema_ruby.rb +49 -109
- data/golden/simple_math/expected/lir_06_const_prop.txt +3 -6
- data/golden/simple_math/expected/schema_javascript.mjs +3 -6
- data/golden/simple_math/expected/schema_ruby.rb +8 -39
- data/golden/streaming_basics/expected/lir_06_const_prop.txt +6 -12
- data/golden/streaming_basics/expected/schema_javascript.mjs +6 -12
- data/golden/streaming_basics/expected/schema_ruby.rb +14 -51
- data/golden/tuples/expected/lir_06_const_prop.txt +5 -22
- data/golden/tuples/expected/schema_javascript.mjs +5 -22
- data/golden/tuples/expected/schema_ruby.rb +11 -57
- data/golden/tuples_and_arrays/expected/lir_06_const_prop.txt +4 -8
- data/golden/tuples_and_arrays/expected/schema_javascript.mjs +4 -8
- data/golden/tuples_and_arrays/expected/schema_ruby.rb +9 -41
- data/golden/us_tax_2024/expected/lir_06_const_prop.txt +94 -171
- data/golden/us_tax_2024/expected/schema_javascript.mjs +13 -21
- data/golden/us_tax_2024/expected/schema_ruby.rb +15 -48
- data/golden/with_constants/expected/lir_06_const_prop.txt +3 -8
- data/golden/with_constants/expected/schema_javascript.mjs +3 -8
- data/golden/with_constants/expected/schema_ruby.rb +5 -35
- data/lib/kumi/analyzer.rb +8 -7
- data/lib/kumi/configuration.rb +7 -6
- data/lib/kumi/core/analyzer/passes/attach_anchors_pass.rb +1 -1
- data/lib/kumi/core/analyzer/passes/attach_terminal_info_pass.rb +1 -1
- data/lib/kumi/core/analyzer/passes/codegen/js/declaration_emitter.rb +20 -0
- data/lib/kumi/core/analyzer/passes/codegen/ruby/declaration_emitter.rb +16 -7
- data/lib/kumi/core/analyzer/passes/codegen/ruby/output_buffer.rb +3 -35
- data/lib/kumi/core/analyzer/passes/dependency_resolver.rb +6 -0
- data/lib/kumi/core/analyzer/passes/import_analysis_pass.rb +90 -0
- data/lib/kumi/core/analyzer/passes/lir/constant_propagation_pass.rb +77 -36
- data/lib/kumi/core/analyzer/passes/lir/lower_pass.rb +26 -11
- data/lib/kumi/core/analyzer/passes/name_indexer.rb +20 -2
- data/lib/kumi/core/analyzer/passes/nast_dimensional_analyzer_pass.rb +44 -0
- data/lib/kumi/core/analyzer/passes/normalize_to_nast_pass.rb +30 -0
- data/lib/kumi/core/analyzer/passes/semantic_constraint_validator.rb +5 -1
- data/lib/kumi/core/analyzer/passes/snast_pass.rb +15 -0
- data/lib/kumi/core/lir/build.rb +27 -0
- data/lib/kumi/core/lir/peephole.rb +164 -0
- data/lib/kumi/core/nast.rb +16 -0
- data/lib/kumi/core/ruby_parser/build_context.rb +3 -1
- data/lib/kumi/core/ruby_parser/parser.rb +1 -1
- data/lib/kumi/core/ruby_parser/schema_builder.rb +33 -3
- data/lib/kumi/dev/golden/result.rb +9 -3
- data/lib/kumi/dev/golden/runtime_test.rb +16 -1
- data/lib/kumi/dev/golden.rb +18 -20
- data/lib/kumi/dev/golden_schema_modules.rb +8 -0
- data/lib/kumi/dev/golden_schema_wrapper.rb +116 -0
- data/lib/kumi/dev/support/kumi_runner.mjs +18 -0
- data/lib/kumi/schema.rb +44 -2
- data/lib/kumi/support/lir_printer.rb +21 -5
- data/lib/kumi/support/nast_printer.rb +11 -0
- data/lib/kumi/support/s_expression_printer.rb +9 -0
- data/lib/kumi/support/snast_printer.rb +6 -0
- data/lib/kumi/syntax/import_call.rb +11 -0
- data/lib/kumi/syntax/import_declaration.rb +11 -0
- data/lib/kumi/syntax/root.rb +2 -2
- data/lib/kumi/test_shared_schemas/compound.rb +21 -0
- data/lib/kumi/test_shared_schemas/discount.rb +19 -0
- data/lib/kumi/test_shared_schemas/price.rb +19 -0
- data/lib/kumi/test_shared_schemas/subtotal.rb +22 -0
- data/lib/kumi/test_shared_schemas/tax.rb +18 -0
- data/lib/kumi/version.rb +1 -1
- data/lib/kumi.rb +19 -4
- metadata +176 -3
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export function _tax_amount(input) {
|
|
2
|
+
let t1 = input["amount"];
|
|
3
|
+
let t2 = Kumi.TestSharedSchemas.Tax.from({'amount': t1})._tax;
|
|
4
|
+
return t2;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function _price_after_tax(input) {
|
|
8
|
+
let t3 = input["amount"];
|
|
9
|
+
let t14 = Kumi.TestSharedSchemas.Tax.from({'amount': t3})._tax;
|
|
10
|
+
let t5 = t3 + t14;
|
|
11
|
+
return t5;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function _discounted_price(input) {
|
|
15
|
+
let t15 = input["amount"];
|
|
16
|
+
let t19 = Kumi.TestSharedSchemas.Tax.from({'amount': t15})._tax;
|
|
17
|
+
let t17 = t15 + t19;
|
|
18
|
+
let t7 = input["discount_rate"];
|
|
19
|
+
let t8 = Kumi.TestSharedSchemas.Discount.from({'price': t17, 'rate': t7})._discounted;
|
|
20
|
+
return t8;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function _discount_amount(input) {
|
|
24
|
+
let t20 = input["amount"];
|
|
25
|
+
let t24 = Kumi.TestSharedSchemas.Tax.from({'amount': t20})._tax;
|
|
26
|
+
let t22 = t20 + t24;
|
|
27
|
+
let t10 = input["discount_rate"];
|
|
28
|
+
let t11 = Kumi.TestSharedSchemas.Discount.from({'price': t22, 'rate': t10})._savings;
|
|
29
|
+
return t11;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function _final_price(input) {
|
|
33
|
+
let t28 = input["amount"];
|
|
34
|
+
let t32 = Kumi.TestSharedSchemas.Tax.from({'amount': t28})._tax;
|
|
35
|
+
let t30 = t28 + t32;
|
|
36
|
+
let t26 = input["discount_rate"];
|
|
37
|
+
let t27 = Kumi.TestSharedSchemas.Discount.from({'price': t30, 'rate': t26})._discounted;
|
|
38
|
+
return t27;
|
|
39
|
+
}
|
|
40
|
+
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Autogenerated by Kumi Codegen
|
|
2
|
+
module Kumi::Compiled::KUMI_961d4a6a57de79f20352ffed1ab82e2d27ed499da191961682290cf5c54d0e26
|
|
3
|
+
def self._tax_amount(input)
|
|
4
|
+
t1 = input["amount"] || input[:amount]
|
|
5
|
+
Kumi::TestSharedSchemas::Tax._tax({"amount" => t1})
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def self._price_after_tax(input)
|
|
9
|
+
t3 = input["amount"] || input[:amount]
|
|
10
|
+
t14 = Kumi::TestSharedSchemas::Tax._tax({"amount" => t3})
|
|
11
|
+
t3 + t14
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def self._discounted_price(input)
|
|
15
|
+
t15 = input["amount"] || input[:amount]
|
|
16
|
+
t19 = Kumi::TestSharedSchemas::Tax._tax({"amount" => t15})
|
|
17
|
+
t17 = t15 + t19
|
|
18
|
+
t7 = input["discount_rate"] || input[:discount_rate]
|
|
19
|
+
Kumi::TestSharedSchemas::Discount._discounted({"price" => t17, "rate" => t7})
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self._discount_amount(input)
|
|
23
|
+
t20 = input["amount"] || input[:amount]
|
|
24
|
+
t24 = Kumi::TestSharedSchemas::Tax._tax({"amount" => t20})
|
|
25
|
+
t22 = t20 + t24
|
|
26
|
+
t10 = input["discount_rate"] || input[:discount_rate]
|
|
27
|
+
Kumi::TestSharedSchemas::Discount._savings({"price" => t22, "rate" => t10})
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def self._final_price(input)
|
|
31
|
+
t28 = input["amount"] || input[:amount]
|
|
32
|
+
t32 = Kumi::TestSharedSchemas::Tax._tax({"amount" => t28})
|
|
33
|
+
t30 = t28 + t32
|
|
34
|
+
t26 = input["discount_rate"] || input[:discount_rate]
|
|
35
|
+
Kumi::TestSharedSchemas::Discount._discounted({"price" => t30, "rate" => t26})
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
(SNAST
|
|
2
|
+
(VALUE tax_amount
|
|
3
|
+
(ImportCall :tax
|
|
4
|
+
(amount (InputRef amount key_chain=[]) :: [] -> decimal)
|
|
5
|
+
) :: [] -> float
|
|
6
|
+
) :: [] -> float
|
|
7
|
+
(VALUE price_after_tax
|
|
8
|
+
(Call :core.add
|
|
9
|
+
(InputRef amount key_chain=[]) :: [] -> decimal
|
|
10
|
+
(Ref tax_amount) :: [] -> float
|
|
11
|
+
) :: [] -> float
|
|
12
|
+
) :: [] -> float
|
|
13
|
+
(VALUE discounted_price
|
|
14
|
+
(ImportCall :discounted
|
|
15
|
+
(price (Ref price_after_tax) :: [] -> float)
|
|
16
|
+
(rate (InputRef discount_rate key_chain=[]) :: [] -> decimal)
|
|
17
|
+
) :: [] -> float
|
|
18
|
+
) :: [] -> float
|
|
19
|
+
(VALUE discount_amount
|
|
20
|
+
(ImportCall :savings
|
|
21
|
+
(price (Ref price_after_tax) :: [] -> float)
|
|
22
|
+
(rate (InputRef discount_rate key_chain=[]) :: [] -> decimal)
|
|
23
|
+
) :: [] -> decimal
|
|
24
|
+
) :: [] -> decimal
|
|
25
|
+
(VALUE final_price
|
|
26
|
+
(Ref discounted_price) :: [] -> float
|
|
27
|
+
) :: [] -> float
|
|
28
|
+
)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
schema do
|
|
2
|
+
import :tax, from: Kumi::TestSharedSchemas::Tax
|
|
3
|
+
import :discounted, :savings, from: Kumi::TestSharedSchemas::Discount
|
|
4
|
+
|
|
5
|
+
input do
|
|
6
|
+
decimal :amount
|
|
7
|
+
decimal :discount_rate
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
value :tax_amount, tax(amount: input.amount)
|
|
11
|
+
value :price_after_tax, input.amount + tax_amount
|
|
12
|
+
value :discounted_price, discounted(price: price_after_tax, rate: input.discount_rate)
|
|
13
|
+
value :discount_amount, savings(price: price_after_tax, rate: input.discount_rate)
|
|
14
|
+
value :final_price, discounted_price
|
|
15
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
(Root
|
|
2
|
+
inputs: [
|
|
3
|
+
(InputDeclaration :amount :decimal)
|
|
4
|
+
(InputDeclaration :rate :decimal)
|
|
5
|
+
(InputDeclaration :periods :integer)
|
|
6
|
+
]
|
|
7
|
+
values: [
|
|
8
|
+
(ValueDeclaration :interest
|
|
9
|
+
(ImportCall :annual_interest
|
|
10
|
+
(principal (CallExpression :multiply
|
|
11
|
+
(InputReference :amount)
|
|
12
|
+
(Literal 1.05)
|
|
13
|
+
))
|
|
14
|
+
(rate (InputReference :rate))
|
|
15
|
+
)
|
|
16
|
+
)
|
|
17
|
+
(ValueDeclaration :total_over_periods
|
|
18
|
+
(CallExpression :multiply
|
|
19
|
+
(DeclarationReference :interest)
|
|
20
|
+
(InputReference :periods)
|
|
21
|
+
)
|
|
22
|
+
)
|
|
23
|
+
(ValueDeclaration :doubled
|
|
24
|
+
(CallExpression :multiply
|
|
25
|
+
(DeclarationReference :total_over_periods)
|
|
26
|
+
(Literal 2)
|
|
27
|
+
)
|
|
28
|
+
)
|
|
29
|
+
]
|
|
30
|
+
traits: []
|
|
31
|
+
)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
(LIR
|
|
2
|
+
(Declaration interest
|
|
3
|
+
%t1 = load_input "amount" :: decimal
|
|
4
|
+
%t2 = const 1.05 :: float
|
|
5
|
+
%t3 = call core.mul:numeric(%t1, %t2) :: float
|
|
6
|
+
%t4 = load_input "rate" :: decimal
|
|
7
|
+
%t5 = importschemacall %t3, %t4 fn_name="annual_interest" source_module="Kumi::TestSharedSchemas::Compound" input_mapping_keys=["principal", "rate"] :: decimal
|
|
8
|
+
yield %t5
|
|
9
|
+
)
|
|
10
|
+
(Declaration total_over_periods
|
|
11
|
+
%t6 = load_decl interest :: decimal
|
|
12
|
+
%t7 = load_input "periods" :: integer
|
|
13
|
+
%t8 = call core.mul:numeric(%t6, %t7) :: integer
|
|
14
|
+
yield %t8
|
|
15
|
+
)
|
|
16
|
+
(Declaration doubled
|
|
17
|
+
%t9 = load_decl total_over_periods :: integer
|
|
18
|
+
%t10 = const 2 :: integer
|
|
19
|
+
%t11 = call core.mul:numeric(%t9, %t10) :: integer
|
|
20
|
+
yield %t11
|
|
21
|
+
)
|
|
22
|
+
)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
(LIR
|
|
2
|
+
(Declaration interest
|
|
3
|
+
%t1 = load_input "amount" :: decimal
|
|
4
|
+
%t2 = const 1.05 :: float
|
|
5
|
+
%t3 = call core.mul:numeric(%t1, %t2) :: float
|
|
6
|
+
%t4 = load_input "rate" :: decimal
|
|
7
|
+
%t5 = importschemacall %t3, %t4 fn_name="annual_interest" source_module="Kumi::TestSharedSchemas::Compound" input_mapping_keys=["principal", "rate"] :: decimal
|
|
8
|
+
yield %t5
|
|
9
|
+
)
|
|
10
|
+
(Declaration total_over_periods
|
|
11
|
+
%t6 = load_decl interest :: decimal
|
|
12
|
+
%t7 = load_input "periods" :: integer
|
|
13
|
+
%t8 = call core.mul:numeric(%t6, %t7) :: integer
|
|
14
|
+
yield %t8
|
|
15
|
+
)
|
|
16
|
+
(Declaration doubled
|
|
17
|
+
%t9 = load_decl total_over_periods :: integer
|
|
18
|
+
%t10 = const 2 :: integer
|
|
19
|
+
%t11 = call core.mul:numeric(%t9, %t10) :: integer
|
|
20
|
+
yield %t11
|
|
21
|
+
)
|
|
22
|
+
)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
(LIR
|
|
2
|
+
(Declaration interest
|
|
3
|
+
%t1 = load_input "amount" :: decimal
|
|
4
|
+
%t2 = const 1.05 :: float
|
|
5
|
+
%t3 = call core.mul:numeric(%t1, %t2) :: float
|
|
6
|
+
%t4 = load_input "rate" :: decimal
|
|
7
|
+
%t5 = importschemacall %t3, %t4 fn_name="annual_interest" source_module="Kumi::TestSharedSchemas::Compound" input_mapping_keys=["principal", "rate"] :: decimal
|
|
8
|
+
yield %t5
|
|
9
|
+
)
|
|
10
|
+
(Declaration total_over_periods
|
|
11
|
+
%t12 = load_input "amount" :: decimal
|
|
12
|
+
%t13 = const 1.05 :: float
|
|
13
|
+
%t14 = call core.mul:numeric(%t12, %t13) :: float
|
|
14
|
+
%t15 = load_input "rate" :: decimal
|
|
15
|
+
%t16 = importschemacall %t14, %t15 fn_name="annual_interest" source_module="Kumi::TestSharedSchemas::Compound" input_mapping_keys=["principal", "rate"] :: decimal
|
|
16
|
+
%t7 = load_input "periods" :: integer
|
|
17
|
+
%t8 = call core.mul:numeric(%t16, %t7) :: integer
|
|
18
|
+
yield %t8
|
|
19
|
+
)
|
|
20
|
+
(Declaration doubled
|
|
21
|
+
%t20 = load_input "amount" :: decimal
|
|
22
|
+
%t21 = const 1.05 :: float
|
|
23
|
+
%t22 = call core.mul:numeric(%t20, %t21) :: float
|
|
24
|
+
%t23 = load_input "rate" :: decimal
|
|
25
|
+
%t24 = importschemacall %t22, %t23 fn_name="annual_interest" source_module="Kumi::TestSharedSchemas::Compound" input_mapping_keys=["principal", "rate"] :: decimal
|
|
26
|
+
%t18 = load_input "periods" :: integer
|
|
27
|
+
%t19 = call core.mul:numeric(%t24, %t18) :: integer
|
|
28
|
+
%t10 = const 2 :: integer
|
|
29
|
+
%t11 = call core.mul:numeric(%t19, %t10) :: integer
|
|
30
|
+
yield %t11
|
|
31
|
+
)
|
|
32
|
+
)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
(LIR
|
|
2
|
+
(Declaration interest
|
|
3
|
+
%t1 = load_input "amount" :: decimal
|
|
4
|
+
%t2 = const 1.05 :: float
|
|
5
|
+
%t3 = call core.mul:numeric(%t1, %t2) :: float
|
|
6
|
+
%t4 = load_input "rate" :: decimal
|
|
7
|
+
%t5 = importschemacall %t3, %t4 fn_name="annual_interest" source_module="Kumi::TestSharedSchemas::Compound" input_mapping_keys=["principal", "rate"] :: decimal
|
|
8
|
+
yield %t5
|
|
9
|
+
)
|
|
10
|
+
(Declaration total_over_periods
|
|
11
|
+
%t12 = load_input "amount" :: decimal
|
|
12
|
+
%t13 = const 1.05 :: float
|
|
13
|
+
%t14 = call core.mul:numeric(%t12, %t13) :: float
|
|
14
|
+
%t15 = load_input "rate" :: decimal
|
|
15
|
+
%t16 = importschemacall %t14, %t15 fn_name="annual_interest" source_module="Kumi::TestSharedSchemas::Compound" input_mapping_keys=["principal", "rate"] :: decimal
|
|
16
|
+
%t7 = load_input "periods" :: integer
|
|
17
|
+
%t8 = call core.mul:numeric(%t16, %t7) :: integer
|
|
18
|
+
yield %t8
|
|
19
|
+
)
|
|
20
|
+
(Declaration doubled
|
|
21
|
+
%t20 = load_input "amount" :: decimal
|
|
22
|
+
%t21 = const 1.05 :: float
|
|
23
|
+
%t22 = call core.mul:numeric(%t20, %t21) :: float
|
|
24
|
+
%t23 = load_input "rate" :: decimal
|
|
25
|
+
%t24 = importschemacall %t22, %t23 fn_name="annual_interest" source_module="Kumi::TestSharedSchemas::Compound" input_mapping_keys=["principal", "rate"] :: decimal
|
|
26
|
+
%t18 = load_input "periods" :: integer
|
|
27
|
+
%t19 = call core.mul:numeric(%t24, %t18) :: integer
|
|
28
|
+
%t10 = const 2 :: integer
|
|
29
|
+
%t11 = call core.mul:numeric(%t19, %t10) :: integer
|
|
30
|
+
yield %t11
|
|
31
|
+
)
|
|
32
|
+
)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
(LIR
|
|
2
|
+
(Declaration interest
|
|
3
|
+
%t1 = load_input "amount" :: decimal
|
|
4
|
+
%t2 = const 1.05 :: float
|
|
5
|
+
%t3 = call core.mul:numeric(%t1, %t2) :: float
|
|
6
|
+
%t4 = load_input "rate" :: decimal
|
|
7
|
+
%t5 = importschemacall %t3, %t4 fn_name="annual_interest" source_module="Kumi::TestSharedSchemas::Compound" input_mapping_keys=["principal", "rate"] :: decimal
|
|
8
|
+
yield %t5
|
|
9
|
+
)
|
|
10
|
+
(Declaration total_over_periods
|
|
11
|
+
%t12 = load_input "amount" :: decimal
|
|
12
|
+
%t13 = const 1.05 :: float
|
|
13
|
+
%t14 = call core.mul:numeric(%t12, %t13) :: float
|
|
14
|
+
%t15 = load_input "rate" :: decimal
|
|
15
|
+
%t16 = importschemacall %t14, %t15 fn_name="annual_interest" source_module="Kumi::TestSharedSchemas::Compound" input_mapping_keys=["principal", "rate"] :: decimal
|
|
16
|
+
%t7 = load_input "periods" :: integer
|
|
17
|
+
%t8 = call core.mul:numeric(%t16, %t7) :: integer
|
|
18
|
+
yield %t8
|
|
19
|
+
)
|
|
20
|
+
(Declaration doubled
|
|
21
|
+
%t20 = load_input "amount" :: decimal
|
|
22
|
+
%t21 = const 1.05 :: float
|
|
23
|
+
%t22 = call core.mul:numeric(%t20, %t21) :: float
|
|
24
|
+
%t23 = load_input "rate" :: decimal
|
|
25
|
+
%t24 = importschemacall %t22, %t23 fn_name="annual_interest" source_module="Kumi::TestSharedSchemas::Compound" input_mapping_keys=["principal", "rate"] :: decimal
|
|
26
|
+
%t18 = load_input "periods" :: integer
|
|
27
|
+
%t19 = call core.mul:numeric(%t24, %t18) :: integer
|
|
28
|
+
%t10 = const 2 :: integer
|
|
29
|
+
%t11 = call core.mul:numeric(%t19, %t10) :: integer
|
|
30
|
+
yield %t11
|
|
31
|
+
)
|
|
32
|
+
)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
(LIR
|
|
2
|
+
(Declaration interest
|
|
3
|
+
%t1 = load_input "amount" :: decimal
|
|
4
|
+
%t2 = const 1.05 :: float
|
|
5
|
+
%t3 = call core.mul:numeric(%t1, %t2) :: float
|
|
6
|
+
%t4 = load_input "rate" :: decimal
|
|
7
|
+
%t5 = importschemacall %t3, %t4 fn_name="annual_interest" source_module="Kumi::TestSharedSchemas::Compound" input_mapping_keys=["principal", "rate"] :: decimal
|
|
8
|
+
yield %t5
|
|
9
|
+
)
|
|
10
|
+
(Declaration total_over_periods
|
|
11
|
+
%t12 = load_input "amount" :: decimal
|
|
12
|
+
%t13 = const 1.05 :: float
|
|
13
|
+
%t14 = call core.mul:numeric(%t12, %t13) :: float
|
|
14
|
+
%t15 = load_input "rate" :: decimal
|
|
15
|
+
%t16 = importschemacall %t14, %t15 fn_name="annual_interest" source_module="Kumi::TestSharedSchemas::Compound" input_mapping_keys=["principal", "rate"] :: decimal
|
|
16
|
+
%t7 = load_input "periods" :: integer
|
|
17
|
+
%t8 = call core.mul:numeric(%t16, %t7) :: integer
|
|
18
|
+
yield %t8
|
|
19
|
+
)
|
|
20
|
+
(Declaration doubled
|
|
21
|
+
%t20 = load_input "amount" :: decimal
|
|
22
|
+
%t21 = const 1.05 :: float
|
|
23
|
+
%t22 = call core.mul:numeric(%t20, %t21) :: float
|
|
24
|
+
%t23 = load_input "rate" :: decimal
|
|
25
|
+
%t24 = importschemacall %t22, %t23 fn_name="annual_interest" source_module="Kumi::TestSharedSchemas::Compound" input_mapping_keys=["principal", "rate"] :: decimal
|
|
26
|
+
%t18 = load_input "periods" :: integer
|
|
27
|
+
%t19 = call core.mul:numeric(%t24, %t18) :: integer
|
|
28
|
+
%t10 = const 2 :: integer
|
|
29
|
+
%t11 = call core.mul:numeric(%t19, %t10) :: integer
|
|
30
|
+
yield %t11
|
|
31
|
+
)
|
|
32
|
+
)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
(LIR
|
|
2
|
+
(Declaration interest
|
|
3
|
+
%t1 = load_input "amount" :: decimal
|
|
4
|
+
%t3 = call core.mul:numeric(%t1, 1.05) :: float
|
|
5
|
+
%t4 = load_input "rate" :: decimal
|
|
6
|
+
%t5 = importschemacall %t3, %t4 fn_name="annual_interest" source_module="Kumi::TestSharedSchemas::Compound" input_mapping_keys=["principal", "rate"] :: decimal
|
|
7
|
+
yield %t5
|
|
8
|
+
)
|
|
9
|
+
(Declaration total_over_periods
|
|
10
|
+
%t12 = load_input "amount" :: decimal
|
|
11
|
+
%t14 = call core.mul:numeric(%t12, 1.05) :: float
|
|
12
|
+
%t15 = load_input "rate" :: decimal
|
|
13
|
+
%t16 = importschemacall %t14, %t15 fn_name="annual_interest" source_module="Kumi::TestSharedSchemas::Compound" input_mapping_keys=["principal", "rate"] :: decimal
|
|
14
|
+
%t7 = load_input "periods" :: integer
|
|
15
|
+
%t8 = call core.mul:numeric(%t16, %t7) :: integer
|
|
16
|
+
yield %t8
|
|
17
|
+
)
|
|
18
|
+
(Declaration doubled
|
|
19
|
+
%t20 = load_input "amount" :: decimal
|
|
20
|
+
%t22 = call core.mul:numeric(%t20, 1.05) :: float
|
|
21
|
+
%t23 = load_input "rate" :: decimal
|
|
22
|
+
%t24 = importschemacall %t22, %t23 fn_name="annual_interest" source_module="Kumi::TestSharedSchemas::Compound" input_mapping_keys=["principal", "rate"] :: decimal
|
|
23
|
+
%t18 = load_input "periods" :: integer
|
|
24
|
+
%t19 = call core.mul:numeric(%t24, %t18) :: integer
|
|
25
|
+
%t11 = call core.mul:numeric(%t19, 2) :: integer
|
|
26
|
+
yield %t11
|
|
27
|
+
)
|
|
28
|
+
)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
(NAST
|
|
2
|
+
(VALUE interest
|
|
3
|
+
(ImportCall :annual_interest
|
|
4
|
+
(principal (Call :multiply
|
|
5
|
+
(InputRef [:amount])
|
|
6
|
+
(Const 1.05)
|
|
7
|
+
))
|
|
8
|
+
(rate (InputRef [:rate]))
|
|
9
|
+
)
|
|
10
|
+
)
|
|
11
|
+
(VALUE total_over_periods
|
|
12
|
+
(Call :multiply
|
|
13
|
+
(Ref interest)
|
|
14
|
+
(InputRef [:periods])
|
|
15
|
+
)
|
|
16
|
+
)
|
|
17
|
+
(VALUE doubled
|
|
18
|
+
(Call :multiply
|
|
19
|
+
(Ref total_over_periods)
|
|
20
|
+
(Const 2)
|
|
21
|
+
)
|
|
22
|
+
)
|
|
23
|
+
)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export function _interest(input) {
|
|
2
|
+
let t1 = input["amount"];
|
|
3
|
+
let t3 = t1 * 1.05;
|
|
4
|
+
let t4 = input["rate"];
|
|
5
|
+
let t5 = Kumi.TestSharedSchemas.Compound.from({'principal': t3, 'rate': t4})._annual_interest;
|
|
6
|
+
return t5;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function _total_over_periods(input) {
|
|
10
|
+
let t12 = input["amount"];
|
|
11
|
+
let t14 = t12 * 1.05;
|
|
12
|
+
let t15 = input["rate"];
|
|
13
|
+
let t16 = Kumi.TestSharedSchemas.Compound.from({'principal': t14, 'rate': t15})._annual_interest;
|
|
14
|
+
let t7 = input["periods"];
|
|
15
|
+
let t8 = t16 * t7;
|
|
16
|
+
return t8;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function _doubled(input) {
|
|
20
|
+
let t20 = input["amount"];
|
|
21
|
+
let t22 = t20 * 1.05;
|
|
22
|
+
let t23 = input["rate"];
|
|
23
|
+
let t24 = Kumi.TestSharedSchemas.Compound.from({'principal': t22, 'rate': t23})._annual_interest;
|
|
24
|
+
let t18 = input["periods"];
|
|
25
|
+
let t19 = t24 * t18;
|
|
26
|
+
let t11 = t19 * 2;
|
|
27
|
+
return t11;
|
|
28
|
+
}
|
|
29
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Autogenerated by Kumi Codegen
|
|
2
|
+
module Kumi::Compiled::KUMI_86d4c5af0aab2bb05be7a6a85b41111fe2e80f38440fb7afb0214c3ea192d3fb
|
|
3
|
+
def self._interest(input)
|
|
4
|
+
t1 = input["amount"] || input[:amount]
|
|
5
|
+
t3 = t1 * 1.05
|
|
6
|
+
t4 = input["rate"] || input[:rate]
|
|
7
|
+
Kumi::TestSharedSchemas::Compound._annual_interest({"principal" => t3, "rate" => t4})
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def self._total_over_periods(input)
|
|
11
|
+
t12 = input["amount"] || input[:amount]
|
|
12
|
+
t14 = t12 * 1.05
|
|
13
|
+
t15 = input["rate"] || input[:rate]
|
|
14
|
+
t16 = Kumi::TestSharedSchemas::Compound._annual_interest({"principal" => t14, "rate" => t15})
|
|
15
|
+
t7 = input["periods"] || input[:periods]
|
|
16
|
+
t16 * t7
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self._doubled(input)
|
|
20
|
+
t20 = input["amount"] || input[:amount]
|
|
21
|
+
t22 = t20 * 1.05
|
|
22
|
+
t23 = input["rate"] || input[:rate]
|
|
23
|
+
t24 = Kumi::TestSharedSchemas::Compound._annual_interest({"principal" => t22, "rate" => t23})
|
|
24
|
+
t18 = input["periods"] || input[:periods]
|
|
25
|
+
t19 = t24 * t18
|
|
26
|
+
t19 * 2
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
(SNAST
|
|
2
|
+
(VALUE interest
|
|
3
|
+
(ImportCall :annual_interest
|
|
4
|
+
(principal (Call :core.mul:numeric
|
|
5
|
+
(InputRef amount key_chain=[]) :: [] -> decimal
|
|
6
|
+
(Const 1.05) :: [] -> float
|
|
7
|
+
) :: [] -> float)
|
|
8
|
+
(rate (InputRef rate key_chain=[]) :: [] -> decimal)
|
|
9
|
+
) :: [] -> decimal
|
|
10
|
+
) :: [] -> decimal
|
|
11
|
+
(VALUE total_over_periods
|
|
12
|
+
(Call :core.mul:numeric
|
|
13
|
+
(Ref interest) :: [] -> decimal
|
|
14
|
+
(InputRef periods key_chain=[]) :: [] -> integer
|
|
15
|
+
) :: [] -> integer
|
|
16
|
+
) :: [] -> integer
|
|
17
|
+
(VALUE doubled
|
|
18
|
+
(Call :core.mul:numeric
|
|
19
|
+
(Ref total_over_periods) :: [] -> integer
|
|
20
|
+
(Const 2) :: [] -> integer
|
|
21
|
+
) :: [] -> integer
|
|
22
|
+
) :: [] -> integer
|
|
23
|
+
)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
schema do
|
|
2
|
+
import :annual_interest, from: Kumi::TestSharedSchemas::Compound
|
|
3
|
+
|
|
4
|
+
input do
|
|
5
|
+
decimal :amount
|
|
6
|
+
decimal :rate
|
|
7
|
+
integer :periods
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
value :interest, annual_interest(principal: input.amount * 1.05, rate: input.rate)
|
|
11
|
+
value :total_over_periods, interest * input.periods
|
|
12
|
+
value :doubled, total_over_periods * 2
|
|
13
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
(Root
|
|
2
|
+
inputs: [
|
|
3
|
+
(InputDeclaration :tax_rate_override :decimal)
|
|
4
|
+
(InputDeclaration :orders :array
|
|
5
|
+
[
|
|
6
|
+
(InputDeclaration :order :hash
|
|
7
|
+
[
|
|
8
|
+
(InputDeclaration :items :array
|
|
9
|
+
[
|
|
10
|
+
(InputDeclaration :item :hash
|
|
11
|
+
[
|
|
12
|
+
(InputDeclaration :quantity :integer)
|
|
13
|
+
(InputDeclaration :unit_price :integer)
|
|
14
|
+
]
|
|
15
|
+
)
|
|
16
|
+
]
|
|
17
|
+
)
|
|
18
|
+
]
|
|
19
|
+
)
|
|
20
|
+
]
|
|
21
|
+
)
|
|
22
|
+
]
|
|
23
|
+
values: [
|
|
24
|
+
(ValueDeclaration :order_subtotals
|
|
25
|
+
(ImportCall :subtotal
|
|
26
|
+
(items (InputElementReference orders.order.items))
|
|
27
|
+
)
|
|
28
|
+
)
|
|
29
|
+
(ValueDeclaration :total_before_tax
|
|
30
|
+
(CallExpression :sum
|
|
31
|
+
(DeclarationReference :order_subtotals)
|
|
32
|
+
)
|
|
33
|
+
)
|
|
34
|
+
(ValueDeclaration :tax_for_all
|
|
35
|
+
(ImportCall :tax
|
|
36
|
+
(amount (DeclarationReference :total_before_tax))
|
|
37
|
+
)
|
|
38
|
+
)
|
|
39
|
+
(ValueDeclaration :grand_total
|
|
40
|
+
(CallExpression :add
|
|
41
|
+
(DeclarationReference :total_before_tax)
|
|
42
|
+
(DeclarationReference :tax_for_all)
|
|
43
|
+
)
|
|
44
|
+
)
|
|
45
|
+
]
|
|
46
|
+
traits: []
|
|
47
|
+
)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
tax_rate_override: decimal
|
|
2
|
+
orders: array (array) access_mode=element
|
|
3
|
+
└─> order: element_access
|
|
4
|
+
order: hash (hash)
|
|
5
|
+
└─> items: property_access → array_loop
|
|
6
|
+
items: array (array) access_mode=element
|
|
7
|
+
└─> item: element_access
|
|
8
|
+
item: hash (hash)
|
|
9
|
+
└─> quantity: property_access
|
|
10
|
+
└─> unit_price: property_access
|
|
11
|
+
quantity: integer
|
|
12
|
+
unit_price: integer
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
(LIR
|
|
2
|
+
(Declaration order_subtotals
|
|
3
|
+
%t1 = load_input "orders" :: array
|
|
4
|
+
loop orders id=L1 in %t1 as el=%orders_el_2, idx=%orders_i_3
|
|
5
|
+
%t4 = load_field orders_el_2["items"] :: array
|
|
6
|
+
%t5 = importschemacall %t4 fn_name="subtotal" source_module="Kumi::TestSharedSchemas::Subtotal" input_mapping_keys=["items"] :: integer
|
|
7
|
+
yield %t5
|
|
8
|
+
end_loop
|
|
9
|
+
)
|
|
10
|
+
(Declaration total_before_tax
|
|
11
|
+
%acc_6 = decl_acc :: integer
|
|
12
|
+
%t7 = load_input "orders" :: array
|
|
13
|
+
loop orders id=L2 in %t7 as el=%orders_el_8, idx=%orders_i_9
|
|
14
|
+
%t10 = load_decl order_subtotals axes=[orders] :: integer
|
|
15
|
+
%acc_6 = acc_add agg.sum(%acc_6, %t10) :: integer
|
|
16
|
+
end_loop
|
|
17
|
+
%t11 = acc_load %acc_6 :: integer
|
|
18
|
+
yield %t11
|
|
19
|
+
)
|
|
20
|
+
(Declaration tax_for_all
|
|
21
|
+
%t12 = load_decl total_before_tax :: integer
|
|
22
|
+
%t13 = importschemacall %t12 fn_name="tax" source_module="Kumi::TestSharedSchemas::Tax" input_mapping_keys=["amount"] :: float
|
|
23
|
+
yield %t13
|
|
24
|
+
)
|
|
25
|
+
(Declaration grand_total
|
|
26
|
+
%t14 = load_decl total_before_tax :: integer
|
|
27
|
+
%t15 = load_decl tax_for_all :: float
|
|
28
|
+
%t16 = call core.add(%t14, %t15) :: float
|
|
29
|
+
yield %t16
|
|
30
|
+
)
|
|
31
|
+
)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
(LIR
|
|
2
|
+
(Declaration order_subtotals
|
|
3
|
+
%t1 = load_input "orders" :: array
|
|
4
|
+
loop orders id=L1 in %t1 as el=%orders_el_2, idx=%orders_i_3
|
|
5
|
+
%t4 = load_field orders_el_2["items"] :: array
|
|
6
|
+
%t5 = importschemacall %t4 fn_name="subtotal" source_module="Kumi::TestSharedSchemas::Subtotal" input_mapping_keys=["items"] :: integer
|
|
7
|
+
yield %t5
|
|
8
|
+
end_loop
|
|
9
|
+
)
|
|
10
|
+
(Declaration total_before_tax
|
|
11
|
+
%acc_6 = decl_acc :: integer
|
|
12
|
+
%t7 = load_input "orders" :: array
|
|
13
|
+
loop orders id=L2 in %t7 as el=%orders_el_8, idx=%orders_i_9
|
|
14
|
+
%t10 = load_decl order_subtotals axes=[orders] :: integer
|
|
15
|
+
%acc_6 = acc_add agg.sum(%acc_6, %t10) :: integer
|
|
16
|
+
end_loop
|
|
17
|
+
%t11 = acc_load %acc_6 :: integer
|
|
18
|
+
yield %t11
|
|
19
|
+
)
|
|
20
|
+
(Declaration tax_for_all
|
|
21
|
+
%t12 = load_decl total_before_tax :: integer
|
|
22
|
+
%t13 = importschemacall %t12 fn_name="tax" source_module="Kumi::TestSharedSchemas::Tax" input_mapping_keys=["amount"] :: float
|
|
23
|
+
yield %t13
|
|
24
|
+
)
|
|
25
|
+
(Declaration grand_total
|
|
26
|
+
%t14 = load_decl total_before_tax :: integer
|
|
27
|
+
%t15 = load_decl tax_for_all :: float
|
|
28
|
+
%t16 = call core.add(%t14, %t15) :: float
|
|
29
|
+
yield %t16
|
|
30
|
+
)
|
|
31
|
+
)
|