2025-02-16 - Supply Chain Transform Units examples
Jump to navigation
Jump to search
Calculate cost of outputUnit from many inputUnits
{
properties: {
inputUnits: [
{
unitTypeId: "fabric",
numberOfUnits: 1,
calculatedProperties:{
unitTypeTrackedPropertyId(remainingYards): {
integerOnly: false,
quantityReductionSetting: "clearPerUnit",
valueUsePerOutputUnit: 5.7
},
},
},
{
unitTypeId: "bagOfButtons",
numberOfUnits: 2,
calculatedProperties:{
unitTypeTrackedPropertyId(remainingButtons): {
integerOnly: true,
quantityReductionSetting: "clearPerUnit",
valueUsePerOutputUnit: 4
},
},
},
//..
],
outputUnits: [
{
unitTypeId: "shirt",
numberOfUnits: 2,
calculatedProperties: {
unitTypeTrackedPropertyId(shirtCost): {
calculationType: "calculateValue",
integerOnly: false,
combinationEquation: "[yardCost]+[buttonCost]+[stitchCost]", // not needed as default is to sum all calculateByProperties
calculateByProperties: {
yardCost: {
calculation: "[valueUsePerOutputUnit:{inputUnitTypeId(fabric)}:{unitTypeTrackedPropertyId(remainingYards)}]*[unitTypeTrackedProperty:{inputUnitTypeId(fabric)}:{unitTypeTrackedPropertyId(costPerYard)}]",
},
buttonCost: {
calculation: "[valueUsePerOutputUnit:{inputUnitTypeId(bagOfButtons)}:{unitTypeTrackedPropertyId(remainingButtons)}]*([unitTypeTrackedProperty:{inputUnitTypeId(fabric)}:{unitTypeTrackedPropertyId(costPerBag)}]/5)",
round: "round",
},
stitchCost: {
defaultValue: "30",
},
},
},
//..
}
},
//..
],
},
}
- fabric has costPerYard property
- bagOfButtons has costPerBag property
- each bagOfButtons has 5 buttons in it, so divide costPerBag/5 to get per button cost
With default settings above example:
- initial state: fabric has 100 remainingYards, costPerYard = 3
- initial state: 2 bagOfButtons, each has 5 remainingButtons, costPerBag = 30
- reduce fabric remainingYards by 11.4 (1 unit of fabric must have enough yard remaining, but additional units could be added to make up needed yardage)
- reduce bagOfButtons 1 unit to 0 remainingButtons, and another to 2 remainingButtons (if bagOfButtons.inactiveIfZero is true 0 remainingButtons will be set to inactive)
- if bagOfButtons quantityReductionSetting was set to "spread", each bagOfButtons would have 1 remainingButtons
- create 2 shirts
- each shirt valueUsePerOutputUnit for fabric.remainingYards will be 5.7 and bagOfButtons.remainingButtons will be 4
- yardCost = 5.7*3 = 17.1
- buttonCost = 4*(20/5) = 24
- shirtCost = 17.1+24+30 = 71.1