changing view for group_order_invoices
testing ui of goi restructuring
This commit is contained in:
parent
de6643722a
commit
90c5450525
52 changed files with 783 additions and 57 deletions
|
|
@ -6,6 +6,8 @@ class Group < ApplicationRecord
|
|||
|
||||
has_many :memberships, dependent: :destroy
|
||||
has_many :users, -> { where(deleted_at: nil) }, through: :memberships
|
||||
has_one :sepa_account_holder, dependent: :destroy
|
||||
accepts_nested_attributes_for :sepa_account_holder, allow_destroy: true
|
||||
|
||||
validates :name, presence: true, length: { in: 1..25 }
|
||||
validates :name, uniqueness: true
|
||||
|
|
|
|||
|
|
@ -1,10 +1,18 @@
|
|||
class GroupOrderInvoice < ApplicationRecord
|
||||
|
||||
belongs_to :group_order
|
||||
validates_presence_of :group_order
|
||||
validates_uniqueness_of :invoice_number
|
||||
validate :tax_number_set
|
||||
after_initialize :init, unless: :persisted?
|
||||
|
||||
enum sequence_type: {
|
||||
FRST: "Erst-Lastschrift",
|
||||
RCUR: "Folge-Lastschrift",
|
||||
OOFF: "Einmalige Lastschrift",
|
||||
FNAL: "Letztmalige Lastschrift"
|
||||
}
|
||||
|
||||
def generate_invoice_number(count)
|
||||
trailing_number = count.to_s.rjust(4, '0')
|
||||
if GroupOrderInvoice.find_by(invoice_number: self.invoice_date.strftime("%Y%m%d") + trailing_number)
|
||||
|
|
@ -20,6 +28,16 @@ class GroupOrderInvoice < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
def mark_sepa_downloaded
|
||||
self.sepa_downloaded = true
|
||||
self.save
|
||||
end
|
||||
|
||||
def unmark_sepa_downloaded
|
||||
self.sepa_downloaded = false
|
||||
self.save
|
||||
end
|
||||
|
||||
def init
|
||||
self.invoice_date = Time.now unless invoice_date
|
||||
self.invoice_number = generate_invoice_number(1) unless self.invoice_number
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ class Ordergroup < Group
|
|||
|
||||
APPLE_MONTH_AGO = 6 # How many month back we will count tasks and orders sum
|
||||
|
||||
attr_accessor :sepa_account_holder_user_id
|
||||
|
||||
serialize :stats
|
||||
|
||||
has_many :financial_transactions
|
||||
|
|
@ -182,6 +184,10 @@ class Ordergroup < Group
|
|||
result.order(Arel.sql(sort_param_map[param]))
|
||||
end
|
||||
|
||||
def sepa_possible?
|
||||
sepa_account_holder&.all_fields_present? || false
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Make sure, that a user can only be in one ordergroup
|
||||
|
|
|
|||
8
app/models/sepa_account_holder.rb
Normal file
8
app/models/sepa_account_holder.rb
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
class SepaAccountHolder < ApplicationRecord
|
||||
belongs_to :group
|
||||
belongs_to :user
|
||||
|
||||
def all_fields_present?
|
||||
iban.present? && bic.present? && mandate_id.present? && user_id.present? && mandate_date_of_signature.present? && group_id.present?
|
||||
end
|
||||
end
|
||||
|
|
@ -17,6 +17,7 @@ class User < ApplicationRecord
|
|||
has_many :send_messages, class_name: 'Message', foreign_key: 'sender_id'
|
||||
has_many :created_orders, class_name: 'Order', foreign_key: 'created_by_user_id', dependent: :nullify
|
||||
has_many :mail_delivery_status, class_name: 'MailDeliveryStatus', foreign_key: 'email', primary_key: 'email'
|
||||
has_many :accountable_payment_groups, class_name: 'PaymentAccountHolder'
|
||||
|
||||
attr_accessor :create_ordergroup, :password, :send_welcome_mail, :settings_attributes
|
||||
|
||||
|
|
@ -120,6 +121,10 @@ class User < ApplicationRecord
|
|||
settings.messages['send_as_email'] && email.present?
|
||||
end
|
||||
|
||||
def sepa_possible?
|
||||
iban.present? && bic.present? && creditor_identifier.present? && mandate_id.present?
|
||||
end
|
||||
|
||||
# Sets the user's password. It will be stored encrypted along with a random salt.
|
||||
def set_password
|
||||
return if password.blank?
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue