Added insert date to voucher items and save date to vouchers. Additional voucher descriptions (name, contact...) are now copied from saved vouchers when load items.

closes #286
print
Josef Rokos 8 years ago
parent d4b5ca681c
commit c6e4e5818a

@ -281,6 +281,16 @@ void Voucher::setEetFik(const QString &eetFik)
m_eetFik = eetFik; m_eetFik = eetFik;
} }
QDateTime Voucher::saveDateTime() const
{
return m_saveDateTime;
}
void Voucher::setSaveDateTime(const QDateTime &saveDateTime)
{
m_saveDateTime = saveDateTime;
}
int Voucher::id() const int Voucher::id() const
{ {
return m_id; return m_id;

@ -18,6 +18,7 @@ class Voucher : public QObject
Q_PROPERTY(QString numSer READ numSer WRITE setNumSer) Q_PROPERTY(QString numSer READ numSer WRITE setNumSer)
Q_PROPERTY(QDateTime payDateTime READ payDateTime WRITE setPayDateTime) 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 name READ name WRITE setName)
Q_PROPERTY(QString description READ description WRITE setDescription) Q_PROPERTY(QString description READ description WRITE setDescription)
Q_PROPERTY(QSharedPointer<QObject> contact READ contact WRITE setContact) Q_PROPERTY(QSharedPointer<QObject> contact READ contact WRITE setContact)
@ -139,12 +140,16 @@ public:
QString eetFik() const; QString eetFik() const;
void setEetFik(const QString &eetFik); void setEetFik(const QString &eetFik);
QDateTime saveDateTime() const;
void setSaveDateTime(const QDateTime &saveDateTime);
private: private:
friend class odb::access; friend class odb::access;
#pragma db id auto #pragma db id auto
int m_id; int m_id;
QString m_numSer; QString m_numSer;
QDateTime m_payDateTime; QDateTime m_payDateTime;
QDateTime m_saveDateTime;
QString m_name; QString m_name;
QString m_description; QString m_description;
QSharedPointer<AddressbookData> m_contact; QSharedPointer<AddressbookData> m_contact;

@ -127,4 +127,14 @@ void VoucherItem::setVoucher(const QWeakPointer<Voucher> &voucher)
m_voucher = voucher; m_voucher = voucher;
} }
QDateTime VoucherItem::insertDate() const
{
return m_insertDate;
}
void VoucherItem::setInsertDate(const QDateTime &insertDate)
{
m_insertDate = insertDate;
}

@ -6,6 +6,7 @@
#include <QDecDouble.hh> #include <QDecDouble.hh>
#include <odb/core.hxx> #include <odb/core.hxx>
#include <QSharedPointer> #include <QSharedPointer>
#include <QDateTime>
#include <enums.h> #include <enums.h>
@ -16,6 +17,7 @@ class VoucherItem : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(QDateTime insertDate READ insertDate WRITE setInsertDate)
Q_PROPERTY(QString name READ name WRITE setName) Q_PROPERTY(QString name READ name WRITE setName)
Q_PROPERTY(int count READ count WRITE setCount NOTIFY countChanged) Q_PROPERTY(int count READ count WRITE setCount NOTIFY countChanged)
Q_PROPERTY(QDecDouble unitPrice READ unitPrice WRITE setUnitPrice) Q_PROPERTY(QDecDouble unitPrice READ unitPrice WRITE setUnitPrice)
@ -62,6 +64,9 @@ public:
QWeakPointer<Voucher> voucher() const; QWeakPointer<Voucher> voucher() const;
void setVoucher(const QWeakPointer<Voucher> &voucher); void setVoucher(const QWeakPointer<Voucher> &voucher);
QDateTime insertDate() const;
void setInsertDate(const QDateTime &insertDate);
signals: signals:
void countChanged(int oldCount); void countChanged(int oldCount);
@ -76,6 +81,7 @@ private:
int m_priceWitouthVat; int m_priceWitouthVat;
int m_price; int m_price;
int m_refId; int m_refId;
QDateTime m_insertDate;
QString m_itemPlugin; QString m_itemPlugin;
Enums::VatType m_vatType; Enums::VatType m_vatType;
#pragma db not_null #pragma db not_null

