Skip to content

Commit d771669

Browse files
committed
fixed bug for multiple quantities
1 parent dd54d78 commit d771669

File tree

1 file changed

+38
-11
lines changed

1 file changed

+38
-11
lines changed

rosetta-source/src/main/rosetta/product-common-settlement-func.rosetta

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ func UpdateAmountForEachMatchingQuantity: <"Updates any price or quantity from t
2525
direction
2626
),
2727
quantity: priceQuantity -> quantity
28-
extract
29-
UpdateQuantityAmountForEachMatchingQuantity(
28+
extract
29+
UpdateQuantityAmountForEachMatchingQuantity(
3030
item,
3131
change, // FilterChangePriceQuantity(priceQuantity, change),
32-
// PriceQuantity used as input to keep the quantity and effectiveDate linked
32+
// PriceQuantity used as input to keep the quantity and effectiveDate linked
3333
direction
3434
),
3535
observable: priceQuantity -> observable,
@@ -85,24 +85,32 @@ func UpdateQuantityAmountForEachMatchingQuantity: <"Updates any quantity from th
8585
[metadata location]
8686

8787
alias changeMatching:
88-
change
89-
filter UnitEquals(item -> quantity first -> unit, quantity -> unit)
88+
SplitQuantityChange(change)
89+
filter UnitEquals(item -> quantity only-element -> unit, quantity -> unit)
9090
then first
9191

9292
alias changedAmount:
93-
UpdateAmount(quantity -> value, changeMatching -> quantity only-element -> value, direction)
93+
UpdateAmount(
94+
quantity -> value,
95+
changeMatching -> quantity only-element -> value,
96+
direction
97+
)
9498

9599
alias changeEffectiveDate:
96100
AdjustableDateResolution(changeMatching -> effectiveDate -> adjustableDate)
97-
//ResolveAdjustableDate(changeMatching -> effectiveDate)
98-
// TODO uncomment usage once function is available
99-
101+
// ResolveAdjustableDate(changeMatching -> effectiveDate)
102+
// TODO uncomment usage once function is available
100103
alias changedDatedValue:
101-
UpdateDatedValues(quantity -> datedValue, changeMatching -> quantity only-element -> value, direction, changeEffectiveDate)
104+
UpdateDatedValues(
105+
quantity -> datedValue,
106+
changeMatching -> quantity only-element -> value,
107+
direction,
108+
changeEffectiveDate
109+
)
102110

103111
set updatedQuantity: quantity
104112
set updatedQuantity -> value: changedAmount default quantity -> value
105-
set updatedQuantity -> datedValue : changedDatedValue default quantity -> datedValue
113+
set updatedQuantity -> datedValue: changedDatedValue default quantity -> datedValue
106114

107115
func PriceUnitEquals: <"Compares two PriceSchedule to check if all attributes match, except for the amount.">
108116
inputs:
@@ -125,3 +133,22 @@ func PriceUnitEquals: <"Compares two PriceSchedule to check if all attributes ma
125133

126134
set result:
127135
unitMatches and perUnitOfMatches and priceTypeMatches and priceExpressionMatches and arithmeticOperatorMatches
136+
137+
func SplitQuantityChange: <"Splits a PriceQuantity list into separate elements, each containing a single quantity and its corresponding effective date, if multiple quantities exist.">
138+
inputs:
139+
changeList PriceQuantity (1..*) <"Original PriceQuantity list where each of them may contain multiple quantities.">
140+
output:
141+
splitChange PriceQuantity (1..*) <"New list of PriceQuantity where each of them contain a single quantity.">
142+
143+
set splitChange: <"Iterates through the original PriceQuantity list and the quantity list.">
144+
changeList
145+
extract change [
146+
change -> quantity
147+
extract quantity [
148+
PriceQuantity {
149+
quantity: quantity,
150+
effectiveDate: change -> effectiveDate,
151+
...
152+
}
153+
]
154+
] then flatten

0 commit comments

Comments
 (0)