Skip to content

Commit 33b7b01

Browse files
committed
Exclude lots with no tax impact during export
1 parent 3d850e6 commit 33b7b01

1 file changed

Lines changed: 28 additions & 23 deletions

File tree

src/bin/sys.rs

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2619,29 +2619,34 @@ async fn process_account_xls(
26192619
}
26202620
}
26212621

2622-
sheet_writer.append_row(row![
2623-
disposed_lot.token.to_string(),
2624-
disposed_lot.token.ui_amount(disposed_lot.lot.amount),
2625-
income,
2626-
disposed_lot.lot.acquisition.when.to_string(),
2627-
disposed_lot.lot.acquisition.price().to_string(),
2628-
disposed_lot.lot.acquisition.kind.to_string(),
2629-
disposed_lot
2630-
.lot
2631-
.cap_gain(disposed_lot.token, disposed_lot.price()),
2632-
if long_term_cap_gain { "Long" } else { "Short" },
2633-
disposed_lot.when.to_string(),
2634-
disposed_lot.price().to_string(),
2635-
disposed_lot
2636-
.kind
2637-
.fee()
2638-
.map(|(amount, currency)| {
2639-
assert_eq!(currency, "USD");
2640-
*amount
2641-
})
2642-
.unwrap_or_default(),
2643-
disposed_lot.kind.to_string()
2644-
])?;
2622+
let cap_gain = disposed_lot
2623+
.lot
2624+
.cap_gain(disposed_lot.token, disposed_lot.price());
2625+
2626+
if income + cap_gain > f64::EPSILON {
2627+
// Exclude disposals with no tax impact
2628+
sheet_writer.append_row(row![
2629+
disposed_lot.token.to_string(),
2630+
disposed_lot.token.ui_amount(disposed_lot.lot.amount),
2631+
income,
2632+
disposed_lot.lot.acquisition.when.to_string(),
2633+
disposed_lot.lot.acquisition.price().to_string(),
2634+
disposed_lot.lot.acquisition.kind.to_string(),
2635+
cap_gain,
2636+
if long_term_cap_gain { "Long" } else { "Short" },
2637+
disposed_lot.when.to_string(),
2638+
disposed_lot.price().to_string(),
2639+
disposed_lot
2640+
.kind
2641+
.fee()
2642+
.map(|(amount, currency)| {
2643+
assert_eq!(currency, "USD");
2644+
*amount
2645+
})
2646+
.unwrap_or_default(),
2647+
disposed_lot.kind.to_string()
2648+
])?;
2649+
}
26452650
}
26462651
Ok(())
26472652
})?;

0 commit comments

Comments
 (0)