Non inviare in automatico le istruzioni di bonifico.

IBAN e causale restano da comunicare a mano dall'admin; la richiesta registra solo l'ordine in attesa.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-19 18:40:45 +02:00
co-authored by Cursor
parent 5bcb4170c7
commit a51d5e8da5
2 changed files with 10 additions and 12 deletions
@@ -28,7 +28,6 @@ module Billing
existing = @club.billing_transfer_orders.awaiting_payment.first existing = @club.billing_transfer_orders.awaiting_payment.first
if existing if existing
if existing.plan_slug == @plan_slug && existing.billing_interval == @interval && existing.amount_cents == amount_cents if existing.plan_slug == @plan_slug && existing.billing_interval == @interval && existing.amount_cents == amount_cents
MatchLiveTv.deliver_mail(BankTransferMailer.with(order: existing).instructions)
return existing return existing
end end
@@ -59,7 +58,8 @@ module Billing
) )
end end
MatchLiveTv.deliver_mail(BankTransferMailer.with(order: order).instructions) # Le istruzioni (IBAN/causale) le manda a mano l'admin da /admin/billing.
Rails.logger.info("[BankTransfer] ordine #{order.reference_code} in attesa, nessuna mail istruzioni")
order order
end end
@@ -26,11 +26,11 @@ RSpec.describe Billing::RequestBankTransfer do
) )
end end
it "crea l'ordine a listino e invia le istruzioni" do it "crea l'ordine a listino senza inviare le istruzioni" do
expect { expect {
described_class.call(club: club, user: user, plan_slug: "premium_light", interval: "yearly") described_class.call(club: club, user: user, plan_slug: "premium_light", interval: "yearly")
}.to change { club.billing_transfer_orders.count }.by(1) }.to change { club.billing_transfer_orders.count }.by(1)
.and change { ActionMailer::Base.deliveries.size }.by(1) .and change { ActionMailer::Base.deliveries.size }.by(0)
order = club.billing_transfer_orders.last order = club.billing_transfer_orders.last
expect(order).to be_awaiting_payment expect(order).to be_awaiting_payment
@@ -41,16 +41,14 @@ RSpec.describe Billing::RequestBankTransfer do
expect(club.reload.subscription.plan.slug).to eq("free") expect(club.reload.subscription.plan.slug).to eq("free")
end end
it "crea comunque l'ordine se in produzione manca SMTP" do it "non reinvia istruzioni se l'ordine è già in attesa" do
allow(MatchLiveTv).to receive(:smtp_configured?).and_return(false) first = described_class.call(club: club, user: user, plan_slug: "premium_light", interval: "yearly")
allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new("production")) ActionMailer::Base.deliveries.clear
expect { expect {
described_class.call(club: club, user: user, plan_slug: "premium_light", interval: "yearly") second = described_class.call(club: club, user: user, plan_slug: "premium_light", interval: "yearly")
}.to change { club.billing_transfer_orders.count }.by(1) expect(second.id).to eq(first.id)
.and change { ActionMailer::Base.deliveries.size }.by(0) }.not_to change { ActionMailer::Base.deliveries.size }
expect(club.billing_transfer_orders.last).to be_awaiting_payment
end end
it "usa l'importo concordato se presente" do it "usa l'importo concordato se presente" do