@ -21,23 +21,25 @@ PaydVouchersDialog::PaydVouchersDialog(QWidget *parent) :
ui->tableVouchers->setModel(m_voucherModel); ui->tableVouchers->setModel(m_voucherModel);
ui->tableItems->setModel(m_itemModel); ui->tableItems->setModel(m_itemModel);
ui->tableVouchers->setColumnHidden(5, true); ui->tableVouchers->setColumnHidden(2, true);
ui->tableVouchers->setColumnHidden(6, true); ui->tableVouchers->setColumnHidden(6, true);
ui->tableVouchers->setColumnHidden(7, true); ui->tableVouchers->setColumnHidden(7, true);
ui->tableVouchers->setColumnHidden(8, true); ui->tableVouchers->setColumnHidden(8, true);
ui->tableVouchers->setColumnHidden(9, true); ui->tableVouchers->setColumnHidden(9, true);
ui->tableVouchers->setColumnHidden(10, true); ui->tableVouchers->setColumnHidden(10, true);
ui->tableVouchers->setColumnHidden(12, true); ui->tableVouchers->setColumnHidden(11, true);
ui->tableVouchers->setColumnHidden(13, true); ui->tableVouchers->setColumnHidden(13, true);
ui->tableVouchers->setColumnHidden(14, true); ui->tableVouchers->setColumnHidden(14, true);
ui->tableVouchers->setColumnHidden(15, true); ui->tableVouchers->setColumnHidden(15, true);
ui->tableVouchers->setColumnHidden(16, true); ui->tableVouchers->setColumnHidden(16, true);
ui->tableVouchers->setColumnHidden(17, 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(3, QHeaderView::Stretch);
ui->tableVouchers->horizontalHeader()->setSectionResizeMode(4, 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; ShopService srv;
m_voucherModel->setData(srv.paiedVouchers()); m_voucherModel->setData(srv.paiedVouchers());

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>900</width> <width>1000</width>
<height>650</height> <height>700</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -249,8 +249,8 @@
</layout> </layout>
</widget> </widget>
<resources> <resources>
<include location="shoprc.qrc"/>
<include location="../core/rc.qrc"/> <include location="../core/rc.qrc"/>
<include location="shoprc.qrc"/>
</resources> </resources>
<connections/> <connections/>
</ui> </ui>

@ -16,23 +16,29 @@ ReceiptLoadForm::ReceiptLoadForm(QWidget *parent) :
m_voucherModel->setData(srv.all(QString("status = %1").arg(QString::number(Voucher::NOT_PAID)))); m_voucherModel->setData(srv.all(QString("status = %1").arg(QString::number(Voucher::NOT_PAID))));
m_voucherModel->setTranslations(Context::instance().plugin("SHOP")->translations()); m_voucherModel->setTranslations(Context::instance().plugin("SHOP")->translations());
ui->tabVouchers->setModel(m_voucherModel); ui->tabVouchers->setModel(m_voucherModel);
ui->tabVouchers->hideColumn(0); ui->tabVouchers->setColumnHidden(0, true);
ui->tabVouchers->hideColumn(1); ui->tabVouchers->setColumnHidden(1, true);
ui->tabVouchers->hideColumn(5); ui->tabVouchers->setColumnHidden(6, true);
ui->tabVouchers->hideColumn(6); ui->tabVouchers->setColumnHidden(7, true);
ui->tabVouchers->hideColumn(7); ui->tabVouchers->setColumnHidden(8, true);
ui->tabVouchers->hideColumn(8); ui->tabVouchers->setColumnHidden(9, true);
ui->tabVouchers->hideColumn(9); ui->tabVouchers->setColumnHidden(10, true);
ui->tabVouchers->hideColumn(10); ui->tabVouchers->setColumnHidden(11, true);
ui->tabVouchers->hideColumn(12); ui->tabVouchers->setColumnHidden(13, true);
ui->tabVouchers->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Stretch); ui->tabVouchers->setColumnHidden(14, true);
ui->tabVouchers->setColumnWidth(3, 200); ui->tabVouchers->setColumnHidden(15, true);
ui->tabVouchers->setColumnWidth(4, 200); 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<VoucherItem>(this); m_itemModel = new AutoTableModel<VoucherItem>(this);
m_itemModel->setTranslations(Context::instance().plugin("SHOP")->translations());
m_itemModel->setCheckboxSelect(true); m_itemModel->setCheckboxSelect(true);
ui->tabItems->setModel(m_itemModel); 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 &current, QModelIndex){ connect(ui->tabVouchers->selectionModel(), &QItemSelectionModel::currentRowChanged, [this](const QModelIndex &current, QModelIndex){
ShopService srv; ShopService srv;

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>804</width> <width>1000</width>
<height>500</height> <height>700</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">

@ -26,16 +26,23 @@ ReceiptSaveForm::ReceiptSaveForm(QSharedPointer<Voucher> voucher, QWidget *paren
m_voucherModel->setData(srv.all(QString("status = %1").arg(QString::number(Voucher::NOT_PAID)))); m_voucherModel->setData(srv.all(QString("status = %1").arg(QString::number(Voucher::NOT_PAID))));
m_voucherModel->setTranslations(Context::instance().plugin("SHOP")->translations()); m_voucherModel->setTranslations(Context::instance().plugin("SHOP")->translations());
ui->tabVouchers->setModel(m_voucherModel); ui->tabVouchers->setModel(m_voucherModel);
ui->tabVouchers->hideColumn(3); ui->tabVouchers->setColumnHidden(0, true);
ui->tabVouchers->hideColumn(4); ui->tabVouchers->setColumnHidden(1, true);
ui->tabVouchers->hideColumn(5); ui->tabVouchers->setColumnHidden(6, true);
ui->tabVouchers->hideColumn(6); ui->tabVouchers->setColumnHidden(7, true);
ui->tabVouchers->hideColumn(7); ui->tabVouchers->setColumnHidden(8, true);
ui->tabVouchers->hideColumn(8); ui->tabVouchers->setColumnHidden(9, true);
ui->tabVouchers->hideColumn(10); ui->tabVouchers->setColumnHidden(10, true);
ui->tabVouchers->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch); ui->tabVouchers->setColumnHidden(11, true);
ui->tabVouchers->setColumnWidth(0, 190); ui->tabVouchers->setColumnHidden(13, true);
ui->tabVouchers->setColumnWidth(2, 200); 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){ connect(ui->tabVouchers->selectionModel(), &QItemSelectionModel::currentRowChanged, [this](QModelIndex, QModelIndex){
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true); ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>804</width> <width>1000</width>
<height>578</height> <height>700</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">

@ -8,7 +8,7 @@
"default" : "", "default" : "",
"CZ" : "" "CZ" : ""
}, },
"schemaVersion" : 1, "schemaVersion" : 3,
"sql" : [ "sql" : [
"CREATE TABLE \"VoucherItem\" ( "CREATE TABLE \"VoucherItem\" (
\"id\" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, \"id\" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
@ -56,6 +56,10 @@ CREATE TABLE \"Voucher\" (
FOREIGN KEY (\"contact\") FOREIGN KEY (\"contact\")
REFERENCES \"AddressbookData\" (\"id\") REFERENCES \"AddressbookData\" (\"id\")
DEFERRABLE INITIALLY DEFERRED); DEFERRABLE INITIALLY DEFERRED);
",
"ALTER TABLE \"VoucherItem\" ADD \"insertDate\" TEXT NULL;
",
"ALTER TABLE \"Voucher\" ADD \"saveDateTime\" TEXT NULL;
" "
], ],
"dependencies" : [ "ADDRESSBOOK" ], "dependencies" : [ "ADDRESSBOOK" ],
@ -86,7 +90,9 @@ CREATE TABLE \"Voucher\" (
"totalPrice" : "Celková cena", "totalPrice" : "Celková cena",
"status" : "Stav", "status" : "Stav",
"numSer" : "Číslo", "numSer" : "Číslo",
"payDateTime" : "Datum" "payDateTime" : "Datum zaplacení",
"saveDateTime" : "Datum uložení",
"insertDate" : "Datum vložení"
} }
} }
} }

