Skip to content

Commit

Permalink
Shared - Add libofx and rapidcsv
Browse files Browse the repository at this point in the history
  • Loading branch information
nlogozzo committed Feb 19, 2024
1 parent 71037f8 commit df85a1c
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
33 changes: 33 additions & 0 deletions flatpak/org.nickvision.money.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
5 changes: 4 additions & 1 deletion libdenaro/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 $<IF:$<TARGET_EXISTS:podofo_shared>,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 $<IF:$<TARGET_EXISTS:podofo_shared>,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}")
Expand Down
24 changes: 23 additions & 1 deletion libdenaro/src/models/account.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Transaction> Account::sendTransfer(const Transfer& transfer, const Color& color)
Expand Down Expand Up @@ -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 {};
}

Expand Down
30 changes: 29 additions & 1 deletion snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit df85a1c

Please sign in to comment.