Use TicketUtils to format date string on ticket

This commit is contained in:
Siegfried Siegert 2024-08-08 10:12:35 +02:00
parent 1bcdb5ba21
commit f20957c14a
Signed by: SiegfriedSiegert
GPG Key ID: 68371E015E8F0B03

View File

@ -6,6 +6,7 @@
#include "src/ATBAPP/support/DBusControllerInterface.h"
#include "src/ATBAPP/support/PTUSystem.h"
#include "src/ATBAPP/support/CashUtils.h"
#include "src/ATBAPP/support/TicketUtils.h"
#include <QTimer>
#include <QThread>
@ -729,11 +730,12 @@ void ATBDeviceControllerPlugin::requestPrintTicket(const QHash<QString, QVariant
<< " currentDateTime = " << printingData["currentDateTime"] << endl
<< " ticketNumber = " << printingData["ticketNumber"] << endl;
QDateTime parkingEndDateTime = QDateTime::fromString(printingData["parkingEnd"].toString(), Qt::ISODate);
QDateTime parkingEndDateTime = QDateTime::fromString(printingData["parkingEnd"].toString(), Qt::ISODate);
QDateTime currentDateTime = QDateTime::fromString(printingData["currentDateTime"].toString(), Qt::ISODate);
QString parkingEndDateString = this->printerLocale.toString(parkingEndDateTime.date(), QLocale::ShortFormat);
QString currentDateString = this->printerLocale.toString(currentDateTime.date(), QLocale::ShortFormat);
QString parkingEndDateString = TicketUtils::getLocaleDateString(this->printerLocale, parkingEndDateTime.date());
QString currentDateString = TicketUtils::getLocaleDateString(this->printerLocale, currentDateTime.date());
/* -----------------------------------------------------------------------------------------
* note: the following highly depends on printer template files!
@ -1057,9 +1059,8 @@ void ATBDeviceControllerPlugin::private_setupDynTemplateData_START_RECEIPT(struc
QDateTime parkingEndDateTime = QDateTime::fromString(ticket->getPrintingData()["parkingEnd"].toString(), Qt::ISODate);
QDateTime currentDateTime = QDateTime::fromString(ticket->getPrintingData()["currentDateTime"].toString(), Qt::ISODate);
QString parkingEndDateString = this->printerLocale.toString(parkingEndDateTime.date(), QLocale::ShortFormat);
QString currentDateString = this->printerLocale.toString(currentDateTime.date(), QLocale::ShortFormat);
QString parkingEndDateString = TicketUtils::getLocaleDateString(this->printerLocale, parkingEndDateTime.date());
QString currentDateString = TicketUtils::getLocaleDateString(this->printerLocale, currentDateTime.date());
// set dynamic printer data:
QByteArray ba_licenseplate = codec->fromUnicode(ticket->getPrintingData()["licenseplate"].toString());
@ -1184,7 +1185,7 @@ void ATBDeviceControllerPlugin::private_setupDynTemplatData_FREE_TICKET(struct T
QByteArray ba_parkingEndTime = codec->fromUnicode(parkingEndDateTime.toString("hh:mm"));
memcpy((char*)dynTicketData->parkingEnd, ba_parkingEndTime.data(), std::min(ba_parkingEndTime.size(),8));
QString parkingEndDateString = this->printerLocale.toString(parkingEndDateTime.date(), QLocale::ShortFormat);
QString parkingEndDateString = TicketUtils::getLocaleDateString(this->printerLocale, parkingEndDateTime.date());
QByteArray ba_parkingEndDate = codec->fromUnicode(parkingEndDateString);
memcpy((char*)dynTicketData->currentTime, ba_parkingEndDate.data(), std::min(ba_parkingEndDate.size(),8));