|
|
|
@ -114,207 +114,226 @@ QByteArray ReceiptGenerator::generate()
|
|
|
|
|
ShopSettingsPtr shopSettings = srvShopSettings.loadSettings<ShopSettings>();
|
|
|
|
|
GlobalSettingsPtr gs = srvGsSettings.loadSettings<GlobalSettings>();
|
|
|
|
|
|
|
|
|
|
out.append("\x1b\x40\x1b\x61\x01");
|
|
|
|
|
out.append(prepareString(gs->firmName()));
|
|
|
|
|
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");
|
|
|
|
|
bool hasDoubleItem = false;
|
|
|
|
|
bool first = true;
|
|
|
|
|
|
|
|
|
|
foreach (QSharedPointer<VoucherItem> item, m_voucher->items()) {
|
|
|
|
|
QString count = QString::number(item->count());
|
|
|
|
|
QString name = item->name();
|
|
|
|
|
QString price = QString::number(item->price().toDouble(), 'f', 2);
|
|
|
|
|
|
|
|
|
|
int numSpaces = 0;
|
|
|
|
|
name = count + "x " + name;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
out.append("\x1b\x40\x1b\x61\x01");
|
|
|
|
|
out.append(prepareString(gs->firmName()));
|
|
|
|
|
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");
|
|
|
|
|
|
|
|
|
|
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("\x0a");
|
|
|
|
|
out.append("-");
|
|
|
|
|
}
|
|
|
|
|
out.append("\x1b\x21");
|
|
|
|
|
out.append((char)0);
|
|
|
|
|
out.append("\x0a");
|
|
|
|
|
|
|
|
|
|
if ((name.length() + price.length()) < shopSettings->lettersPerLine())
|
|
|
|
|
{
|
|
|
|
|
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");
|
|
|
|
|
}
|
|
|
|
|
foreach (QSharedPointer<VoucherItem> item, m_voucher->items()) {
|
|
|
|
|
QString count = QString::number(item->count());
|
|
|
|
|
QString name = item->name();
|
|
|
|
|
QString price = QString::number(item->price().toDouble(), 'f', 2);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < numSpaces; i++)
|
|
|
|
|
{
|
|
|
|
|
out.append(" ");
|
|
|
|
|
}
|
|
|
|
|
out.append(prepareString(price));
|
|
|
|
|
out.append("\x0a");
|
|
|
|
|
}
|
|
|
|
|
hasDoubleItem = name == shopSettings->doublePrintItem();
|
|
|
|
|
|
|
|
|
|
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");
|
|
|
|
|
int numSpaces = 0;
|
|
|
|
|
name = count + "x " + name;
|
|
|
|
|
|
|
|
|
|
if (gs->vatPayer())
|
|
|
|
|
{
|
|
|
|
|
QString zaklad = "Zaklad DPH ";
|
|
|
|
|
QString dph = "DPH ";
|
|
|
|
|
QString output;
|
|
|
|
|
QDecDouble zero(0);
|
|
|
|
|
if (gs->vatPayer())
|
|
|
|
|
{
|
|
|
|
|
out.append(prepareString("DPH " + QString::number(item->vatRate().toDouble(), 'f', 0)) + "%");
|
|
|
|
|
out.append("\x0a");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_voucher->vatAmountHigh() > zero)
|
|
|
|
|
{
|
|
|
|
|
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++)
|
|
|
|
|
if ((name.length() + price.length()) < shopSettings->lettersPerLine())
|
|
|
|
|
{
|
|
|
|
|
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++)
|
|
|
|
|
{
|
|
|
|
|
out.append(" ");
|
|
|
|
|
}
|
|
|
|
|
out.append(prepareString(amount));
|
|
|
|
|
out.append(prepareString(price));
|
|
|
|
|
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(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("\x1b\x21");
|
|
|
|
|
out.append((char)0);
|
|
|
|
|
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()) + "%";
|
|
|
|
|
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++)
|
|
|
|
|
if (m_voucher->vatAmountFirstLower() > zero)
|
|
|
|
|
{
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
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++)
|
|
|
|
|
if (m_voucher->VatAmountSecondLower() > zero)
|
|
|
|
|
{
|
|
|
|
|
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(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("\x1b\x21");
|
|
|
|
|
out.append(printMode);
|
|
|
|
|
for (int i = 0; i < shopSettings->lettersPerLine(); i++ )
|
|
|
|
|
{
|
|
|
|
|
out.append(" ");
|
|
|
|
|
out.append("-");
|
|
|
|
|
}
|
|
|
|
|
out.append(prepareString(amount));
|
|
|
|
|
out.append("\x1b\x21");
|
|
|
|
|
out.append((char)0);
|
|
|
|
|
out.append("\x0a");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
out.append("\x1b\x21");
|
|
|
|
|
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((char)0);
|
|
|
|
|
out.append("\x0a");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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("Datum:");
|
|
|
|
|
out.append(prepareString(m_voucher->payDateTime().toString()));
|
|
|
|
|
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(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");
|
|
|
|
|
first = false;
|
|
|
|
|
}
|
|
|
|
|
else if (!first)
|
|
|
|
|
{
|
|
|
|
|
first = true;
|
|
|
|
|
}
|
|
|
|
|
} while (shopSettings->doublePrint() && hasDoubleItem && !first);
|
|
|
|
|
|
|
|
|
|
return out;
|
|
|
|
|
}
|
|
|
|
|