Skip to content
Draft
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
289 changes: 279 additions & 10 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ readme = "README.md"
keywords = ["etrade", "revolut"]
repository = "https://github.com/jczaja/e-trade-tax-return-pl-helper"
homepage = "https://github.com/jczaja/e-trade-tax-return-pl-helper"
default-run = "etradeTaxReturnHelper"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

exclude = [
Expand Down Expand Up @@ -49,5 +50,6 @@ polars = "0.35.4"
csv = "1.3.0"
serde_json = { version = "=1.0.133", optional = true }
holidays = { version = "0.1.0", default-features = false, features = ["PL"] }
rust_decimal = { version = "1.36.0", features = ["macros", "serde-with-float"] }


1 change: 1 addition & 0 deletions REUSE.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ SPDX-License-Identifier = "LicenseRef-ETrade-MorganStanley"
path=[
"Cargo.lock",
"assets/etradetaxreturnhelper-640x480.gif",
"rust_decimal.natvis",
]
SPDX-FileCopyrightText = "2025 RustInFinance"
SPDX-License-Identifier = "BSD-3-Clause"
Expand Down
48 changes: 48 additions & 0 deletions rust_decimal.natvis
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Natvis debugger visualizer for rust_decimal::Decimal.
Lets Visual Studio (and VS Code with C++ debugger) display Decimal values
as human-readable numbers instead of raw {flags, hi, mid, lo} fields.
Referenced via #![debugger_visualizer(natvis_file = "...")] in lib.rs / main.rs.
-->
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="rust_decimal::decimal::Decimal">
<!-- mantissa = hi*2^64 + mid*2^32 + lo; value = (-1)^sign * mantissa / 10^scale -->
<!-- Use (double) casting to show the value. Precision limited to ~15 digits but readable. -->

<!-- Positive values (sign bit = 0) -->
<DisplayString Condition="(flags &gt;&gt; 31) == 0 &amp;&amp; ((flags &gt;&gt; 16) &amp; 0xFF) == 0 &amp;&amp; hi == 0">{(double)((unsigned __int64)mid * 4294967296 + (unsigned __int64)lo),g}</DisplayString>
<DisplayString Condition="(flags &gt;&gt; 31) == 0 &amp;&amp; ((flags &gt;&gt; 16) &amp; 0xFF) == 1 &amp;&amp; hi == 0">{(double)((unsigned __int64)mid * 4294967296 + (unsigned __int64)lo) / 10.0,g}</DisplayString>
<DisplayString Condition="(flags &gt;&gt; 31) == 0 &amp;&amp; ((flags &gt;&gt; 16) &amp; 0xFF) == 2 &amp;&amp; hi == 0">{(double)((unsigned __int64)mid * 4294967296 + (unsigned __int64)lo) / 100.0,g}</DisplayString>
<DisplayString Condition="(flags &gt;&gt; 31) == 0 &amp;&amp; ((flags &gt;&gt; 16) &amp; 0xFF) == 3 &amp;&amp; hi == 0">{(double)((unsigned __int64)mid * 4294967296 + (unsigned __int64)lo) / 1000.0,g}</DisplayString>
<DisplayString Condition="(flags &gt;&gt; 31) == 0 &amp;&amp; ((flags &gt;&gt; 16) &amp; 0xFF) == 4 &amp;&amp; hi == 0">{(double)((unsigned __int64)mid * 4294967296 + (unsigned __int64)lo) / 10000.0,g}</DisplayString>
<DisplayString Condition="(flags &gt;&gt; 31) == 0 &amp;&amp; ((flags &gt;&gt; 16) &amp; 0xFF) == 5 &amp;&amp; hi == 0">{(double)((unsigned __int64)mid * 4294967296 + (unsigned __int64)lo) / 100000.0,g}</DisplayString>
<DisplayString Condition="(flags &gt;&gt; 31) == 0 &amp;&amp; ((flags &gt;&gt; 16) &amp; 0xFF) == 6 &amp;&amp; hi == 0">{(double)((unsigned __int64)mid * 4294967296 + (unsigned __int64)lo) / 1000000.0,g}</DisplayString>
<DisplayString Condition="(flags &gt;&gt; 31) == 0 &amp;&amp; ((flags &gt;&gt; 16) &amp; 0xFF) == 7 &amp;&amp; hi == 0">{(double)((unsigned __int64)mid * 4294967296 + (unsigned __int64)lo) / 10000000.0,g}</DisplayString>
<DisplayString Condition="(flags &gt;&gt; 31) == 0 &amp;&amp; ((flags &gt;&gt; 16) &amp; 0xFF) == 8 &amp;&amp; hi == 0">{(double)((unsigned __int64)mid * 4294967296 + (unsigned __int64)lo) / 100000000.0,g}</DisplayString>

<!-- Negative values (sign bit = 1) -->
<DisplayString Condition="(flags &gt;&gt; 31) == 1 &amp;&amp; ((flags &gt;&gt; 16) &amp; 0xFF) == 0 &amp;&amp; hi == 0">{-(double)((unsigned __int64)mid * 4294967296 + (unsigned __int64)lo),g}</DisplayString>
<DisplayString Condition="(flags &gt;&gt; 31) == 1 &amp;&amp; ((flags &gt;&gt; 16) &amp; 0xFF) == 1 &amp;&amp; hi == 0">{-(double)((unsigned __int64)mid * 4294967296 + (unsigned __int64)lo) / 10.0,g}</DisplayString>
<DisplayString Condition="(flags &gt;&gt; 31) == 1 &amp;&amp; ((flags &gt;&gt; 16) &amp; 0xFF) == 2 &amp;&amp; hi == 0">{-(double)((unsigned __int64)mid * 4294967296 + (unsigned __int64)lo) / 100.0,g}</DisplayString>
<DisplayString Condition="(flags &gt;&gt; 31) == 1 &amp;&amp; ((flags &gt;&gt; 16) &amp; 0xFF) == 3 &amp;&amp; hi == 0">{-(double)((unsigned __int64)mid * 4294967296 + (unsigned __int64)lo) / 1000.0,g}</DisplayString>
<DisplayString Condition="(flags &gt;&gt; 31) == 1 &amp;&amp; ((flags &gt;&gt; 16) &amp; 0xFF) == 4 &amp;&amp; hi == 0">{-(double)((unsigned __int64)mid * 4294967296 + (unsigned __int64)lo) / 10000.0,g}</DisplayString>
<DisplayString Condition="(flags &gt;&gt; 31) == 1 &amp;&amp; ((flags &gt;&gt; 16) &amp; 0xFF) == 5 &amp;&amp; hi == 0">{-(double)((unsigned __int64)mid * 4294967296 + (unsigned __int64)lo) / 100000.0,g}</DisplayString>
<DisplayString Condition="(flags &gt;&gt; 31) == 1 &amp;&amp; ((flags &gt;&gt; 16) &amp; 0xFF) == 6 &amp;&amp; hi == 0">{-(double)((unsigned __int64)mid * 4294967296 + (unsigned __int64)lo) / 1000000.0,g}</DisplayString>
<DisplayString Condition="(flags &gt;&gt; 31) == 1 &amp;&amp; ((flags &gt;&gt; 16) &amp; 0xFF) == 7 &amp;&amp; hi == 0">{-(double)((unsigned __int64)mid * 4294967296 + (unsigned __int64)lo) / 10000000.0,g}</DisplayString>
<DisplayString Condition="(flags &gt;&gt; 31) == 1 &amp;&amp; ((flags &gt;&gt; 16) &amp; 0xFF) == 8 &amp;&amp; hi == 0">{-(double)((unsigned __int64)mid * 4294967296 + (unsigned __int64)lo) / 100000000.0,g}</DisplayString>

<!-- Fallback for hi != 0 or scale > 8 (large values using full 96-bit mantissa) -->
<DisplayString Condition="(flags &gt;&gt; 31) == 0">~{(double)((double)hi * 18446744073709551616.0 + (double)((unsigned __int64)mid * 4294967296 + (unsigned __int64)lo)),g} (approx, scale={(flags &gt;&gt; 16) &amp; 0xFF})</DisplayString>
<DisplayString>~{-(double)((double)hi * 18446744073709551616.0 + (double)((unsigned __int64)mid * 4294967296 + (unsigned __int64)lo)),g} (approx, scale={(flags &gt;&gt; 16) &amp; 0xFF})</DisplayString>

<Expand>
<Item Name="[value]" Condition="hi == 0 &amp;&amp; (flags &gt;&gt; 31) == 0">(double)((unsigned __int64)mid * 4294967296 + (unsigned __int64)lo) / (((flags &gt;&gt; 16) &amp; 0xFF) == 0 ? 1.0 : ((flags &gt;&gt; 16) &amp; 0xFF) == 1 ? 10.0 : ((flags &gt;&gt; 16) &amp; 0xFF) == 2 ? 100.0 : ((flags &gt;&gt; 16) &amp; 0xFF) == 3 ? 1000.0 : ((flags &gt;&gt; 16) &amp; 0xFF) == 4 ? 10000.0 : ((flags &gt;&gt; 16) &amp; 0xFF) == 5 ? 100000.0 : ((flags &gt;&gt; 16) &amp; 0xFF) == 6 ? 1000000.0 : ((flags &gt;&gt; 16) &amp; 0xFF) == 7 ? 10000000.0 : 100000000.0)</Item>
<Item Name="[lo]">lo</Item>
<Item Name="[mid]">mid</Item>
<Item Name="[hi]">hi</Item>
<Item Name="[scale]">(flags &gt;&gt; 16) &amp; 0xFF</Item>
<Item Name="[sign]">(flags &gt;&gt; 31) &amp; 1</Item>
</Expand>
</Type>
</AutoVisualizer>
9 changes: 5 additions & 4 deletions src/bin/gen_exchange_rates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,28 +87,29 @@ fn main() {
let mut output_content = String::new();
output_content.push_str("use std::collections::HashMap;\n\n");
output_content.push_str("use etradeTaxReturnHelper::Exchange;\n\n");
output_content.push_str("use rust_decimal::Decimal;\nuse rust_decimal::dec;\n\n");
output_content.push_str("#[allow(clippy::approx_constant)]\n");

output_content.push_str("pub fn get_exchange_rates() -> HashMap<Exchange, f64> {\n");
output_content.push_str("pub fn get_exchange_rates() -> HashMap<Exchange, Decimal> {\n");
output_content.push_str(" let mut exchange_rates = HashMap::new();\n");

for (exchange, kurs) in &kursy_map {
match exchange {
Exchange::USD(data) => {
output_content.push_str(&format!(
" exchange_rates.insert(Exchange::USD(\"{}\".to_string()), {}f64);\n",
" exchange_rates.insert(Exchange::USD(\"{}\".to_string()), dec!({}));\n",
data, kurs
));
}
Exchange::EUR(data) => {
output_content.push_str(&format!(
" exchange_rates.insert(Exchange::EUR(\"{}\".to_string()), {}f64);\n",
" exchange_rates.insert(Exchange::EUR(\"{}\".to_string()), dec!({}));\n",
data, kurs
));
}
Exchange::PLN(data) => {
output_content.push_str(&format!(
" exchange_rates.insert(Exchange::PLN(\"{}\".to_string()), {}f64);\n",
" exchange_rates.insert(Exchange::PLN(\"{}\".to_string()), dec!({}));\n",
data, kurs
));
}
Expand Down
Loading
Loading