Add IBAN field to supplier and user model

This commit is contained in:
Patrick Gansterer 2017-01-18 11:12:56 +01:00 committed by wvengen
parent 925727d3ae
commit c6731b4e4f
12 changed files with 34 additions and 2 deletions

View file

@ -10,12 +10,14 @@ class Supplier < ActiveRecord::Base
belongs_to :shared_supplier # for the sharedLists-App
include ActiveModel::MassAssignmentSecurity
attr_accessible :name, :address, :phone, :phone2, :fax, :email, :url, :contact_person, :customer_number,
attr_accessible :name, :address, :phone, :phone2, :fax, :email, :url, :contact_person, :customer_number, :iban,
:delivery_days, :order_howto, :note, :shared_supplier_id, :min_order_quantity, :shared_sync_method
validates :name, :presence => true, :length => { :in => 4..30 }
validates :phone, :presence => true, :length => { :in => 8..25 }
validates :address, :presence => true, :length => { :in => 8..50 }
validates_format_of :iban, :with => /\A[A-Z]{2}[0-9]{2}[0-9A-Z]{,30}\z/, :allow_blank => true
validates_uniqueness_of :iban, :case_sensitive => false, :allow_blank => true
validates_length_of :order_howto, :note, maximum: 250
validate :valid_shared_sync_method
validate :uniqueness_of_name

View file

@ -41,6 +41,8 @@ class User < ActiveRecord::Base
validates_length_of :nick, :in => 2..25, :allow_nil => true, :unless => Proc.new { FoodsoftConfig[:use_nick] }
validates_length_of :nick, :in => 2..25, :allow_nil => false, :if => Proc.new { FoodsoftConfig[:use_nick] }
validates_uniqueness_of :nick, :case_sensitive => false, :allow_nil => true # allow_nil in length validation
validates_format_of :iban, :with => /\A[A-Z]{2}[0-9]{2}[0-9A-Z]{,30}\z/, :allow_blank => true
validates_uniqueness_of :iban, :case_sensitive => false, :allow_blank => true
before_validation :set_password
after_initialize do

View file

@ -10,6 +10,7 @@
.input-prepend
%span.add-on= t 'number.currency.format.unit'
= config_input_field form, :minimum_balance, as: :decimal, class: 'input-small'
= config_input form, :use_iban, as: :boolean
%h4= t '.schedule_title'
= form.simple_fields_for :order_schedule do |fields|

View file

@ -10,6 +10,8 @@
= f.input :password, :required => f.object.new_record?, input_html: password_html
= f.input :password_confirmation, :required => f.object.new_record?, input_html: password_html
= f.input :phone
- if FoodsoftConfig[:use_iban]
= f.input :iban
- if local_assigns[:with_address] && (f.object.ordergroup || f.object.new_record?)
= f.fields_for [:ordergroup, f.object.ordergroup || Ordergroup.new] do |ogf|

View file

@ -12,6 +12,8 @@
= f.input :url
= f.input :contact_person
= f.input :customer_number
- if FoodsoftConfig[:use_iban]
= f.input :iban
= f.input :delivery_days
= f.input :order_howto, as: :text, input_html: {rows: 5}
= f.input :note, as: :text, input_html: {rows: 5}

View file

@ -29,6 +29,9 @@
%dd= @supplier.contact_person
%dt= heading_helper(Supplier, :customer_number) + ':'
%dd= @supplier.customer_number
- if FoodsoftConfig[:use_iban]
%dt= heading_helper(Supplier, :iban) + ':'
%dd= @supplier.iban
%dt= heading_helper(Supplier, :delivery_days) + ':'
%dd= @supplier.delivery_days
%dt= heading_helper(Supplier, :order_howto) + ':'