Aggiunge fatturazione club, pagina regia condivisibile senza account, roster squadre e rimuove la modalità controller dall'app (v1.1.0). Co-authored-by: Cursor <cursoragent@cursor.com>
51 lines
1.2 KiB
Ruby
51 lines
1.2 KiB
Ruby
module Admin
|
|
class BillingInvoicesController < BaseController
|
|
before_action :set_club
|
|
|
|
def index
|
|
@invoices = @club.billing_invoices.recent
|
|
end
|
|
|
|
def new
|
|
@invoice = @club.billing_invoices.build(issued_on: Date.current, currency: "eur", source: "aruba")
|
|
end
|
|
|
|
def create
|
|
@invoice = @club.billing_invoices.build(invoice_params)
|
|
@invoice.source = "aruba"
|
|
|
|
if @invoice.save
|
|
redirect_to admin_club_billing_invoices_path(@club), notice: "Fattura #{@invoice.number} registrata."
|
|
else
|
|
flash.now[:alert] = @invoice.errors.full_messages.join(", ")
|
|
render :new, status: :unprocessable_entity
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def set_club
|
|
@club = Club.find(params[:club_id])
|
|
end
|
|
|
|
def invoice_params
|
|
params.require(:billing_invoice).permit(
|
|
:number,
|
|
:issued_on,
|
|
:amount_cents,
|
|
:amount_euros,
|
|
:currency,
|
|
:status,
|
|
:aruba_document_id,
|
|
:billing_payment_id,
|
|
:notes,
|
|
:pdf
|
|
).tap do |p|
|
|
if p[:amount_euros].present?
|
|
p[:amount_cents] = (p.delete(:amount_euros).to_f * 100).round
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|