Calculation of appropriate reference price
Consider following example:
{
queryProduct(
filterBy: {
entityPrimaryKeyInSet: [
103885
],
priceInCurrency: EUR,
priceInPriceLists: [
"employee-basic-price",
"basic"
]
}
) {
recordPage {
data {
primaryKey
attributes {
code
}
priceForSale {
priceWithoutTax
priceWithTax
taxRate
}
referencePrice: price(priceList: "basic") {
priceWithoutTax
priceWithTax
taxRate
}
}
}
}
}
We can only specify a single price in the referencePrice: price(priceList: "basic") part. The real use cases often work with multiple fallback price lists and need to consider the inner record handling logic of the price. So we want to extend support for the following declaration:
referencePrice: price(priceLists: ["reference", "basic_milagro_cz", basic"]) {
priceWithoutTax
priceWithTax
taxRate
}
which would take the first available price according to the passed sequence of price lists and use it as the result price for the field. The logic will also take into account the price inner record handling logic:
- for
LOWEST_PRICEit returns the first available price that has the sameinnerRecordIdas the price for sale - for
SUM, it returns the sum of the first available prices selected for each differentinnerRecordIdthat also has the sale price available.
This needs to be added to the EntityContract interface and opened both in GraphQL and consider propagating to the REST API as well (since this logic is hard to compute on the client side).
@lho the logic is prepared in method io.evitadb.api.requestResponse.data.PricesContract#getPriceForSaleWithAccompanyingPrices including basic tests. Please:
- [ ] add the logic to GraphQL API
- [ ] consider relevant support also in REST API
- [ ] add tests
- [ ] document usage in reference documentation (or transfer issue back to me after implementation on your side)
This issue changes behaviour of allPricesForSale and breaks backward compatibility for someone who relied on flawed implementation logic. Now the method mimics the calculation and behavior of priceForSale, which is more consistent.
@novoj the GQL support, tests and user documentation are done.