Invoices: issued in Billingo by the worker, downloadable on Számláim
CI / test (push) Successful in 1m29s
CI / build (push) Successful in 9m7s
CI / deploy (push) Skipped

A paid checkout queues an invoice row with every invoice detail (buyer,
tax type and number, item, net, VAT, gross). The worker's new 'invoices'
task creates the Billingo partner and the paid card invoice and e-mails
it (API v3), saving each step so a retry never issues a second invoice,
and keeps Billingo's whole answer; the PDF is fetched from Billingo when
the user downloads it from the new Számláim page (in the menu once there
is an invoice). Payments and invoices outlive a deleted account.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
feco
2026-11-20 07:52:34 +00:00
co-authored by Claude Opus 5.5
parent e530e78c54
commit 2a0830fda0
24 changed files with 1090 additions and 35 deletions
+24 -1
View File
@@ -4,6 +4,7 @@
//! * e-mail delivery from `email_outbox` over SMTP (Mailpit in development)
//! * hourly cleanup of expired sessions, tokens, invites and old e-mails
//! * writing the requested text analyses with an LLM (OpenRouter)
//! * issuing the invoices of the payments in Billingo
//!
//! `WORKER_TASKS` (e.g. `email,cleanup` or `analyses`) picks the jobs of one
//! process, so they can run in separate containers; all of them by default.
@@ -18,6 +19,7 @@ mod cleanup;
mod compare;
mod config;
mod email;
mod invoices;
mod ses;
mod templates {
pub use email_templates::*;
@@ -95,7 +97,13 @@ async fn main() -> anyhow::Result<()> {
let (stop_tx, stop) = watch::channel(false);
let mut jobs = tokio::task::JoinSet::new();
let tasks = config.tasks;
tracing::info!(email = tasks.email, cleanup = tasks.cleanup, analyses = tasks.analyses, "worker tasks");
tracing::info!(
email = tasks.email,
cleanup = tasks.cleanup,
analyses = tasks.analyses,
invoices = tasks.invoices,
"worker tasks"
);
match &config.smtp_url {
_ if !tasks.email => {}
Some(url) => {
@@ -125,6 +133,21 @@ async fn main() -> anyhow::Result<()> {
if tasks.cleanup {
jobs.spawn(cleanup::run(pool.clone(), stop.clone()));
}
match &config.billingo_api_key {
_ if !tasks.invoices => {}
Some(key) => {
let billingo = invoices::Billingo::new(&config.billingo_api_url, key, config.billingo_block_id);
tracing::info!("invoicing enabled (Billingo)");
jobs.spawn(invoices::run(
pool.clone(),
billingo,
config.max_invoice_attempts,
config.poll_interval,
stop.clone(),
));
}
None => tracing::warn!("BILLINGO_API_KEY is not set: invoices stay pending"),
}
let app = Router::new().route("/healthz", get(healthz)).with_state(pool);
let listener = tokio::net::TcpListener::bind(addr).await.with_context(|| format!("binding {addr}"))?;