diff --git a/tracktor/order/tracktor_order_automatically_update_status/README.md b/tracktor/order/tracktor_order_automatically_update_status/README.md new file mode 100644 index 00000000..1647da5a --- /dev/null +++ b/tracktor/order/tracktor_order_automatically_update_status/README.md @@ -0,0 +1,6 @@ +## Setup +* Add one or more custom statuses in your [Tracktor Dashboard](https://poulet-sauvage.myshopify.com/admin/apps/tracktor-dev) +* Edit the Update Manual Status steps in the Automation so the statuses match what you added in Tracktor + +## Optional Customizations +* If you want to add a third custom status, add a new Step, select Tracktor > Order > Update Custom Status and make the status value match a custom status entered in Tracktor \ No newline at end of file diff --git a/tracktor/order/tracktor_order_automatically_update_status/mesa.json b/tracktor/order/tracktor_order_automatically_update_status/mesa.json new file mode 100644 index 00000000..43b09db7 --- /dev/null +++ b/tracktor/order/tracktor_order_automatically_update_status/mesa.json @@ -0,0 +1,146 @@ +{ + "key": "tracktor_order_automatically_update_status", + "name": "Automatically Update Tracktor Order Status", + "version": "1.0.0", + "description": "Progresses the Tracktor custom order status after one day to the first step in manufacturing, and after a subsequent day to the next step.", + "video": "", + "readme": "", + "tags": [], + "source": "tracktor", + "destination": "tracktor", + "enabled": false, + "logging": false, + "debug": false, + "config": { + "inputs": [ + { + "trigger_type": "input", + "type": "tracktor", + "entity": "order", + "action": "order\/all", + "name": "Tracktor Order Status Any Update", + "key": "tracktor_order", + "metadata": [], + "local_fields": null, + "weight": 0 + } + ], + "outputs": [ + { + "trigger_type": "output", + "type": "delay", + "entity": "", + "action": "", + "name": "Delay ", + "key": "delay", + "metadata": { + "amount": "1", + "unit": "days", + "test_bypass": false + }, + "local_fields": null, + "weight": 0 + }, + { + "trigger_type": "output", + "type": "transform", + "entity": "mapping", + "action": null, + "name": "Mapping to Tracktor Status", + "key": "transformmapping", + "metadata": { + "script": "transform_js.js", + "mapping": [ + { + "destination": "status", + "source": "Cutting" + }, + { + "destination": "automatic_carrier_updates", + "source": "false" + }, + { + "destination": "force", + "source": "true" + } + ] + }, + "local_fields": [ + { + "key": "mapping", + "type": "mapping", + "tokens": "brackets" + } + ], + "weight": 1 + }, + { + "trigger_type": "output", + "type": "tracktor", + "entity": "order", + "action": "update", + "name": "Tracktor Update Manual Status Order", + "key": "tracktor_order_1", + "metadata": { + "order_id": "{{delay.order_id}}" + }, + "local_fields": null, + "weight": 2 + }, + { + "trigger_type": "output", + "type": "delay", + "entity": "", + "action": "", + "name": "Delay ", + "key": "delay_1", + "metadata": { + "amount": "1", + "unit": "days", + "test_bypass": false + }, + "local_fields": null, + "weight": 3 + }, + { + "trigger_type": "output", + "type": "transform", + "entity": "", + "action": "", + "name": "Mapping to Tracktor Status", + "key": "tracktor_order_2_transform", + "metadata": { + "script": "tracktor_order_2_transform_js.js", + "mapping": [ + { + "destination": "status", + "source": "Sewing" + } + ] + }, + "local_fields": [ + { + "key": "mapping", + "type": "mapping", + "tokens": "brackets" + } + ], + "weight": 4 + }, + { + "trigger_type": "output", + "type": "tracktor", + "entity": "order", + "action": "update", + "name": "Tracktor Update Manual Status Order", + "key": "tracktor_order_2", + "metadata": { + "order_id": "{{delay.order_id}}" + }, + "local_fields": null, + "weight": 5 + } + ], + "storage": [] + } +} \ No newline at end of file diff --git a/tracktor/order/tracktor_order_automatically_update_status/tracktor_order_2_transform_js.js b/tracktor/order/tracktor_order_automatically_update_status/tracktor_order_2_transform_js.js new file mode 100644 index 00000000..3888c68c --- /dev/null +++ b/tracktor/order/tracktor_order_automatically_update_status/tracktor_order_2_transform_js.js @@ -0,0 +1,27 @@ +const Mesa = require('vendor/Mesa.js'); +const Transform = require('vendor/Transform.js'); + +/** + * A Mesa Script exports a class with a script() method. + */ +module.exports = new class { + + /** + * Mesa Script + * + * @param {object} payload The payload data + * @param {object} context Additional context about this task + */ + script = (payload, context) => { + + // Adjust `payload` here to alter data before we transform it. + + // Alter the payload data based on our transform rules + const output = Transform.convert(context, payload); + + // Adjust `output` here to alter data after we transform it. + + // We're done, call the next step! + Mesa.output.next(output); + } +} diff --git a/tracktor/order/tracktor_order_automatically_update_status/transform_js.js b/tracktor/order/tracktor_order_automatically_update_status/transform_js.js new file mode 100644 index 00000000..3888c68c --- /dev/null +++ b/tracktor/order/tracktor_order_automatically_update_status/transform_js.js @@ -0,0 +1,27 @@ +const Mesa = require('vendor/Mesa.js'); +const Transform = require('vendor/Transform.js'); + +/** + * A Mesa Script exports a class with a script() method. + */ +module.exports = new class { + + /** + * Mesa Script + * + * @param {object} payload The payload data + * @param {object} context Additional context about this task + */ + script = (payload, context) => { + + // Adjust `payload` here to alter data before we transform it. + + // Alter the payload data based on our transform rules + const output = Transform.convert(context, payload); + + // Adjust `output` here to alter data after we transform it. + + // We're done, call the next step! + Mesa.output.next(output); + } +}