@ -39,10 +39,11 @@ void ShopForm::loadLast()
if (m_itemsModel == NULL) if (m_itemsModel == NULL)
{ {
m_itemsModel = new AutoTableModel<VoucherItem>(this); m_itemsModel = new AutoTableModel<VoucherItem>(this);
m_itemsModel->setEditableCols(QList<int>() << 1); m_itemsModel->setEditableCols(QList<int>() << 2);
m_itemsModel->setTranslations(Context::instance().plugin("SHOP")->translations()); m_itemsModel->setTranslations(Context::instance().plugin("SHOP")->translations());
ui->actualReceipt->setModel(m_itemsModel); 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; ShopService srv;
@ -140,6 +141,7 @@ void ShopForm::on_saveButton_clicked()
if (form->saveAsNew()) if (form->saveAsNew())
{ {
m_voucher->setStatus(Voucher::NOT_PAID); m_voucher->setStatus(Voucher::NOT_PAID);
m_voucher->setSaveDateTime(QDateTime::currentDateTime());
srv.updateVoucher(m_voucher); srv.updateVoucher(m_voucher);
createEmptyVoucher(); createEmptyVoucher();
} }
@ -164,6 +166,11 @@ void ShopForm::on_loadButton_clicked()
form->setAttribute(Qt::WA_DeleteOnClose); form->setAttribute(Qt::WA_DeleteOnClose);
connect(form, &QDialog::accepted, [this, form](){ connect(form, &QDialog::accepted, [this, form](){
if (form->selectedItems().isEmpty())
{
return;
}
ShopService srv; ShopService srv;
if (m_voucher.isNull()) if (m_voucher.isNull())
@ -172,6 +179,9 @@ void ShopForm::on_loadButton_clicked()
} }
srv.moveItems(form->selectedItems(), form->selectedVoucher(), this->m_voucher); 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()); m_itemsModel->setData(m_voucher->items());

@ -28,6 +28,7 @@ void ShopService::addShopItem(VoucherPtr voucher, QSharedPointer<IShopItem> item
vItem->setRefId(item->id()); vItem->setRefId(item->id());
vItem->setItemPlugin(item->pluginId()); vItem->setItemPlugin(item->pluginId());
vItem->setVatType(item->vatType()); vItem->setVatType(item->vatType());
vItem->setInsertDate(QDateTime::currentDateTime());
voucher->addItem(vItem); voucher->addItem(vItem);

Loading…
Cancel
Save