Added sell commodity feature.

This commit is contained in:
2016-07-21 16:24:07 +02:00
parent fb6b4fe027
commit 44c74a5cfe
13 changed files with 122 additions and 19 deletions
+14
View File
@@ -25,6 +25,8 @@ void ShopService::addShopItem(QSharedPointer<Voucher> voucher, QSharedPointer<IS
vItem->setVatType(item->vatType());
voucher->addItem(vItem);
updateRelatedItem(vItem.data(), count);
}
void ShopService::calculate(QSharedPointer<Voucher> voucher)
@@ -106,6 +108,18 @@ void ShopService::pay(QSharedPointer<Voucher> voucher)
tx.commit();
}
void ShopService::updateRelatedItem(VoucherItem* item, int countAdded)
{
IPlugin *plugin = Context::instance().plugin(item->itemPlugin());
IService *srv = (plugin != NULL ? plugin->service<IService>() : NULL);
ISellableService *selSrv = dynamic_cast<ISellableService*>(srv);
if (selSrv != NULL)
{
selSrv->addedToVoucher(item->refId(), countAdded);
}
}
QList<QSharedPointer<Voucher> > ShopService::savedVouchers()
{
return all(QString("status = %1").arg(QString::number(Voucher::NOT_PAID)));