Compare commits
8 Commits
87b14ee3f8
...
2.1.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
d8a4c4eaa7
|
|||
| 4f45db4fde | |||
| a744a1ebb3 | |||
| df16bd7f9c | |||
| b751ba339e | |||
|
588a88455b
|
|||
|
92bfdced6a
|
|||
| 8bbec596c9 |
@@ -84,6 +84,51 @@ struct CALCULATE_LIBRARY_API CalcState {
|
|||||||
return (m_status == State::SUCCESS);
|
return (m_status == State::SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString toString() {
|
||||||
|
QString s;
|
||||||
|
switch (m_status) {
|
||||||
|
case State::SUCCESS:
|
||||||
|
s = "SUCCESS";
|
||||||
|
break;
|
||||||
|
case State::ERROR_PARSING_ZONE_NR:
|
||||||
|
s = "ERROR_PARSING_ZONE_NR";
|
||||||
|
break;
|
||||||
|
case State::ERROR_LOADING_TARIFF:
|
||||||
|
s = "ERROR_LOADING_TARIFF";
|
||||||
|
break;
|
||||||
|
case State::ERROR_PARSING_TARIFF:
|
||||||
|
s = "ERROR_PARSING_TARIFF";
|
||||||
|
break;
|
||||||
|
case State::NEGATIVE_PARING_TIME:
|
||||||
|
s = "NEGATIVE_PARKING_TIME";
|
||||||
|
break;
|
||||||
|
case State::ABOVE_MAX_PARKING_TIME:
|
||||||
|
s = "ABOVE_MAX_PARKING_TIME";
|
||||||
|
break;
|
||||||
|
case State::WRONG_PARAM_VALUES:
|
||||||
|
s = "WRONG_PARAM_VALUES";
|
||||||
|
break;
|
||||||
|
case State::BELOW_MIN_PARKING_TIME:
|
||||||
|
s = "BELOW_MIN_PARKING_TIME";
|
||||||
|
break;
|
||||||
|
case State::BELOW_MIN_PARKING_PRICE:
|
||||||
|
s = "BELOW_MIN_PARKING_PRICE";
|
||||||
|
break;
|
||||||
|
case State::OVERPAID:
|
||||||
|
s = "OVERPAID";
|
||||||
|
break;
|
||||||
|
case State::INVALID_START_DATE:
|
||||||
|
s = "INVALID_START_DATE";
|
||||||
|
break;
|
||||||
|
case State::WRONG_ISO_TIME_FORMAT:
|
||||||
|
s = "WRONG_ISO_TIME_FORMAT";
|
||||||
|
break;
|
||||||
|
case State::OUTSIDE_ALLOWED_PARKING_TIME:
|
||||||
|
s = "OUTSIDE_ALLOWED_PARKING_TIME";
|
||||||
|
}
|
||||||
|
return s + ":" + m_desc;
|
||||||
|
}
|
||||||
|
|
||||||
explicit operator QString () const noexcept {
|
explicit operator QString () const noexcept {
|
||||||
QString s;
|
QString s;
|
||||||
switch (m_status) {
|
switch (m_status) {
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ enum class PERMIT_TYPE : quint8 {
|
|||||||
DAY_TICKET_ADULT,
|
DAY_TICKET_ADULT,
|
||||||
DAY_TICKET_TEEN,
|
DAY_TICKET_TEEN,
|
||||||
DAY_TICKET_CHILD,
|
DAY_TICKET_CHILD,
|
||||||
|
FOOD_STAMP,
|
||||||
INVALID
|
INVALID
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -41,6 +42,9 @@ struct PermitType {
|
|||||||
case 6:
|
case 6:
|
||||||
m_permitType = PERMIT_TYPE::DAY_TICKET_CHILD;
|
m_permitType = PERMIT_TYPE::DAY_TICKET_CHILD;
|
||||||
break;
|
break;
|
||||||
|
case 7:
|
||||||
|
m_permitType = PERMIT_TYPE::FOOD_STAMP;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
m_permitType = PERMIT_TYPE::INVALID;
|
m_permitType = PERMIT_TYPE::INVALID;
|
||||||
}
|
}
|
||||||
@@ -68,6 +72,8 @@ struct PermitType {
|
|||||||
return 5;
|
return 5;
|
||||||
case PERMIT_TYPE::DAY_TICKET_TEEN:
|
case PERMIT_TYPE::DAY_TICKET_TEEN:
|
||||||
return 6;
|
return 6;
|
||||||
|
case PERMIT_TYPE::FOOD_STAMP:
|
||||||
|
return 7;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -75,6 +81,30 @@ struct PermitType {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
operator QString () {
|
||||||
|
switch(m_permitType) {
|
||||||
|
case PERMIT_TYPE::DAY_TICKET:
|
||||||
|
return QString("DAY_TICKET");
|
||||||
|
case PERMIT_TYPE::DAY_TICKET_ADULT:
|
||||||
|
return QString("DAY_TICKET_ADULT");
|
||||||
|
case PERMIT_TYPE::DAY_TICKET_CHILD:
|
||||||
|
return QString("DAY_TICKET_CHILD");
|
||||||
|
case PERMIT_TYPE::DAY_TICKET_TEEN:
|
||||||
|
return QString("DAY_TICKET_TEEN");
|
||||||
|
case PERMIT_TYPE::SHORT_TERM_PARKING:
|
||||||
|
return QString("SHORT_TERM_PARKING");
|
||||||
|
case PERMIT_TYPE::SZEGED_START:
|
||||||
|
return QString("SZEGED_START");
|
||||||
|
case PERMIT_TYPE::SZEGED_STOP:
|
||||||
|
return QString("SZEGED_STOP");
|
||||||
|
case PERMIT_TYPE::FOOD_STAMP:
|
||||||
|
return QString("FOOD_STAMP");
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return QString("INVALID");
|
||||||
|
}
|
||||||
|
|
||||||
operator QString () const {
|
operator QString () const {
|
||||||
switch(m_permitType) {
|
switch(m_permitType) {
|
||||||
case PERMIT_TYPE::DAY_TICKET:
|
case PERMIT_TYPE::DAY_TICKET:
|
||||||
@@ -91,6 +121,8 @@ struct PermitType {
|
|||||||
return QString("SZEGED_START");
|
return QString("SZEGED_START");
|
||||||
case PERMIT_TYPE::SZEGED_STOP:
|
case PERMIT_TYPE::SZEGED_STOP:
|
||||||
return QString("SZEGED_STOP");
|
return QString("SZEGED_STOP");
|
||||||
|
case PERMIT_TYPE::FOOD_STAMP:
|
||||||
|
return QString("FOOD_STAMP");
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,12 +85,17 @@ int CALCULATE_LIBRARY_API compute_product_price(Configuration const *cfg, PERMIT
|
|||||||
// [[fallthrough]];
|
// [[fallthrough]];
|
||||||
case PERMIT_TYPE::DAY_TICKET_TEEN:
|
case PERMIT_TYPE::DAY_TICKET_TEEN:
|
||||||
// [[fallthrough]];
|
// [[fallthrough]];
|
||||||
|
case PERMIT_TYPE::FOOD_STAMP:
|
||||||
|
// [[fallthrough]];
|
||||||
case PERMIT_TYPE::DAY_TICKET_ADULT: {
|
case PERMIT_TYPE::DAY_TICKET_ADULT: {
|
||||||
std::optional<QVector<ATBTariffProduct>> products = cfg->getTariffProductForProductId(permitType);
|
std::optional<QVector<ATBTariffProduct>> products = cfg->getTariffProductForProductId(permitType);
|
||||||
if (products) {
|
if (products) {
|
||||||
QVector<ATBTariffProduct> product = products.value();
|
QVector<ATBTariffProduct> product = products.value();
|
||||||
if (product.size() > 0) {
|
if (product.size() > 0) {
|
||||||
ATBTariffProduct const &p = product[0];
|
ATBTariffProduct const &p = product[0];
|
||||||
|
return p.m_tariff_product_price;
|
||||||
|
#if 0
|
||||||
|
// in case we do not have prepaid-option
|
||||||
QTime const ¤tTime = QDateTime::currentDateTime().time();
|
QTime const ¤tTime = QDateTime::currentDateTime().time();
|
||||||
|
|
||||||
if (p.m_tariff_product_start <= currentTime && currentTime <= p.m_tariff_product_end) {
|
if (p.m_tariff_product_start <= currentTime && currentTime <= p.m_tariff_product_end) {
|
||||||
@@ -103,6 +108,7 @@ int CALCULATE_LIBRARY_API compute_product_price(Configuration const *cfg, PERMIT
|
|||||||
<< p.m_tariff_product_start.toString(Qt::ISODate)
|
<< p.m_tariff_product_start.toString(Qt::ISODate)
|
||||||
<< p.m_tariff_product_end.toString(Qt::ISODate) << ")";
|
<< p.m_tariff_product_end.toString(Qt::ISODate) << ")";
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|||||||
@@ -1736,6 +1736,9 @@ Calculator::GetDailyTicketPrice(Configuration* cfg,
|
|||||||
if (dailyTickets) {
|
if (dailyTickets) {
|
||||||
QVector<ATBDailyTicket> const tickets = dailyTickets.value();
|
QVector<ATBDailyTicket> const tickets = dailyTickets.value();
|
||||||
switch (permitType) {
|
switch (permitType) {
|
||||||
|
case PERMIT_TYPE::FOOD_STAMP: {
|
||||||
|
// TODO
|
||||||
|
} break;
|
||||||
case PERMIT_TYPE::DAY_TICKET_ADULT: {
|
case PERMIT_TYPE::DAY_TICKET_ADULT: {
|
||||||
std::optional<ATBCustomer> c = cfg->getCustomerForType(ATBCustomer::CustomerType::ADULT);
|
std::optional<ATBCustomer> c = cfg->getCustomerForType(ATBCustomer::CustomerType::ADULT);
|
||||||
if (c) {
|
if (c) {
|
||||||
|
|||||||
@@ -37,8 +37,8 @@ extern "C" char* strptime(const char* s,
|
|||||||
#define SZEGED (0)
|
#define SZEGED (0)
|
||||||
#define SCHOENAU_KOENIGSEE (0)
|
#define SCHOENAU_KOENIGSEE (0)
|
||||||
#define NEUHAUSER_KORNEUBURG (0)
|
#define NEUHAUSER_KORNEUBURG (0)
|
||||||
#define NEUHAUSER_LINSINGER_MASCHINENBAU (0)
|
#define NEUHAUSER_LINSINGER_MASCHINENBAU (1)
|
||||||
#define NEUHAUSER_NORDISCHES_AUSBILDUNGSZENTRUM (1)
|
#define NEUHAUSER_NORDISCHES_AUSBILDUNGSZENTRUM (0)
|
||||||
#define NEUHAUSER_BILEXA_GALTUER (0)
|
#define NEUHAUSER_BILEXA_GALTUER (0)
|
||||||
#define NEUHAUSER_KIRCHDORF (0)
|
#define NEUHAUSER_KIRCHDORF (0)
|
||||||
|
|
||||||
@@ -639,38 +639,8 @@ int main() {
|
|||||||
cout << endl;
|
cout << endl;
|
||||||
|
|
||||||
if (isParsed) {
|
if (isParsed) {
|
||||||
bool nextDay = false;
|
int const price = compute_product_price(&cfg, PERMIT_TYPE::FOOD_STAMP);
|
||||||
bool prePaid = false;
|
qCritical() << "price food stamp" << price;
|
||||||
|
|
||||||
// zone 1 (lila)
|
|
||||||
QDateTime s(QDate(2023, 11, 30), QTime());
|
|
||||||
QDateTime end;
|
|
||||||
int marken[] = { 3*60, 5*60, 10*60};
|
|
||||||
for (int duration = 0; duration < 3; ++duration) {
|
|
||||||
for (int offset = 360; offset <= 360; ++offset) {
|
|
||||||
// for (int offset = 360; offset < 1080; ++offset) {
|
|
||||||
QDateTime start = s.addSecs(offset * 60);
|
|
||||||
//qCritical() << "start" << start.toString(Qt::ISODate);
|
|
||||||
|
|
||||||
// note: prepaid == false (!)
|
|
||||||
// double cost = Calculator::GetInstance().GetCostFromDuration(&cfg, 4, start, end, marken[duration], nextDay, prePaid);
|
|
||||||
|
|
||||||
struct price_t price;
|
|
||||||
if (compute_price_for_parking_ticket(&cfg, start, marken[duration], end, &price, prePaid)) {
|
|
||||||
double cost = price.netto;
|
|
||||||
|
|
||||||
qCritical() << "start" << start.toString(Qt::ISODate)
|
|
||||||
<< "end" << end.toString(Qt::ISODate)
|
|
||||||
<< "duration" << marken[duration]
|
|
||||||
<< "cost" << cost;
|
|
||||||
}
|
|
||||||
|
|
||||||
//std::string d = Calculator::GetInstance().GetDurationFromCost(&cfg, 4, start.toString(Qt::ISODate).toStdString().c_str(), cost);
|
|
||||||
//qCritical() << "start" << start.toString(Qt::ISODate)
|
|
||||||
// << "cost" << cost
|
|
||||||
// << "until" << d.c_str() << start.secsTo(QDateTime::fromString(d.c_str(), Qt::ISODate)) / 60;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user