diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b90deb..6f861be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,7 +47,7 @@ else() outputdialog.h outputdialog.cpp outputdialog.ui output/output_options.h output/output_options.cpp ofd/ofd.h ofd/ofd.cpp - ofd/module.h ofd/module.cpp + utils/utils.h utils/utils.cpp image/checkimage.h image/checkimage.cpp net/net.h net/net.cpp @@ -92,4 +92,7 @@ include_directories("/usr/include/opencv4") target_link_libraries(checks-parser PRIVATE -ltesseract) target_link_libraries(checks-parser PRIVATE -lcurl) -target_link_libraries(checks-parser PRIVATE ${OpenCV_LIBS}) +pkg_search_module(opencv REQUIRED IMPORTED_TARGET opencv) +target_link_libraries(checks-parser PRIVATE PkgConfig::opencv) +# target_link_libraries(checks-parser PRIVATE ${OpenCV_LIBS}) +# target_link_libraries(checks-parser PRIVATE -lopencv) diff --git a/CMakeLists.txt.user b/CMakeLists.txt.user index bf27976..d8ae996 100644 --- a/CMakeLists.txt.user +++ b/CMakeLists.txt.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -102,14 +102,14 @@ 2 false - -DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} --DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} + -DCMAKE_GENERATOR:STRING=Ninja +-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} +-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} -DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} --DCMAKE_GENERATOR:STRING=Ninja --DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake --DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} +-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} +-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} 0 /home/leca/projects/qt/checks-parser/build/Desktop-Debug @@ -159,14 +159,14 @@ 2 false - -DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} --DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} + -DCMAKE_GENERATOR:STRING=Ninja +-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} +-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} -DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} --DCMAKE_GENERATOR:STRING=Ninja --DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake --DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} +-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} +-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} /home/leca/projects/qt/checks-parser/build/Desktop-Release @@ -213,14 +213,14 @@ 2 false - -DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} --DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} + -DCMAKE_GENERATOR:STRING=Ninja +-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo -DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} +-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} -DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} --DCMAKE_GENERATOR:STRING=Ninja --DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake --DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} +-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} +-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} /home/leca/projects/qt/checks-parser/build/Desktop-RelWithDebInfo @@ -267,14 +267,14 @@ 2 false - -DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} --DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} + -DCMAKE_GENERATOR:STRING=Ninja +-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo -DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} +-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} -DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} --DCMAKE_GENERATOR:STRING=Ninja --DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake --DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} +-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} +-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} 0 /home/leca/projects/qt/checks-parser/build/Desktop-Profile @@ -322,14 +322,14 @@ 2 false - -DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} --DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} + -DCMAKE_GENERATOR:STRING=Ninja +-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake -DCMAKE_BUILD_TYPE:STRING=MinSizeRel -DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} +-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} -DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} --DCMAKE_GENERATOR:STRING=Ninja --DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake --DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} +-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} +-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} /home/leca/projects/qt/checks-parser/build/Desktop-MinSizeRel diff --git a/captcha.png b/captcha.png new file mode 100644 index 0000000..dee9d34 Binary files /dev/null and b/captcha.png differ diff --git a/main.cpp b/main.cpp index a9e3ac8..081b897 100644 --- a/main.cpp +++ b/main.cpp @@ -21,17 +21,17 @@ int main(int argc, char *argv[]) { OFD ofd; Net n; - std::vector ofd_updates = ofd.check_updates(); - for (const std::string &update : ofd_updates) { - std::cout << "Downloading " - << s.get_setting("ofds_modules_url") + update << " to " - << get_path_relative_to_home(s.get_setting("ofds_modules_dir") + - "/" + update) - << std::endl; - n.get_file(s.get_setting("ofds_modules_url") + "/" + update, - get_path_relative_to_home(s.get_setting("ofds_modules_dir") + - "/" + update)); - } + // std::vector ofd_updates = ofd.check_updates(); + // for (const std::string &update : ofd_updates) { + // std::cout << "Downloading " + // << s.get_setting("ofds_modules_url") + update << " to " + // << get_path_relative_to_home(s.get_setting("ofds_modules_dir") + + // "/" + update) + // << std::endl; + // n.get_file(s.get_setting("ofds_modules_url") + "/" + update, + // get_path_relative_to_home(s.get_setting("ofds_modules_dir") + + // "/" + update)); + // } Parser p; std::vector stores_updates = p.check_updates();\ diff --git a/mainwindow.cpp b/mainwindow.cpp index 7c5f6d4..bbd9ffd 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -36,9 +36,9 @@ void MainWindow::setupStoresList() { #endif } -void MainWindow::on_checkType_currentIndexChanged(int index) { - ui->inputHolder->setCurrentIndex(index); -} +// void MainWindow::on_checkType_currentIndexChanged(int index) { +// ui->inputHolder->setCurrentIndex(index); +// } void MainWindow::on_parseButton_clicked() { QString s; @@ -82,7 +82,7 @@ void MainWindow::on_chooseImageButton_clicked() { std::cout << filename.toStdString() << std::endl; // this->options.set_path(filename.toStdString()); - std::string new_text = "Path to export: " + filename.toStdString(); + std::string new_text = "Selected: " + filename.toStdString(); ui->pathLabel->setText(QString::fromStdString(new_text)); CheckImage i(filename.toStdString()); diff --git a/mainwindow.h b/mainwindow.h index 6995ec2..3fd8086 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -25,7 +25,7 @@ public: Check get_check(); private slots: - void on_checkType_currentIndexChanged(int index); + // void on_checkType_currentIndexChanged(int index); void on_parseButton_clicked(); diff --git a/mainwindow.ui b/mainwindow.ui index 4b8482f..cdca4ae 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -70,95 +70,6 @@ - - - - 10 - 80 - 501 - 471 - - - - 0 - - - - - - 10 - 10 - 101 - 18 - - - - Check content - - - - - - 10 - 50 - 431 - 401 - - - - - - - - - 110 - 20 - 381 - 18 - - - - Path to image: - - - - - - 10 - 20 - 80 - 26 - - - - Choose - - - - - - 10 - 50 - 571 - 18 - - - - Here is recognised check text. Please, edit it if something's wrong: - - - - - - 10 - 80 - 471 - 371 - - - - - @@ -185,6 +96,106 @@ Preferences + + + + 10 + 80 + 601 + 471 + + + + 0 + + + + Text + + + + + 0 + 0 + 101 + 18 + + + + Check content + + + + + + 0 + 30 + 431 + 241 + + + + + + + OCR + + + + + 0 + 0 + 80 + 26 + + + + Choose + + + + + + 0 + 60 + 471 + 231 + + + + + + + 100 + 0 + 381 + 18 + + + + Path to image: + + + + + + 0 + 30 + 571 + 18 + + + + Here is recognised check text. Please, edit it if something's wrong: + + + + + + OFD + + + diff --git a/ofd.desc b/ofd.desc new file mode 100644 index 0000000..8c903e2 --- /dev/null +++ b/ofd.desc @@ -0,0 +1,2 @@ +1. curl -X GET https://check.ofd.ru/api/captcha/common/img +2. curl 'https://check.ofd.ru/Document/FetchReceiptFromFns' -H 'content-type: application/json;charset=UTF-8' --data-raw '{"TotalSum":52344,"FnNumber":"7281440701327430","ReceiptOperationType":"1","DocNumber":"25955","DocFiscalSign":"2518183888","Captcha":"INSERT SOLVED CAPTCHA","DocDateTime":"2024-08-16T19:36:00.000Z"}' diff --git a/ofd/module.h b/ofd/module.h deleted file mode 100644 index 09bdfcd..0000000 --- a/ofd/module.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef OFD_MODULE_H -#define OFD_MODULE_H - -#include - -class OFDModule { - std::string path; - std::wstring name; - std::wstring url; -public: - OFDModule(std::string); - OFDModule(); - - std::wstring get_name(); - std::wstring get_url(); -}; - -#endif // OFDMODULE_H diff --git a/ofd/ofd.cpp b/ofd/ofd.cpp index ee3689d..0333ae9 100644 --- a/ofd/ofd.cpp +++ b/ofd/ofd.cpp @@ -1,67 +1,3 @@ #include "ofd.h" -#include "../utils/utils.h" -#include -#include -#include -#include -#include "../net/net.h" -#include "../settings/settings.h" OFD::OFD() {} - -OFD::OFD(std::string path) { this->module = OFDModule(path); }; - -std::vector OFD::search_ofds() { - Settings s(get_path_relative_to_home(".local/share/checks_parser/settings.json")); - std::vector result{}; - - std::string path = get_path_relative_to_home(s.get_setting("ods_modules_dir")); - std::filesystem::directory_entry modules_dir(path); - - if (!modules_dir.exists()) { - std::filesystem::create_directories(path); - std::cout << "No modules directory found. Created one at " << path - << std::endl; - std::cout << "Please, download modules to that directory from my git." - << std::endl; - } - - for (auto file : std::filesystem::directory_iterator(path)) { - result.push_back(file.path()); - } - - return result; -} - -void OFD::set_module(std::string path) { this->module = OFDModule(path); } - -std::string OFD::get_check_data(std::string fn, std::string fd, - std::string fp) { - //TODO - return ""; -} - -std::vector OFD::check_updates() { - Settings s(get_path_relative_to_home(".local/share/checks_parser/settings.json")); - - std::string path = get_path_relative_to_home(s.get_setting("ofds_modules_dir")); - std::vector to_download; - std::vector stored_modules; - - for (const auto& file : std::filesystem::directory_iterator(path)) { - if (!file.is_regular_file()) continue; - stored_modules.push_back(file.path().filename()); - std::cout << "Detected OFD module" << file.path().filename() << std::endl; - } - Net n; - std::vector remote_modules = n.get_all_modules(s.get_setting("ofds_modules_url")); - - for (const std::string& module : remote_modules) { - if (!vector_contains_element(stored_modules, module)) { - to_download.push_back(module); - std::cout << "I need to download OFD module " << module << std::endl; - } - } - - return to_download; -} diff --git a/ofd/ofd.h b/ofd/ofd.h index 6f98355..22c1325 100644 --- a/ofd/ofd.h +++ b/ofd/ofd.h @@ -2,22 +2,12 @@ #define OFD_H #include -#include -#include "module.h" class OFD { - OFDModule module; - public: OFD(); - OFD(std::string); - - std::vector search_ofds(); - - void set_module(std::string); - - std::string get_check_data(std::string fn, std::string fd, std::string fp); - std::vector check_updates(); + void ask_captcha(); + std::string request_and_parse_check(long fiscal_number, long fiscal_document, long fiscal_sign, std::string datetime, double total, std::string captcha); }; #endif // OFD_H diff --git a/output/output_options.h b/output/output_options.h index 78ee716..1c66b40 100644 --- a/output/output_options.h +++ b/output/output_options.h @@ -3,6 +3,12 @@ #include #include +#include +#include +#include +#include +#include "../net/net.h" +#include "../settings/settings.h" enum class ColumnType { goods_name, @@ -18,7 +24,6 @@ struct Column { // Example: unsigned int position; // "0" <-- 0 = "A", 1 = "B", etc.. column letter in // table processor (i.e. excel or libreoffice) } typedef Column; - enum class OutputFormat { csv, ods, xlsx, plaintext } typedef OutputFormat; class OutputOptions {