Merge pull request #76 from mhochsteger/fix_spar_units_for_weighted_products

Use price-per-unit field for weighted products in spar
This commit is contained in:
Mario Zechner 2023-06-06 20:49:50 +02:00 committed by GitHub
commit 8632ca7024
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -45,6 +45,12 @@ exports.getCanonical = function (item, today) {
};
}
const isWeighted = item.masterValues["item-type"] === "WeightProduct";
if (isWeighted) {
unit = fallback.unit;
quantity = fallback.quantity;
}
return utils.convertUnit(
{
id: item.masterValues["code-internal"],
@ -54,7 +60,7 @@ exports.getCanonical = function (item, today) {
priceHistory: [{ date: today, price }],
unit,
quantity,
isWeighted: item.masterValues["item-type"] === "WeightProduct",
isWeighted,
bio: item.masterValues.biolevel === "Bio",
url: item.masterValues.url,
},