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
This commit is contained in:
+12
-2
@@ -39,10 +39,11 @@ void ShopForm::loadLast()
|
||||
if (m_itemsModel == NULL)
|
||||
{
|
||||
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());
|
||||
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());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user