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 -4
View File
@@ -14,22 +14,26 @@ pub struct Tasks {
pub cleanup: bool,
/// Writing the analyses and answers with the LLM (both lanes).
pub analyses: bool,
/// Issuing the invoices of the payments in Billingo.
pub invoices: bool,
}
impl Tasks {
pub const ALL: Tasks = Tasks { email: true, cleanup: true, analyses: true };
pub const ALL: Tasks = Tasks { email: true, cleanup: true, analyses: true, invoices: true };
const NONE: Tasks = Tasks { email: false, cleanup: false, analyses: false, invoices: false };
pub fn parse(raw: &str) -> anyhow::Result<Self> {
let mut tasks = Tasks { email: false, cleanup: false, analyses: false };
let mut tasks = Self::NONE;
for name in raw.split(',').map(str::trim).filter(|n| !n.is_empty()) {
match name {
"email" => tasks.email = true,
"cleanup" => tasks.cleanup = true,
"analyses" => tasks.analyses = true,
other => anyhow::bail!("unknown task '{other}' in WORKER_TASKS (email, cleanup, analyses)"),
"invoices" => tasks.invoices = true,
other => anyhow::bail!("unknown task '{other}' in WORKER_TASKS (email, cleanup, analyses, invoices)"),
}
}
anyhow::ensure!(tasks != Tasks { email: false, cleanup: false, analyses: false }, "WORKER_TASKS names no task");
anyhow::ensure!(tasks != Self::NONE, "WORKER_TASKS names no task");
Ok(tasks)
}
}
@@ -61,6 +65,15 @@ pub struct Config {
pub quick_concurrency: usize,
/// After this many failed attempts an analysis fails and is refunded.
pub max_analysis_attempts: i32,
/// `BILLINGO_API_KEY`; unset: invoices stay pending.
pub billingo_api_key: Option<String>,
/// `BILLINGO_API_URL` (default `https://api.billingo.hu/v3`).
pub billingo_api_url: String,
/// `BILLINGO_BLOCK_ID`: the invoice pad (default: the account's first one).
pub billingo_block_id: Option<i64>,
/// `MAX_INVOICE_ATTEMPTS` (default 10, about a day with the backoff):
/// then the invoice is marked failed for an admin.
pub max_invoice_attempts: i32,
}
fn var(name: &str) -> Option<String> {
@@ -103,6 +116,13 @@ impl Config {
analysis_concurrency: parsed("ANALYSIS_CONCURRENCY", 4)?,
quick_concurrency: parsed("QUICK_CONCURRENCY", 2)?,
max_analysis_attempts: parsed("MAX_ANALYSIS_ATTEMPTS", 3)?,
billingo_api_key: var("BILLINGO_API_KEY"),
billingo_api_url: var("BILLINGO_API_URL").unwrap_or_else(|| crate::invoices::DEFAULT_BASE_URL.into()),
billingo_block_id: var("BILLINGO_BLOCK_ID")
.map(|v| v.parse())
.transpose()
.context("invalid BILLINGO_BLOCK_ID")?,
max_invoice_attempts: parsed("MAX_INVOICE_ATTEMPTS", 10)?,
})
}
}