#include "shopservice.h" ShopService::ShopService() { } QSharedPointer ShopService::createVoucher() { QSharedPointer voucher(new Voucher); voucher->setStatus(Voucher::NEW); return voucher; } void ShopService::addShopItem(QSharedPointer voucher, QSharedPointer item, int count) { QSharedPointer vItem(new VoucherItem); vItem->setName(item->name()); vItem->setUnitPrice(item->unitPrice()); vItem->setCount(count); vItem->setRefId(item->id()); vItem->setItemPlugin(item->pluginId()); vItem->setVatType(item->vatType()); voucher->addItem(vItem); } void ShopService::calculate(QSharedPointer voucher) { QDecDouble total; foreach (QSharedPointer item, voucher->items()) { calculateItem(item); total += item->price(); } voucher->setTotalPrice(total); } void ShopService::calculateItem(QSharedPointer item) { item->setPrice(item->unitPrice() * item->count()); }