add specs
This commit is contained in:
parent
e902aa0d5a
commit
45db0575b1
46 changed files with 714 additions and 238 deletions
34
app/models/concerns/invoice_common.rb
Normal file
34
app/models/concerns/invoice_common.rb
Normal 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
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue