diff --git a/shop/isellableservice.h b/shop/isellableservice.h index 8ce1372..41ba709 100644 --- a/shop/isellableservice.h +++ b/shop/isellableservice.h @@ -11,7 +11,8 @@ class SHOPSHARED_EXPORT ISellableService public: ISellableService(); - virtual QList > shopItems() = 0; + virtual QList shopItems() = 0; + //virtual void addToReceipt() }; #endif // ISELLABLESERVICE_H diff --git a/shop/shopitem.h b/shop/shopitem.h index d23eac1..e9c9f26 100644 --- a/shop/shopitem.h +++ b/shop/shopitem.h @@ -30,4 +30,6 @@ public: virtual QString pluginId() override { return ""; } }; +typedef QSharedPointer ShopItemPtr; + #endif // SHOPITEM_H diff --git a/shop/shopservice.cpp b/shop/shopservice.cpp index 6220085..23833d7 100644 --- a/shop/shopservice.cpp +++ b/shop/shopservice.cpp @@ -7,14 +7,14 @@ ShopService::ShopService() { } -QSharedPointer ShopService::createVoucher() +VoucherPtr ShopService::createVoucher() { QSharedPointer voucher(new Voucher); voucher->setStatus(Voucher::NEW); return voucher; } -void ShopService::addShopItem(QSharedPointer voucher, QSharedPointer item, int count) +void ShopService::addShopItem(VoucherPtr voucher, QSharedPointer item, int count) { QSharedPointer vItem(new VoucherItem); vItem->setName(item->name()); @@ -27,7 +27,7 @@ void ShopService::addShopItem(QSharedPointer voucher, QSharedPointeraddItem(vItem); } -void ShopService::calculate(QSharedPointer voucher) +void ShopService::calculate(VoucherPtr voucher) { QDecDouble total; @@ -66,7 +66,7 @@ void ShopService::calculate(QSharedPointer voucher) voucher->setTotalPrice(total); } -void ShopService::calculateItem(QSharedPointer item) +void ShopService::calculateItem(VoucherItemPtr item) { loadSettings(); if (m_gs->vatPayer()) @@ -82,13 +82,13 @@ void ShopService::calculateItem(QSharedPointer item) } } -void ShopService::loadItems(QSharedPointer voucher) +void ShopService::loadItems(VoucherPtr voucher) { Service srv; voucher->setItems(srv.all(QString("voucher = %1").arg(voucher->id()))); } -void ShopService::pay(QSharedPointer voucher) +void ShopService::pay(VoucherPtr voucher) { Transaction tx; NumberSeriesService srvNs; @@ -106,22 +106,22 @@ void ShopService::pay(QSharedPointer voucher) tx.commit(); } -QList > ShopService::savedVouchers() +QList ShopService::savedVouchers() { return all(QString("status = %1").arg(QString::number(Voucher::NOT_PAID))); } -QList > ShopService::tempVouchers() +QList ShopService::tempVouchers() { return all(QString("status = %1").arg(QString::number(Voucher::TEMPORARY))); } -QList > ShopService::paiedVouchers() +QList ShopService::paiedVouchers() { return all(QString("status = %1").arg(QString::number(Voucher::PAID))); } -QList > ShopService::allSellableItems() +QList ShopService::allSellableItems() { QList > items; foreach (IPlugin *plugin, Context::instance().plugins()) { @@ -176,7 +176,7 @@ QDecDouble ShopService::vatRate(Enums::VatType vatType) return vatRate; } -void ShopService::saveVoucher(QSharedPointer entity) +void ShopService::saveVoucher(VoucherPtr entity) { Transaction tr; odb::database *db = Context::instance().db(); @@ -191,7 +191,7 @@ void ShopService::saveVoucher(QSharedPointer entity) tr.commit(); } -void ShopService::updateVoucher(QSharedPointer entity) +void ShopService::updateVoucher(VoucherPtr entity) { Transaction tr; odb::database *db = Context::instance().db(); diff --git a/shop/shopservice.h b/shop/shopservice.h index 87eae88..2b1ef82 100644 --- a/shop/shopservice.h +++ b/shop/shopservice.h @@ -13,16 +13,16 @@ class ShopService : public Service { public: ShopService(); - QSharedPointer createVoucher(); - void addShopItem(QSharedPointer voucher, QSharedPointer item, int count); - void calculate(QSharedPointer voucher); - void calculateItem(QSharedPointer item); - void loadItems(QSharedPointer voucher); - void pay(QSharedPointer voucher); - QList > savedVouchers(); - QList > tempVouchers(); - QList > paiedVouchers(); - QList > allSellableItems(); + VoucherPtr createVoucher(); + void addShopItem(VoucherPtr voucher, QSharedPointer item, int count); + void calculate(VoucherPtr voucher); + void calculateItem(VoucherItemPtr item); + void loadItems(VoucherPtr voucher); + void pay(VoucherPtr voucher); + QList savedVouchers(); + QList tempVouchers(); + QList paiedVouchers(); + QList allSellableItems(); private: QDecDouble includeVat(QDecDouble price, Enums::VatType vatType); @@ -32,8 +32,8 @@ private: QDecDouble vatRate(Enums::VatType vatType); public: - void saveVoucher(QSharedPointer entity); - void updateVoucher(QSharedPointer entity); + void saveVoucher(VoucherPtr entity); + void updateVoucher(VoucherPtr entity); }; #endif // SHOPSERVICE_H