diff --git a/README.md b/README.md index a4d91a97..bf328dfe 100644 --- a/README.md +++ b/README.md @@ -31,10 +31,10 @@ A C++20 compiler is also required to build Denaro. 1. Set the `VCPKG_ROOT` environment variable to the path of your vcpkg installation's root directory. ### Windows 1. Set the `VCPKG_DEFAULT_TRIPLET` environment variable to `x64-windows` -1. Run `vcpkg install boost-date-time libnick matplotplusplus podofo` +1. Run `vcpkg install boost-date-time libnick libofx matplotplusplus podofo rapidcsv` ### Linux 1. Set the `VCPKG_DEFAULT_TRIPLET` environment variable to `x64-linux` -1. Run `vcpkg install boost-date-time libnick libxmlpp matplotplusplus podofo` +1. Run `vcpkg install boost-date-time libnick libofx libxmlpp matplotplusplus podofo rapidcsv` ## Building 1. First, clone/download the repo. diff --git a/flatpak/org.nickvision.money.json b/flatpak/org.nickvision.money.json index 8393c909..bba7e668 100644 --- a/flatpak/org.nickvision.money.json +++ b/flatpak/org.nickvision.money.json @@ -93,6 +93,25 @@ } ] }, + { + "name": "libofx", + "buildsystem": "cmake-ninja", + "builddir": true, + "config-opts": [ + "-DCMAKE_BUILD_TYPE=Release", + "-DENABLE_ICONV=OFF", + "-DENABLE_OFX2QIF=OFF", + "-DENABLE_OFXDUMP=OFF", + "-DENABLE_OFXCONNECT=OFF" + ], + "sources": [ + { + "type": "git", + "url": "https://github.com/libofx/libofx", + "tag": "0.10.9" + } + ] + }, { "name": "libxmlplusplus", "buildsystem": "meson", @@ -142,6 +161,20 @@ } ] }, + { + "name": "rapidcsv", + "buildsystem": "cmake-ninja", + "config-opts": [ + "-DCMAKE_BUILD_TYPE=Release" + ], + "sources": [ + { + "type": "git", + "url": "https://github.com/d99kris/rapidcsv", + "tag": "v8.80" + } + ] + }, { "name": "org.nickvision.money", "buildsystem": "cmake-ninja", diff --git a/libdenaro/CMakeLists.txt b/libdenaro/CMakeLists.txt index 4ccae3b6..9ff09595 100644 --- a/libdenaro/CMakeLists.txt +++ b/libdenaro/CMakeLists.txt @@ -30,9 +30,12 @@ endif() find_package(libnick CONFIG REQUIRED) find_package(Boost REQUIRED COMPONENTS date_time) +find_package(LibOFX CONFIG REQUIRED) find_package(Matplot++ CONFIG REQUIRED) find_package(podofo CONFIG REQUIRED) -target_link_libraries(libdenaro PUBLIC libnick::libnick Boost::date_time Matplot++::cimg Matplot++::matplot $,podofo_shared,podofo_static>) +find_path(RAPIDCSV_INCLUDE_DIRS "rapidcsv.h") +target_link_libraries(libdenaro PUBLIC libnick::libnick Boost::date_time libofx::libofx Matplot++::cimg Matplot++::matplot OpenSP::OpenSP $,podofo_shared,podofo_static>) +target_include_directories(libdenaro PUBLIC ${RAPIDCSV_INCLUDE_DIRS}) if(HAS_GETTEXT) add_custom_command(TARGET libdenaro POST_BUILD COMMAND "${GETTEXT_XGETTEXT_EXECUTABLE}" --from-code=utf-8 --add-comments --c++ --force-po --output="${POT_FILE}" --keyword=_ --keyword=_n:1,2 --keyword=_p:1c,2 --keyword=_pn:1c,2,3 --keyword=C_:1c,2 --width=80 ${TRANSLATE_FILES} WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}") diff --git a/libdenaro/src/models/account.cpp b/libdenaro/src/models/account.cpp index 965b9194..7c38c9b6 100644 --- a/libdenaro/src/models/account.cpp +++ b/libdenaro/src/models/account.cpp @@ -612,7 +612,12 @@ namespace Nickvision::Money::Shared::Models bool Account::syncRepeatTransactions() { - return false; + //Delete repeat transactions if the date from the original transaction was changed to a smaller date + SqlStatement statement{ m_database.createStatement("DELETE FROM transactions WHERE repeatFrom > 0 AND (SELECT fixDate(date) FROM transactions WHERE id = repeatFrom) < fixDate(date)") }; + bool res{ !statement.step() }; + //Add missing repeat transactions up until today + + return res; } std::optional Account::sendTransfer(const Transfer& transfer, const Color& color) @@ -653,6 +658,23 @@ namespace Nickvision::Money::Shared::Models ImportResult Account::importFromFile(const std::filesystem::path& path, const Color& defaultTransactionColor, const Color& defaultGroupColor) { + if(!std::filesystem::exists(path)) + { + return {}; + } + std::string extension{ StringHelpers::toLower(path.extension().string()) }; + if(extension == ".csv") + { + return importFromCSV(path, defaultTransactionColor, defaultGroupColor); + } + else if(extension == ".ofx") + { + return importFromOFX(path, defaultTransactionColor); + } + else if(extension == ".qif") + { + return importFromQIF(path, defaultTransactionColor, defaultGroupColor); + } return {}; } diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index f88787a0..ebb73c36 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -74,6 +74,22 @@ parts: - uuid-dev override-prime: '' + libofx: + after: [build-deps] + source: https://github.com/libofx/libofx.git + source-tag: '0.10.9' + source-depth: 1 + plugin: cmake + cmake-parameters: + - -DCMAKE_INSTALL_PREFIX=/usr + - -DCMAKE_BUILD_TYPE=Release + - -DENABLE_ICONV=OFF + - -DENABLE_OFX2QIF=OFF + - -DENABLE_OFXDUMP=OFF + - -DENABLE_OFXCONNECT=OFF + build-environment: + - CPLUS_INCLUDE_PATH: ${CRAFT_STAGE}/include + libxmlplusplus: after: [build-deps] source: https://github.com/libxmlplusplus/libxmlplusplus.git @@ -115,8 +131,20 @@ parts: build-environment: - CPLUS_INCLUDE_PATH: ${CRAFT_STAGE}/include + rapidcsv: + after: [build-deps] + source: https://github.com/d99kris/rapidcsv.git + source-tag: 'v8.80' + source-depth: 1 + plugin: cmake + cmake-parameters: + - -DCMAKE_INSTALL_PREFIX=/usr + - -DCMAKE_BUILD_TYPE=Release + build-environment: + - CPLUS_INCLUDE_PATH: ${CRAFT_STAGE}/include + denaro: - after: [build-deps, maddy, libnick, libxmlplusplus, matplotplusplus, podofo] + after: [build-deps, maddy, libnick, libofx, libxmlplusplus, matplotplusplus, podofo, rapidcsv] plugin: cmake source: . build-snaps: