Skip to content

Instantly share code, notes, and snippets.

@smidyo
Last active September 17, 2019 06:38
Show Gist options
  • Save smidyo/e5b8bc3ac4d000e90d4c6be5aa7d7751 to your computer and use it in GitHub Desktop.
Save smidyo/e5b8bc3ac4d000e90d4c6be5aa7d7751 to your computer and use it in GitHub Desktop.
Sheet material quotation process
{
"type": "PROCESS",
"inputs": [
{
"name": "width-mm",
"dataShape": {
"type": "number",
"list": false,
"nullable": false
}
},
{
"name": "height-mm",
"dataShape": {
"type": "number",
"list": false,
"nullable": false
}
}
],
"outputs": [
{
"name": "m2",
"dataShape": {
"type": "number",
"list": false,
"nullable": false
}
}
],
"steps": [
{
"type": "OPERATION_BLOCK",
"operationBlockSlug": "length-conversion.r.1",
"in": [
{
"type": "INLINE_VALUE",
"inFrom": {
"dataShape": {
"type": "text",
"nullable": false,
"list": false
},
"data": [
"millimeters"
]
},
"inTo": "convert-from"
},
{
"type": "INLINE_VALUE",
"inFrom": {
"dataShape": {
"type": "text",
"nullable": false,
"list": false
},
"data": [
"meters"
]
},
"inTo": "convert-to"
},
{
"type": "PIPELINE_VALUE",
"inFrom": "width-mm",
"inTo": "length"
}
],
"out": [
{
"outFrom": "converted",
"outTo": "width-m"
}
]
},
{
"type": "OPERATION_BLOCK",
"operationBlockSlug": "length-conversion.r.1",
"in": [
{
"type": "INLINE_VALUE",
"inFrom": {
"dataShape": {
"type": "text",
"nullable": false,
"list": false
},
"data": [
"millimeters"
]
},
"inTo": "convert-from"
},
{
"type": "INLINE_VALUE",
"inFrom": {
"dataShape": {
"type": "text",
"nullable": false,
"list": false
},
"data": [
"meters"
]
},
"inTo": "convert-to"
},
{
"type": "PIPELINE_VALUE",
"inFrom": "height-mm",
"inTo": "length"
}
],
"out": [
{
"outFrom": "converted",
"outTo": "height-m"
}
]
},
{
"type": "OPERATION_BLOCK",
"operationBlockSlug": "math-basic.r.1",
"in": [
{
"type": "INLINE_VALUE",
"inFrom": {
"dataShape": {
"type": "text",
"nullable": false,
"list": false
},
"data": [
"multiply"
]
},
"inTo": "operation"
},
{
"type": "PIPELINE_VALUE",
"inFrom": "width-m",
"inTo": "a"
},
{
"type": "PIPELINE_VALUE",
"inFrom": "height-m",
"inTo": "b"
}
],
"out": [
{
"outFrom": "result",
"outTo": "m2"
}
]
}
]
}
{
"type": "FORM",
"inputs": [],
"outputs": [
{
"name": "width-mm",
"dataShape": { "type": "number", "nullable": false, "list": false }
},
{
"name": "height-mm",
"dataShape": { "type": "number", "nullable": false, "list": false }
},
{
"name": "material-id",
"dataShape": { "type": "text", "nullable": false, "list": false }
},
{
"name": "quantity",
"dataShape": { "type": "number", "nullable": false, "list": false }
}
],
"steps": [
{
"type": "INTERNAL_SOURCE_BLOCK",
"sourceBlock": "TABLE_COLUMNS",
"tableSlug": "test-salesdomain.t.sample-materials",
"out": [
{
"outFrom": "row-names",
"outTo": "material-keys"
},
{
"outFrom": "name",
"outTo": "material-names"
}
]
},
{
"type": "ELEMENT_BLOCK",
"elementBlockSlug": "select.r.1",
"label": "Select material",
"in": [
{
"type": "PIPELINE_VALUE",
"inFrom": "material-keys",
"inTo": "options"
},
{
"type": "PIPELINE_VALUE",
"inFrom": "material-names",
"inTo": "option-titles"
}
],
"out": [
{
"outFrom": "option",
"outTo": "material-id"
}
]
},
{
"type": "ELEMENT_BLOCK",
"elementBlockSlug": "number-input.r.1",
"label": "Width",
"in": [
{
"type": "INLINE_VALUE",
"inFrom": {
"dataShape": { "type": "number", "list": false, "nullable": false },
"data": [1]
},
"inTo": "limit-decimal-places"
},
{
"type": "INLINE_VALUE",
"inFrom": {
"dataShape": {
"type": "number",
"list": false,
"nullable": false
},
"data": [10000]
},
"inTo": "max"
},
{
"type": "INLINE_VALUE",
"inFrom": {
"dataShape": { "type": "number", "list": false, "nullable": false },
"data": [1]
},
"inTo": "min"
},
{
"type": "INLINE_VALUE",
"inFrom": {
"dataShape": {
"type": "text",
"list": false,
"nullable": false
},
"data": ["mm"]
},
"inTo": "suffix"
}
],
"out": [
{
"outFrom": "number",
"outTo": "width-mm"
}
]
},
{
"type": "ELEMENT_BLOCK",
"elementBlockSlug": "number-input.r.1",
"label": "Height",
"in": [
{
"type": "INLINE_VALUE",
"inFrom": {
"dataShape": { "type": "number", "list": false, "nullable": false },
"data": [1]
},
"inTo": "limit-decimal-places"
},
{
"type": "INLINE_VALUE",
"inFrom": {
"dataShape": { "type": "number", "list": false, "nullable": false },
"data": [10000]
},
"inTo": "max"
},
{
"type": "INLINE_VALUE",
"inFrom": {
"dataShape": { "type": "number", "list": false, "nullable": false },
"data": [1]
},
"inTo": "min"
},
{
"type": "INLINE_VALUE",
"inFrom": {
"dataShape": { "type": "text", "list": false, "nullable": false },
"data": ["mm"]
},
"inTo": "suffix"
}
],
"out": [
{
"outFrom": "number",
"outTo": "height-mm"
}
]
},
{
"type": "ELEMENT_BLOCK",
"elementBlockSlug": "number-input.r.1",
"label": "Quantity",
"in": [
{
"type": "INLINE_VALUE",
"inFrom": {
"dataShape": { "type": "number", "list": false, "nullable": false },
"data": [0]
},
"inTo": "limit-decimal-places"
},
{
"type": "INLINE_VALUE",
"inFrom": {
"dataShape": { "type": "number", "list": false, "nullable": false },
"data": [10000]
},
"inTo": "max"
},
{
"type": "INLINE_VALUE",
"inFrom": {
"dataShape": { "type": "number", "list": false, "nullable": false },
"data": [0]
},
"inTo": "min"
},
{
"type": "INLINE_VALUE",
"inFrom": {
"dataShape": { "type": "text", "list": false, "nullable": false
},
"data": ["pcs"]
},
"inTo": "suffix"
}
],
"out": [
{
"outFrom": "number",
"outTo": "quantity"
}
]
}
]
}
{
"type": "PROCESS",
"inputs": [
{
"name": "min-quantities",
"dataShape": {
"type": "number",
"list": true,
"nullable": false
}
},
{
"name": "discount-percentages",
"dataShape": {
"type": "number",
"list": true,
"nullable": false
}
},
{
"name": "quantity",
"dataShape": {
"type": "number",
"list": false,
"nullable": false
}
}
],
"outputs": [
{
"name": "discount-percentage",
"dataShape": {
"type": "number",
"list": false,
"nullable": false
}
}
],
"steps": [
{
"type": "OPERATION_BLOCK",
"operationBlockSlug": "find-list-index-by-number.r.1",
"in": [
{
"type": "INLINE_VALUE",
"inFrom": {
"dataShape": {
"type": "text",
"nullable": false,
"list": false
},
"data": [
"equal-or-closest-less"
]
},
"inTo": "condition"
},
{
"type": "PIPELINE_VALUE",
"inFrom": "min-quantities",
"inTo": "number-list"
},
{
"type": "PIPELINE_VALUE",
"inFrom": "quantity",
"inTo": "find-by-number"
}
],
"out": [
{
"outFrom": "index",
"outTo": "index-maybe"
}
]
},
{
"type": "ASSERT",
"inPriority": [
{
"type": "PIPELINE_VALUE",
"inFrom": "index-maybe"
}
],
"fallback": {
"type": "REJECT",
"message": {
"type": "INLINE_VALUE",
"inFrom": {
"dataShape": {
"type": "text",
"nullable": false,
"list": false
},
"data": [
"No discount percentage was found."
]
}
}
},
"out": [
{
"outTo": "index"
}
]
},
{
"type": "OPERATION_BLOCK",
"operationBlockSlug": "pick-list-item-by-index.r.1",
"in": [
{
"type": "PIPELINE_VALUE",
"inFrom": "index",
"inTo": "index"
},
{
"type": "PIPELINE_VALUE",
"inFrom": "discount-percentages",
"inTo": "list"
}
],
"out": [
{
"outFrom": "list-item",
"outTo": "discount-percentage"
}
]
}
]
}
row-names name m2-price
smidyo-data-type text!s number!s
2mm-stainless-steel 2mm stainless steel 65
8mm-acrylic 8mm acrylic 55.5
5mm-acrylic 5mm acrylic 30
row-names min-quantity discount-percentage
smidyo-data-type number!s number!s
jb2ib6 0 0
4funko 10 10
fuiiil 100 20
hdqjvh 1000 30
{
"type": "YIELD",
"inputs": [
{
"name": "width-mm",
"dataShape": {
"type": "number",
"list": false,
"nullable": false
}
},
{
"name": "height-mm",
"dataShape": {
"type": "number",
"list": false,
"nullable": false
}
},
{
"name": "material-id",
"dataShape": {
"type": "text",
"list": false,
"nullable": false
}
},
{
"name": "quantity",
"dataShape": {
"type": "number",
"list": false,
"nullable": false
}
}
],
"quoteSteps": [
{
"type": "INTERNAL_SOURCE_BLOCK",
"sourceBlock": "TABLE_CELLS",
"tableSlug": "test-salesdomain.t.materials",
"in": [
{
"type": "PIPELINE_VALUE",
"inFrom": "material-id",
"inTo": "row-name"
}
],
"out": [
{
"outFrom": "m2-price",
"outTo": "m2-price"
},
{
"outFrom": "name",
"outTo": "material-name"
}
]
},
{
"type": "SUB_PROCESS_PIPELINE",
"subProcessPipelineSlug": "test-salesdomain.pp.calculate-square-area",
"in": [
{
"type": "PIPELINE_VALUE",
"inFrom": "width-mm",
"inTo": "width-mm"
},
{
"type": "PIPELINE_VALUE",
"inFrom": "height-mm",
"inTo": "height-mm"
}
],
"out": [
{
"outFrom": "m2",
"outTo": "m2"
}
]
},
{
"type": "INTERNAL_SOURCE_BLOCK",
"sourceBlock": "TABLE_COLUMNS",
"tableSlug": "test-salesdomain.t.quantity-discount-breaks",
"out": [
{
"outFrom": "min-quantity",
"outTo": "min-quantities"
},
{
"outFrom": "discount-percentage",
"outTo": "discount-percentages"
}
]
},
{
"type": "SUB_PROCESS_PIPELINE",
"subProcessPipelineSlug": "test-salesdomain.pp.get-discount-percentage",
"in": [
{
"type": "PIPELINE_VALUE",
"inFrom": "discount-percentages",
"inTo": "discount-percentages"
},
{
"type": "PIPELINE_VALUE",
"inFrom": "min-quantities",
"inTo": "min-quantities"
},
{
"type": "PIPELINE_VALUE",
"inFrom": "quantity",
"inTo": "quantity"
}
],
"out": [
{
"outFrom": "discount-percentage",
"outTo": "discount-percentage"
}
]
},
{
"type": "INTERNAL_SOURCE_BLOCK",
"sourceBlock": "CONSTANT",
"constantSlug": "test-salesdomain.c.material-cutting-cost",
"out": {
"outTo": "cutting-cost"
}
}
],
"quoteOutputs": [],
"quotePriceSequence": [
{
"type": "ADD",
"title": "Material",
"specification": {
"type": "PIPELINE_VALUE",
"inFrom": "material-name"
},
"name": "m2-price"
},
{
"type": "MULTIPLY",
"title": "Usage, m2",
"name": "m2"
},
{
"type": "ADD",
"title": "Cutting cost",
"name": "cutting-cost"
},
{
"type": "PERCENTAGE_OFF",
"title": "Quantity discount",
"name": "discount-percentage"
},
{
"type": "MULTIPLY",
"title": "Quantity",
"name": "quantity"
}
],
"orderSteps": [],
"orderOutputs": []
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment