Skip to content
Open
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
2 changes: 0 additions & 2 deletions apps/labrinth/.env.docker-compose
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,6 @@ AVALARA_1099_API_KEY=none
AVALARA_1099_API_TEAM_ID=none
AVALARA_1099_COMPANY_ID=207337084

COMPLIANCE_PAYOUT_THRESHOLD=disabled

ANROK_API_KEY=none
ANROK_API_URL=none

Expand Down
2 changes: 0 additions & 2 deletions apps/labrinth/.env.local
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,6 @@ AVALARA_1099_API_KEY=none
AVALARA_1099_API_TEAM_ID=none
AVALARA_1099_COMPANY_ID=207337084

COMPLIANCE_PAYOUT_THRESHOLD=disabled

ANROK_API_KEY=none
ANROK_API_URL=none

Expand Down
2 changes: 0 additions & 2 deletions apps/labrinth/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,6 @@ vars! {
ANROK_API_URL: String;
ANROK_API_KEY: String;

COMPLIANCE_PAYOUT_THRESHOLD: String;

PAYOUT_ALERT_SLACK_WEBHOOK: String;
CLOUDFLARE_INTEGRATION: bool = false;

Expand Down
2 changes: 1 addition & 1 deletion apps/labrinth/src/routes/internal/globals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub struct Globals {
pub captcha_enabled: bool,
}

static GLOBALS: LazyLock<Globals> = LazyLock::new(|| Globals {
pub static GLOBALS: LazyLock<Globals> = LazyLock::new(|| Globals {
tax_compliance_thresholds: [(2025, 600), (2026, 2000)]
.into_iter()
.collect(),
Expand Down
26 changes: 24 additions & 2 deletions apps/labrinth/src/routes/v3/payouts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::util::avalara1099;
use crate::util::error::Context;
use crate::util::gotenberg::GotenbergClient;
use actix_web::{HttpRequest, HttpResponse, delete, get, post, web};
use chrono::{DateTime, Duration, Utc};
use chrono::{DateTime, Datelike, Duration, Utc};
use hex::ToHex;
use hmac::{Hmac, Mac};
use modrinth_util::decimal::Decimal2dp;
Expand Down Expand Up @@ -1117,7 +1117,29 @@ async fn update_compliance_status(
}

fn tax_compliance_payout_threshold() -> Option<Decimal> {
ENV.COMPLIANCE_PAYOUT_THRESHOLD.parse().ok()
let globals = &crate::routes::internal::globals::GLOBALS;
let current_year = Utc::now().year() as u16;
let thresholds = &globals.tax_compliance_thresholds;

if thresholds.is_empty() {
return None;
}

let mut years: Vec<u16> = thresholds.keys().copied().collect();
years.sort();

let value = if current_year <= years[0] {
thresholds[&years[0]]
} else if current_year >= *years.last().unwrap() {
thresholds[years.last().unwrap()]
} else {
thresholds
.get(&current_year)
.copied()
.unwrap_or_else(|| thresholds[years.last().unwrap()])
};

Some(Decimal::from(value))
}

#[derive(Deserialize)]
Expand Down
Loading