From f9d7df9ab5b26ae70c62aaf72676f53a474b00af Mon Sep 17 00:00:00 2001 From: Josef Rokos Date: Wed, 6 Jul 2016 22:52:34 +0200 Subject: [PATCH] Merge fix --- shop/receiptgenerator.cpp | 25 ++++++++++++++++++------- shop/receiptsaveform.cpp | 6 ++++++ shop/shopform.cpp | 2 ++ 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/shop/receiptgenerator.cpp b/shop/receiptgenerator.cpp index e9c9e6e..4f513e1 100644 --- a/shop/receiptgenerator.cpp +++ b/shop/receiptgenerator.cpp @@ -60,6 +60,8 @@ QByteArray ReceiptGenerator::generate() { QByteArray out; + char printMode = 8 | 16 ; + SettingsService srvGsSettings("CORE"); SettingsService srvShopSettings("SHOP"); @@ -73,14 +75,17 @@ QByteArray ReceiptGenerator::generate() out.append("\x0a"); out.append(prepareString(gs->zipCode() + " " + gs->city())); out.append("\x0a"); - out.append(prepareString("IC: " + gs->ic())); + out.append(prepareString("IC: " + QString::number(gs->ic()))); out.append("\x0a"); - out.append("\x1b\x61\0"); + out.append("\x1b\x21"); + out.append(printMode); for (int i = 0; i < shopSettings->lettersPerLine(); i++ ) { - out.append("_"); + out.append("-"); } + out.append("\x1b\x21"); + out.append((char)0); out.append("\x0a"); foreach (QSharedPointer item, m_voucher->items()) { @@ -108,26 +113,32 @@ QByteArray ReceiptGenerator::generate() out.append("\x0a"); } + out.append("\x1b\x21"); + out.append(printMode); for (int i = 0; i < shopSettings->lettersPerLine(); i++ ) { - out.append("_"); + out.append("-"); } + out.append("\x1b\x21"); + out.append((char)0); out.append("\x0a"); - char printMode = 8 | 16 ; out.append("\x1b\x21"); out.append(printMode); out.append("Celekem:"); QString totalPrice = QString::number(m_voucher->totalPrice().toDouble(), 'f', 2); - int numSpaces = shopSettings->lettersPerLine() - (8 * 2 + totalPrice.length() * 2); + int numSpaces = shopSettings->lettersPerLine() - (8 + totalPrice.length()); for (int i = 0; i < numSpaces; i++) { out.append(" "); } out.append(prepareString(totalPrice)); - out.append("\x1b\x21\0"); + out.append("\x1b\x21"); + out.append((char)0); + out.append("\x0a"); + out.append("\x0a"); out.append("\x0a"); out.append("\x0a"); out.append("\x0a"); diff --git a/shop/receiptsaveform.cpp b/shop/receiptsaveform.cpp index 7cd16cf..8106eb4 100644 --- a/shop/receiptsaveform.cpp +++ b/shop/receiptsaveform.cpp @@ -100,3 +100,9 @@ void ReceiptSaveForm::on_radioAdd_toggled(bool checked) ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!ui->name->text().isEmpty()); } } + +void ReceiptSaveForm::accept() +{ + m_binder.bindToData(); + QDialog::accept(); +} diff --git a/shop/shopform.cpp b/shop/shopform.cpp index 48a6f97..0819eee 100644 --- a/shop/shopform.cpp +++ b/shop/shopform.cpp @@ -106,6 +106,8 @@ void ShopForm::on_saveButton_clicked() connect(form, &QDialog::accepted, [this]() { ShopService srv; + m_voucher->setStatus(Voucher::NOT_PAID); + srv.saveVoucher(m_voucher); m_voucher = srv.createVoucher(); m_itemsModel->setData(m_voucher->items()); ui->total->setText("0");