From 32a836d3cf181b6eba80468d4e728d30603507b2 Mon Sep 17 00:00:00 2001 From: Josef Rokos Date: Mon, 1 Jul 2019 20:26:04 +0200 Subject: [PATCH] Fixed people prices recalculation. --- camp/campservice.cpp | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/camp/campservice.cpp b/camp/campservice.cpp index 055e7bd..4ca5293 100644 --- a/camp/campservice.cpp +++ b/camp/campservice.cpp @@ -238,10 +238,26 @@ void CampService::calcPeople(CampDataPtr data) first = first.addDays(daysEnd); int endAge = first.year() - 1; + auto setTotal = [&](){ + if (sale != QDecDouble(0) && !fixedSale) + { + QDecDouble itemSale = (item->price() * sale) / 100; + item->setSale(itemSale); + item->setTotalPrice(item->price() - itemSale); + } + else + { + item->setSale(0); + item->setTotalPrice(item->price()); + } + + addAccFee(data, item, startAge, endAge, days); + }; + if (!item->personPrice().isNull()) { item->setPrice(item->personPrice()->price() * days); - addAccFee(data, item, startAge, endAge, days); + setTotal(); continue; } else @@ -258,19 +274,7 @@ void CampService::calcPeople(CampDataPtr data) } } - if (sale != QDecDouble(0) && !fixedSale) - { - QDecDouble itemSale = (item->price() * sale) / 100; - item->setSale(itemSale); - item->setTotalPrice(item->price() - itemSale); - } - else - { - item->setSale(0); - item->setTotalPrice(item->price()); - } - - addAccFee(data, item, startAge, endAge, days); + setTotal(); } }