grid_tariffs/
tax_reductions.rs1use chrono::NaiveDate;
2use serde::Serialize;
3
4use crate::{Money, helpers::date};
5
6pub(crate) static SE_TAX_REDUCTIONS: &[TaxReduction] = &[TaxReduction::new(
7 "Skatteavdrag mikroproduktion",
8 Money::from_inner(60000),
9 TaxReductionAppliedBy::KwhFeedIn,
10 date(2025, 1, 1),
11 Some(date(2025, 12, 31)),
12)];
13
14#[derive(Debug, Clone, Copy, Serialize)]
15#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
16pub enum TaxReductionAppliedBy {
17 KwhFeedIn,
18}
19
20#[derive(Debug, Clone, Copy, Serialize)]
21#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
22pub struct TaxReduction {
23 description: &'static str,
24 cost: Money,
25 applied_by: TaxReductionAppliedBy,
26 from_date: NaiveDate,
27 to_date: Option<NaiveDate>,
29}
30
31impl TaxReduction {
32 pub(crate) const fn new(
33 description: &'static str,
34 cost: Money,
35 applied_by: TaxReductionAppliedBy,
36 from_date: NaiveDate,
37 to_date: Option<NaiveDate>,
38 ) -> Self {
39 Self {
40 description,
41 cost,
42 applied_by,
43 from_date,
44 to_date,
45 }
46 }
47
48 pub(crate) fn valid_for(&self, today: NaiveDate) -> bool {
49 today >= self.from_date && self.to_date.is_none_or(|to_date| today <= to_date)
50 }
51}