Database Reference
In-Depth Information
Impact simulation on product hierarchy
Our original objective was all about impact simulation. We want to understand
what happens to the price of the product at the top of our product hierarchy by
simulating what happens if one or more cost component price changes. If this
simulationwouldbesuficientlyperformant,thenwecouldprobablyiterateon
these changes quite frequently and use it as a way to optimize all the processes
dependent on an appropriate price calculation of the product.
In the new, optimized strategy that we have previously outlined, we can very easily
change the price of a cost component (at the bottom of the hierarchy), and as we
update that price, recalculate all the intermediate prices that are set at the levels
abovethecostcomponent(cost,costsubtype,costtype,costgroup,andinally,
the product). Let's look at the following query (which consists of multiple parts):
Part
Query
Part 1
match (n6:COST_COMPONENT)
with n6, n6.price as OLDPRICE limit 1
set n6.price = n6.price*10
with n6.price-OLDPRICE as PRICEDIFF,n6
match n6-[r5:PART_OF]->(n5:COST)-[r4:PART_OF]-
>(n4:COST_SUBTYPE)-[r3:PART_OF]->(n3:COST_TYPE)-
[r2:PART_OF]->(n2:COST_GROUP)-[r1:PART_OF]-
(n1:PRODUCT)
Part 2
set n5.price=n5.price+(PRICEDIFF*r5.quantity),
n4.price=n4.price+(PRICEDIFF*r5.quantity*r4.
quantity),
n3.price=n3.price+(PRICEDIFF*r5.quantity*r4.
quantity*r3.quantity),
n2.price=n2.price+(PRICEDIFF*r5.quantity*r4.
quantity*r3.quantity*r2.quantity),
n1.price=n1.price+(PRICEDIFF*r5.quantity*r4.
quantity*r3.quantity*r2.quantity*r1.quantity)
return PRICEDIFF, n1.price;
Part 3
Part 1 : This looks up the price of one single cost component, changes it
by multiplying it by 10, and then passes the difference between the new
price and the old price ( PRICEDIFF ) to the next part of the query.
Part 2 :Thisclimbsthetreetotheverytopofthehierarchyandidentiies
all of the parts of the hierarchy that will be affected by the change executed
in Part 1.
Search WWH ::




Custom Search