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 belongs_to :shared_supplier # for the sharedLists-App
include ActiveModel::MassAssignmentSecurity 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 :delivery_days, :order_howto, :note, :shared_supplier_id, :min_order_quantity, :shared_sync_method
validates :name, :presence => true, :length => { :in => 4..30 } validates :name, :presence => true, :length => { :in => 4..30 }
validates :phone, :presence => true, :length => { :in => 8..25 } validates :phone, :presence => true, :length => { :in => 8..25 }
validates :address, :presence => true, :length => { :in => 8..50 } 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 validates_length_of :order_howto, :note, maximum: 250
validate :valid_shared_sync_method validate :valid_shared_sync_method
validate :uniqueness_of_name 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 => true, :unless => Proc.new { FoodsoftConfig[:use_nick] }
validates_length_of :nick, :in => 2..25, :allow_nil => false, :if => 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_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 before_validation :set_password
after_initialize do after_initialize do

View file

@ -10,6 +10,7 @@
.input-prepend .input-prepend
%span.add-on= t 'number.currency.format.unit' %span.add-on= t 'number.currency.format.unit'
= config_input_field form, :minimum_balance, as: :decimal, class: 'input-small' = config_input_field form, :minimum_balance, as: :decimal, class: 'input-small'
= config_input form, :use_iban, as: :boolean
%h4= t '.schedule_title' %h4= t '.schedule_title'
= form.simple_fields_for :order_schedule do |fields| = 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, :required => f.object.new_record?, input_html: password_html
= f.input :password_confirmation, :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 = f.input :phone
- if FoodsoftConfig[:use_iban]
= f.input :iban
- if local_assigns[:with_address] && (f.object.ordergroup || f.object.new_record?) - if local_assigns[:with_address] && (f.object.ordergroup || f.object.new_record?)
= f.fields_for [:ordergroup, f.object.ordergroup || Ordergroup.new] do |ogf| = f.fields_for [:ordergroup, f.object.ordergroup || Ordergroup.new] do |ogf|

View file

@ -12,6 +12,8 @@
= f.input :url = f.input :url
= f.input :contact_person = f.input :contact_person
= f.input :customer_number = f.input :customer_number
- if FoodsoftConfig[:use_iban]
= f.input :iban
= f.input :delivery_days = f.input :delivery_days
= f.input :order_howto, as: :text, input_html: {rows: 5} = f.input :order_howto, as: :text, input_html: {rows: 5}
= f.input :note, 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 %dd= @supplier.contact_person
%dt= heading_helper(Supplier, :customer_number) + ':' %dt= heading_helper(Supplier, :customer_number) + ':'
%dd= @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) + ':' %dt= heading_helper(Supplier, :delivery_days) + ':'
%dd= @supplier.delivery_days %dd= @supplier.delivery_days
%dt= heading_helper(Supplier, :order_howto) + ':' %dt= heading_helper(Supplier, :order_howto) + ':'

View file

@ -143,6 +143,7 @@ de:
delivery_days: Liefertage delivery_days: Liefertage
email: E-Mail email: E-Mail
fax: Fax fax: Fax
iban: IBAN
is_subscribed: abonniert? is_subscribed: abonniert?
min_order_quantity: Mindestbestellmenge min_order_quantity: Mindestbestellmenge
min_order_quantity_short: Menge (mind.) min_order_quantity_short: Menge (mind.)
@ -165,6 +166,7 @@ de:
user: user:
email: E-Mail email: E-Mail
first_name: Vorname first_name: Vorname
iban: IBAN
last_activity: Letzte Aktivität last_activity: Letzte Aktivität
last_login: Letzter login last_login: Letzter login
last_name: Nachname last_name: Nachname
@ -518,6 +520,7 @@ de:
use_boxfill: Wenn aktiviert, können Benutzer nahe am Ende der Bestellung diese nur mehr so verändern, dass sich die Gesamtsumme erhöht. Dies hilft beim auffüllen der verbleibenden Kisten. Es muss trotzdem noch das Kistenauffülldatum bei der Bestellung gesetzt werden. use_boxfill: Wenn aktiviert, können Benutzer nahe am Ende der Bestellung diese nur mehr so verändern, dass sich die Gesamtsumme erhöht. Dies hilft beim auffüllen der verbleibenden Kisten. Es muss trotzdem noch das Kistenauffülldatum bei der Bestellung gesetzt werden.
use_current_orders: use_current_orders:
use_documents: Einfache Dokumentenverwaltung aktivieren use_documents: Einfache Dokumentenverwaltung aktivieren
use_iban: Zusätzlich Feld für die internationale Kontonummer bei Benutzern und Lieferanten anzeigen
use_messages: Den Mitgliedern erlauben, miteinander innerhalb Foodsoft zu kommunizieren use_messages: Den Mitgliedern erlauben, miteinander innerhalb Foodsoft zu kommunizieren
use_nick: Benutzernamen anstatt reale Namen zeigen und verwenden, jeder Benutzer muss dazu einen Benutzernamen (Spitznamen) haben. use_nick: Benutzernamen anstatt reale Namen zeigen und verwenden, jeder Benutzer muss dazu einen Benutzernamen (Spitznamen) haben.
use_wiki: "Änderbare Wiki Seiten aktivieren" use_wiki: "Änderbare Wiki Seiten aktivieren"
@ -569,6 +572,7 @@ de:
use_boxfill: Kistenauffüllphase use_boxfill: Kistenauffüllphase
use_current_orders: use_current_orders:
use_documents: Dokumente verwenden use_documents: Dokumente verwenden
use_iban: IBAN verwenden
use_messages: Nachrichten use_messages: Nachrichten
use_nick: Benutzernamen verwenden use_nick: Benutzernamen verwenden
use_wiki: Wiki verwenden use_wiki: Wiki verwenden

