bugfixes
This commit is contained in:
parent
d17695a7fa
commit
1b32774e55
|
@ -1,7 +1,8 @@
|
|||
{
|
||||
"name":"Пятёрочка",
|
||||
"goods_name_regex": "([\\(\\)\\%\\*a-zA-Z0-9\u0401\u0451\u0410-\u044f \\.\\-\/]{17,100})",
|
||||
"goods_name_regex": "^\\d+\\s\\t[\\(\\)\\%\\*a-zA-Z0-9\\u0401\\u0451\\u0410-\\u044f \\.\\-\\/]+",
|
||||
"goods_price_regex": "[0-9]{0,4}[^%]\\.[0-9]{2} ",
|
||||
"goods_net_weight_regex": "((\\d+(\\.|,)?\\d{0,}((м|)л|(к|м|)г|т|ц|шт|(pc|)s|(m|k|)g|(m|)l|t))(\\s|\\t){0,})+",
|
||||
"goods_quantity_regex": "([0-9]{0,4}[^%]\\.[0-9]{3} )|(\t\\d )",
|
||||
"check_start_regex": "КАССОВЫЙ ЧЕК\nприход",
|
||||
"check_end_regex": "Итог\\:.{0,3}[0-9]{0,6}\\.[0-9]{2}"
|
||||
|
|
|
@ -6,14 +6,17 @@
|
|||
#include <utils/utils.h>
|
||||
#include <boost/regex.hpp>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
StoreModule::StoreModule() {}
|
||||
|
||||
std::vector<std::string> StoreModule::parse(std::wstring str, std::wstring regexp, boost::regex_constants::flag_type_ flag) {
|
||||
std::vector<std::string> result;
|
||||
boost::wregex r(regexp, flag);
|
||||
|
||||
std::cout << "Handling: " << to_utf8(str) << std::endl;
|
||||
for (boost::wsregex_iterator it{str.begin(), str.end(), r}, end{}; it != end;
|
||||
it++) {
|
||||
std::wcout << "Parsed" << it->str() << std::endl;
|
||||
result.push_back(to_utf8(it->str()));
|
||||
}
|
||||
|
||||
|
@ -34,7 +37,7 @@ StoreModule::StoreModule(std::string path) {
|
|||
}
|
||||
|
||||
std::vector<std::string> StoreModule::parse_name(std::wstring str) {
|
||||
return parse(str, this->goods_name_regex, boost::regex_constants::extended);
|
||||
return parse(str, this->goods_name_regex, boost::regex_constants::perl);
|
||||
}
|
||||
|
||||
std::vector<std::string> StoreModule::parse_price(std::wstring str) {
|
||||
|
@ -49,6 +52,7 @@ std::vector<std::string> StoreModule::parse_net_weight(std::vector<std::string>
|
|||
result.push_back("?");
|
||||
} else {
|
||||
result.push_back(parsed[0]);
|
||||
name.erase(0, name.find(parsed[0]) + parsed[0].length());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -68,7 +68,7 @@ std::vector<Goods> Parser::parse(std::wstring check_plaintext) {
|
|||
std::vector<std::string> goods_quantities = module.parse_quantity(check_plaintext);
|
||||
|
||||
|
||||
if (areAllSizesEqual(goods_names, goods_prices, goods_net_weights, goods_quantities)) {
|
||||
if (!areAllSizesEqual(goods_names, goods_prices, goods_net_weights, goods_quantities)) {
|
||||
|
||||
// dumpVectorsToStderr(goods_names, goods_prices, goods_net_weights, goods_quantities);
|
||||
|
||||
|
|
|
@ -42,15 +42,16 @@ SettingsDialog::SettingsDialog(QWidget *parent)
|
|||
int currentLanguageIndex = 0;
|
||||
bool languageSettingPresent = false;
|
||||
|
||||
//TODO: check that "language" exists before getting its value
|
||||
languageSettingPresent = settings.get_all_settings().find("language") != settings.get_all_settings().end();
|
||||
|
||||
if (languageSettingPresent) {
|
||||
currentLanguageIndex = ui->languageComboBox->findText(QString::fromStdString(this->settings.get_all_settings()["language"]));
|
||||
|
||||
} else {
|
||||
currentLanguageIndex = ui->languageComboBox->findText(QLocale::system().name());
|
||||
if (currentLanguageIndex < 0) {
|
||||
currentLanguageIndex = ui->languageComboBox->findText("en_US");
|
||||
}
|
||||
} else {
|
||||
currentLanguageIndex = ui->languageComboBox->findText(QString::fromStdString(this->settings.get_all_settings()["language"]));
|
||||
}
|
||||
ui->languageComboBox->setCurrentIndex(currentLanguageIndex);
|
||||
|
||||
|
|
|
@ -562,12 +562,12 @@
|
|||
<context>
|
||||
<name>SettingsDialog</name>
|
||||
<message>
|
||||
<location filename="../settingsdialog.cpp" line="160"/>
|
||||
<location filename="../settingsdialog.cpp" line="161"/>
|
||||
<source>You need to restart program to apply language changes</source>
|
||||
<translation>You need to restart program to apply language changes</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../settingsdialog.cpp" line="162"/>
|
||||
<location filename="../settingsdialog.cpp" line="163"/>
|
||||
<source>Restart required</source>
|
||||
<translation>Restart required</translation>
|
||||
</message>
|
||||
|
|
|
@ -562,12 +562,12 @@
|
|||
<context>
|
||||
<name>SettingsDialog</name>
|
||||
<message>
|
||||
<location filename="../settingsdialog.cpp" line="160"/>
|
||||
<location filename="../settingsdialog.cpp" line="161"/>
|
||||
<source>You need to restart program to apply language changes</source>
|
||||
<translation>Требуется перезагрузить программу, чтобы применить изменения языка</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../settingsdialog.cpp" line="162"/>
|
||||
<location filename="../settingsdialog.cpp" line="163"/>
|
||||
<source>Restart required</source>
|
||||
<translation>Требуется перезагрузка</translation>
|
||||
</message>
|
||||
|
|
|
@ -98,6 +98,20 @@ std::vector<std::string> split(std::string s, std::string delimiter) {
|
|||
return result;
|
||||
}
|
||||
|
||||
std::vector<std::wstring> split(std::wstring s, std::wstring delimiter) {
|
||||
std::vector<std::wstring> result;
|
||||
size_t pos = 0;
|
||||
std::wstring token;
|
||||
while ((pos = s.find(delimiter)) != std::string::npos) {
|
||||
token = s.substr(0, pos);
|
||||
result.push_back(token);
|
||||
s.erase(0, pos + delimiter.length());
|
||||
}
|
||||
result.push_back(s);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
std::wstring substring_from_to(std::wstring& text, std::wstring from, std::wstring to) {
|
||||
unsigned int start_pos = 0;
|
||||
unsigned int end_pos = 0;
|
||||
|
@ -169,12 +183,13 @@ std::vector<std::wstring> find_amounts_in_html(std::string html) {
|
|||
std::vector<std::wstring> find_net_weights_in_names(std::vector<std::wstring> &names) {
|
||||
std::vector<std::wstring> result;
|
||||
for (std::wstring &name : names ) {
|
||||
boost::wregex regexp(from_utf8("((\\d+(.|,)?\\d?((м|)л|(к|м|)г|т|ц|шт|(pc|)s|(m|k|)g|(m|)l|t)).?)+"), boost::regex_constants::collate);
|
||||
boost::wregex regexp(from_utf8("((\\d+(\\.|,)?\\d{0,}((м|)л|(к|м|)г|т|ц|шт|(pc|)s|(m|k|)g|(m|)l|t))(\\s|\\t){0,})+"), boost::regex_constants::collate);
|
||||
bool found = false;
|
||||
for (boost::wsregex_iterator it{name.begin(), name.end(), regexp}, end{}; it != end;
|
||||
it++) {
|
||||
result.push_back(it->str());
|
||||
found = true;
|
||||
name.erase(it->position(), it->str().length());
|
||||
break;
|
||||
}
|
||||
if (!found) {
|
||||
|
|
|
@ -17,6 +17,7 @@ bool areAllSizesEqual(const std::vector<T>& v1, const std::vector<T>& v2,
|
|||
const std::vector<T>& v3, const std::vector<T>& v4);
|
||||
|
||||
std::vector<std::string> split(std::string, std::string);
|
||||
std::vector<std::wstring> split(std::wstring s, std::wstring delimiter);
|
||||
|
||||
#ifdef BUILD_OFD_MODE
|
||||
Check parseOfdRuAnswer(std::string);
|
||||
|
|
Loading…
Reference in New Issue