|
|
|
#ifndef SHOPSERVICE_H
|
|
|
|
#define SHOPSERVICE_H
|
|
|
|
|
|
|
|
#include <QSharedPointer>
|
|
|
|
|
|
|
|
#include <core.h>
|
|
|
|
#include <settings/globalsettings.h>
|
|
|
|
|
|
|
|
#include "data/shop-data.h"
|
|
|
|
#include "shopitem.h"
|
|
|
|
|
|
|
|
#include "shop_global.h"
|
|
|
|
|
|
|
|
#define ROUNDING_ITEM -9999
|
|
|
|
|
|
|
|
class PayDialog;
|
|
|
|
class ShopForm;
|
|
|
|
|
|
|
|
void SHOPSHARED_EXPORT payVoucherFromUI(const VoucherPtr& voucher, PayDialog *dialog, ShopForm *form = nullptr);
|
|
|
|
|
|
|
|
class SHOPSHARED_EXPORT ShopService : public Service<Voucher>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ShopService() = default;
|
|
|
|
VoucherPtr createVoucher();
|
|
|
|
void addShopItem(VoucherPtr voucher, QSharedPointer<IShopItem> item, int count);
|
|
|
|
void calculate(VoucherPtr voucher);
|
|
|
|
void calculateItem(VoucherItemPtr item);
|
|
|
|
void pay(VoucherPtr voucher);
|
|
|
|
void saveVoucher(VoucherPtr entity, qx::QxSession* pSession = nullptr);
|
|
|
|
void moveItems(QList<VoucherItemPtr> items, VoucherPtr source, VoucherPtr target);
|
|
|
|
void updateRelatedItem(VoucherItem* item, int countAdded);
|
|
|
|
bool processEet(VoucherPtr voucher, QString &message);
|
|
|
|
void setEetOnline(bool online);
|
|
|
|
bool isEetOnline();
|
|
|
|
bool isEetEnabled();
|
|
|
|
void roundVoucher(VoucherPtr voucher);
|
|
|
|
VoucherItemPtr roundingItem(VoucherPtr voucher);
|
|
|
|
QList<VoucherPtr> savedVouchers();
|
|
|
|
QList<VoucherPtr> tempVouchers();
|
|
|
|
QList<VoucherPtr> paiedVouchers();
|
|
|
|
QList<VoucherPtr> vouchersForEet();
|
|
|
|
QList<IShopItemPtr> allSellableItems();
|
|
|
|
VoucherSum unpaidSummary();
|
|
|
|
VoucherSum unsendEET();
|
|
|
|
|
|
|
|
private:
|
|
|
|
QDecDouble includeVat(QDecDouble price, Enums::VatType vatType);
|
|
|
|
QDecDouble excludeVat(QDecDouble price, Enums::VatType vatType);
|
|
|
|
void loadSettings();
|
|
|
|
|
|
|
|
QSharedPointer<GlobalSettings> m_gs;
|
|
|
|
QDecDouble vatRate(Enums::VatType vatType);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SHOPSERVICE_H
|