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(); } }