Compare commits
172 Commits
8ec6e48938
...
renovate/e
Author | SHA1 | Date | |
---|---|---|---|
2490b5b4f4 | |||
11fb50af9a | |||
76d1430ecb | |||
22848bcec4 | |||
d2f948c8fa | |||
05aff4bbfb | |||
74b1a4dbcc | |||
8ad7b589ce | |||
ff20cb7bc9 | |||
1c345127b4 | |||
71e54b8d72 | |||
13a8bbad1d | |||
ec212902e9 | |||
6786ed6075 | |||
c881f58cf4 | |||
586204dcba | |||
da56f99ce6 | |||
57d2b1bf6a | |||
831ccd073c | |||
c5269a587b | |||
71ce57d205 | |||
d57107cfc1 | |||
68a3eb4218 | |||
514f140527 | |||
4bac50b676 | |||
884b86daa9 | |||
64365916bd | |||
77c0640ec0 | |||
96c80eb18c | |||
0cde9f5635 | |||
5e35dae02f | |||
f321376990 | |||
86b86d4d68 | |||
35c629a339 | |||
da0d5adcb9 | |||
2214387010 | |||
667ce69be8 | |||
57f4ed53f6 | |||
deb884a1f0 | |||
0e5d878e30 | |||
b266cbcadb | |||
91bca2b6b1 | |||
a741662251 | |||
34f0493c51 | |||
b538b6fcb3 | |||
9d18d975d0 | |||
43049bc229 | |||
19ca17b43a | |||
572046f418 | |||
24af473dd3 | |||
8a57c57ec4 | |||
50a5e7745f | |||
675e4d9ecd | |||
83c214af7d | |||
bfa6af5749 | |||
6ab157504c | |||
bb98ea5e46 | |||
2d104a54b5 | |||
3b0ff29bc8 | |||
4ade72a0ee | |||
6021b44a13 | |||
eb92e8c0c5 | |||
d98305908c | |||
ae5ef99e3a | |||
2f592183e4 | |||
74291a258c | |||
df8cd6a046 | |||
079fbbf154 | |||
ba443629e6 | |||
2c07a69b90 | |||
0de551f1de | |||
2488ef0125 | |||
aa2e764262 | |||
1202219e98 | |||
112597084c | |||
4f64404ffa | |||
c39b53c721 | |||
bd2e343601 | |||
85ee2b2549 | |||
154551aeaf | |||
7b10c3508a | |||
61c96629a1 | |||
8644075a09 | |||
81bfa75eec | |||
de0dd4e36a | |||
f9d7a63738 | |||
0ef6f8288f | |||
2f23e4dadb | |||
5cf5fac8f4 | |||
8e143db354 | |||
1237c9706e | |||
1add0b4cfe | |||
6920d6d9b0 | |||
27e92660f1 | |||
743e5ba410 | |||
8039b1c807 | |||
9ef84ba63a | |||
56e5ae6629 | |||
4443131516 | |||
365d7589b1 | |||
23cc189e53 | |||
3098d12e8a | |||
0943104cc8 | |||
3beaba806a | |||
1788e7f184 | |||
71d32d72ef | |||
28f61a3099 | |||
f61e3541fb | |||
fb7891d913 | |||
d9ede224cf | |||
fc9334b20b | |||
c4cbd7ec8b | |||
a4ef3e74dc | |||
dbb988f2b5 | |||
b2aff4902d | |||
6f578b39f9 | |||
de519ecb6c | |||
3049e545e9 | |||
1f1c01a287 | |||
92885b8af6 | |||
44320db760 | |||
1f2a28aa65 | |||
f9566315eb | |||
63bed07015 | |||
4b84d926d4 | |||
8191a28986 | |||
8c30b50d0c | |||
389b2c96ba | |||
5a08b0c971 | |||
b3fd066633 | |||
5c987473a5 | |||
c3d2612f9a | |||
130cc1ef0d | |||
aebefd114a | |||
34d3e08149 | |||
ccd3540804 | |||
b9b871224b | |||
17a22d7a4c | |||
8db2cf3ece | |||
e45648e038 | |||
55144da943 | |||
5065f780f2 | |||
28d8b96ebe | |||
baf62aa2a5 | |||
8a9a8d6b14 | |||
c19d46a50f | |||
f001c618cd | |||
f9d46e46a5 | |||
96f1bf589c | |||
467393dad0 | |||
f619f26e93 | |||
cc4ce19af2 | |||
192dc5827b | |||
37674a6229 | |||
ef86667029 | |||
07f63a96fa | |||
fa88a3c9ed | |||
85c6a0b955 | |||
21ee97b8a4 | |||
119f026a21 | |||
d72acfac9b | |||
77c8866bb8 | |||
133f235639 | |||
7ef0499abf | |||
1383da4483 | |||
4f1a9d0865 | |||
31803feaa9 | |||
aad32f9c25 | |||
1ea2bd6acf | |||
a085116018 | |||
952a66042c | |||
6cf6ab5a37 |
59
.drone.yml
59
.drone.yml
@@ -4,9 +4,17 @@ type: docker
|
||||
name: default
|
||||
|
||||
steps:
|
||||
# Needs a full git clone
|
||||
- name: fetch
|
||||
image: alpine/git
|
||||
commands:
|
||||
- git fetch --tags
|
||||
|
||||
# Frontend
|
||||
- name: web_build
|
||||
image: node:23
|
||||
depends_on:
|
||||
- fetch
|
||||
volumes:
|
||||
- name: web_app
|
||||
path: /tmp/web_build
|
||||
@@ -20,6 +28,8 @@ steps:
|
||||
# Backend
|
||||
- name: backend_fetch_deps
|
||||
image: rust
|
||||
depends_on:
|
||||
- fetch
|
||||
volumes:
|
||||
- name: rust_registry
|
||||
path: /usr/local/cargo/registry
|
||||
@@ -54,6 +64,9 @@ steps:
|
||||
|
||||
- name: backend_build
|
||||
image: rust
|
||||
when:
|
||||
event:
|
||||
- tag
|
||||
volumes:
|
||||
- name: rust_registry
|
||||
path: /usr/local/cargo/registry
|
||||
@@ -72,12 +85,58 @@ steps:
|
||||
- ls -lah target/release/moneymgr_backend target/release/examples/api_curl
|
||||
- cp target/release/moneymgr_backend target/release/examples/api_curl /tmp/release
|
||||
|
||||
# Mobile app code quality
|
||||
- name: mobile_app_code_quality
|
||||
image: ghcr.io/cirruslabs/flutter:latest
|
||||
depends_on:
|
||||
- fetch
|
||||
commands:
|
||||
- echo "Build version:" $(git describe --tags --abbrev=0)
|
||||
- echo "Build number:" $(git rev-list --count $(git describe --tags --abbrev=0))
|
||||
- cd moneymgr_mobile
|
||||
- flutter --disable-analytics
|
||||
- flutter pub get --enforce-lockfile
|
||||
- dart run build_runner build
|
||||
- flutter analyze
|
||||
|
||||
# Mobile app build
|
||||
- name: mobile_app_build
|
||||
image: ghcr.io/cirruslabs/flutter:latest
|
||||
depends_on:
|
||||
- backend_build # prevent synchronous backend & frontend build
|
||||
- mobile_app_code_quality
|
||||
when:
|
||||
event:
|
||||
- tag
|
||||
environment:
|
||||
JKS_KEYSTORE:
|
||||
from_secret: JKS_KEYSTORE
|
||||
JKS_KEYSTORE_PASSWORD:
|
||||
from_secret: JKS_KEYSTORE_PASSWORD
|
||||
volumes:
|
||||
- name: release
|
||||
path: /tmp/release
|
||||
commands:
|
||||
- cd moneymgr_mobile
|
||||
- flutter --disable-analytics
|
||||
- bash android/ci_write_keystore.sh
|
||||
- flutter pub get --enforce-lockfile
|
||||
- dart run build_runner build
|
||||
- flutter build apk
|
||||
--release
|
||||
--flavor publish
|
||||
--build-name $(git describe --tags --abbrev=0)
|
||||
--split-per-abi
|
||||
--target-platform android-arm64
|
||||
--build-number $(git rev-list --count $(git describe --tags --abbrev=0))
|
||||
- cp build/app/outputs/flutter-apk/app-arm64-v8a-publish-release.apk /tmp/release/moneymgr_mobile_arm64-v8a.apk
|
||||
|
||||
# Release
|
||||
- name: gitea_release
|
||||
image: plugins/gitea-release
|
||||
depends_on:
|
||||
- backend_build
|
||||
- mobile_app_build
|
||||
when:
|
||||
event:
|
||||
- tag
|
||||
|
69
moneymgr_backend/Cargo.lock
generated
69
moneymgr_backend/Cargo.lock
generated
@@ -36,9 +36,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "actix-files"
|
||||
version = "0.6.6"
|
||||
version = "0.6.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0773d59061dedb49a8aed04c67291b9d8cf2fe0b60130a381aab53c6dd86e9be"
|
||||
checksum = "6c0d87f10d70e2948ad40e8edea79c8e77c6c66e0250a4c1f09b690465199576"
|
||||
dependencies = [
|
||||
"actix-http",
|
||||
"actix-service",
|
||||
@@ -46,7 +46,7 @@ dependencies = [
|
||||
"actix-web",
|
||||
"bitflags",
|
||||
"bytes",
|
||||
"derive_more 0.99.20",
|
||||
"derive_more 2.0.1",
|
||||
"futures-core",
|
||||
"http-range",
|
||||
"log",
|
||||
@@ -87,7 +87,7 @@ dependencies = [
|
||||
"mime",
|
||||
"percent-encoding",
|
||||
"pin-project-lite",
|
||||
"rand 0.9.1",
|
||||
"rand 0.9.2",
|
||||
"sha1",
|
||||
"smallvec",
|
||||
"tokio",
|
||||
@@ -364,12 +364,6 @@ dependencies = [
|
||||
"alloc-no-stdlib",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "android-tzdata"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0"
|
||||
|
||||
[[package]]
|
||||
name = "android_system_properties"
|
||||
version = "0.1.5"
|
||||
@@ -431,9 +425,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.98"
|
||||
version = "1.0.100"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487"
|
||||
checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61"
|
||||
|
||||
[[package]]
|
||||
name = "arbitrary"
|
||||
@@ -700,16 +694,15 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "chrono"
|
||||
version = "0.4.41"
|
||||
version = "0.4.42"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c469d952047f47f91b68d1cba3f10d63c11d73e4636f24f08daf0278abf01c4d"
|
||||
checksum = "145052bdd345b87320e369255277e3fb5152762ad123a901ef5c262dd38fe8d2"
|
||||
dependencies = [
|
||||
"android-tzdata",
|
||||
"iana-time-zone",
|
||||
"js-sys",
|
||||
"num-traits",
|
||||
"wasm-bindgen",
|
||||
"windows-link",
|
||||
"windows-link 0.2.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -724,9 +717,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.5.40"
|
||||
version = "4.5.48"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "40b6887a1d8685cebccf115538db5c0efe625ccac9696ad45c409d96566e910f"
|
||||
checksum = "e2134bb3ea021b78629caa971416385309e0131b351b25e01dc16fb54e1b5fae"
|
||||
dependencies = [
|
||||
"clap_builder",
|
||||
"clap_derive",
|
||||
@@ -734,9 +727,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap_builder"
|
||||
version = "4.5.40"
|
||||
version = "4.5.48"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e0c66c08ce9f0c698cbce5c0279d0bb6ac936d8674174fe48f736533b964f59e"
|
||||
checksum = "c2ba64afa3c0a6df7fa517765e31314e983f51dda798ffba27b988194fb65dc9"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
@@ -746,9 +739,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "4.5.40"
|
||||
version = "4.5.47"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d2c7947ae4cc3d851207c1adb5b5e260ff0cca11446b1d6d1423788e442257ce"
|
||||
checksum = "bbfd7eae0b0f1a6e63d4b13c9c478de77c2eb546fba158ad50b4203dc24b9f9c"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
@@ -1100,9 +1093,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "diesel"
|
||||
version = "2.2.11"
|
||||
version = "2.2.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a917a9209950404d5be011c81d081a2692a822f73c3d6af586f0cab5ff50f614"
|
||||
checksum = "229850a212cd9b84d4f0290ad9d294afc0ae70fccaa8949dbe8b43ffafa1e20c"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"byteorder",
|
||||
@@ -2157,9 +2150,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.27"
|
||||
version = "0.4.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
|
||||
checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432"
|
||||
|
||||
[[package]]
|
||||
name = "lzma-rs"
|
||||
@@ -2298,7 +2291,7 @@ dependencies = [
|
||||
"light-openid",
|
||||
"log",
|
||||
"mime_guess",
|
||||
"rand 0.9.1",
|
||||
"rand 0.9.2",
|
||||
"rust-embed",
|
||||
"rust-s3",
|
||||
"rust_xlsxwriter",
|
||||
@@ -2741,9 +2734,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.9.1"
|
||||
version = "0.9.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9fbfd9d094a40bf3ae768db9361049ace4c0e04a4fd6b359518bd7b73a73dd97"
|
||||
checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1"
|
||||
dependencies = [
|
||||
"rand_chacha 0.9.0",
|
||||
"rand_core 0.9.3",
|
||||
@@ -3232,9 +3225,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.140"
|
||||
version = "1.0.142"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373"
|
||||
checksum = "030fedb782600dcbd6f02d479bf0d817ac3bb40d644745b769d6a96bc3afc5a7"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"memchr",
|
||||
@@ -3994,7 +3987,7 @@ checksum = "46ec44dc15085cea82cf9c78f85a9114c463a369786585ad2882d1ff0b0acf40"
|
||||
dependencies = [
|
||||
"windows-implement",
|
||||
"windows-interface",
|
||||
"windows-link",
|
||||
"windows-link 0.1.1",
|
||||
"windows-result",
|
||||
"windows-strings 0.4.1",
|
||||
]
|
||||
@@ -4027,6 +4020,12 @@ version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "76840935b766e1b0a05c0066835fb9ec80071d4c09a16f6bd5f7e655e3c14c38"
|
||||
|
||||
[[package]]
|
||||
name = "windows-link"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "45e46c0661abb7180e7b9c281db115305d49ca1709ab8242adf09666d2173c65"
|
||||
|
||||
[[package]]
|
||||
name = "windows-registry"
|
||||
version = "0.4.0"
|
||||
@@ -4044,7 +4043,7 @@ version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4b895b5356fc36103d0f64dd1e94dfa7ac5633f1c9dd6e80fe9ec4adef69e09d"
|
||||
dependencies = [
|
||||
"windows-link",
|
||||
"windows-link 0.1.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4053,7 +4052,7 @@ version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "87fa48cc5d406560701792be122a10132491cff9d0aeb23583cc2dcafc847319"
|
||||
dependencies = [
|
||||
"windows-link",
|
||||
"windows-link 0.1.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4062,7 +4061,7 @@ version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2a7ab927b2637c19b3dbe0965e75d8f2d30bdd697a1516191cad2ec4df8fb28a"
|
||||
dependencies = [
|
||||
"windows-link",
|
||||
"windows-link 0.1.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@@ -5,26 +5,26 @@ edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
env_logger = "0.11.8"
|
||||
log = "0.4.27"
|
||||
diesel = { version = "2.2.11", features = ["postgres", "r2d2"] }
|
||||
log = "0.4.28"
|
||||
diesel = { version = "2.2.12", features = ["postgres", "r2d2"] }
|
||||
diesel_migrations = "2.2.0"
|
||||
clap = { version = "4.5.40", features = ["env", "derive"] }
|
||||
clap = { version = "4.5.48", features = ["env", "derive"] }
|
||||
actix-web = "4.11.0"
|
||||
actix-cors = "0.7.1"
|
||||
actix-multipart = "0.7.2"
|
||||
actix-remote-ip = "0.1.0"
|
||||
actix-session = { version = "0.10.1", features = ["redis-session"] }
|
||||
actix-files = "0.6.6"
|
||||
actix-files = "0.6.8"
|
||||
lazy_static = "1.5.0"
|
||||
anyhow = "1.0.98"
|
||||
anyhow = "1.0.100"
|
||||
serde = { version = "1.0.219", features = ["derive"] }
|
||||
rust-s3 = "0.36.0-beta.2"
|
||||
thiserror = "2.0.12"
|
||||
tokio = "1.45.1"
|
||||
futures-util = "0.3.31"
|
||||
serde_json = "1.0.140"
|
||||
serde_json = "1.0.142"
|
||||
light-openid = "1.0.4"
|
||||
rand = "0.9.1"
|
||||
rand = "0.9.2"
|
||||
ipnet = { version = "2.11.0", features = ["serde"] }
|
||||
lazy-regex = "3.4.1"
|
||||
jwt-simple = { version = "0.12.12", default-features = false, features = ["pure-rust"] }
|
||||
@@ -33,7 +33,7 @@ rust-embed = { version = "8.7.2" }
|
||||
sha2 = "0.11.0-rc.0"
|
||||
base16ct = "0.2.0"
|
||||
httpdate = "1.0.3"
|
||||
chrono = "0.4.41"
|
||||
chrono = "0.4.42"
|
||||
tempfile = "3.20.0"
|
||||
zip = "3.0.0"
|
||||
rust_xlsxwriter = "0.87.0"
|
@@ -29,7 +29,7 @@ pub struct AppConfig {
|
||||
/// Unsecure : for development, bypass authentication, using the account with the given
|
||||
/// email address by default
|
||||
#[clap(long, env)]
|
||||
pub unsecure_auto_login_email: Option<String>,
|
||||
unsecure_auto_login_email: Option<String>,
|
||||
|
||||
/// PostgreSQL database host
|
||||
#[clap(long, env, default_value = "localhost")]
|
||||
@@ -126,6 +126,14 @@ pub struct AppConfig {
|
||||
/// Redis password
|
||||
#[clap(long, env, default_value = "secretredis")]
|
||||
redis_password: String,
|
||||
|
||||
/// Application download URL
|
||||
#[clap(
|
||||
long,
|
||||
env,
|
||||
default_value = "https://gitea.communiquons.org/pierre/MoneyMgr/releases/download/latest/moneymgr_mobile_arm64-v8a.apk"
|
||||
)]
|
||||
pub apk_download_url: String,
|
||||
}
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
@@ -140,9 +148,17 @@ impl AppConfig {
|
||||
&ARGS
|
||||
}
|
||||
|
||||
/// Get auto login email (if not empty)
|
||||
pub fn unsecure_auto_login_email(&self) -> Option<&str> {
|
||||
match self.unsecure_auto_login_email.as_deref() {
|
||||
None | Some("") => None,
|
||||
s => s,
|
||||
}
|
||||
}
|
||||
|
||||
/// Check if auth is disabled
|
||||
pub fn is_auth_disabled(&self) -> bool {
|
||||
self.unsecure_auto_login_email.is_some()
|
||||
self.unsecure_auto_login_email().is_some()
|
||||
}
|
||||
|
||||
/// Get auth cookie domain
|
||||
|
@@ -70,6 +70,7 @@ impl Default for ServerConstraints {
|
||||
struct ServerConfig {
|
||||
auth_disabled: bool,
|
||||
oidc_provider_name: &'static str,
|
||||
apk_download_url: &'static str,
|
||||
accounts_types: &'static [AccountTypeDesc],
|
||||
constraints: ServerConstraints,
|
||||
}
|
||||
@@ -79,6 +80,7 @@ impl Default for ServerConfig {
|
||||
Self {
|
||||
auth_disabled: AppConfig::get().is_auth_disabled(),
|
||||
oidc_provider_name: AppConfig::get().openid_provider().name,
|
||||
apk_download_url: AppConfig::get().apk_download_url.as_str(),
|
||||
constraints: Default::default(),
|
||||
accounts_types: &ACCOUNT_TYPES,
|
||||
}
|
||||
|
@@ -56,7 +56,7 @@ impl FromRequest for AuthExtractor {
|
||||
};
|
||||
|
||||
Box::pin(async move {
|
||||
// Check for authentication using OpenID
|
||||
// Check for authentication using API token
|
||||
if let Some(token) = req.headers().get(constants::API_TOKEN_HEADER) {
|
||||
let Ok(jwt_token) = token.to_str() else {
|
||||
return Err(actix_web::error::ErrorBadRequest(
|
||||
@@ -182,7 +182,7 @@ impl FromRequest for AuthExtractor {
|
||||
}
|
||||
|
||||
// Check if login is hard-coded as program argument
|
||||
if let Some(email) = &AppConfig::get().unsecure_auto_login_email {
|
||||
if let Some(email) = &AppConfig::get().unsecure_auto_login_email() {
|
||||
let user = users_service::get_user_by_email(email).map_err(|e| {
|
||||
log::error!("Failed to retrieve dev user: {e}");
|
||||
ErrorPreconditionFailed("Unable to retrieve dev user!")
|
||||
|
@@ -38,7 +38,7 @@ async fn main() -> std::io::Result<()> {
|
||||
db_connection::initialize_conn().expect("Failed to connect to PostgresSQL database!");
|
||||
|
||||
// Auto create default account, if requested
|
||||
if let Some(mail) = &AppConfig::get().unsecure_auto_login_email {
|
||||
if let Some(mail) = &AppConfig::get().unsecure_auto_login_email() {
|
||||
users_service::create_or_update_user(mail, "Anonymous")
|
||||
.await
|
||||
.expect("Failed to create default account!");
|
||||
|
2
moneymgr_mobile/android/.gitignore
vendored
2
moneymgr_mobile/android/.gitignore
vendored
@@ -1,3 +1,5 @@
|
||||
publish_key.properties
|
||||
|
||||
gradle-wrapper.jar
|
||||
/.gradle
|
||||
/captures/
|
||||
|
8
moneymgr_mobile/android/README.md
Normal file
8
moneymgr_mobile/android/README.md
Normal file
@@ -0,0 +1,8 @@
|
||||
# Android version of application
|
||||
|
||||
Generate keystore:
|
||||
|
||||
```bash
|
||||
keytool -genkey -v -keystore ./keystore.jks -keyalg RSA \
|
||||
-keysize 2048 -validity 20000 -alias moneymgr
|
||||
```
|
@@ -1,3 +1,6 @@
|
||||
import java.util.Properties
|
||||
import java.io.FileInputStream
|
||||
|
||||
plugins {
|
||||
id("com.android.application")
|
||||
id("kotlin-android")
|
||||
@@ -5,6 +8,12 @@ plugins {
|
||||
id("dev.flutter.flutter-gradle-plugin")
|
||||
}
|
||||
|
||||
val keystoreProperties = Properties()
|
||||
val keystorePropertiesFile = rootProject.file("publish_key.properties")
|
||||
if (keystorePropertiesFile.exists()) {
|
||||
keystoreProperties.load(FileInputStream(keystorePropertiesFile))
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "org.communiquons.moneymgr"
|
||||
compileSdk = flutter.compileSdkVersion
|
||||
@@ -21,7 +30,6 @@ android {
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
||||
applicationId = "org.communiquons.moneymgr"
|
||||
// You can update the following values to match your application needs.
|
||||
// For more information, see: https://flutter.dev/to/review-gradle-config.
|
||||
@@ -31,13 +39,34 @@ android {
|
||||
versionName = flutter.versionName
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
// TODO: Add your own signing config for the release build.
|
||||
// Signing with the debug keys for now, so `flutter run --release` works.
|
||||
signingConfig = signingConfigs.getByName("debug")
|
||||
signingConfigs {
|
||||
create("publish") {
|
||||
keyAlias = keystoreProperties["keyAlias"] as String
|
||||
keyPassword = keystoreProperties["keyPassword"] as String
|
||||
storeFile = keystoreProperties["storeFile"]?.let { file(it) }
|
||||
storePassword = keystoreProperties["storePassword"] as String
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
// signingConfig = signingConfigs.getByName("debug")
|
||||
}
|
||||
}
|
||||
|
||||
flavorDimensions += "default"
|
||||
productFlavors {
|
||||
create("development") {
|
||||
dimension = "default"
|
||||
applicationIdSuffix = ".debug"
|
||||
signingConfig = signingConfigs.getByName("debug")
|
||||
}
|
||||
create("publish") {
|
||||
dimension = "default"
|
||||
signingConfig = signingConfigs.getByName("publish")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
flutter {
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- The INTERNET permission is required for development. Specifically,
|
||||
the Flutter tool needs it to communicate with the running application
|
||||
to allow setting breakpoints, to provide hot reload, etc.
|
||||
@@ -6,5 +7,8 @@
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<!-- In debug mode, unsecure traffic is permitted -->
|
||||
<application android:usesCleartextTraffic="true" />
|
||||
<application
|
||||
android:label="MoneyMgr Debug"
|
||||
android:usesCleartextTraffic="true"
|
||||
tools:replace="android:label" />
|
||||
</manifest>
|
||||
|
@@ -0,0 +1,7 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<application
|
||||
android:allowBackup="false"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
android:fullBackupContent="false" />
|
||||
</manifest>
|
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<data-extraction-rules>
|
||||
<cloud-backup>
|
||||
<exclude domain="root" />
|
||||
<exclude domain="file" />
|
||||
<exclude domain="database" />
|
||||
<exclude domain="sharedpref" />
|
||||
<exclude domain="external" />
|
||||
</cloud-backup>
|
||||
<device-transfer>
|
||||
<exclude domain="root" />
|
||||
<exclude domain="file" />
|
||||
<exclude domain="database" />
|
||||
<exclude domain="sharedpref" />
|
||||
<exclude domain="external" />
|
||||
</device-transfer>
|
||||
</data-extraction-rules>
|
23
moneymgr_mobile/android/ci_write_keystore.sh
Normal file
23
moneymgr_mobile/android/ci_write_keystore.sh
Normal file
@@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPT_DIR="$(temp=$( realpath "$0" ) && dirname "$temp")"
|
||||
|
||||
KEYSTORE_PATH="$SCRIPT_DIR/keystore.jks"
|
||||
PROPERTIES_PATH="$SCRIPT_DIR/publish_key.properties"
|
||||
|
||||
echo Keystore path : $KEYSTORE_PATH
|
||||
echo Properties path : $PROPERTIES_PATH
|
||||
|
||||
[ ! -n "$JKS_KEYSTORE" ] && echo 'Missing JKS_KEYSTORE variable!'&& exit 1
|
||||
[ ! -n "$JKS_KEYSTORE_PASSWORD" ] && echo 'Missing JKS_KEYSTORE_PASSWORD variable!' && exit 1
|
||||
|
||||
# Write keystore
|
||||
echo $JKS_KEYSTORE | base64 -d > "$KEYSTORE_PATH"
|
||||
|
||||
# Write keystore config
|
||||
cat > "$PROPERTIES_PATH" <<_EOF
|
||||
storePassword=$JKS_KEYSTORE_PASSWORD
|
||||
keyPassword=$JKS_KEYSTORE_PASSWORD
|
||||
keyAlias=moneymgr
|
||||
storeFile=$KEYSTORE_PATH
|
||||
_EOF
|
4
moneymgr_mobile/android/publish_key.properties.sample
Normal file
4
moneymgr_mobile/android/publish_key.properties.sample
Normal file
@@ -0,0 +1,4 @@
|
||||
storePassword=<password-from-previous-step>
|
||||
keyPassword=<password-from-previous-step>
|
||||
keyAlias=upload
|
||||
storeFile=<keystore-file-location>
|
@@ -1,45 +1,31 @@
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:moneymgr_mobile/services/router/routes_list.dart';
|
||||
import 'package:moneymgr_mobile/services/storage/expenses.dart';
|
||||
import 'package:moneymgr_mobile/services/storage/prefs.dart';
|
||||
import 'package:moneymgr_mobile/utils/ocr_utils.dart';
|
||||
import 'package:moneymgr_mobile/utils/pdf_utils.dart';
|
||||
import 'package:moneymgr_mobile/widgets/expense_editor.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:scanbot_sdk/scanbot_sdk.dart';
|
||||
import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart' hide IconButton, EdgeInsets;
|
||||
|
||||
part 'scan_screen.g.dart';
|
||||
|
||||
/// Scan a document & return generated PDF as byte file
|
||||
@riverpod
|
||||
Future<Uint8List?> _scanDocument(Ref ref) async {
|
||||
var configuration = DocumentScanningFlow(
|
||||
appearance: DocumentFlowAppearanceConfiguration(
|
||||
statusBarMode: StatusBarMode.DARK,
|
||||
),
|
||||
cleanScanningSession: true,
|
||||
outputSettings: DocumentScannerOutputSettings(pagesScanLimit: 1),
|
||||
screens: DocumentScannerScreens(
|
||||
review: ReviewScreenConfiguration(enabled: false),
|
||||
),
|
||||
);
|
||||
var documentResult = await ScanbotSdkUiV2.startDocumentScanner(configuration);
|
||||
Future<(Uint8List?, BaseExpenseInfo?)> _scanDocument(Ref ref) async {
|
||||
final prefs = ref.watch(prefsProvider).requireValue;
|
||||
|
||||
if (documentResult.status != OperationStatus.OK) {
|
||||
throw Exception("Scanner failed with status ${documentResult.status}");
|
||||
}
|
||||
|
||||
// Convert result to PDF
|
||||
var result = await ScanbotSdk.document.createPDFForDocument(
|
||||
PDFFromDocumentParams(
|
||||
documentID: documentResult.data!.uuid,
|
||||
pdfConfiguration: PdfConfiguration(),
|
||||
),
|
||||
final pdf = await scanDocAsPDF();
|
||||
final img = await renderPdf(pdfBytes: pdf);
|
||||
final amount = await extractInfoFromBill(
|
||||
imgBuff: img,
|
||||
extractDates: !prefs.disableExtractDates(),
|
||||
);
|
||||
final pdfPath = result.pdfFileUri.replaceFirst("file://", "");
|
||||
return File(pdfPath).readAsBytes();
|
||||
return (pdf, amount);
|
||||
}
|
||||
|
||||
class ScanScreen extends HookConsumerWidget {
|
||||
@@ -52,8 +38,8 @@ class ScanScreen extends HookConsumerWidget {
|
||||
|
||||
restartScan() async {
|
||||
try {
|
||||
final val = ref.refresh(_scanDocumentProvider);
|
||||
Logger.root.info("Load again startup result: $val");
|
||||
ref.invalidate(_scanDocumentProvider);
|
||||
Logger.root.info("Load again startup");
|
||||
} catch (e, s) {
|
||||
Logger.root.shout("Failed to try again startup loading! $e $s");
|
||||
}
|
||||
@@ -62,21 +48,24 @@ class ScanScreen extends HookConsumerWidget {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: switch (scanDocProvider) {
|
||||
AsyncData(:final value) when value != null => ExpenseEditor(
|
||||
file: value,
|
||||
AsyncData(:final value) when value.$1 != null => ExpenseEditor(
|
||||
file: value.$1!,
|
||||
initialData: value.$2,
|
||||
onFinished: (expense) async {
|
||||
await expenses.add(
|
||||
info: expense,
|
||||
fileContent: value,
|
||||
fileContent: value.$1!,
|
||||
fileMimeType: "application/pdf",
|
||||
);
|
||||
restartScan();
|
||||
if (context.mounted) {
|
||||
context.pushReplacement(scansPage);
|
||||
}
|
||||
},
|
||||
onRescan: restartScan,
|
||||
),
|
||||
|
||||
// No data
|
||||
AsyncData(:final value) when value == null => ScanErrorScreen(
|
||||
AsyncData(:final value) when value.$1 == null => ScanErrorScreen(
|
||||
message: "No document scanned!",
|
||||
onTryAgain: restartScan,
|
||||
),
|
||||
|
@@ -48,6 +48,12 @@ class _ExpensesList extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (list.isEmpty) {
|
||||
return const Center(
|
||||
child: Text("There is no entry waiting for upload (yet)"),
|
||||
);
|
||||
}
|
||||
|
||||
return ListView.builder(
|
||||
itemBuilder: (context, entryNum) {
|
||||
final expense = list[entryNum];
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:moneymgr_mobile/providers/settings.dart';
|
||||
import 'package:moneymgr_mobile/services/storage/prefs.dart';
|
||||
import 'package:moneymgr_mobile/utils/extensions.dart';
|
||||
|
||||
class SettingsScreen extends ConsumerWidget {
|
||||
@@ -8,6 +9,7 @@ class SettingsScreen extends ConsumerWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final prefs = ref.watch(prefsProvider).requireValue;
|
||||
final themeMode = ref.watch(currentThemeModeProvider);
|
||||
|
||||
void onTapThemeMode() =>
|
||||
@@ -15,6 +17,16 @@ class SettingsScreen extends ConsumerWidget {
|
||||
|
||||
void onTapLicenses() => context.showAppLicensePage();
|
||||
|
||||
handleToggleStartScreen(v) async {
|
||||
await prefs.setStartOnScansListScreen(v);
|
||||
ref.invalidate(prefsProvider);
|
||||
}
|
||||
|
||||
handleToggleDisableExtractDate(v) async {
|
||||
await prefs.setDisableExtractDates(v);
|
||||
ref.invalidate(prefsProvider);
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Settings')),
|
||||
body: ListView(
|
||||
@@ -25,6 +37,22 @@ class SettingsScreen extends ConsumerWidget {
|
||||
trailing: Text(themeMode.label),
|
||||
onTap: onTapThemeMode,
|
||||
),
|
||||
SwitchListTile(
|
||||
value: prefs.startOnScansListScreen(),
|
||||
onChanged: handleToggleStartScreen,
|
||||
title: Text("Start on scans screen"),
|
||||
subtitle: Text(
|
||||
"Do not start camera automatically on application startup",
|
||||
),
|
||||
),
|
||||
SwitchListTile(
|
||||
value: prefs.disableExtractDates(),
|
||||
onChanged: handleToggleDisableExtractDate,
|
||||
title: Text("Do not extract dates"),
|
||||
subtitle: Text(
|
||||
"Do not attempt to extract dates from scanned expenses",
|
||||
),
|
||||
),
|
||||
const Divider(),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.info_outline),
|
||||
|
27
moneymgr_mobile/lib/services/api/inbox_api.dart
Normal file
27
moneymgr_mobile/lib/services/api/inbox_api.dart
Normal file
@@ -0,0 +1,27 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
import 'api_client.dart';
|
||||
|
||||
part 'inbox_api.freezed.dart';
|
||||
part 'inbox_api.g.dart';
|
||||
|
||||
@freezed
|
||||
abstract class UpdateInboxEntryRequest with _$UpdateInboxEntryRequest {
|
||||
const factory UpdateInboxEntryRequest({
|
||||
// ignore: non_constant_identifier_names
|
||||
required int file_id,
|
||||
required int time,
|
||||
required String? label,
|
||||
required double? amount,
|
||||
}) = _UpdateInboxEntryRequest;
|
||||
|
||||
factory UpdateInboxEntryRequest.fromJson(Map<String, dynamic> json) =>
|
||||
_$UpdateInboxEntryRequestFromJson(json);
|
||||
}
|
||||
|
||||
extension InboxApi on ApiClient {
|
||||
/// Create a new inbox entry
|
||||
Future<void> createInboxEntry(UpdateInboxEntryRequest entry) async {
|
||||
await execute("/inbox", method: "POST", data: entry.toJson());
|
||||
}
|
||||
}
|
@@ -11,6 +11,7 @@ import 'package:moneymgr_mobile/routes/scan_details/scan_details.dart';
|
||||
import 'package:moneymgr_mobile/routes/scans_list/scans_list_screen.dart';
|
||||
import 'package:moneymgr_mobile/routes/settings/settings_screen.dart';
|
||||
import 'package:moneymgr_mobile/services/router/routes_list.dart';
|
||||
import 'package:moneymgr_mobile/services/storage/prefs.dart';
|
||||
import 'package:moneymgr_mobile/widgets/load_startup_data.dart';
|
||||
import 'package:moneymgr_mobile/widgets/scaffold_with_navigation.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
@@ -29,6 +30,8 @@ GoRouter router(Ref ref) {
|
||||
authStateNotifier.value = value;
|
||||
});
|
||||
|
||||
final prefs = ref.read(prefsProvider).requireValue;
|
||||
|
||||
// This is the only place you need to define your navigation items. The items
|
||||
// will be propagated automatically to the router and the navigation bar/rail
|
||||
// of the scaffold.
|
||||
@@ -70,22 +73,22 @@ GoRouter router(Ref ref) {
|
||||
|
||||
final router = GoRouter(
|
||||
debugLogDiagnostics: true,
|
||||
initialLocation: navigationItems.first.path,
|
||||
initialLocation: prefs.startOnScansListScreen() ? scansPage : capturePage,
|
||||
routes: [
|
||||
GoRoute(path: homePage, builder: (_, __) => const Scaffold()),
|
||||
GoRoute(path: authPage, builder: (_, __) => const LoginScreen()),
|
||||
GoRoute(path: qrAuthPath, builder: (_, __) => const QrAuthScreen()),
|
||||
GoRoute(path: homePage, builder: (_, _) => const Scaffold()),
|
||||
GoRoute(path: authPage, builder: (_, _) => const LoginScreen()),
|
||||
GoRoute(path: qrAuthPath, builder: (_, _) => const QrAuthScreen()),
|
||||
GoRoute(
|
||||
path: manualAuthPage,
|
||||
builder: (_, __) => const ManualAuthScreen(),
|
||||
builder: (_, _) => const ManualAuthScreen(),
|
||||
),
|
||||
GoRoute(path: settingsPage, builder: (_, __) => const SettingsScreen()),
|
||||
GoRoute(path: settingsPage, builder: (_, _) => const SettingsScreen()),
|
||||
|
||||
// Configuration for the bottom navigation bar routes. The routes themselves
|
||||
// should be defined in [navigationItems]. Modification to this [ShellRoute]
|
||||
// config is rarely needed.
|
||||
ShellRoute(
|
||||
builder: (_, __, child) => child,
|
||||
builder: (_, _, child) => child,
|
||||
routes: [
|
||||
for (final (index, item) in navigationItems.indexed)
|
||||
GoRoute(
|
||||
|
@@ -15,6 +15,22 @@ Future<SharedPreferencesWithCache> prefs(Ref ref) =>
|
||||
);
|
||||
|
||||
extension MoneyMgrSharedPreferences on SharedPreferencesWithCache {
|
||||
bool startOnScansListScreen() {
|
||||
return getBool("startOnScansListScreen") ?? false;
|
||||
}
|
||||
|
||||
Future<void> setStartOnScansListScreen(bool start) async {
|
||||
await setBool("startOnScansListScreen", start);
|
||||
}
|
||||
|
||||
bool disableExtractDates() {
|
||||
return getBool("disableExtractDates") ?? false;
|
||||
}
|
||||
|
||||
Future<void> setDisableExtractDates(bool disable) async {
|
||||
await setBool("disableExtractDates", disable);
|
||||
}
|
||||
|
||||
ServerConfig? serverConfig() {
|
||||
final json = getString("serverConfig");
|
||||
if (json != null) return ServerConfig.fromJson(jsonDecode(json));
|
||||
|
86
moneymgr_mobile/lib/utils/ocr_utils.dart
Normal file
86
moneymgr_mobile/lib/utils/ocr_utils.dart
Normal file
@@ -0,0 +1,86 @@
|
||||
import 'dart:math';
|
||||
import 'dart:typed_data';
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:google_mlkit_text_recognition/google_mlkit_text_recognition.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:moneymgr_mobile/services/storage/expenses.dart';
|
||||
|
||||
/// Attempt to extract information from invoice image
|
||||
Future<BaseExpenseInfo?> extractInfoFromBill({
|
||||
required Uint8List imgBuff,
|
||||
required bool extractDates,
|
||||
}) async {
|
||||
final decodedImage = await decodeImageFromList(imgBuff);
|
||||
|
||||
final byteData = await decodedImage.toByteData(
|
||||
format: ui.ImageByteFormat.rawRgba,
|
||||
);
|
||||
|
||||
final image = InputImage.fromBitmap(
|
||||
bitmap: byteData!.buffer.asUint8List(),
|
||||
width: decodedImage.width,
|
||||
height: decodedImage.height,
|
||||
);
|
||||
|
||||
final textRecognizer = TextRecognizer(script: TextRecognitionScript.latin);
|
||||
final extractionResult = await textRecognizer.processImage(image);
|
||||
|
||||
Logger.root.fine("Expense text: ${extractionResult.text}");
|
||||
|
||||
// Check for highestCost amount on invoice
|
||||
final costRegexp = RegExp(
|
||||
r'([0-9]+([ ]*(\\.|,)[ ]*[0-9]{1,2}){0,1})([ \\t\\n]*(EUR|eur|€)|E)',
|
||||
multiLine: true,
|
||||
caseSensitive: false,
|
||||
);
|
||||
var highestCost = 0.0;
|
||||
for (final match in costRegexp.allMatches(extractionResult.text)) {
|
||||
if (match.groupCount == 0) continue;
|
||||
|
||||
// Process only numeric value
|
||||
final value = (match.group(1) ?? "").replaceAll(",", ".");
|
||||
highestCost = max(highestCost, double.tryParse(value) ?? 0.0);
|
||||
}
|
||||
|
||||
// Check for highestCost amount on invoice
|
||||
final dateRegexp = RegExp(
|
||||
r'([0-3][0-9])(\/|-)([0-1][0-9])(\/|-)((20|)[0-9]{2})',
|
||||
multiLine: false,
|
||||
caseSensitive: false,
|
||||
);
|
||||
final currDate = DateTime.now();
|
||||
DateTime? newest;
|
||||
for (final match in dateRegexp.allMatches(extractionResult.text)) {
|
||||
if (match.groupCount < 6) continue;
|
||||
|
||||
int year = int.tryParse(match.group(5)!) ?? currDate.year;
|
||||
|
||||
try {
|
||||
final date = DateTime(
|
||||
year > 99 ? year : (2000 + year),
|
||||
int.tryParse(match.group(3)!) ?? currDate.month,
|
||||
int.tryParse(match.group(1)!) ?? currDate.day,
|
||||
);
|
||||
|
||||
if (newest == null) {
|
||||
newest = date;
|
||||
} else {
|
||||
newest = DateTime.fromMillisecondsSinceEpoch(
|
||||
max(newest.millisecondsSinceEpoch, date.millisecondsSinceEpoch),
|
||||
);
|
||||
}
|
||||
} catch (e, s) {
|
||||
Logger.root.warning("Failed to parse date! $e$s");
|
||||
}
|
||||
}
|
||||
|
||||
return BaseExpenseInfo(
|
||||
label: null,
|
||||
cost: highestCost,
|
||||
time: extractDates && (newest?.isBefore(currDate) ?? false)
|
||||
? newest!
|
||||
: currDate,
|
||||
);
|
||||
}
|
@@ -6,14 +6,40 @@ import 'package:flutter/material.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:pdf_image_renderer/pdf_image_renderer.dart';
|
||||
import 'package:scanbot_sdk/scanbot_sdk.dart';
|
||||
import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart' hide IconButton, EdgeInsets;
|
||||
|
||||
/// Scan document as PDF
|
||||
Future<Uint8List> scanDocAsPDF() async {
|
||||
var configuration = DocumentScanningFlow(
|
||||
appearance: DocumentFlowAppearanceConfiguration(
|
||||
statusBarMode: StatusBarMode.DARK,
|
||||
),
|
||||
cleanScanningSession: true,
|
||||
outputSettings: DocumentScannerOutputSettings(pagesScanLimit: 1),
|
||||
screens: DocumentScannerScreens(
|
||||
review: ReviewScreenConfiguration(enabled: false),
|
||||
),
|
||||
);
|
||||
var documentResult = await ScanbotSdkUiV2.startDocumentScanner(configuration);
|
||||
|
||||
if (documentResult.status != OperationStatus.OK) {
|
||||
throw Exception("Scanner failed with status ${documentResult.status}");
|
||||
}
|
||||
|
||||
// Convert result to PDF
|
||||
var result = await ScanbotSdk.document.createPDFForDocument(
|
||||
PDFFromDocumentParams(
|
||||
documentID: documentResult.data!.uuid,
|
||||
pdfConfiguration: PdfConfiguration(),
|
||||
),
|
||||
);
|
||||
final pdfPath = result.pdfFileUri.replaceFirst("file://", "");
|
||||
return File(pdfPath).readAsBytes();
|
||||
}
|
||||
|
||||
/// Render PDF to image bits
|
||||
Future<Uint8List> renderPdf(
|
||||
{
|
||||
String? path,
|
||||
Uint8List? pdfBytes,
|
||||
}) async {
|
||||
Future<Uint8List> renderPdf({String? path, Uint8List? pdfBytes}) async {
|
||||
assert(path != null || pdfBytes != null);
|
||||
|
||||
// Create temporary file if required
|
||||
@@ -62,4 +88,4 @@ Future<Uint8List> renderPdf(
|
||||
await File(path).delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -40,6 +40,20 @@ class ExpenseEditor extends HookConsumerWidget {
|
||||
|
||||
final (:pending, :snapshot, :hasError) = useAsyncTask();
|
||||
|
||||
// Force refresh of field if required
|
||||
final previousData = useState<BaseExpenseInfo?>(null);
|
||||
if (initialData != previousData.value) {
|
||||
previousData.value = initialData;
|
||||
labelController.text = initialData?.label ?? "";
|
||||
costController.text = initialData?.cost.toString() ?? "";
|
||||
timeController.value = initialData?.time ?? DateTime.now();
|
||||
}
|
||||
|
||||
// Clear cost value
|
||||
handleClearCost() {
|
||||
costController.text = "";
|
||||
}
|
||||
|
||||
// Pick a new date
|
||||
handlePickDate() async {
|
||||
final date = await showDatePicker(
|
||||
@@ -65,6 +79,11 @@ class ExpenseEditor extends HookConsumerWidget {
|
||||
time: timeController.value,
|
||||
),
|
||||
);
|
||||
|
||||
// Reset screen after a scan
|
||||
await pending.value;
|
||||
labelController.text = "";
|
||||
costController.text = "";
|
||||
}
|
||||
|
||||
// Cancel operation
|
||||
@@ -89,6 +108,19 @@ class ExpenseEditor extends HookConsumerWidget {
|
||||
}
|
||||
}
|
||||
|
||||
// Open invoice in full screen
|
||||
handleFullScreenInvoice() {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (c) => Scaffold(
|
||||
appBar: AppBar(title: Text("Expense")),
|
||||
body: SingleChildScrollView(
|
||||
child: PDFViewer(pdfBytes: file, fit: BoxFit.fitWidth),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("Expense info"),
|
||||
@@ -120,7 +152,10 @@ class ExpenseEditor extends HookConsumerWidget {
|
||||
children: [
|
||||
// Expense preview
|
||||
Expanded(
|
||||
child: PDFViewer(pdfBytes: file, fit: BoxFit.contain),
|
||||
child: GestureDetector(
|
||||
onTap: handleFullScreenInvoice,
|
||||
child: PDFViewer(pdfBytes: file, fit: BoxFit.contain),
|
||||
),
|
||||
),
|
||||
|
||||
SizedBox(height: 10),
|
||||
@@ -132,7 +167,13 @@ class ExpenseEditor extends HookConsumerWidget {
|
||||
decimal: true,
|
||||
signed: false,
|
||||
),
|
||||
decoration: const InputDecoration(labelText: 'Cost'),
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Cost',
|
||||
suffixIcon: IconButton(
|
||||
onPressed: handleClearCost,
|
||||
icon: const Icon(Icons.clear),
|
||||
),
|
||||
),
|
||||
textInputAction: TextInputAction.done,
|
||||
),
|
||||
|
||||
|
@@ -3,6 +3,7 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:moneymgr_mobile/services/api/api_client.dart';
|
||||
import 'package:moneymgr_mobile/services/api/files_api.dart';
|
||||
import 'package:moneymgr_mobile/services/api/inbox_api.dart';
|
||||
import 'package:moneymgr_mobile/services/storage/expenses.dart';
|
||||
import 'package:moneymgr_mobile/utils/extensions.dart';
|
||||
import 'package:moneymgr_mobile/utils/hooks.dart';
|
||||
@@ -27,9 +28,21 @@ Future<void> _performSynchronization(Ref ref) async {
|
||||
bytes: bytes,
|
||||
);
|
||||
|
||||
// TODO continue
|
||||
break;
|
||||
// Then, create the inbox entry
|
||||
await apiService.createInboxEntry(
|
||||
UpdateInboxEntryRequest(
|
||||
file_id: file.id,
|
||||
time: exp.time,
|
||||
label: exp.label,
|
||||
amount: -1 * exp.cost,
|
||||
),
|
||||
);
|
||||
|
||||
// Lastly delete the local expense
|
||||
ref.watch(expensesProvider).requireValue.deleteExpense(exp);
|
||||
}
|
||||
|
||||
ref.invalidate(expensesProvider);
|
||||
}
|
||||
|
||||
class SynchronizeButton extends HookConsumerWidget {
|
||||
|
@@ -141,10 +141,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: built_value
|
||||
sha256: "082001b5c3dc495d4a42f1d5789990505df20d8547d42507c29050af6933ee27"
|
||||
sha256: "0b1b12a0a549605e5f04476031cd0bc91ead1d7c8e830773a18ee54179b3cb62"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "8.10.1"
|
||||
version: "8.11.0"
|
||||
characters:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -370,10 +370,10 @@ packages:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: flutter_lints
|
||||
sha256: "5398f14efa795ffb7a33e9b6a08798b26a180edac4ad7db3f231e40f82ce11e1"
|
||||
sha256: "3105dc8492f6183fb076ccf1f351ac3d60564bff92e20bfc4af9cc1651f4e7e1"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "5.0.0"
|
||||
version: "6.0.0"
|
||||
flutter_native_splash:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@@ -452,18 +452,18 @@ packages:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: freezed
|
||||
sha256: "6022db4c7bfa626841b2a10f34dd1e1b68e8f8f9650db6112dcdeeca45ca793c"
|
||||
sha256: "2d399f823b8849663744d2a9ddcce01c49268fb4170d0442a655bf6a2f47be22"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.6"
|
||||
version: "3.1.0"
|
||||
freezed_annotation:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: freezed_annotation
|
||||
sha256: c87ff004c8aa6af2d531668b46a4ea379f7191dc6dfa066acd53d506da6e044b
|
||||
sha256: "7294967ff0a6d98638e7acb774aac3af2550777accd8149c90af5b014e6d44d8"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.0"
|
||||
version: "3.1.0"
|
||||
frontend_server_client:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -484,10 +484,26 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: go_router
|
||||
sha256: ac294be30ba841830cfa146e5a3b22bb09f8dc5a0fdd9ca9332b04b0bde99ebf
|
||||
sha256: c489908a54ce2131f1d1b7cc631af9c1a06fac5ca7c449e959192089f9489431
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "15.2.4"
|
||||
version: "16.0.0"
|
||||
google_mlkit_commons:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: google_mlkit_commons
|
||||
sha256: "8f40fbac10685cad4715d11e6a0d86837d9ad7168684dfcad29610282a88e67a"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.11.0"
|
||||
google_mlkit_text_recognition:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: google_mlkit_text_recognition
|
||||
sha256: "96173ad4dd7fd06c660e22ac3f9e9f1798a517fe7e48bee68eeec83853224224"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.15.0"
|
||||
graphs:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -604,10 +620,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: lints
|
||||
sha256: c35bb79562d980e9a453fc715854e1ed39e24e7d0297a880ef54e17f9874a9d7
|
||||
sha256: a5e2b223cb7c9c8efdc663ef484fdd95bb243bff242ef5b13e26883547fce9a0
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "5.1.1"
|
||||
version: "6.0.0"
|
||||
logging:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@@ -921,10 +937,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: source_helper
|
||||
sha256: "86d247119aedce8e63f4751bd9626fc9613255935558447569ad42f9f5b48b3c"
|
||||
sha256: "4f81479fe5194a622cdd1713fe1ecb683a6e6c85cd8cec8e2e35ee5ab3fdf2a1"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.3.5"
|
||||
version: "1.3.6"
|
||||
source_span:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@@ -49,10 +49,10 @@ dependencies:
|
||||
riverpod_annotation: ^2.6.1
|
||||
|
||||
# Implement React hooks in Flutter
|
||||
flutter_hooks: ^0.21.2
|
||||
flutter_hooks: ^0.21.3+1
|
||||
|
||||
# Router
|
||||
go_router: ^15.2.4
|
||||
go_router: ^16.0.0
|
||||
|
||||
# Flutter extras widgets for columns and rows
|
||||
flextras: ^1.0.0
|
||||
@@ -84,7 +84,7 @@ dependencies:
|
||||
# Document scanner
|
||||
# flutter_doc_scanner: ^0.0.16 # no bundled support yet
|
||||
# https://developers.google.com/ml-kit/tips/installation-paths
|
||||
scanbot_sdk: ^7.0.0
|
||||
scanbot_sdk: ^7.0.1
|
||||
|
||||
# Get documents path
|
||||
path_provider: ^2.1.5
|
||||
@@ -93,6 +93,9 @@ dependencies:
|
||||
# PDF renderer
|
||||
pdf_image_renderer: ^1.0.1
|
||||
|
||||
# Text extraction
|
||||
google_mlkit_text_recognition: ^0.15.0
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
@@ -102,13 +105,13 @@ dev_dependencies:
|
||||
# activated in the `analysis_options.yaml` file located at the root of your
|
||||
# package. See that file for information about deactivating specific lint
|
||||
# rules and activating additional ones.
|
||||
flutter_lints: ^5.0.0
|
||||
flutter_lints: ^6.0.0
|
||||
|
||||
# Manage app icon
|
||||
flutter_launcher_icons: ^0.14.4
|
||||
|
||||
# Generate source code
|
||||
build_runner: ^2.5.4
|
||||
build_runner: ^2.6.1
|
||||
|
||||
# Riverpod code generation
|
||||
riverpod_generator: ^2.6.5
|
||||
@@ -127,6 +130,9 @@ dev_dependencies:
|
||||
# The following section is specific to Flutter packages.
|
||||
flutter:
|
||||
|
||||
# Default Android flavor
|
||||
default-flavor: development
|
||||
|
||||
# The following line ensures that the Material Icons font is
|
||||
# included with your application, so that you can use the icons in
|
||||
# the material Icons class.
|
||||
|
2890
moneymgr_web/package-lock.json
generated
2890
moneymgr_web/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -11,39 +11,39 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@emotion/react": "^11.14.0",
|
||||
"@emotion/styled": "^11.14.0",
|
||||
"@fontsource/roboto": "^5.2.6",
|
||||
"@emotion/styled": "^11.14.1",
|
||||
"@fontsource/roboto": "^5.2.8",
|
||||
"@jsonjoy.com/base64": "^1.1.2",
|
||||
"@mdi/js": "^7.4.47",
|
||||
"@mdi/react": "^1.6.1",
|
||||
"@mui/icons-material": "^7.1.2",
|
||||
"@mui/material": "^7.1.2",
|
||||
"@mui/x-charts": "^8.5.3",
|
||||
"@mui/x-data-grid": "^8.5.3",
|
||||
"@mui/x-date-pickers": "^8.5.3",
|
||||
"@mui/x-charts": "^8.10.2",
|
||||
"@mui/x-data-grid": "^8.9.2",
|
||||
"@mui/x-date-pickers": "^8.9.2",
|
||||
"date-and-time": "^3.6.0",
|
||||
"dayjs": "^1.11.13",
|
||||
"dayjs": "^1.11.18",
|
||||
"filesize": "^10.1.6",
|
||||
"qrcode.react": "^4.2.0",
|
||||
"react": "^19.1.0",
|
||||
"react-dom": "^19.1.0",
|
||||
"react-router": "^7.6.2",
|
||||
"react-router-dom": "^7.6.2",
|
||||
"ts-pattern": "^5.7.1"
|
||||
"react": "^19.2.0",
|
||||
"react-dom": "^19.2.0",
|
||||
"react-router": "^7.6.3",
|
||||
"react-router-dom": "^7.6.3",
|
||||
"ts-pattern": "^5.8.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.29.0",
|
||||
"@types/react": "^19.1.8",
|
||||
"@types/react-dom": "^19.1.6",
|
||||
"@vitejs/plugin-react": "^4.6.0",
|
||||
"eslint": "^9.26.0",
|
||||
"eslint-plugin-react-dom": "^1.49.0",
|
||||
"@eslint/js": "^9.33.0",
|
||||
"@types/react": "^19.2.0",
|
||||
"@types/react-dom": "^19.2.0",
|
||||
"@vitejs/plugin-react": "^4.7.0",
|
||||
"eslint": "^9.32.0",
|
||||
"eslint-plugin-react-dom": "^1.53.1",
|
||||
"eslint-plugin-react-hooks": "^5.2.0",
|
||||
"eslint-plugin-react-refresh": "^00.4.20",
|
||||
"eslint-plugin-react-x": "^1.52.2",
|
||||
"globals": "^16.2.0",
|
||||
"eslint-plugin-react-x": "^1.52.9",
|
||||
"globals": "^16.3.0",
|
||||
"typescript": "~5.8.3",
|
||||
"typescript-eslint": "^8.32.1",
|
||||
"vite": "^6.3.5"
|
||||
"vite": "^6.3.6"
|
||||
}
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@ import { APIClient } from "./ApiClient";
|
||||
export interface ServerConfig {
|
||||
auth_disabled: boolean;
|
||||
oidc_provider_name: string;
|
||||
apk_download_url: string;
|
||||
accounts_types: AccountType[];
|
||||
constraints: ServerConstraints;
|
||||
}
|
||||
|
@@ -2,9 +2,11 @@ import DeleteIcon from "@mui/icons-material/DeleteOutlined";
|
||||
import DriveFileMoveOutlineIcon from "@mui/icons-material/DriveFileMoveOutline";
|
||||
import LinkOffIcon from "@mui/icons-material/LinkOff";
|
||||
import MoreVertIcon from "@mui/icons-material/MoreVert";
|
||||
import ClearIcon from "@mui/icons-material/Clear";
|
||||
import RefreshIcon from "@mui/icons-material/Refresh";
|
||||
import {
|
||||
IconButton,
|
||||
InputAdornment,
|
||||
ListItemIcon,
|
||||
ListItemText,
|
||||
TextField,
|
||||
@@ -392,6 +394,19 @@ function MovementsTable(p: {
|
||||
setFilter(e.target.value);
|
||||
}}
|
||||
style={{ padding: "0px", flex: 1 }}
|
||||
slotProps={{
|
||||
input: {
|
||||
endAdornment: filter.length > 0 && (
|
||||
<InputAdornment position="end">
|
||||
<Tooltip title="Clear current filter">
|
||||
<IconButton size="small" onClick={() => { setFilter(""); }}>
|
||||
<ClearIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
</InputAdornment>
|
||||
),
|
||||
},
|
||||
}}
|
||||
/>
|
||||
<span style={{ flex: 1 }}></span>
|
||||
<Tooltip title="Refresh table">
|
||||
|
@@ -280,6 +280,8 @@ function CreatedToken(p: { token: TokenWithSecret }): React.ReactElement {
|
||||
The API token was successfully created. Please note the following
|
||||
information as they won't be available next.
|
||||
<br />
|
||||
API URL : <CopyTextChip text={APIClient.ActualBackendURL()} />
|
||||
<br />
|
||||
Token ID: <CopyTextChip text={p.token.id.toString()} />
|
||||
<br />
|
||||
Token value: <CopyTextChip text={p.token.token} />
|
||||
|
@@ -1,5 +1,6 @@
|
||||
import { mdiApi, mdiCash } from "@mdi/js";
|
||||
import Icon from "@mdi/react";
|
||||
import AndroidIcon from "@mui/icons-material/Android";
|
||||
import CloudDownloadIcon from "@mui/icons-material/CloudDownload";
|
||||
import LogoutIcon from "@mui/icons-material/Logout";
|
||||
import SettingsIcon from "@mui/icons-material/Settings";
|
||||
@@ -10,6 +11,7 @@ import MenuItem from "@mui/material/MenuItem";
|
||||
import Toolbar from "@mui/material/Toolbar";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import * as React from "react";
|
||||
import { ServerApi } from "../api/ServerApi";
|
||||
import { useAuthInfo } from "./BaseAuthenticatedPage";
|
||||
import { DarkThemeButton } from "./DarkThemeButtonWidget";
|
||||
import { PublicModeButton } from "./PublicModeButtonWidget";
|
||||
@@ -100,6 +102,18 @@ export function MoneyWebAppBar(p: {
|
||||
</MenuItem>
|
||||
</RouterLink>
|
||||
|
||||
{/* APK download */}
|
||||
<RouterLink to={ServerApi.Config.apk_download_url}>
|
||||
<MenuItem>
|
||||
<ListItemIcon>
|
||||
<AndroidIcon />
|
||||
</ListItemIcon>
|
||||
<ListItemText secondary="Scan expenses from your smartphone">
|
||||
Mobile Application
|
||||
</ListItemText>
|
||||
</MenuItem>
|
||||
</RouterLink>
|
||||
|
||||
<Divider />
|
||||
|
||||
{/* Sign out */}
|
||||
|
Reference in New Issue
Block a user