Aggiunge pagamento con bonifico e importo concordato per società.

Il piano si attiva solo dopo la conferma admin; Stripe resta a listino se non c'è un prezzo commerciale.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-18 23:20:43 +02:00
co-authored by Cursor
parent 1e4e0560f1
commit e436f5ece4
56 changed files with 1571 additions and 53 deletions
@@ -0,0 +1,26 @@
module Billing
class EuroAmount
class Error < StandardError; end
def self.to_cents(value)
raw = value.to_s.strip
raise Error, "Indica l'importo in euro" if raw.blank?
normalized = raw.gsub(/\s+/, "")
if normalized.match?(/\A\d{1,3}(\.\d{3})*,\d{1,2}\z/)
normalized = normalized.gsub(".", "").tr(",", ".")
elsif normalized.match?(/\A\d+,\d{1,2}\z/)
normalized = normalized.tr(",", ".")
elsif normalized.match?(/\A\d{1,3}(,\d{3})*\.\d{1,2}\z/)
normalized = normalized.gsub(",", "")
end
raise Error, "Importo non valido" unless normalized.match?(/\A\d+(\.\d{1,2})?\z/)
cents = (BigDecimal(normalized) * 100).round
raise Error, "L'importo deve essere maggiore di zero" unless cents.positive?
cents.to_i
end
end
end