kumi 0.0.30 → 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,33 @@
|
|
|
1
|
+
(LIR
|
|
2
|
+
(Declaration subtotal
|
|
3
|
+
%t1 = load_input "item_price" :: decimal
|
|
4
|
+
%t2 = load_input "quantity" :: decimal
|
|
5
|
+
%t3 = call core.mul:numeric(%t1, %t2) :: decimal
|
|
6
|
+
yield %t3
|
|
7
|
+
)
|
|
8
|
+
(Declaration price_after_discount
|
|
9
|
+
%t12 = load_input "item_price" :: decimal
|
|
10
|
+
%t13 = load_input "quantity" :: decimal
|
|
11
|
+
%t14 = call core.mul:numeric(%t12, %t13) :: decimal
|
|
12
|
+
%t5 = load_input "discount_rate" :: decimal
|
|
13
|
+
%t6 = importschemacall %t14, %t5 fn_name="discounted" source_module="Kumi::TestSharedSchemas::Price" input_mapping_keys=["base_price", "discount_rate"] :: float
|
|
14
|
+
yield %t6
|
|
15
|
+
)
|
|
16
|
+
(Declaration discount_amt
|
|
17
|
+
%t15 = load_input "item_price" :: decimal
|
|
18
|
+
%t16 = load_input "quantity" :: decimal
|
|
19
|
+
%t17 = call core.mul:numeric(%t15, %t16) :: decimal
|
|
20
|
+
%t8 = load_input "discount_rate" :: decimal
|
|
21
|
+
%t9 = importschemacall %t17, %t8 fn_name="discount_amount" source_module="Kumi::TestSharedSchemas::Price" input_mapping_keys=["base_price", "discount_rate"] :: decimal
|
|
22
|
+
yield %t9
|
|
23
|
+
)
|
|
24
|
+
(Declaration final_total
|
|
25
|
+
%t21 = load_input "item_price" :: decimal
|
|
26
|
+
%t22 = load_input "quantity" :: decimal
|
|
27
|
+
%t23 = call core.mul:numeric(%t21, %t22) :: decimal
|
|
28
|
+
%t19 = load_input "discount_rate" :: decimal
|
|
29
|
+
%t20 = importschemacall %t23, %t19 fn_name="discounted" source_module="Kumi::TestSharedSchemas::Price" input_mapping_keys=["base_price", "discount_rate"] :: float
|
|
30
|
+
%t11 = importschemacall %t20 fn_name="total" source_module="Kumi::TestSharedSchemas::Tax" input_mapping_keys=["amount"] :: float
|
|
31
|
+
yield %t11
|
|
32
|
+
)
|
|
33
|
+
)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
(NAST
|
|
2
|
+
(VALUE subtotal
|
|
3
|
+
(Call :multiply
|
|
4
|
+
(InputRef [:item_price])
|
|
5
|
+
(InputRef [:quantity])
|
|
6
|
+
)
|
|
7
|
+
)
|
|
8
|
+
(VALUE price_after_discount
|
|
9
|
+
(ImportCall :discounted
|
|
10
|
+
(base_price (Ref subtotal))
|
|
11
|
+
(discount_rate (InputRef [:discount_rate]))
|
|
12
|
+
)
|
|
13
|
+
)
|
|
14
|
+
(VALUE discount_amt
|
|
15
|
+
(ImportCall :discount_amount
|
|
16
|
+
(base_price (Ref subtotal))
|
|
17
|
+
(discount_rate (InputRef [:discount_rate]))
|
|
18
|
+
)
|
|
19
|
+
)
|
|
20
|
+
(VALUE final_total
|
|
21
|
+
(ImportCall :total
|
|
22
|
+
(amount (Ref price_after_discount))
|
|
23
|
+
)
|
|
24
|
+
)
|
|
25
|
+
)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export function _subtotal(input) {
|
|
2
|
+
let t1 = input["item_price"];
|
|
3
|
+
let t2 = input["quantity"];
|
|
4
|
+
let t3 = t1 * t2;
|
|
5
|
+
return t3;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function _price_after_discount(input) {
|
|
9
|
+
let t12 = input["item_price"];
|
|
10
|
+
let t13 = input["quantity"];
|
|
11
|
+
let t14 = t12 * t13;
|
|
12
|
+
let t5 = input["discount_rate"];
|
|
13
|
+
let t6 = Kumi.TestSharedSchemas.Price.from({'base_price': t14, 'discount_rate': t5})._discounted;
|
|
14
|
+
return t6;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function _discount_amt(input) {
|
|
18
|
+
let t15 = input["item_price"];
|
|
19
|
+
let t16 = input["quantity"];
|
|
20
|
+
let t17 = t15 * t16;
|
|
21
|
+
let t8 = input["discount_rate"];
|
|
22
|
+
let t9 = Kumi.TestSharedSchemas.Price.from({'base_price': t17, 'discount_rate': t8})._discount_amount;
|
|
23
|
+
return t9;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function _final_total(input) {
|
|
27
|
+
let t21 = input["item_price"];
|
|
28
|
+
let t22 = input["quantity"];
|
|
29
|
+
let t23 = t21 * t22;
|
|
30
|
+
let t19 = input["discount_rate"];
|
|
31
|
+
let t20 = Kumi.TestSharedSchemas.Price.from({'base_price': t23, 'discount_rate': t19})._discounted;
|
|
32
|
+
let t11 = Kumi.TestSharedSchemas.Tax.from({'amount': t20})._total;
|
|
33
|
+
return t11;
|
|
34
|
+
}
|
|
35
|
+
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Autogenerated by Kumi Codegen
|
|
2
|
+
module Kumi::Compiled::KUMI_57c1891042228c14a5d8c5f42e295db295f3cbb2bc706573f811f29490855e26
|
|
3
|
+
def self._subtotal(input)
|
|
4
|
+
t1 = input["item_price"] || input[:item_price]
|
|
5
|
+
t2 = input["quantity"] || input[:quantity]
|
|
6
|
+
t1 * t2
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def self._price_after_discount(input)
|
|
10
|
+
t12 = input["item_price"] || input[:item_price]
|
|
11
|
+
t13 = input["quantity"] || input[:quantity]
|
|
12
|
+
t14 = t12 * t13
|
|
13
|
+
t5 = input["discount_rate"] || input[:discount_rate]
|
|
14
|
+
Kumi::TestSharedSchemas::Price._discounted({"base_price" => t14, "discount_rate" => t5})
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def self._discount_amt(input)
|
|
18
|
+
t15 = input["item_price"] || input[:item_price]
|
|
19
|
+
t16 = input["quantity"] || input[:quantity]
|
|
20
|
+
t17 = t15 * t16
|
|
21
|
+
t8 = input["discount_rate"] || input[:discount_rate]
|
|
22
|
+
Kumi::TestSharedSchemas::Price._discount_amount({"base_price" => t17, "discount_rate" => t8})
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def self._final_total(input)
|
|
26
|
+
t21 = input["item_price"] || input[:item_price]
|
|
27
|
+
t22 = input["quantity"] || input[:quantity]
|
|
28
|
+
t23 = t21 * t22
|
|
29
|
+
t19 = input["discount_rate"] || input[:discount_rate]
|
|
30
|
+
t20 = Kumi::TestSharedSchemas::Price._discounted({"base_price" => t23, "discount_rate" => t19})
|
|
31
|
+
Kumi::TestSharedSchemas::Tax._total({"amount" => t20})
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
(SNAST
|
|
2
|
+
(VALUE subtotal
|
|
3
|
+
(Call :core.mul:numeric
|
|
4
|
+
(InputRef item_price key_chain=[]) :: [] -> decimal
|
|
5
|
+
(InputRef quantity key_chain=[]) :: [] -> decimal
|
|
6
|
+
) :: [] -> decimal
|
|
7
|
+
) :: [] -> decimal
|
|
8
|
+
(VALUE price_after_discount
|
|
9
|
+
(ImportCall :discounted
|
|
10
|
+
(base_price (Ref subtotal) :: [] -> decimal)
|
|
11
|
+
(discount_rate (InputRef discount_rate key_chain=[]) :: [] -> decimal)
|
|
12
|
+
) :: [] -> float
|
|
13
|
+
) :: [] -> float
|
|
14
|
+
(VALUE discount_amt
|
|
15
|
+
(ImportCall :discount_amount
|
|
16
|
+
(base_price (Ref subtotal) :: [] -> decimal)
|
|
17
|
+
(discount_rate (InputRef discount_rate key_chain=[]) :: [] -> decimal)
|
|
18
|
+
) :: [] -> decimal
|
|
19
|
+
) :: [] -> decimal
|
|
20
|
+
(VALUE final_total
|
|
21
|
+
(ImportCall :total
|
|
22
|
+
(amount (Ref price_after_discount) :: [] -> float)
|
|
23
|
+
) :: [] -> float
|
|
24
|
+
) :: [] -> float
|
|
25
|
+
)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import :discounted, :discount_amount, from: Kumi::TestSharedSchemas::Price
|
|
2
|
+
import :total, from: Kumi::TestSharedSchemas::Tax
|
|
3
|
+
|
|
4
|
+
schema do
|
|
5
|
+
input do
|
|
6
|
+
decimal :item_price
|
|
7
|
+
decimal :quantity
|
|
8
|
+
decimal :discount_rate
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
value :subtotal, input.item_price * input.quantity
|
|
12
|
+
value :price_after_discount, discounted(base_price: subtotal, discount_rate: input.discount_rate)
|
|
13
|
+
value :discount_amt, discount_amount(base_price: subtotal, discount_rate: input.discount_rate)
|
|
14
|
+
value :final_total, total(amount: price_after_discount)
|
|
15
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
(Root
|
|
2
|
+
inputs: [
|
|
3
|
+
(InputDeclaration :price :decimal)
|
|
4
|
+
(InputDeclaration :discount_rate :decimal)
|
|
5
|
+
]
|
|
6
|
+
values: [
|
|
7
|
+
(ValueDeclaration :tax_amount
|
|
8
|
+
(ImportCall :tax
|
|
9
|
+
(amount (InputReference :price))
|
|
10
|
+
)
|
|
11
|
+
)
|
|
12
|
+
(ValueDeclaration :price_after_discount
|
|
13
|
+
(ImportCall :discounted
|
|
14
|
+
(price (InputReference :price))
|
|
15
|
+
(rate (InputReference :discount_rate))
|
|
16
|
+
)
|
|
17
|
+
)
|
|
18
|
+
(ValueDeclaration :discount_saved
|
|
19
|
+
(ImportCall :savings
|
|
20
|
+
(price (InputReference :price))
|
|
21
|
+
(rate (InputReference :discount_rate))
|
|
22
|
+
)
|
|
23
|
+
)
|
|
24
|
+
(ValueDeclaration :tax_on_discounted
|
|
25
|
+
(ImportCall :tax
|
|
26
|
+
(amount (DeclarationReference :price_after_discount))
|
|
27
|
+
)
|
|
28
|
+
)
|
|
29
|
+
(ValueDeclaration :final_total
|
|
30
|
+
(CallExpression :add
|
|
31
|
+
(DeclarationReference :price_after_discount)
|
|
32
|
+
(DeclarationReference :tax_on_discounted)
|
|
33
|
+
)
|
|
34
|
+
)
|
|
35
|
+
]
|
|
36
|
+
traits: []
|
|
37
|
+
)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
(LIR
|
|
2
|
+
(Declaration tax_amount
|
|
3
|
+
%t1 = load_input "price" :: decimal
|
|
4
|
+
%t2 = importschemacall %t1 fn_name="tax" source_module="Kumi::TestSharedSchemas::Tax" input_mapping_keys=["amount"] :: float
|
|
5
|
+
yield %t2
|
|
6
|
+
)
|
|
7
|
+
(Declaration price_after_discount
|
|
8
|
+
%t3 = load_input "price" :: decimal
|
|
9
|
+
%t4 = load_input "discount_rate" :: decimal
|
|
10
|
+
%t5 = importschemacall %t3, %t4 fn_name="discounted" source_module="Kumi::TestSharedSchemas::Discount" input_mapping_keys=["price", "rate"] :: float
|
|
11
|
+
yield %t5
|
|
12
|
+
)
|
|
13
|
+
(Declaration discount_saved
|
|
14
|
+
%t6 = load_input "price" :: decimal
|
|
15
|
+
%t7 = load_input "discount_rate" :: decimal
|
|
16
|
+
%t8 = importschemacall %t6, %t7 fn_name="savings" source_module="Kumi::TestSharedSchemas::Discount" input_mapping_keys=["price", "rate"] :: decimal
|
|
17
|
+
yield %t8
|
|
18
|
+
)
|
|
19
|
+
(Declaration tax_on_discounted
|
|
20
|
+
%t9 = load_decl price_after_discount :: float
|
|
21
|
+
%t10 = importschemacall %t9 fn_name="tax" source_module="Kumi::TestSharedSchemas::Tax" input_mapping_keys=["amount"] :: float
|
|
22
|
+
yield %t10
|
|
23
|
+
)
|
|
24
|
+
(Declaration final_total
|
|
25
|
+
%t11 = load_decl price_after_discount :: float
|
|
26
|
+
%t12 = load_decl tax_on_discounted :: float
|
|
27
|
+
%t13 = call core.add(%t11, %t12) :: float
|
|
28
|
+
yield %t13
|
|
29
|
+
)
|
|
30
|
+
)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
(LIR
|
|
2
|
+
(Declaration tax_amount
|
|
3
|
+
%t1 = load_input "price" :: decimal
|
|
4
|
+
%t2 = importschemacall %t1 fn_name="tax" source_module="Kumi::TestSharedSchemas::Tax" input_mapping_keys=["amount"] :: float
|
|
5
|
+
yield %t2
|
|
6
|
+
)
|
|
7
|
+
(Declaration price_after_discount
|
|
8
|
+
%t3 = load_input "price" :: decimal
|
|
9
|
+
%t4 = load_input "discount_rate" :: decimal
|
|
10
|
+
%t5 = importschemacall %t3, %t4 fn_name="discounted" source_module="Kumi::TestSharedSchemas::Discount" input_mapping_keys=["price", "rate"] :: float
|
|
11
|
+
yield %t5
|
|
12
|
+
)
|
|
13
|
+
(Declaration discount_saved
|
|
14
|
+
%t6 = load_input "price" :: decimal
|
|
15
|
+
%t7 = load_input "discount_rate" :: decimal
|
|
16
|
+
%t8 = importschemacall %t6, %t7 fn_name="savings" source_module="Kumi::TestSharedSchemas::Discount" input_mapping_keys=["price", "rate"] :: decimal
|
|
17
|
+
yield %t8
|
|
18
|
+
)
|
|
19
|
+
(Declaration tax_on_discounted
|
|
20
|
+
%t9 = load_decl price_after_discount :: float
|
|
21
|
+
%t10 = importschemacall %t9 fn_name="tax" source_module="Kumi::TestSharedSchemas::Tax" input_mapping_keys=["amount"] :: float
|
|
22
|
+
yield %t10
|
|
23
|
+
)
|
|
24
|
+
(Declaration final_total
|
|
25
|
+
%t11 = load_decl price_after_discount :: float
|
|
26
|
+
%t12 = load_decl tax_on_discounted :: float
|
|
27
|
+
%t13 = call core.add(%t11, %t12) :: float
|
|
28
|
+
yield %t13
|
|
29
|
+
)
|
|
30
|
+
)
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
(LIR
|
|
2
|
+
(Declaration tax_amount
|
|
3
|
+
%t1 = load_input "price" :: decimal
|
|
4
|
+
%t2 = importschemacall %t1 fn_name="tax" source_module="Kumi::TestSharedSchemas::Tax" input_mapping_keys=["amount"] :: float
|
|
5
|
+
yield %t2
|
|
6
|
+
)
|
|
7
|
+
(Declaration price_after_discount
|
|
8
|
+
%t3 = load_input "price" :: decimal
|
|
9
|
+
%t4 = load_input "discount_rate" :: decimal
|
|
10
|
+
%t5 = importschemacall %t3, %t4 fn_name="discounted" source_module="Kumi::TestSharedSchemas::Discount" input_mapping_keys=["price", "rate"] :: float
|
|
11
|
+
yield %t5
|
|
12
|
+
)
|
|
13
|
+
(Declaration discount_saved
|
|
14
|
+
%t6 = load_input "price" :: decimal
|
|
15
|
+
%t7 = load_input "discount_rate" :: decimal
|
|
16
|
+
%t8 = importschemacall %t6, %t7 fn_name="savings" source_module="Kumi::TestSharedSchemas::Discount" input_mapping_keys=["price", "rate"] :: decimal
|
|
17
|
+
yield %t8
|
|
18
|
+
)
|
|
19
|
+
(Declaration tax_on_discounted
|
|
20
|
+
%t14 = load_input "price" :: decimal
|
|
21
|
+
%t15 = load_input "discount_rate" :: decimal
|
|
22
|
+
%t16 = importschemacall %t14, %t15 fn_name="discounted" source_module="Kumi::TestSharedSchemas::Discount" input_mapping_keys=["price", "rate"] :: float
|
|
23
|
+
%t10 = importschemacall %t16 fn_name="tax" source_module="Kumi::TestSharedSchemas::Tax" input_mapping_keys=["amount"] :: float
|
|
24
|
+
yield %t10
|
|
25
|
+
)
|
|
26
|
+
(Declaration final_total
|
|
27
|
+
%t17 = load_input "price" :: decimal
|
|
28
|
+
%t18 = load_input "discount_rate" :: decimal
|
|
29
|
+
%t19 = importschemacall %t17, %t18 fn_name="discounted" source_module="Kumi::TestSharedSchemas::Discount" input_mapping_keys=["price", "rate"] :: float
|
|
30
|
+
%t22 = load_input "price" :: decimal
|
|
31
|
+
%t23 = load_input "discount_rate" :: decimal
|
|
32
|
+
%t24 = importschemacall %t22, %t23 fn_name="discounted" source_module="Kumi::TestSharedSchemas::Discount" input_mapping_keys=["price", "rate"] :: float
|
|
33
|
+
%t21 = importschemacall %t24 fn_name="tax" source_module="Kumi::TestSharedSchemas::Tax" input_mapping_keys=["amount"] :: float
|
|
34
|
+
%t13 = call core.add(%t19, %t21) :: float
|
|
35
|
+
yield %t13
|
|
36
|
+
)
|
|
37
|
+
)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
(LIR
|
|
2
|
+
(Declaration tax_amount
|
|
3
|
+
%t1 = load_input "price" :: decimal
|
|
4
|
+
%t2 = importschemacall %t1 fn_name="tax" source_module="Kumi::TestSharedSchemas::Tax" input_mapping_keys=["amount"] :: float
|
|
5
|
+
yield %t2
|
|
6
|
+
)
|
|
7
|
+
(Declaration price_after_discount
|
|
8
|
+
%t3 = load_input "price" :: decimal
|
|
9
|
+
%t4 = load_input "discount_rate" :: decimal
|
|
10
|
+
%t5 = importschemacall %t3, %t4 fn_name="discounted" source_module="Kumi::TestSharedSchemas::Discount" input_mapping_keys=["price", "rate"] :: float
|
|
11
|
+
yield %t5
|
|
12
|
+
)
|
|
13
|
+
(Declaration discount_saved
|
|
14
|
+
%t6 = load_input "price" :: decimal
|
|
15
|
+
%t7 = load_input "discount_rate" :: decimal
|
|
16
|
+
%t8 = importschemacall %t6, %t7 fn_name="savings" source_module="Kumi::TestSharedSchemas::Discount" input_mapping_keys=["price", "rate"] :: decimal
|
|
17
|
+
yield %t8
|
|
18
|
+
)
|
|
19
|
+
(Declaration tax_on_discounted
|
|
20
|
+
%t14 = load_input "price" :: decimal
|
|
21
|
+
%t15 = load_input "discount_rate" :: decimal
|
|
22
|
+
%t16 = importschemacall %t14, %t15 fn_name="discounted" source_module="Kumi::TestSharedSchemas::Discount" input_mapping_keys=["price", "rate"] :: float
|
|
23
|
+
%t10 = importschemacall %t16 fn_name="tax" source_module="Kumi::TestSharedSchemas::Tax" input_mapping_keys=["amount"] :: float
|
|
24
|
+
yield %t10
|
|
25
|
+
)
|
|
26
|
+
(Declaration final_total
|
|
27
|
+
%t17 = load_input "price" :: decimal
|
|
28
|
+
%t18 = load_input "discount_rate" :: decimal
|
|
29
|
+
%t19 = importschemacall %t17, %t18 fn_name="discounted" source_module="Kumi::TestSharedSchemas::Discount" input_mapping_keys=["price", "rate"] :: float
|
|
30
|
+
%t21 = importschemacall %t19 fn_name="tax" source_module="Kumi::TestSharedSchemas::Tax" input_mapping_keys=["amount"] :: float
|
|
31
|
+
%t13 = call core.add(%t19, %t21) :: float
|
|
32
|
+
yield %t13
|
|
33
|
+
)
|
|
34
|
+
)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
(LIR
|
|
2
|
+
(Declaration tax_amount
|
|
3
|
+
%t1 = load_input "price" :: decimal
|
|
4
|
+
%t2 = importschemacall %t1 fn_name="tax" source_module="Kumi::TestSharedSchemas::Tax" input_mapping_keys=["amount"] :: float
|
|
5
|
+
yield %t2
|
|
6
|
+
)
|
|
7
|
+
(Declaration price_after_discount
|
|
8
|
+
%t3 = load_input "price" :: decimal
|
|
9
|
+
%t4 = load_input "discount_rate" :: decimal
|
|
10
|
+
%t5 = importschemacall %t3, %t4 fn_name="discounted" source_module="Kumi::TestSharedSchemas::Discount" input_mapping_keys=["price", "rate"] :: float
|
|
11
|
+
yield %t5
|
|
12
|
+
)
|
|
13
|
+
(Declaration discount_saved
|
|
14
|
+
%t6 = load_input "price" :: decimal
|
|
15
|
+
%t7 = load_input "discount_rate" :: decimal
|
|
16
|
+
%t8 = importschemacall %t6, %t7 fn_name="savings" source_module="Kumi::TestSharedSchemas::Discount" input_mapping_keys=["price", "rate"] :: decimal
|
|
17
|
+
yield %t8
|
|
18
|
+
)
|
|
19
|
+
(Declaration tax_on_discounted
|
|
20
|
+
%t14 = load_input "price" :: decimal
|
|
21
|
+
%t15 = load_input "discount_rate" :: decimal
|
|
22
|
+
%t16 = importschemacall %t14, %t15 fn_name="discounted" source_module="Kumi::TestSharedSchemas::Discount" input_mapping_keys=["price", "rate"] :: float
|
|
23
|
+
%t10 = importschemacall %t16 fn_name="tax" source_module="Kumi::TestSharedSchemas::Tax" input_mapping_keys=["amount"] :: float
|
|
24
|
+
yield %t10
|
|
25
|
+
)
|
|
26
|
+
(Declaration final_total
|
|
27
|
+
%t17 = load_input "price" :: decimal
|
|
28
|
+
%t18 = load_input "discount_rate" :: decimal
|
|
29
|
+
%t19 = importschemacall %t17, %t18 fn_name="discounted" source_module="Kumi::TestSharedSchemas::Discount" input_mapping_keys=["price", "rate"] :: float
|
|
30
|
+
%t21 = importschemacall %t19 fn_name="tax" source_module="Kumi::TestSharedSchemas::Tax" input_mapping_keys=["amount"] :: float
|
|
31
|
+
%t13 = call core.add(%t19, %t21) :: float
|
|
32
|
+
yield %t13
|
|
33
|
+
)
|
|
34
|
+
)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
(LIR
|
|
2
|
+
(Declaration tax_amount
|
|
3
|
+
%t1 = load_input "price" :: decimal
|
|
4
|
+
%t2 = importschemacall %t1 fn_name="tax" source_module="Kumi::TestSharedSchemas::Tax" input_mapping_keys=["amount"] :: float
|
|
5
|
+
yield %t2
|
|
6
|
+
)
|
|
7
|
+
(Declaration price_after_discount
|
|
8
|
+
%t3 = load_input "price" :: decimal
|
|
9
|
+
%t4 = load_input "discount_rate" :: decimal
|
|
10
|
+
%t5 = importschemacall %t3, %t4 fn_name="discounted" source_module="Kumi::TestSharedSchemas::Discount" input_mapping_keys=["price", "rate"] :: float
|
|
11
|
+
yield %t5
|
|
12
|
+
)
|
|
13
|
+
(Declaration discount_saved
|
|
14
|
+
%t6 = load_input "price" :: decimal
|
|
15
|
+
%t7 = load_input "discount_rate" :: decimal
|
|
16
|
+
%t8 = importschemacall %t6, %t7 fn_name="savings" source_module="Kumi::TestSharedSchemas::Discount" input_mapping_keys=["price", "rate"] :: decimal
|
|
17
|
+
yield %t8
|
|
18
|
+
)
|
|
19
|
+
(Declaration tax_on_discounted
|
|
20
|
+
%t14 = load_input "price" :: decimal
|
|
21
|
+
%t15 = load_input "discount_rate" :: decimal
|
|
22
|
+
%t16 = importschemacall %t14, %t15 fn_name="discounted" source_module="Kumi::TestSharedSchemas::Discount" input_mapping_keys=["price", "rate"] :: float
|
|
23
|
+
%t10 = importschemacall %t16 fn_name="tax" source_module="Kumi::TestSharedSchemas::Tax" input_mapping_keys=["amount"] :: float
|
|
24
|
+
yield %t10
|
|
25
|
+
)
|
|
26
|
+
(Declaration final_total
|
|
27
|
+
%t17 = load_input "price" :: decimal
|
|
28
|
+
%t18 = load_input "discount_rate" :: decimal
|
|
29
|
+
%t19 = importschemacall %t17, %t18 fn_name="discounted" source_module="Kumi::TestSharedSchemas::Discount" input_mapping_keys=["price", "rate"] :: float
|
|
30
|
+
%t21 = importschemacall %t19 fn_name="tax" source_module="Kumi::TestSharedSchemas::Tax" input_mapping_keys=["amount"] :: float
|
|
31
|
+
%t13 = call core.add(%t19, %t21) :: float
|
|
32
|
+
yield %t13
|
|
33
|
+
)
|
|
34
|
+
)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
(LIR
|
|
2
|
+
(Declaration tax_amount
|
|
3
|
+
%t1 = load_input "price" :: decimal
|
|
4
|
+
%t2 = importschemacall %t1 fn_name="tax" source_module="Kumi::TestSharedSchemas::Tax" input_mapping_keys=["amount"] :: float
|
|
5
|
+
yield %t2
|
|
6
|
+
)
|
|
7
|
+
(Declaration price_after_discount
|
|
8
|
+
%t3 = load_input "price" :: decimal
|
|
9
|
+
%t4 = load_input "discount_rate" :: decimal
|
|
10
|
+
%t5 = importschemacall %t3, %t4 fn_name="discounted" source_module="Kumi::TestSharedSchemas::Discount" input_mapping_keys=["price", "rate"] :: float
|
|
11
|
+
yield %t5
|
|
12
|
+
)
|
|
13
|
+
(Declaration discount_saved
|
|
14
|
+
%t6 = load_input "price" :: decimal
|
|
15
|
+
%t7 = load_input "discount_rate" :: decimal
|
|
16
|
+
%t8 = importschemacall %t6, %t7 fn_name="savings" source_module="Kumi::TestSharedSchemas::Discount" input_mapping_keys=["price", "rate"] :: decimal
|
|
17
|
+
yield %t8
|
|
18
|
+
)
|
|
19
|
+
(Declaration tax_on_discounted
|
|
20
|
+
%t14 = load_input "price" :: decimal
|
|
21
|
+
%t15 = load_input "discount_rate" :: decimal
|
|
22
|
+
%t16 = importschemacall %t14, %t15 fn_name="discounted" source_module="Kumi::TestSharedSchemas::Discount" input_mapping_keys=["price", "rate"] :: float
|
|
23
|
+
%t10 = importschemacall %t16 fn_name="tax" source_module="Kumi::TestSharedSchemas::Tax" input_mapping_keys=["amount"] :: float
|
|
24
|
+
yield %t10
|
|
25
|
+
)
|
|
26
|
+
(Declaration final_total
|
|
27
|
+
%t17 = load_input "price" :: decimal
|
|
28
|
+
%t18 = load_input "discount_rate" :: decimal
|
|
29
|
+
%t19 = importschemacall %t17, %t18 fn_name="discounted" source_module="Kumi::TestSharedSchemas::Discount" input_mapping_keys=["price", "rate"] :: float
|
|
30
|
+
%t21 = importschemacall %t19 fn_name="tax" source_module="Kumi::TestSharedSchemas::Tax" input_mapping_keys=["amount"] :: float
|
|
31
|
+
%t13 = call core.add(%t19, %t21) :: float
|
|
32
|
+
yield %t13
|
|
33
|
+
)
|
|
34
|
+
)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
(NAST
|
|
2
|
+
(VALUE tax_amount
|
|
3
|
+
(ImportCall :tax
|
|
4
|
+
(amount (InputRef [:price]))
|
|
5
|
+
)
|
|
6
|
+
)
|
|
7
|
+
(VALUE price_after_discount
|
|
8
|
+
(ImportCall :discounted
|
|
9
|
+
(price (InputRef [:price]))
|
|
10
|
+
(rate (InputRef [:discount_rate]))
|
|
11
|
+
)
|
|
12
|
+
)
|
|
13
|
+
(VALUE discount_saved
|
|
14
|
+
(ImportCall :savings
|
|
15
|
+
(price (InputRef [:price]))
|
|
16
|
+
(rate (InputRef [:discount_rate]))
|
|
17
|
+
)
|
|
18
|
+
)
|
|
19
|
+
(VALUE tax_on_discounted
|
|
20
|
+
(ImportCall :tax
|
|
21
|
+
(amount (Ref price_after_discount))
|
|
22
|
+
)
|
|
23
|
+
)
|
|
24
|
+
(VALUE final_total
|
|
25
|
+
(Call :add
|
|
26
|
+
(Ref price_after_discount)
|
|
27
|
+
(Ref tax_on_discounted)
|
|
28
|
+
)
|
|
29
|
+
)
|
|
30
|
+
)
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export function _tax_amount(input) {
|
|
2
|
+
let t1 = input["price"];
|
|
3
|
+
let t2 = Kumi.TestSharedSchemas.Tax.from({'amount': t1})._tax;
|
|
4
|
+
return t2;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function _price_after_discount(input) {
|
|
8
|
+
let t3 = input["price"];
|
|
9
|
+
let t4 = input["discount_rate"];
|
|
10
|
+
let t5 = Kumi.TestSharedSchemas.Discount.from({'price': t3, 'rate': t4})._discounted;
|
|
11
|
+
return t5;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function _discount_saved(input) {
|
|
15
|
+
let t6 = input["price"];
|
|
16
|
+
let t7 = input["discount_rate"];
|
|
17
|
+
let t8 = Kumi.TestSharedSchemas.Discount.from({'price': t6, 'rate': t7})._savings;
|
|
18
|
+
return t8;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function _tax_on_discounted(input) {
|
|
22
|
+
let t14 = input["price"];
|
|
23
|
+
let t15 = input["discount_rate"];
|
|
24
|
+
let t16 = Kumi.TestSharedSchemas.Discount.from({'price': t14, 'rate': t15})._discounted;
|
|
25
|
+
let t10 = Kumi.TestSharedSchemas.Tax.from({'amount': t16})._tax;
|
|
26
|
+
return t10;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function _final_total(input) {
|
|
30
|
+
let t17 = input["price"];
|
|
31
|
+
let t18 = input["discount_rate"];
|
|
32
|
+
let t19 = Kumi.TestSharedSchemas.Discount.from({'price': t17, 'rate': t18})._discounted;
|
|
33
|
+
let t21 = Kumi.TestSharedSchemas.Tax.from({'amount': t19})._tax;
|
|
34
|
+
let t13 = t19 + t21;
|
|
35
|
+
return t13;
|
|
36
|
+
}
|
|
37
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Autogenerated by Kumi Codegen
|
|
2
|
+
module Kumi::Compiled::KUMI_879c3a35caf522702255513fd2a63d8fe507644c985bcc31321a806c4b7de9a4
|
|
3
|
+
def self._tax_amount(input)
|
|
4
|
+
t1 = input["price"] || input[:price]
|
|
5
|
+
Kumi::TestSharedSchemas::Tax._tax({"amount" => t1})
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def self._price_after_discount(input)
|
|
9
|
+
t3 = input["price"] || input[:price]
|
|
10
|
+
t4 = input["discount_rate"] || input[:discount_rate]
|
|
11
|
+
Kumi::TestSharedSchemas::Discount._discounted({"price" => t3, "rate" => t4})
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def self._discount_saved(input)
|
|
15
|
+
t6 = input["price"] || input[:price]
|
|
16
|
+
t7 = input["discount_rate"] || input[:discount_rate]
|
|
17
|
+
Kumi::TestSharedSchemas::Discount._savings({"price" => t6, "rate" => t7})
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def self._tax_on_discounted(input)
|
|
21
|
+
t14 = input["price"] || input[:price]
|
|
22
|
+
t15 = input["discount_rate"] || input[:discount_rate]
|
|
23
|
+
t16 = Kumi::TestSharedSchemas::Discount._discounted({"price" => t14, "rate" => t15})
|
|
24
|
+
Kumi::TestSharedSchemas::Tax._tax({"amount" => t16})
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def self._final_total(input)
|
|
28
|
+
t17 = input["price"] || input[:price]
|
|
29
|
+
t18 = input["discount_rate"] || input[:discount_rate]
|
|
30
|
+
t19 = Kumi::TestSharedSchemas::Discount._discounted({"price" => t17, "rate" => t18})
|
|
31
|
+
t21 = Kumi::TestSharedSchemas::Tax._tax({"amount" => t19})
|
|
32
|
+
t19 + t21
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
(SNAST
|
|
2
|
+
(VALUE tax_amount
|
|
3
|
+
(ImportCall :tax
|
|
4
|
+
(amount (InputRef price key_chain=[]) :: [] -> decimal)
|
|
5
|
+
) :: [] -> float
|
|
6
|
+
) :: [] -> float
|
|
7
|
+
(VALUE price_after_discount
|
|
8
|
+
(ImportCall :discounted
|
|
9
|
+
(price (InputRef price key_chain=[]) :: [] -> decimal)
|
|
10
|
+
(rate (InputRef discount_rate key_chain=[]) :: [] -> decimal)
|
|
11
|
+
) :: [] -> float
|
|
12
|
+
) :: [] -> float
|
|
13
|
+
(VALUE discount_saved
|
|
14
|
+
(ImportCall :savings
|
|
15
|
+
(price (InputRef price key_chain=[]) :: [] -> decimal)
|
|
16
|
+
(rate (InputRef discount_rate key_chain=[]) :: [] -> decimal)
|
|
17
|
+
) :: [] -> decimal
|
|
18
|
+
) :: [] -> decimal
|
|
19
|
+
(VALUE tax_on_discounted
|
|
20
|
+
(ImportCall :tax
|
|
21
|
+
(amount (Ref price_after_discount) :: [] -> float)
|
|
22
|
+
) :: [] -> float
|
|
23
|
+
) :: [] -> float
|
|
24
|
+
(VALUE final_total
|
|
25
|
+
(Call :core.add
|
|
26
|
+
(Ref price_after_discount) :: [] -> float
|
|
27
|
+
(Ref tax_on_discounted) :: [] -> float
|
|
28
|
+
) :: [] -> float
|
|
29
|
+
) :: [] -> float
|
|
30
|
+
)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import :tax, from: Kumi::TestSharedSchemas::Tax
|
|
2
|
+
import :discounted, :savings, from: Kumi::TestSharedSchemas::Discount
|
|
3
|
+
|
|
4
|
+
schema do
|
|
5
|
+
input do
|
|
6
|
+
decimal :price
|
|
7
|
+
decimal :discount_rate
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
value :tax_amount, tax(amount: input.price)
|
|
11
|
+
value :price_after_discount, discounted(price: input.price, rate: input.discount_rate)
|
|
12
|
+
value :discount_saved, savings(price: input.price, rate: input.discount_rate)
|
|
13
|
+
value :tax_on_discounted, tax(amount: price_after_discount)
|
|
14
|
+
value :final_total, price_after_discount + tax_on_discounted
|
|
15
|
+
end
|