Added setting for bill double printing.

master
Josef Rokos 7 years ago
parent dd39ebb5cb
commit b113d5fca1

@ -114,207 +114,226 @@ QByteArray ReceiptGenerator::generate()
ShopSettingsPtr shopSettings = srvShopSettings.loadSettings<ShopSettings>(); ShopSettingsPtr shopSettings = srvShopSettings.loadSettings<ShopSettings>();
GlobalSettingsPtr gs = srvGsSettings.loadSettings<GlobalSettings>(); GlobalSettingsPtr gs = srvGsSettings.loadSettings<GlobalSettings>();
out.append("\x1b\x40\x1b\x61\x01"); bool hasDoubleItem = false;
out.append(prepareString(gs->firmName())); bool first = true;
out.append("\x0a");
out.append(prepareString(gs->street() + " " + gs->houseNumber()));
out.append("\x0a");
out.append(prepareString(gs->zipCode() + " " + gs->city()));
out.append("\x0a");
out.append(prepareString("IC: " + QString::number(gs->ic())));
out.append("\x0a");
out.append(prepareString("DIC: " + gs->dic()));
out.append("\x0a");
out.append(prepareString("ID provozovny: " + shopSettings->eetShopId()));
out.append("\x0a");
out.append(prepareString("ID pokladny: " + shopSettings->eetRegisterId()));
out.append("\x0a");
out.append(prepareString("Cislo uctenky: " + m_voucher->numSer()));
out.append("\x0a");
out.append("\x1b\x21");
out.append(printMode);
for (int i = 0; i < shopSettings->lettersPerLine(); i++ )
{
out.append("-");
}
out.append("\x1b\x21");
out.append((char)0);
out.append("\x0a");
foreach (QSharedPointer<VoucherItem> item, m_voucher->items()) { do
QString count = QString::number(item->count()); {
QString name = item->name(); out.append("\x1b\x40\x1b\x61\x01");
QString price = QString::number(item->price().toDouble(), 'f', 2); out.append(prepareString(gs->firmName()));
out.append("\x0a");
int numSpaces = 0; out.append(prepareString(gs->street() + " " + gs->houseNumber()));
name = count + "x " + name; out.append("\x0a");
out.append(prepareString(gs->zipCode() + " " + gs->city()));
out.append("\x0a");
out.append(prepareString("IC: " + QString::number(gs->ic())));
out.append("\x0a");
out.append(prepareString("DIC: " + gs->dic()));
out.append("\x0a");
out.append(prepareString("ID provozovny: " + shopSettings->eetShopId()));
out.append("\x0a");
out.append(prepareString("ID pokladny: " + shopSettings->eetRegisterId()));
out.append("\x0a");
out.append(prepareString("Cislo uctenky: " + m_voucher->numSer()));
out.append("\x0a");
if (gs->vatPayer()) out.append("\x1b\x21");
out.append(printMode);
for (int i = 0; i < shopSettings->lettersPerLine(); i++ )
{ {
out.append(prepareString("DPH " + QString::number(item->vatRate().toDouble(), 'f', 0)) + "%"); out.append("-");
out.append("\x0a");
} }
out.append("\x1b\x21");
out.append((char)0);
out.append("\x0a");
if ((name.length() + price.length()) < shopSettings->lettersPerLine()) foreach (QSharedPointer<VoucherItem> item, m_voucher->items()) {
{ QString count = QString::number(item->count());
numSpaces = shopSettings->lettersPerLine() - (name.length() + price.length()); QString name = item->name();
out.append(prepareString(name)); QString price = QString::number(item->price().toDouble(), 'f', 2);
}
else
{
numSpaces = shopSettings->lettersPerLine() - (name.length() + price.length());
out.append(prepareString(name));
out.append("\x0a");
}
for (int i = 0; i < numSpaces; i++) hasDoubleItem = name == shopSettings->doublePrintItem();
{
out.append(" ");
}
out.append(prepareString(price));
out.append("\x0a");
}
out.append("\x1b\x21"); int numSpaces = 0;
out.append(printMode); name = count + "x " + name;
for (int i = 0; i < shopSettings->lettersPerLine(); i++ )
{
out.append("-");
}
out.append("\x1b\x21");
out.append((char)0);
out.append("\x0a");
if (gs->vatPayer()) if (gs->vatPayer())
{ {
QString zaklad = "Zaklad DPH "; out.append(prepareString("DPH " + QString::number(item->vatRate().toDouble(), 'f', 0)) + "%");
QString dph = "DPH "; out.append("\x0a");
QString output; }
QDecDouble zero(0);
if (m_voucher->vatAmountHigh() > zero) if ((name.length() + price.length()) < shopSettings->lettersPerLine())
{
output = zaklad + QString::number(m_voucher->vatRateHigh().toDouble()) + "%";
out.append(prepareString(output));
QString amount = QString::number(m_voucher->priceVatHigh().toDouble(), 'f', 2);
int numSpaces = shopSettings->lettersPerLine() - (output.length() + amount.length());
for (int i = 0; i < numSpaces; i++)
{ {
out.append(" "); numSpaces = shopSettings->lettersPerLine() - (name.length() + price.length());
out.append(prepareString(name));
}
else
{
numSpaces = shopSettings->lettersPerLine() - (name.length() + price.length());
out.append(prepareString(name));
out.append("\x0a");
} }
out.append(prepareString(amount));
out.append("\x0a");
output = dph + QString::number(m_voucher->vatRateHigh().toDouble()) + "%";
out.append(prepareString(output));
amount = QString::number(m_voucher->vatAmountHigh().toDouble(), 'f', 2);
numSpaces = shopSettings->lettersPerLine() - (output.length() + amount.length());
for (int i = 0; i < numSpaces; i++) for (int i = 0; i < numSpaces; i++)
{ {
out.append(" "); out.append(" ");
} }
out.append(prepareString(amount)); out.append(prepareString(price));
out.append("\x0a"); out.append("\x0a");
} }
if (m_voucher->vatAmountFirstLower() > zero) out.append("\x1b\x21");
out.append(printMode);
for (int i = 0; i < shopSettings->lettersPerLine(); i++ )
{ {
output = zaklad + QString::number(m_voucher->vatRateFirstLower().toDouble()) + "%"; out.append("-");
out.append(prepareString(output)); }
QString amount = QString::number(m_voucher->priceVatFirstLower().toDouble(), 'f', 2); out.append("\x1b\x21");
int numSpaces = shopSettings->lettersPerLine() - (output.length() + amount.length()); out.append((char)0);
for (int i = 0; i < numSpaces; i++) out.append("\x0a");
if (gs->vatPayer())
{
QString zaklad = "Zaklad DPH ";
QString dph = "DPH ";
QString output;
QDecDouble zero(0);
if (m_voucher->vatAmountHigh() > zero)
{ {
out.append(" "); output = zaklad + QString::number(m_voucher->vatRateHigh().toDouble()) + "%";
out.append(prepareString(output));
QString amount = QString::number(m_voucher->priceVatHigh().toDouble(), 'f', 2);
int numSpaces = shopSettings->lettersPerLine() - (output.length() + amount.length());
for (int i = 0; i < numSpaces; i++)
{
out.append(" ");
}
out.append(prepareString(amount));
out.append("\x0a");
output = dph + QString::number(m_voucher->vatRateHigh().toDouble()) + "%";
out.append(prepareString(output));
amount = QString::number(m_voucher->vatAmountHigh().toDouble(), 'f', 2);
numSpaces = shopSettings->lettersPerLine() - (output.length() + amount.length());
for (int i = 0; i < numSpaces; i++)
{
out.append(" ");
}
out.append(prepareString(amount));
out.append("\x0a");
} }
out.append(prepareString(amount));
out.append("\x0a");
output = dph + QString::number(m_voucher->vatRateFirstLower().toDouble()) + "%"; if (m_voucher->vatAmountFirstLower() > zero)
out.append(prepareString(output));
amount = QString::number(m_voucher->vatAmountFirstLower().toDouble(), 'f', 2);
numSpaces = shopSettings->lettersPerLine() - (output.length() + amount.length());
for (int i = 0; i < numSpaces; i++)
{ {
out.append(" "); output = zaklad + QString::number(m_voucher->vatRateFirstLower().toDouble()) + "%";
out.append(prepareString(output));
QString amount = QString::number(m_voucher->priceVatFirstLower().toDouble(), 'f', 2);
int numSpaces = shopSettings->lettersPerLine() - (output.length() + amount.length());
for (int i = 0; i < numSpaces; i++)
{
out.append(" ");
}
out.append(prepareString(amount));
out.append("\x0a");
output = dph + QString::number(m_voucher->vatRateFirstLower().toDouble()) + "%";
out.append(prepareString(output));
amount = QString::number(m_voucher->vatAmountFirstLower().toDouble(), 'f', 2);
numSpaces = shopSettings->lettersPerLine() - (output.length() + amount.length());
for (int i = 0; i < numSpaces; i++)
{
out.append(" ");
}
out.append(prepareString(amount));
out.append("\x0a");
} }
out.append(prepareString(amount));
out.append("\x0a");
}
if (m_voucher->VatAmountSecondLower() > zero) if (m_voucher->VatAmountSecondLower() > zero)
{
output = zaklad + QString::number(m_voucher->vatRateSecondLower().toDouble()) + "%";
out.append(prepareString(output));
QString amount = QString::number(m_voucher->priceVatSecondLower().toDouble(), 'f', 2);
int numSpaces = shopSettings->lettersPerLine() - (output.length() + amount.length());
for (int i = 0; i < numSpaces; i++)
{ {
out.append(" "); output = zaklad + QString::number(m_voucher->vatRateSecondLower().toDouble()) + "%";
out.append(prepareString(output));
QString amount = QString::number(m_voucher->priceVatSecondLower().toDouble(), 'f', 2);
int numSpaces = shopSettings->lettersPerLine() - (output.length() + amount.length());
for (int i = 0; i < numSpaces; i++)
{
out.append(" ");
}
out.append(prepareString(amount));
out.append("\x0a");
output = dph + QString::number(m_voucher->vatRateSecondLower().toDouble()) + "%";
out.append(prepareString(output));
amount = QString::number(m_voucher->VatAmountSecondLower().toDouble(), 'f', 2);
numSpaces = shopSettings->lettersPerLine() - (output.length() + amount.length());
for (int i = 0; i < numSpaces; i++)
{
out.append(" ");
}
out.append(prepareString(amount));
out.append("\x0a");
} }
out.append(prepareString(amount));
out.append("\x0a");
output = dph + QString::number(m_voucher->vatRateSecondLower().toDouble()) + "%"; out.append("\x1b\x21");
out.append(prepareString(output)); out.append(printMode);
amount = QString::number(m_voucher->VatAmountSecondLower().toDouble(), 'f', 2); for (int i = 0; i < shopSettings->lettersPerLine(); i++ )
numSpaces = shopSettings->lettersPerLine() - (output.length() + amount.length());
for (int i = 0; i < numSpaces; i++)
{ {
out.append(" "); out.append("-");
} }
out.append(prepareString(amount)); out.append("\x1b\x21");
out.append((char)0);
out.append("\x0a"); out.append("\x0a");
} }
out.append("\x1b\x21"); out.append("\x1b\x21");
out.append(printMode); out.append(printMode);
for (int i = 0; i < shopSettings->lettersPerLine(); i++ ) out.append("Celkem:");
QString totalPrice = QString::number(m_voucher->totalPrice().toDouble(), 'f', 2);
int numSpaces = shopSettings->lettersPerLine() - (8 + totalPrice.length());
for (int i = 0; i < numSpaces; i++)
{ {
out.append("-"); out.append(" ");
} }
out.append(prepareString(totalPrice));
out.append("\x1b\x21"); out.append("\x1b\x21");
out.append((char)0); out.append((char)0);
out.append("\x0a"); out.append("\x0a");
out.append("Datum:");
} out.append(prepareString(m_voucher->payDateTime().toString()));
out.append("\x1b\x21");
out.append(printMode);
out.append("Celkem:");
QString totalPrice = QString::number(m_voucher->totalPrice().toDouble(), 'f', 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");
out.append((char)0);
out.append("\x0a");
out.append("Datum:");
out.append(prepareString(m_voucher->payDateTime().toString()));
out.append("\x0a");
if (!m_voucher->eetBkp().isEmpty())
{
out.append("Rezim EET: bezny");
out.append("\x0a");
out.append("BKP:");
out.append("\x0a");
out.append(prepareString(m_voucher->eetBkp()));
out.append("\x0a"); out.append("\x0a");
out.append("FIK:"); if (!m_voucher->eetBkp().isEmpty())
{
out.append("Rezim EET: bezny");
out.append("\x0a");
out.append("BKP:");
out.append("\x0a");
out.append(prepareString(m_voucher->eetBkp()));
out.append("\x0a");
out.append("FIK:");
out.append("\x0a");
out.append(prepareString(m_voucher->eetFik()));
out.append("\x0a");
out.append("\x0a");
}
out.append("\x0a"); out.append("\x0a");
out.append(prepareString(m_voucher->eetFik()));
out.append("\x0a"); out.append("\x0a");
out.append("\x0a"); out.append("\x0a");
}
out.append("\x0a"); if (shopSettings->doublePrint() && hasDoubleItem && first)
out.append("\x0a"); {
out.append("\x0a"); out.append("\x0a");
out.append("\x0a");
first = false;
}
else if (!first)
{
first = true;
}
} while (shopSettings->doublePrint() && hasDoubleItem && !first);
return out; return out;
} }

