Service - Transform Units: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 37: | Line 37: | ||
calculatedProperties: { // calculates a property added to the outputUnits | calculatedProperties: { // calculates a property added to the outputUnits | ||
{propertyName}: { | {propertyName}: { | ||
calculationType: " | calculationType: "calculateValue", // can add other types later | ||
combinationEquation: "[propertyA]+[propertyB]", // optional, method of combining multiple calculateByProperties together, defaults to adding/sum | |||
calculateByProperties: [ // can set many inputType properties | |||
{ | { | ||
inputUnitTypeId: "xxx", | inputUnitTypeId: "xxx", // different unitTypeIds can have different properties/calculations | ||
propertyName: "xxx", // property that gets | propertyName: "xxx", // property that gets inserted into calculation | ||
calculation: "[property]*[quantity]", // regExp equation? use a standard format to perform calculation | |||
}, | }, | ||
// .. | // .. |
Revision as of 14:31, 9 August 2023
Overview
Transformations are used to convert a number of input Units into sets of output Units.
Repository
https://bitbucket.org/izara-supply-units/izara-supply-units-transform-units
DynamoDB tables
Standard Config Table Per Service
Configuration tags
{
configTag: "SupplyGraphServiceName"
configKey: "SupplyGraphServiceName"
configValue: xxx // eg: "SupplyGraph"
}
transformConfig structure
{
inputUnitTypes: {
{unitTypeId}: {
stageId: "xx", // optional stage that Units get updated to
quantityProperty: "xx", // optional, name of property that is used as quantity to spread across output Units, if none set then quantity is 1
splitIntegerOnly: false, // default false, if true splits can only be integers, will not process transformation if split per outputUnit is not integer
}, //
},
outputUnitTypes: {
{unitTypeId}: {
stageId: "xx", // required initial stage Units are set to
calculatedProperties: { // calculates a property added to the outputUnits
{propertyName}: {
calculationType: "calculateValue", // can add other types later
combinationEquation: "[propertyA]+[propertyB]", // optional, method of combining multiple calculateByProperties together, defaults to adding/sum
calculateByProperties: [ // can set many inputType properties
{
inputUnitTypeId: "xxx", // different unitTypeIds can have different properties/calculations
propertyName: "xxx", // property that gets inserted into calculation
calculation: "[property]*[quantity]", // regExp equation? use a standard format to perform calculation
},
// ..
]
},
//..
}
},
//..
},
}
Transform request
- Input Units might have multiple Unit records of the same UnitType, and each record has it's quantityProperty which might be >1
- All quantityProperty will be used completely in one transformation, no partial quantities handled
- Do not differentiate which inputUnits are used on which outputUnits, if want to do that need to split into multiple transformations
- When we calculate calculatedProperties we sum all inputUnits calculations together to work out a value per quantity, then apply the ratio set for each outputUnit to calculate each outputUnits property
- outputUnits are split by itemType, but each itemType is split by sets so different calculatedProperties can be done (eg calcualting cost for sizes of different clothing)
- each itemType sets the quantity (number of Units) that are created
- each itemType set defaults to even ratio usage of inputUnit total quantity
- each itemType set can set to override default ratio with a set value (total or per Unit) for each input ItemType, as long as all input quantities are used in full (either by having >0 sets use remaining ratio, or override accurately to use all quantity)
- if multiple
Graph database
Service - Supply Graph
Nodes
{
nodeLabel: "{transformUnitsLib.TRANSFORM_UNITS_GRAPH_NODE_LABEL}", // transformUnits
schema: {
identifier: true,
restrictProperties: true,
restrictRelationships: true,
properties: {
transformConfigId: {
identifier: true, //(random uuid)
},
},
}
}
- One transform units task
{
nodeLabel: "{transformUnitsLib.TRANSFORM_UNITS_CONFIG_GRAPH_NODE_LABEL}", // transformUnitsConfig
schema: {
identifier: true,
restrictProperties: true,
restrictRelationships: true,
properties: {
transformConfigId: {
identifier: true, //(random uuid)
},
},
}
}
- Main Transform Confirm object
Versioned data
transformUnitsConfigSettings
- At the moment a stage Adjustment can only be edited by the user who created it (use standard createdBy relationship), in future could make RBAC per stageAdjustment
{
properties: {
inputUnitTypes: [],
outputUnitTypes: [],
},
}
Relationships
{
relationshipType: "{transformUnitsLib.TO_TRANSFORM_TRANSFORM_UNITS_FROM_GRAPH_REL_TYPE}", // "toTransform_TransformUnits"
schema: {
elementCanBeRemoved: false,
allPropertiesImmutable: true,
restrictProperties: true,
properties: {
originTimestamp: //timestamp the request to create/change this relationship was sent
},
}
}
- connects inputUnits to transformUnits node
{
relationshipType: "{transformUnitsLib.FROM_TRANSFORM_TRANSFORM_UNITS_FROM_GRAPH_REL_TYPE}", // "fromTransform_TransformUnits"
schema: {
elementCanBeRemoved: false,
allPropertiesImmutable: true,
restrictProperties: true,
properties: {
originTimestamp: //timestamp the request to create/change this relationship was sent
},
}
}
- connects outputUnits to transformUnits node