Implemented base functionality of DirectSaleForm.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user