@ -16,6 +16,8 @@ ShopSettings::ShopSettings(QObject *parent) : QObject(parent)
m_rounding = Enums::R_NONE; m_rounding = Enums::R_NONE;
m_decimalPlaces = 0; m_decimalPlaces = 0;
m_doublePrint = false;
} }
QString ShopSettings::output() const QString ShopSettings::output() const
@ -197,3 +199,23 @@ void ShopSettings::setRoundingItem(const QString &roundingItem)
{ {
m_roundingItem = roundingItem; m_roundingItem = roundingItem;
} }
bool ShopSettings::doublePrint() const
{
return m_doublePrint;
}
void ShopSettings::setDoublePrint(bool doublePrint)
{
m_doublePrint = doublePrint;
}
QString ShopSettings::doublePrintItem() const
{
return m_doublePrintItem;
}
void ShopSettings::setDoublePrintItem(const QString &doublePrintItem)
{
m_doublePrintItem = doublePrintItem;
}

@ -23,6 +23,9 @@ class ShopSettings : public QObject
Q_PROPERTY(int favBtnRows READ favBtnRows WRITE setFavBtnRows) Q_PROPERTY(int favBtnRows READ favBtnRows WRITE setFavBtnRows)
Q_PROPERTY(int favBtnSize READ favBtnSize WRITE setFavBtnSize) Q_PROPERTY(int favBtnSize READ favBtnSize WRITE setFavBtnSize)
Q_PROPERTY(bool doublePrint READ doublePrint WRITE setDoublePrint)
Q_PROPERTY(QString doublePrintItem READ doublePrintItem WRITE setDoublePrintItem)
Q_PROPERTY(Enums::Rounding rounding READ rounding WRITE setRounding) Q_PROPERTY(Enums::Rounding rounding READ rounding WRITE setRounding)
Q_PROPERTY(int decimalPlaces READ decimalPlaces WRITE setDecimalPlaces) Q_PROPERTY(int decimalPlaces READ decimalPlaces WRITE setDecimalPlaces)
Q_PROPERTY(QString roundingItem READ roundingItem WRITE setRoundingItem) Q_PROPERTY(QString roundingItem READ roundingItem WRITE setRoundingItem)
@ -91,6 +94,12 @@ public:
QString roundingItem() const; QString roundingItem() const;
void setRoundingItem(const QString &roundingItem); void setRoundingItem(const QString &roundingItem);
bool doublePrint() const;
void setDoublePrint(bool doublePrint);
QString doublePrintItem() const;
void setDoublePrintItem(const QString &doublePrintItem);
private: private:
QString m_output; QString m_output;
CODEPAGE m_codepage; CODEPAGE m_codepage;
@ -106,6 +115,9 @@ private:
bool m_eetTest; bool m_eetTest;
bool m_eetPlayground; bool m_eetPlayground;
bool m_doublePrint;
QString m_doublePrintItem;
int m_favBtnCols; int m_favBtnCols;
int m_favBtnRows; int m_favBtnRows;
int m_favBtnSize; int m_favBtnSize;

@ -45,6 +45,9 @@ ShopSettingsForm::ShopSettingsForm(QWidget *parent) :
registerBinding(ui->decimalPlaces); registerBinding(ui->decimalPlaces);
registerBinding(ui->roundingItem); registerBinding(ui->roundingItem);
registerBinding(ui->doublePrint);
registerBinding(ui->doublePrintItem);
m_itemModel = new AutoTableModel<ShopItem>(); m_itemModel = new AutoTableModel<ShopItem>();
} }

@ -320,6 +320,31 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="QGroupBox" name="doublePrint">
<property name="title">
<string>Doub&amp;le print bill</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QFormLayout" name="formLayout_5">
<item row="0" column="0">
<widget class="QLabel" name="label_15">
<property name="text">
<string>Item name</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="doublePrintItem"/>
</item>
</layout>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</widget> </widget>

Loading…
Cancel
Save