diff --git a/shop/data/voucher.cpp b/shop/data/voucher.cpp index 807895b..7de2e73 100644 --- a/shop/data/voucher.cpp +++ b/shop/data/voucher.cpp @@ -421,3 +421,13 @@ QDecDouble VoucherSum::totalPrice() const int VoucherSum::count() const { return m_count; } + +VoucherSum::VoucherSum(int count, int totalPrice) : m_count(count), m_totalPrice(totalPrice) {} + +void VoucherSum::addPrice(QDecDouble price) { + m_totalPrice += FROM_DEC(price); +} + +void VoucherSum::addCount(int count) { + m_count += count; +} diff --git a/shop/data/voucher.h b/shop/data/voucher.h index 5794266..240d34c 100644 --- a/shop/data/voucher.h +++ b/shop/data/voucher.h @@ -210,9 +210,13 @@ class VoucherSum QX_REGISTER_FRIEND_CLASS(VoucherSum) public: VoucherSum() = default; + VoucherSum(int count, int totalPrice); QDecDouble totalPrice() const; int count() const; + + void addPrice(QDecDouble price); + void addCount(int count); private: int m_count{0}; diff --git a/shop/paydvouchersdialog.cpp b/shop/paydvouchersdialog.cpp index 6e65f3f..862b5df 100644 --- a/shop/paydvouchersdialog.cpp +++ b/shop/paydvouchersdialog.cpp @@ -47,12 +47,20 @@ PaydVouchersDialog::PaydVouchersDialog(QWidget *parent) : ui->tableItems->setColumnHidden(0, true); ui->tableItems->verticalScrollBar()->setStyleSheet("QScrollBar:vertical { width: 30px; }"); +#ifndef EET + ui->btnEetNotSen->setVisible(false); + ui->btnSendEet->setVisible(false); + ui->label_2->setVisible(false); + ui->lblEetStatus->setVisible(false); +#endif + ShopService srv; m_voucherModel->setData(srv.paiedVouchers()); ui->tableVouchers->sortByColumn(0,Qt::AscendingOrder); ui->tableVouchers->verticalScrollBar()->setStyleSheet("QScrollBar:vertical { width: 30px; }"); - connect(ui->tableVouchers->selectionModel(), &QItemSelectionModel::currentRowChanged, [this, &srv](const QModelIndex ¤t, const QModelIndex &) { + connect(ui->tableVouchers->selectionModel(), &QItemSelectionModel::currentRowChanged, [this](const QModelIndex ¤t, const QModelIndex &) { + ShopService srv; QSharedPointer voucher = m_voucherModel->itemFromIndex(current); if (voucher->items().isEmpty()) { srv.load(voucher); diff --git a/shop/settings/shopsettingsform.cpp b/shop/settings/shopsettingsform.cpp index c270aa2..cf9bc79 100644 --- a/shop/settings/shopsettingsform.cpp +++ b/shop/settings/shopsettingsform.cpp @@ -16,6 +16,7 @@ ShopSettingsForm::ShopSettingsForm(QWidget *parent) : registerBinding(ui->lettersPerLine); registerBinding(ui->byMessage); +#ifdef EET registerBinding(ui->eetActive); registerBinding(ui->eetShopId); registerBinding(ui->eetRegisterId); @@ -26,6 +27,9 @@ ShopSettingsForm::ShopSettingsForm(QWidget *parent) : registerBinding(ui->eetKeyPassword); registerBinding(ui->eetTest); registerBinding(ui->eetPlayground); +#else + ui->tabWidget->removeTab(2); +#endif registerBinding(ui->favBtnCols); registerBinding(ui->favBtnRows); diff --git a/shop/shopoverview.cpp b/shop/shopoverview.cpp index f980bef..0342f6e 100644 --- a/shop/shopoverview.cpp +++ b/shop/shopoverview.cpp @@ -7,6 +7,11 @@ ShopOverview::ShopOverview(QWidget *parent) : ui(new Ui::ShopOverview) { ui->setupUi(this); + +#ifndef EET + ui->labelUnsendEET->setVisible(false); + ui->label_6->setVisible(false); +#endif } ShopOverview::~ShopOverview() @@ -19,9 +24,16 @@ void ShopOverview::refresh() ShopService srv; VoucherSum unpaid = srv.unpaidSummary(); - VoucherSum unsend = srv.unsendEET(); ui->labelUnapiedCount->setText(QString::number(unpaid.count())); ui->labelUnpaiedAmount->setText(QString::number(unpaid.totalPrice().toDouble())); + + VoucherSum today = srv.salesSummary(QDate::currentDate()); + ui->labelSales->setText(QString::number(today.totalPrice().toDouble())); + ui->labelNumSales->setText(QString::number(today.count())); + +#ifdef EET + VoucherSum unsend = srv.unsendEET(); ui->labelUnsendEET->setText(QString::number(unsend.count())); +#endif } diff --git a/shop/shopoverview.ui b/shop/shopoverview.ui index f228cc6..8604080 100644 --- a/shop/shopoverview.ui +++ b/shop/shopoverview.ui @@ -7,7 +7,7 @@ 0 0 908 - 95 + 162 @@ -83,7 +83,6 @@ - 75 true @@ -102,7 +101,6 @@ - 75 true @@ -114,6 +112,52 @@ + + + + Today sales: + + + + + + + + 90 + 0 + + + + TextLabel + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Number of sales today: + + + + + + + + 90 + 0 + + + + TextLabel + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + diff --git a/shop/shopservice.cpp b/shop/shopservice.cpp index 7216bad..9e17a10 100644 --- a/shop/shopservice.cpp +++ b/shop/shopservice.cpp @@ -437,9 +437,7 @@ QList ShopService::allSellableItems(const QString& category/* = "" VoucherSum ShopService::unpaidSummary() { - VoucherSum sum; //= db->query_value("status = " + query::_ref((int)Voucher::NOT_PAID)); - - return sum; + return summary("status = " + QString::number(Voucher::NOT_PAID)); } VoucherSum ShopService::unsendEET() @@ -551,3 +549,18 @@ void ShopService::update(VoucherPtr entity, qx::QxSession* pSession) { } } +VoucherSum ShopService::salesSummary(QDate date) { + return summary("payDateTime >= '" + date.toString("yyyy-MM-dd") + "'"); +} + +VoucherSum ShopService::summary(const QString& where) { + auto sums = all(where); + VoucherSum sum(sums.count(), 0); + + for (const auto& item : sums) { + sum.addPrice(item->totalPrice()); + } + + return sum; +} + diff --git a/shop/shopservice.h b/shop/shopservice.h index a7b2a91..ed06003 100644 --- a/shop/shopservice.h +++ b/shop/shopservice.h @@ -44,12 +44,14 @@ public: QList allSellableItems(const QString& category = ""); QMap allCategories(); VoucherSum unpaidSummary(); + VoucherSum salesSummary(QDate date); VoucherSum unsendEET(); private: QDecDouble includeVat(QDecDouble price, Enums::VatType vatType); QDecDouble excludeVat(QDecDouble price, Enums::VatType vatType); void loadSettings(); + VoucherSum summary(const QString& where); QSharedPointer m_gs; QDecDouble vatRate(Enums::VatType vatType);