View file

@ -143,6 +143,7 @@ en:
delivery_days: Delivery days delivery_days: Delivery days
email: Email email: Email
fax: Fax fax: Fax
iban: IBAN
is_subscribed: subscribed? is_subscribed: subscribed?
min_order_quantity: Minimum order quantity min_order_quantity: Minimum order quantity
min_order_quantity_short: Min. quantity min_order_quantity_short: Min. quantity
@ -165,6 +166,7 @@ en:
user: user:
email: Email email: Email
first_name: First name first_name: First name
iban: IBAN
last_activity: Last activity last_activity: Last activity
last_login: Last login last_login: Last login
last_name: Last name last_name: Last name
@ -520,6 +522,7 @@ en:
use_boxfill: When enabled, near end of an order, members are only able to change their order when increases the total amount ordered. This helps to fill any remaining boxes. You still need to set a box-fill date for the orders. use_boxfill: When enabled, near end of an order, members are only able to change their order when increases the total amount ordered. This helps to fill any remaining boxes. You still need to set a box-fill date for the orders.
use_current_orders: Enable the current_orders plugin. Allows members with the order permission to change member amounts in multiple orders, using three new screens in the Orders menu. Especially useful for pick-up days. use_current_orders: Enable the current_orders plugin. Allows members with the order permission to change member amounts in multiple orders, using three new screens in the Orders menu. Especially useful for pick-up days.
use_documents: Add a basic document sharing page to the foodcoop menu. use_documents: Add a basic document sharing page to the foodcoop menu.
use_iban: When enabled, supplier and user provide an additonal field for storing the international bank account number.
use_messages: Allow members to communicate with each other within Foodsoft. use_messages: Allow members to communicate with each other within Foodsoft.
use_nick: Show and use nicknames instead of real names. When enabling this, please check that each user has a nickname. use_nick: Show and use nicknames instead of real names. When enabling this, please check that each user has a nickname.
use_wiki: Enable editable wiki pages. use_wiki: Enable editable wiki pages.
@ -571,6 +574,7 @@ en:
use_boxfill: Box-fill phase use_boxfill: Box-fill phase
use_current_orders: Extra distribute screens use_current_orders: Extra distribute screens
use_documents: Enable documents use_documents: Enable documents
use_iban: Use IBAN
use_messages: Messages use_messages: Messages
use_nick: Use nicknames use_nick: Use nicknames
use_wiki: Enable wiki use_wiki: Enable wiki

View file

@ -143,6 +143,7 @@ fr:
delivery_days: Jours de livraison delivery_days: Jours de livraison
email: Email email: Email
fax: Fax fax: Fax
iban: IBAN
is_subscribed: abonné? is_subscribed: abonné?
min_order_quantity: Prix minimum d'une commande min_order_quantity: Prix minimum d'une commande
min_order_quantity_short: Qté min. min_order_quantity_short: Qté min.
@ -165,6 +166,7 @@ fr:
user: user:
email: Email email: Email
first_name: Prénom first_name: Prénom
iban: IBAN
last_activity: last_activity:
last_login: Dernière connection last_login: Dernière connection
last_name: Nom de famille last_name: Nom de famille

View file

@ -143,6 +143,7 @@ nl:
delivery_days: Bezorgdagen delivery_days: Bezorgdagen
email: Email email: Email
fax: Fax fax: Fax
iban: IBAN
is_subscribed: geabonneerd? is_subscribed: geabonneerd?
min_order_quantity: Minimale bestelhoeveelheid min_order_quantity: Minimale bestelhoeveelheid
min_order_quantity_short: Min. bestelling min_order_quantity_short: Min. bestelling
@ -165,6 +166,7 @@ nl:
user: user:
email: Email email: Email
first_name: Voornaam first_name: Voornaam
iban: IBAN
last_activity: Laatst actief last_activity: Laatst actief
last_login: Laatste login last_login: Laatste login
last_name: Achternaam last_name: Achternaam

View file

@ -0,0 +1,6 @@
class AddIbanToSupplierAndUser < ActiveRecord::Migration
def change
add_column :suppliers, :iban, :string
add_column :users, :iban, :string
end
end

View file

@ -11,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20160226000000) do ActiveRecord::Schema.define(version: 20161001000000) do
create_table "article_categories", force: :cascade do |t| create_table "article_categories", force: :cascade do |t|
t.string "name", limit: 255, default: "", null: false t.string "name", limit: 255, default: "", null: false
@ -317,6 +317,7 @@ ActiveRecord::Schema.define(version: 20160226000000) do
t.string "min_order_quantity", limit: 255 t.string "min_order_quantity", limit: 255
t.datetime "deleted_at" t.datetime "deleted_at"
t.string "shared_sync_method", limit: 255 t.string "shared_sync_method", limit: 255
t.string "iban"
end end
add_index "suppliers", ["name"], name: "index_suppliers_on_name", unique: true, using: :btree add_index "suppliers", ["name"], name: "index_suppliers_on_name", unique: true, using: :btree
@ -352,6 +353,7 @@ ActiveRecord::Schema.define(version: 20160226000000) do
t.datetime "last_login" t.datetime "last_login"
t.datetime "last_activity" t.datetime "last_activity"
t.datetime "deleted_at" t.datetime "deleted_at"
t.string "iban"
end end
add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree