Gift packages: buy a main package for someone, with a printable gift card

- /ajandek: the package, whom it is for and from whom, the recipient's
  address typed twice (or "I hand it over"), a message; paid on Stripe
  like any package, the invoice is the buyer's
- On payment the gift gets its own code (not a promo code: it cannot be
  withdrawn, and it adds the whole package); redeemed on /bevaltas
- The recipient's e-mail carries the message and the code, with the gift
  card attached as a PDF; the buyer's confirmation says it was a gift
- /ajandekaim: codes, state, the card to download, sending it by e-mail
  (again, or to another address) up to three times
- crates/gift-card draws the A4 card (example chart, questions avatar,
  QR code) as SVG and makes a PDF with krilla, fonts compiled in; the
  backend draws downloads on a blocking thread, the worker the e-mails
- Telegram notices say "(ajándék)"; unpaid gifts go after a week

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-23 20:28:11 +00:00
co-authored by Claude Opus 5.5
parent 699ce2abbd
commit c90232f40c
46 changed files with 3647 additions and 88 deletions
+11 -3
View File
@@ -210,6 +210,8 @@ pub enum Source {
Mock,
/// A redeemed promo code.
Promo,
/// A redeemed gift code (someone else paid for it).
Gift,
/// Paid through Stripe Checkout.
Stripe,
}
@@ -220,6 +222,7 @@ impl Source {
Source::Admin => "admin",
Source::Mock => "mock",
Source::Promo => "promo",
Source::Gift => "gift",
Source::Stripe => "stripe",
}
}
@@ -228,6 +231,11 @@ impl Source {
impl Package {
/// What the package gives, as a phrase: "2 részletes képletelemzés, 1 kapcsolati elemzés, …".
pub fn contents_text(&self) -> String {
self.contents_items().join(", ")
}
/// What the package gives, item by item ("2 részletes képletelemzés").
pub fn contents_items(&self) -> Vec<String> {
[
(self.natal, "részletes képletelemzés"),
(self.synastry, "kapcsolati elemzés"),
@@ -239,8 +247,7 @@ impl Package {
.into_iter()
.filter(|&(n, _)| n > 0)
.map(|(n, what)| format!("{n} {what}"))
.collect::<Vec<_>>()
.join(", ")
.collect()
}
/// The invoice item: a name that says what the service is (online,
@@ -349,7 +356,8 @@ async fn record(
) -> Result<Uuid, ApiError> {
let order = Uuid::now_v7();
let price = match source {
Source::Admin | Source::Promo => 0,
// A gift's price is on the buyer's checkout.
Source::Admin | Source::Promo | Source::Gift => 0,
Source::Mock | Source::Stripe => package.price_huf,
};
sqlx::query(