add specs

This commit is contained in:
viehlieb 2025-05-22 12:27:25 +02:00
parent e902aa0d5a
commit 45db0575b1
46 changed files with 714 additions and 238 deletions

View file

@ -0,0 +1,34 @@
# app/models/concerns/invoice_common.rb
module InvoiceCommon
extend ActiveSupport::Concern
included do
include InvoiceHelper
validates_presence_of :invoice_number
validates_uniqueness_of :invoice_number
validate :tax_number_set
after_initialize :init, unless: :persisted?
end
def mark_sepa_downloaded
self.sepa_downloaded = true
save
end
def unmark_sepa_downloaded
self.sepa_downloaded = false
save
end
def name
I18n.t("activerecord.attributes.#{self.class.name.underscore}.name") + "_#{invoice_number}"
end
def tax_number_set
return if FoodsoftConfig[:contact][:tax_number].present?
errors.add(:base, "Keine Steuernummer in FoodsoftConfig :contact gesetzt")
end
end