Review fixes: no duplicate invoices, safer logins and redirects, one charge per click
Invoicing: the invoice request is marked before it goes to Billingo; a retry after a lost answer looks the invoice up under the invoice's own partner instead of issuing a second one. An invoice issued but never e-mailed counts as issued (downloadable). A Hungarian company with only an EU VAT number is invoiced without a domestic tax number, the EU number in the comment. Security: the login redirect takes only plain local paths (no backslash); the waitlist rate limit and share visits use X-Real-IP, which Caddy sets from Cloudflare's address, not the spoofable first X-Forwarded-For entry; a Google/Apple sign-in to an unconfirmed password account removes its password and sessions; a person's birth data can no longer be published through a share. Credits and jobs: analysis requests are serialized per user, so a double click queues and pays once; a forecast analysis also fixes a person's birth data; admins can restart stuck tarot readings; a worker forgets an attempt an admin restarted, so a stop does not requeue it; two people accepting one comparison invite at once get one comparison. Expired invitations are no longer accepted by e-mail, and unsubscribing revokes the invitation's promo codes too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -65,7 +65,11 @@ fn text(v: &Value) -> Option<String> {
|
||||
|
||||
impl Buyer {
|
||||
/// A company ("buying as a business") gives its name and tax id: a
|
||||
/// Hungarian tax number (`hu_tin`) is preferred to an EU VAT number.
|
||||
/// Hungarian tax number (`hu_tin`) is preferred to an EU VAT number. A
|
||||
/// Hungarian company with only an EU VAT number (`HU12345678`) is invoiced
|
||||
/// without a tax type number: Billingo takes only the full domestic
|
||||
/// number (`12345678-1-23`) for HAS_TAX_NUMBER; the EU number still goes
|
||||
/// on the invoice, in its comment (the worker adds it).
|
||||
pub fn from_stripe(details: &Value, fallback_email: Option<&str>) -> Self {
|
||||
let address = &details["address"];
|
||||
let tax_ids = details["tax_ids"].as_array().map(Vec::as_slice).unwrap_or_default();
|
||||
@@ -74,8 +78,8 @@ impl Buyer {
|
||||
let country = text(&address["country"]).unwrap_or_else(|| "HU".into()).to_uppercase();
|
||||
let tax_type = match (&tax_number, country.as_str()) {
|
||||
(_, c) if c != "HU" => "FOREIGN",
|
||||
(Some(_), _) => "HAS_TAX_NUMBER",
|
||||
(None, _) => "NO_TAX_NUMBER",
|
||||
(Some(_), _) if tax_id("hu_tin").is_some() => "HAS_TAX_NUMBER",
|
||||
_ => "NO_TAX_NUMBER",
|
||||
};
|
||||
let street = [text(&address["line1"]), text(&address["line2"])].into_iter().flatten().collect::<Vec<_>>();
|
||||
Self {
|
||||
@@ -176,6 +180,14 @@ mod tests {
|
||||
assert_eq!(company.email.as_deref(), Some("anna@example.com"));
|
||||
assert_eq!((company.tax_type, company.tax_number.as_deref()), ("HAS_TAX_NUMBER", Some("12345678-1-23")));
|
||||
|
||||
let eu_only = Buyer::from_stripe(
|
||||
&json!({"name": "Kovács Anna", "business_name": "Csillag Kft.", "address": {"country": "HU"},
|
||||
"tax_ids": [{"type": "eu_vat", "value": "HU12345678"}]}),
|
||||
None,
|
||||
);
|
||||
assert_eq!(eu_only.name, "Csillag Kft.");
|
||||
assert_eq!((eu_only.tax_type, eu_only.tax_number.as_deref()), ("NO_TAX_NUMBER", Some("HU12345678")));
|
||||
|
||||
let abroad = Buyer::from_stripe(&json!({"name": "Anna", "address": {"country": "at"}}), None);
|
||||
assert_eq!((abroad.country.as_str(), abroad.tax_type), ("AT", "FOREIGN"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user