add specs
This commit is contained in:
parent
e902aa0d5a
commit
45db0575b1
46 changed files with 714 additions and 238 deletions
|
|
@ -1,25 +1,10 @@
|
|||
class OrdergroupInvoice < ApplicationRecord
|
||||
include InvoiceHelper
|
||||
include InvoiceCommon
|
||||
|
||||
belongs_to :multi_group_order, optional: true
|
||||
belongs_to :multi_group_order
|
||||
|
||||
# has_many :group_orders, through: :multi_group_order, dependent: :nullify
|
||||
|
||||
validates_presence_of :invoice_number
|
||||
validates_uniqueness_of :invoice_number
|
||||
validate :tax_number_set
|
||||
after_initialize :init, unless: :persisted?
|
||||
|
||||
# accepts_nested_attributes_for :group_orders, :multi_group_order
|
||||
|
||||
|
||||
enum sequence_type: {
|
||||
FRST: "Erst-Lastschrift",
|
||||
RCUR: "Folge-Lastschrift",
|
||||
OOFF: "Einmalige Lastschrift",
|
||||
FNAL: "Letztmalige Lastschrift"
|
||||
}
|
||||
|
||||
def init
|
||||
self.invoice_date = Time.now unless invoice_date
|
||||
self.invoice_number = generate_invoice_number(self, 1) unless self.invoice_number
|
||||
|
|
@ -32,24 +17,8 @@ class OrdergroupInvoice < ApplicationRecord
|
|||
group_orders.first.ordergroup
|
||||
end
|
||||
|
||||
def tax_number_set
|
||||
return if FoodsoftConfig[:contact][:tax_number].present?
|
||||
|
||||
errors.add(:cumulative_invoice, "Keine Steuernummer in FoodsoftConfig :contact gesetzt")
|
||||
end
|
||||
|
||||
def mark_sepa_downloaded
|
||||
self.sepa_downloaded = true
|
||||
self.save
|
||||
end
|
||||
|
||||
def unmark_sepa_downloaded
|
||||
self.sepa_downloaded = false
|
||||
self.save
|
||||
end
|
||||
|
||||
def name
|
||||
I18n.t('activerecord.attributes.ordergroup_invoice.name') + "_#{invoice_number}"
|
||||
def send_invoice
|
||||
NotifyOrdergroupInvoiceJob.perform_now(self)
|
||||
end
|
||||
|
||||
def load_data_for_invoice
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue