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

@@ -1,10 +1,12 @@
use crate::database::redis::RedisPool;
use crate::queue::billing::{index_billing, index_subscriptions};
use crate::queue::email::EmailQueue;
use crate::queue::payouts::{
PayoutsQueue, index_payouts_notifications,
insert_bank_balances_and_webhook, process_payout,
};
use crate::search::indexing::index_projects;
use crate::util::anrok;
use crate::{database, search};
use clap::ValueEnum;
use sqlx::Postgres;
@@ -24,6 +26,7 @@ pub enum BackgroundTask {
}
impl BackgroundTask {
#[allow(clippy::too_many_arguments)]
pub async fn run(
self,
pool: sqlx::Pool<Postgres>,
@@ -31,6 +34,7 @@ impl BackgroundTask {
search_config: search::SearchConfig,
clickhouse: clickhouse::Client,
stripe_client: stripe::Client,
anrok_client: anrok::Client,
email_queue: EmailQueue,
) {
use BackgroundTask::*;
@@ -41,8 +45,9 @@ impl BackgroundTask {
UpdateVersions => update_versions(pool, redis_pool).await,
Payouts => payouts(pool, clickhouse, redis_pool).await,
IndexBilling => {
crate::routes::internal::billing::index_billing(
index_billing(
stripe_client,
anrok_client,
pool.clone(),
redis_pool,
)
@@ -51,8 +56,11 @@ impl BackgroundTask {
update_bank_balances(pool).await;
}
IndexSubscriptions => {
crate::routes::internal::billing::index_subscriptions(
pool, redis_pool,
index_subscriptions(
pool,
redis_pool,
stripe_client,
anrok_client,
)
.await
}