Files
ubicloud/prog/validate_vat.rb
Enes Cakir ec249c7d91 Send an email if the validated VAT is invalid
For now, we will send an email notification to ourselves if the VAT is
invalid. Later, we can send this email to the customer.
2025-03-19 09:46:45 +03:00

28 lines
862 B
Ruby

# frozen_string_literal: true
require "countries"
class Prog::ValidateVat < Prog::Base
subject_is :billing_info
label def start
billing_info.update(valid_vat: billing_info.validate_vat)
if !billing_info.valid_vat && (email = Config.invalid_vat_notification_email)
stripe_data = billing_info.stripe_data
Util.send_email(email, "Customer entered invalid VAT",
greeting: "Hello,",
body: ["Customer entered invalid VAT.",
"Project ID: #{billing_info.project.ubid}",
"Name: #{stripe_data["name"]}",
"E-mail: #{stripe_data["email"]}",
"Country Code: #{stripe_data["country"]}",
"Country: #{billing_info.country.common_name}",
"Company Name: #{stripe_data["company_name"]}",
"VAT ID: #{stripe_data["tax_id"]}"])
end
pop "VAT validated"
end
end