Implemented base functionality of DirectSaleForm.

This commit is contained in:
2016-04-13 22:37:41 +02:00
parent 049314a245
commit 2ed7d7077b
15 changed files with 206 additions and 14 deletions
+31
View File
@@ -4,3 +4,34 @@ ShopService::ShopService()
{
}
QSharedPointer<Voucher> ShopService::createVoucher()
{
QSharedPointer<Voucher> voucher(new Voucher);
voucher->setStatus(Voucher::NEW);
return voucher;
}
void ShopService::addShopItem(QSharedPointer<Voucher> voucher, QSharedPointer<IShopItem> item, int count)
{
QSharedPointer<VoucherItem> vItem(new VoucherItem);
vItem->setName(item->name());
vItem->setUnitPrice(item->unitPrice());
vItem->setCount(count);
vItem->setRefId(item->id());
vItem->setItemPlugin(item->pluginId());
voucher->addItem(vItem);
}
void ShopService::calculate(QSharedPointer<Voucher> voucher)
{
QDecDouble total;
foreach (QSharedPointer<VoucherItem> item, voucher->items()) {
QDecDouble itemPrice = item->unitPrice() * item->count();
total += itemPrice;
}
voucher->setTotalPrice(total);
}