diff --git a/shop/data/voucher.cpp b/shop/data/voucher.cpp index 99cf029..4a8f5be 100644 --- a/shop/data/voucher.cpp +++ b/shop/data/voucher.cpp @@ -281,6 +281,16 @@ void Voucher::setEetFik(const QString &eetFik) m_eetFik = eetFik; } +QDateTime Voucher::saveDateTime() const +{ + return m_saveDateTime; +} + +void Voucher::setSaveDateTime(const QDateTime &saveDateTime) +{ + m_saveDateTime = saveDateTime; +} + int Voucher::id() const { return m_id; diff --git a/shop/data/voucher.h b/shop/data/voucher.h index 3ad0385..70ee1a0 100644 --- a/shop/data/voucher.h +++ b/shop/data/voucher.h @@ -18,6 +18,7 @@ class Voucher : public QObject Q_PROPERTY(QString numSer READ numSer WRITE setNumSer) Q_PROPERTY(QDateTime payDateTime READ payDateTime WRITE setPayDateTime) + Q_PROPERTY(QDateTime saveDateTime READ saveDateTime WRITE setSaveDateTime) Q_PROPERTY(QString name READ name WRITE setName) Q_PROPERTY(QString description READ description WRITE setDescription) Q_PROPERTY(QSharedPointer contact READ contact WRITE setContact) @@ -139,12 +140,16 @@ public: QString eetFik() const; void setEetFik(const QString &eetFik); + QDateTime saveDateTime() const; + void setSaveDateTime(const QDateTime &saveDateTime); + private: friend class odb::access; #pragma db id auto int m_id; QString m_numSer; QDateTime m_payDateTime; + QDateTime m_saveDateTime; QString m_name; QString m_description; QSharedPointer m_contact; diff --git a/shop/data/voucheritem.cpp b/shop/data/voucheritem.cpp index cd7132f..51a3f72 100644 --- a/shop/data/voucheritem.cpp +++ b/shop/data/voucheritem.cpp @@ -127,4 +127,14 @@ void VoucherItem::setVoucher(const QWeakPointer &voucher) m_voucher = voucher; } +QDateTime VoucherItem::insertDate() const +{ + return m_insertDate; +} + +void VoucherItem::setInsertDate(const QDateTime &insertDate) +{ + m_insertDate = insertDate; +} + diff --git a/shop/data/voucheritem.h b/shop/data/voucheritem.h index d41e77f..4510fe1 100644 --- a/shop/data/voucheritem.h +++ b/shop/data/voucheritem.h @@ -6,6 +6,7 @@ #include #include #include +#include #include @@ -16,6 +17,7 @@ class VoucherItem : public QObject { Q_OBJECT + Q_PROPERTY(QDateTime insertDate READ insertDate WRITE setInsertDate) Q_PROPERTY(QString name READ name WRITE setName) Q_PROPERTY(int count READ count WRITE setCount NOTIFY countChanged) Q_PROPERTY(QDecDouble unitPrice READ unitPrice WRITE setUnitPrice) @@ -62,6 +64,9 @@ public: QWeakPointer voucher() const; void setVoucher(const QWeakPointer &voucher); + QDateTime insertDate() const; + void setInsertDate(const QDateTime &insertDate); + signals: void countChanged(int oldCount); @@ -76,6 +81,7 @@ private: int m_priceWitouthVat; int m_price; int m_refId; + QDateTime m_insertDate; QString m_itemPlugin; Enums::VatType m_vatType; #pragma db not_null diff --git a/shop/paydvouchersdialog.cpp b/shop/paydvouchersdialog.cpp index b4ee136..dee6199 100644 --- a/shop/paydvouchersdialog.cpp +++ b/shop/paydvouchersdialog.cpp @@ -21,23 +21,25 @@ PaydVouchersDialog::PaydVouchersDialog(QWidget *parent) : ui->tableVouchers->setModel(m_voucherModel); ui->tableItems->setModel(m_itemModel); - ui->tableVouchers->setColumnHidden(5, true); + ui->tableVouchers->setColumnHidden(2, true); ui->tableVouchers->setColumnHidden(6, true); ui->tableVouchers->setColumnHidden(7, true); ui->tableVouchers->setColumnHidden(8, true); ui->tableVouchers->setColumnHidden(9, true); ui->tableVouchers->setColumnHidden(10, true); - ui->tableVouchers->setColumnHidden(12, true); + ui->tableVouchers->setColumnHidden(11, true); ui->tableVouchers->setColumnHidden(13, true); ui->tableVouchers->setColumnHidden(14, true); ui->tableVouchers->setColumnHidden(15, true); ui->tableVouchers->setColumnHidden(16, true); ui->tableVouchers->setColumnHidden(17, true); - ui->tableVouchers->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Stretch); + ui->tableVouchers->setColumnHidden(18, true); ui->tableVouchers->horizontalHeader()->setSectionResizeMode(3, QHeaderView::Stretch); ui->tableVouchers->horizontalHeader()->setSectionResizeMode(4, QHeaderView::Stretch); + ui->tableVouchers->horizontalHeader()->setSectionResizeMode(5, QHeaderView::Stretch); - ui->tableItems->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch); + ui->tableItems->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch); + ui->tableItems->setColumnHidden(0, true); ShopService srv; m_voucherModel->setData(srv.paiedVouchers()); diff --git a/shop/paydvouchersdialog.ui b/shop/paydvouchersdialog.ui index feeb4dd..44186d9 100644 --- a/shop/paydvouchersdialog.ui +++ b/shop/paydvouchersdialog.ui @@ -6,8 +6,8 @@ 0 0 - 900 - 650 + 1000 + 700 @@ -249,8 +249,8 @@ - + diff --git a/shop/receiptloadform.cpp b/shop/receiptloadform.cpp index f00c506..dc26833 100644 --- a/shop/receiptloadform.cpp +++ b/shop/receiptloadform.cpp @@ -16,23 +16,29 @@ ReceiptLoadForm::ReceiptLoadForm(QWidget *parent) : m_voucherModel->setData(srv.all(QString("status = %1").arg(QString::number(Voucher::NOT_PAID)))); m_voucherModel->setTranslations(Context::instance().plugin("SHOP")->translations()); ui->tabVouchers->setModel(m_voucherModel); - ui->tabVouchers->hideColumn(0); - ui->tabVouchers->hideColumn(1); - ui->tabVouchers->hideColumn(5); - ui->tabVouchers->hideColumn(6); - ui->tabVouchers->hideColumn(7); - ui->tabVouchers->hideColumn(8); - ui->tabVouchers->hideColumn(9); - ui->tabVouchers->hideColumn(10); - ui->tabVouchers->hideColumn(12); - ui->tabVouchers->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Stretch); - ui->tabVouchers->setColumnWidth(3, 200); - ui->tabVouchers->setColumnWidth(4, 200); + ui->tabVouchers->setColumnHidden(0, true); + ui->tabVouchers->setColumnHidden(1, true); + ui->tabVouchers->setColumnHidden(6, true); + ui->tabVouchers->setColumnHidden(7, true); + ui->tabVouchers->setColumnHidden(8, true); + ui->tabVouchers->setColumnHidden(9, true); + ui->tabVouchers->setColumnHidden(10, true); + ui->tabVouchers->setColumnHidden(11, true); + ui->tabVouchers->setColumnHidden(13, true); + ui->tabVouchers->setColumnHidden(14, true); + ui->tabVouchers->setColumnHidden(15, true); + ui->tabVouchers->setColumnHidden(16, true); + ui->tabVouchers->setColumnHidden(17, true); + ui->tabVouchers->setColumnHidden(18, true); + ui->tabVouchers->horizontalHeader()->setSectionResizeMode(3, QHeaderView::Stretch); + ui->tabVouchers->horizontalHeader()->setSectionResizeMode(4, QHeaderView::Stretch); + ui->tabVouchers->horizontalHeader()->setSectionResizeMode(5, QHeaderView::Stretch); m_itemModel = new AutoTableModel(this); + m_itemModel->setTranslations(Context::instance().plugin("SHOP")->translations()); m_itemModel->setCheckboxSelect(true); ui->tabItems->setModel(m_itemModel); - ui->tabItems->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch); + ui->tabItems->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch); connect(ui->tabVouchers->selectionModel(), &QItemSelectionModel::currentRowChanged, [this](const QModelIndex ¤t, QModelIndex){ ShopService srv; diff --git a/shop/receiptloadform.ui b/shop/receiptloadform.ui index 792874f..697bec1 100644 --- a/shop/receiptloadform.ui +++ b/shop/receiptloadform.ui @@ -6,8 +6,8 @@ 0 0 - 804 - 500 + 1000 + 700 diff --git a/shop/receiptsaveform.cpp b/shop/receiptsaveform.cpp index a2dc864..028ce51 100644 --- a/shop/receiptsaveform.cpp +++ b/shop/receiptsaveform.cpp @@ -26,16 +26,23 @@ ReceiptSaveForm::ReceiptSaveForm(QSharedPointer voucher, QWidget *paren m_voucherModel->setData(srv.all(QString("status = %1").arg(QString::number(Voucher::NOT_PAID)))); m_voucherModel->setTranslations(Context::instance().plugin("SHOP")->translations()); ui->tabVouchers->setModel(m_voucherModel); - ui->tabVouchers->hideColumn(3); - ui->tabVouchers->hideColumn(4); - ui->tabVouchers->hideColumn(5); - ui->tabVouchers->hideColumn(6); - ui->tabVouchers->hideColumn(7); - ui->tabVouchers->hideColumn(8); - ui->tabVouchers->hideColumn(10); - ui->tabVouchers->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch); - ui->tabVouchers->setColumnWidth(0, 190); - ui->tabVouchers->setColumnWidth(2, 200); + ui->tabVouchers->setColumnHidden(0, true); + ui->tabVouchers->setColumnHidden(1, true); + ui->tabVouchers->setColumnHidden(6, true); + ui->tabVouchers->setColumnHidden(7, true); + ui->tabVouchers->setColumnHidden(8, true); + ui->tabVouchers->setColumnHidden(9, true); + ui->tabVouchers->setColumnHidden(10, true); + ui->tabVouchers->setColumnHidden(11, true); + ui->tabVouchers->setColumnHidden(13, true); + ui->tabVouchers->setColumnHidden(14, true); + ui->tabVouchers->setColumnHidden(15, true); + ui->tabVouchers->setColumnHidden(16, true); + ui->tabVouchers->setColumnHidden(17, true); + ui->tabVouchers->setColumnHidden(18, true); + ui->tabVouchers->horizontalHeader()->setSectionResizeMode(3, QHeaderView::Stretch); + ui->tabVouchers->horizontalHeader()->setSectionResizeMode(4, QHeaderView::Stretch); + ui->tabVouchers->horizontalHeader()->setSectionResizeMode(5, QHeaderView::Stretch); connect(ui->tabVouchers->selectionModel(), &QItemSelectionModel::currentRowChanged, [this](QModelIndex, QModelIndex){ ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true); diff --git a/shop/receiptsaveform.ui b/shop/receiptsaveform.ui index 58bc2f6..525e4a6 100644 --- a/shop/receiptsaveform.ui +++ b/shop/receiptsaveform.ui @@ -6,8 +6,8 @@ 0 0 - 804 - 578 + 1000 + 700 diff --git a/shop/shop.json b/shop/shop.json index 8b9be10..6fd5750 100644 --- a/shop/shop.json +++ b/shop/shop.json @@ -8,7 +8,7 @@ "default" : "", "CZ" : "" }, - "schemaVersion" : 1, + "schemaVersion" : 3, "sql" : [ "CREATE TABLE \"VoucherItem\" ( \"id\" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, @@ -56,6 +56,10 @@ CREATE TABLE \"Voucher\" ( FOREIGN KEY (\"contact\") REFERENCES \"AddressbookData\" (\"id\") DEFERRABLE INITIALLY DEFERRED); +", + "ALTER TABLE \"VoucherItem\" ADD \"insertDate\" TEXT NULL; +", + "ALTER TABLE \"Voucher\" ADD \"saveDateTime\" TEXT NULL; " ], "dependencies" : [ "ADDRESSBOOK" ], @@ -86,7 +90,9 @@ CREATE TABLE \"Voucher\" ( "totalPrice" : "Celková cena", "status" : "Stav", "numSer" : "Číslo", - "payDateTime" : "Datum" + "payDateTime" : "Datum zaplacení", + "saveDateTime" : "Datum uložení", + "insertDate" : "Datum vložení" } } } diff --git a/shop/shopform.cpp b/shop/shopform.cpp index 7861b76..b4e7385 100644 --- a/shop/shopform.cpp +++ b/shop/shopform.cpp @@ -39,10 +39,11 @@ void ShopForm::loadLast() if (m_itemsModel == NULL) { m_itemsModel = new AutoTableModel(this); - m_itemsModel->setEditableCols(QList() << 1); + m_itemsModel->setEditableCols(QList() << 2); m_itemsModel->setTranslations(Context::instance().plugin("SHOP")->translations()); ui->actualReceipt->setModel(m_itemsModel); - ui->actualReceipt->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch); + ui->actualReceipt->setColumnHidden(0, true); + ui->actualReceipt->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch); } ShopService srv; @@ -140,6 +141,7 @@ void ShopForm::on_saveButton_clicked() if (form->saveAsNew()) { m_voucher->setStatus(Voucher::NOT_PAID); + m_voucher->setSaveDateTime(QDateTime::currentDateTime()); srv.updateVoucher(m_voucher); createEmptyVoucher(); } @@ -164,6 +166,11 @@ void ShopForm::on_loadButton_clicked() form->setAttribute(Qt::WA_DeleteOnClose); connect(form, &QDialog::accepted, [this, form](){ + if (form->selectedItems().isEmpty()) + { + return; + } + ShopService srv; if (m_voucher.isNull()) @@ -172,6 +179,9 @@ void ShopForm::on_loadButton_clicked() } srv.moveItems(form->selectedItems(), form->selectedVoucher(), this->m_voucher); + m_voucher->setDescription(form->selectedVoucher()->description()); + m_voucher->setName(form->selectedVoucher()->name()); + m_voucher->setContact(form->selectedVoucher()->contact()); m_itemsModel->setData(m_voucher->items()); diff --git a/shop/shopservice.cpp b/shop/shopservice.cpp index 53b4730..b528ae4 100644 --- a/shop/shopservice.cpp +++ b/shop/shopservice.cpp @@ -28,6 +28,7 @@ void ShopService::addShopItem(VoucherPtr voucher, QSharedPointer item vItem->setRefId(item->id()); vItem->setItemPlugin(item->pluginId()); vItem->setVatType(item->vatType()); + vItem->setInsertDate(QDateTime::currentDateTime()); voucher->addItem(vItem);