CREATE FUNCTION `calculateEbayPrice`(
    price DECIMAL(10,2),
    corePrice DECIMAL(10,2),
    weight DECIMAL(10,2),
    sumPrice DECIMAL(10,2),
    numberOfPieces INT
) RETURNS DECIMAL(10,2) DETERMINISTIC
BEGIN
    DECLARE productCost DECIMAL(10,2);
    DECLARE finalPrice DECIMAL(10,2);

    SET productCost = IF(numberOfPieces > 1, (price + corePrice + (weight * 2)) * numberOfPieces, price + corePrice + (weight * 2));
    SET finalPrice = 0;

    SET finalPrice = productCost + 20 + (productCost * 20 / 100);

    SET finalPrice = finalPrice + sumPrice;
    SET finalPrice = CEILING(finalPrice * 20) / 20;

    RETURN finalPrice;
END;
