Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/building.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,21 @@ jobs:
LIBRARY_PATH: ./
run: |
cargo test --no-default-features

build_and_test_with_gen_exchange_rates:
name: etradeTaxReturnHelper gen_exchange_rates building
runs-on: ubuntu-latest
steps:
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libx11-dev libxext-dev libxft-dev libxinerama-dev libxcursor-dev libxrender-dev libxfixes-dev libpango1.0-dev
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Cargo build
env:
LIBRARY_PATH: ./
run: |
cargo build --release --features gen_exchange_rates
25 changes: 25 additions & 0 deletions scripts/nbp_script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# SPDX-FileCopyrightText: 2024-2025 RustInFinance
# SPDX-License-Identifier: BSD-3-Clause

#!/bin/bash
curl https://api.nbp.pl/api/exchangerates/rates/a/usd/2025-01-01/2025-12-31/ > rates-2025.json
curl https://api.nbp.pl/api/exchangerates/rates/a/usd/2024-01-01/2024-12-31/ > rates-2024.json
curl https://api.nbp.pl/api/exchangerates/rates/a/usd/2023-01-01/2023-12-31/ > rates-2023.json
curl https://api.nbp.pl/api/exchangerates/rates/a/usd/2022-01-01/2022-12-31/ > rates-2022.json
curl https://api.nbp.pl/api/exchangerates/rates/a/usd/2021-01-01/2021-12-31/ > rates-2021.json
curl https://api.nbp.pl/api/exchangerates/rates/a/usd/2020-01-01/2020-12-31/ > rates-2020.json
curl https://api.nbp.pl/api/exchangerates/rates/a/usd/2019-01-01/2019-12-31/ > rates-2019.json
curl https://api.nbp.pl/api/exchangerates/rates/a/usd/2018-01-01/2018-12-31/ > rates-2018.json
curl https://api.nbp.pl/api/exchangerates/rates/a/usd/2017-01-01/2017-12-31/ > rates-2017.json
curl https://api.nbp.pl/api/exchangerates/rates/a/usd/2016-01-01/2016-12-31/ > rates-2016.json
curl https://api.nbp.pl/api/exchangerates/rates/a/usd/2015-01-01/2015-12-31/ > rates-2015.json
curl https://api.nbp.pl/api/exchangerates/rates/a/usd/2014-01-01/2014-12-31/ > rates-2014.json
curl https://api.nbp.pl/api/exchangerates/rates/a/usd/2013-01-01/2013-12-31/ > rates-2013.json
curl https://api.nbp.pl/api/exchangerates/rates/a/usd/2012-01-01/2012-12-31/ > rates-2012.json

curl https://api.nbp.pl/api/exchangerates/rates/a/eur/2023-01-01/2023-12-31/ > rates-eur-2023.json
curl https://api.nbp.pl/api/exchangerates/rates/a/eur/2024-01-01/2024-12-31/ > rates-eur-2024.json
curl https://api.nbp.pl/api/exchangerates/rates/a/eur/2025-01-01/2025-12-31/ > rates-eur-2025.json

cargo run --features gen_exchange_rates --bin gen_exchange_rates -- --input rates-2025.json --input rates-2023.json --input rates-2024.json --input rates-2022.json --input rates-2021.json --input rates-2020.json --input rates-2019.json --input rates-2018.json --input rates-2017.json --input rates-2016.json --input rates-2015.json --input rates-2014.json --input rates-2013.json --input rates-2012.json --input rates-eur-2023.json --input rates-eur-2024.json --input rates-eur-2025.json > nbp.rs
rm rates-2012.json rates-2013.json rates-2014.json rates-2015.json rates-2016.json rates-2017.json rates-2018.json rates-2019.json rates-2020.json rates-2021.json rates-2022.json rates-2023.json rates-2024.json rates-2025.json rates-eur-2023.json rates-eur-2024.json rates-eur-2025.json
21 changes: 12 additions & 9 deletions src/bin/gen_exchange_rates.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-FileCopyrightText: 2024-2025 RustInFinance
// SPDX-License-Identifier: BSD-3-Clause

use clap::{App, Arg};
use clap::{Arg, Command};
use serde::Deserialize;
use std::collections::HashMap;
use std::fs;
Expand Down Expand Up @@ -29,23 +29,26 @@ pub enum Exchange {
}

fn main() {
let matches = App::new("gen_exchange_rates")
.version("1.0")
.author("Your Name <jacek.czaja@gmail.com>")
let matches = Command::new("etradeTaxHelper")
.version("1.1")
.arg_required_else_help(true)
.about("Consumes NBP exchange rates and produces rust source code with it")
.arg(
Arg::with_name("input")
.short("i")
Arg::new("input")
.long("input")
.value_name("FILE")
.help("Sets the input files")
.takes_value(true)
.multiple(true)
.num_args(1..)
.action(clap::ArgAction::Append)
.required(true),
)
.get_matches();

let file_paths = matches.values_of("input").unwrap().collect::<Vec<_>>();
let file_paths = matches
.get_many::<String>("input")
.unwrap()
.cloned()
.collect::<Vec<_>>();
let mut kursy_map: HashMap<Exchange, f64> = HashMap::new();

for file in file_paths {
Expand Down
Loading
Loading