add new eet and qt 6.12

This commit is contained in:
2026-10-14 22:38:06 +02:00
parent 464216d6c3
commit 99f98b0451
17 changed files with 505 additions and 100 deletions
+49
View File
@@ -2,6 +2,9 @@
#include <QtTest>
#include "data/voucher.h"
#ifdef PRODEJNA_EET_V4
#include "eet/eetv4adapter.h"
#endif
class ShopTests : public QObject
{
@@ -45,6 +48,52 @@ private slots:
QVERIFY(qAbs(sum.totalPrice().toDouble() - 20.0) < 0.0001);
}
#ifdef PRODEJNA_EET_V4
void eetV4AdapterBuildsRequestFromVoucher()
{
Voucher voucher;
voucher.setNumSer(QStringLiteral("SHOP-42"));
voucher.setPayDateTime(QDateTime(QDate(2026, 10, 13),
QTime(20, 30),
Qt::OffsetFromUTC,
7200));
voucher.setTotalPrice(QDecDouble(QStringLiteral("19.90").toLatin1().constData()));
EetV4ShopConfig config;
config.endpoint = QUrl(QStringLiteral("https://eet.example.test/eet"));
config.taxpayerEic = QStringLiteral("CZ123456789");
config.unitId = 3;
config.cashRegisterId = QStringLiteral("KASA1");
EetV4SaleRequest request;
QString error;
QVERIFY2(EetV4ShopAdapter::createRequest(voucher, config, &request, &error),
qPrintable(error));
QCOMPARE(request.receiptNumber, QStringLiteral("SHOP-42"));
QCOMPARE(request.totalSale.toString(), QStringLiteral("19.90"));
QCOMPARE(request.unitId, 3);
QCOMPARE(request.cashRegisterId, QStringLiteral("KASA1"));
QVERIFY(request.verificationMode);
QVERIFY(request.firstSubmission);
}
void eetV4AdapterRejectsInvalidConfiguration()
{
Voucher voucher;
voucher.setNumSer(QStringLiteral("SHOP-42"));
voucher.setPayDateTime(QDateTime::currentDateTime());
voucher.setTotalPrice(QDecDouble(QStringLiteral("1.00").toLatin1().constData()));
EetV4ShopConfig config;
config.endpoint = QUrl(QStringLiteral("http://not-tls.example.test/eet"));
EetV4SaleRequest request;
QString error;
QVERIFY(!EetV4ShopAdapter::createRequest(voucher, config, &request, &error));
QVERIFY(error.contains(QStringLiteral("HTTPS")));
}
#endif
};
int main(int argc, char *argv[])