Charge tax on products (#4361)

* Initial Anrok integration

* Query cache, fmt, clippy

* Fmt

* Use payment intent function in edit_subscription

* Attach Anrok client, use payments in index_billing

* Integrate Anrok with refunds

* Bug fixes

* More bugfixes

* Fix resubscriptions

* Medal promotion bugfixes

* Use stripe metadata constants everywhere

* Pre-fill values in products_tax_identifiers

* Cleanup billing route module

* Cleanup

* Email notification for tax charge

* Don't charge tax on users which haven't been notified of tax change

* Fix taxnotification.amount templates

* Update .env.docker-compose

* Update .env.local

* Clippy

* Fmt

* Query cache

* Periodically update tax amount on upcoming charges

* Fix queries

* Skip indexing tax amount on charges if no charges to process

* chore: query cache, clippy, fmt

* Fix a lot of things

* Remove test code

* chore: query cache, clippy, fmt

* Fix money formatting

* Fix conflicts

* Extra documentation, handle tax association properly

* Track loss in tax drift

* chore: query cache, clippy, fmt

* Add subscription.id variable

* chore: query cache, clippy, fmt

* chore: query cache, clippy, fmt
This commit is contained in:
François-Xavier Talbot
2025-09-25 12:29:29 +01:00
committed by GitHub
parent 47020f34b6
commit 4228a193e9
44 changed files with 3438 additions and 1330 deletions

View File

@@ -66,6 +66,15 @@ pub enum Price {
},
}
impl Price {
pub fn get_interval(&self, interval: PriceDuration) -> Option<i32> {
match self {
Price::OneTime { .. } => None,
Price::Recurring { intervals } => intervals.get(&interval).copied(),
}
}
}
#[derive(Serialize, Deserialize, Hash, Eq, PartialEq, Debug, Copy, Clone)]
#[serde(rename_all = "kebab-case")]
pub enum PriceDuration {
@@ -175,6 +184,16 @@ pub enum SubscriptionMetadata {
Medal { id: String },
}
impl SubscriptionMetadata {
pub fn is_medal(&self) -> bool {
matches!(self, SubscriptionMetadata::Medal { .. })
}
pub fn is_pyro(&self) -> bool {
matches!(self, SubscriptionMetadata::Pyro { .. })
}
}
#[derive(Serialize, Deserialize)]
pub struct Charge {
pub id: ChargeId,