diff --git a/app/models/supplier.rb b/app/models/supplier.rb index dbd012c8..31109d55 100644 --- a/app/models/supplier.rb +++ b/app/models/supplier.rb @@ -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 diff --git a/app/models/user.rb b/app/models/user.rb index f9339cd2..858afaac 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 diff --git a/app/views/admin/configs/_tab_payment.html.haml b/app/views/admin/configs/_tab_payment.html.haml index bbfa1845..d2a70562 100644 --- a/app/views/admin/configs/_tab_payment.html.haml +++ b/app/views/admin/configs/_tab_payment.html.haml @@ -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| diff --git a/app/views/shared/_user_form_fields.html.haml b/app/views/shared/_user_form_fields.html.haml index afca2598..b06dc111 100644 --- a/app/views/shared/_user_form_fields.html.haml +++ b/app/views/shared/_user_form_fields.html.haml @@ -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| diff --git a/app/views/suppliers/_form.html.haml b/app/views/suppliers/_form.html.haml index 0d612c43..97abefe0 100644 --- a/app/views/suppliers/_form.html.haml +++ b/app/views/suppliers/_form.html.haml @@ -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} diff --git a/app/views/suppliers/show.html.haml b/app/views/suppliers/show.html.haml index 892adfa6..d4b5b6ea 100644 --- a/app/views/suppliers/show.html.haml +++ b/app/views/suppliers/show.html.haml @@ -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) + ':' diff --git a/config/locales/de.yml b/config/locales/de.yml index fd58ca68..56666270 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -143,6 +143,7 @@ de: delivery_days: Liefertage email: E-Mail fax: Fax + iban: IBAN is_subscribed: abonniert? min_order_quantity: Mindestbestellmenge min_order_quantity_short: Menge (mind.) @@ -165,6 +166,7 @@ de: user: email: E-Mail first_name: Vorname + iban: IBAN last_activity: Letzte Aktivität last_login: Letzter login 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_current_orders: 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_nick: Benutzernamen anstatt reale Namen zeigen und verwenden, jeder Benutzer muss dazu einen Benutzernamen (Spitznamen) haben. use_wiki: "Änderbare Wiki Seiten aktivieren" @@ -569,6 +572,7 @@ de: use_boxfill: Kistenauffüllphase use_current_orders: use_documents: Dokumente verwenden + use_iban: IBAN verwenden use_messages: Nachrichten use_nick: Benutzernamen verwenden use_wiki: Wiki verwenden diff --git a/config/locales/en.yml b/config/locales/en.yml index c8e6af59..43769850 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -143,6 +143,7 @@ en: delivery_days: Delivery days email: Email fax: Fax + iban: IBAN is_subscribed: subscribed? min_order_quantity: Minimum order quantity min_order_quantity_short: Min. quantity @@ -165,6 +166,7 @@ en: user: email: Email first_name: First name + iban: IBAN last_activity: Last activity last_login: Last login 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_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_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_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. @@ -571,6 +574,7 @@ en: use_boxfill: Box-fill phase use_current_orders: Extra distribute screens use_documents: Enable documents + use_iban: Use IBAN use_messages: Messages use_nick: Use nicknames use_wiki: Enable wiki diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 4b7d4ea6..f8e3d148 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -143,6 +143,7 @@ fr: delivery_days: Jours de livraison email: Email fax: Fax + iban: IBAN is_subscribed: abonné? min_order_quantity: Prix minimum d'une commande min_order_quantity_short: Qté min. @@ -165,6 +166,7 @@ fr: user: email: Email first_name: Prénom + iban: IBAN last_activity: last_login: Dernière connection last_name: Nom de famille diff --git a/config/locales/nl.yml b/config/locales/nl.yml index 2279783b..5827b0cd 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -143,6 +143,7 @@ nl: delivery_days: Bezorgdagen email: Email fax: Fax + iban: IBAN is_subscribed: geabonneerd? min_order_quantity: Minimale bestelhoeveelheid min_order_quantity_short: Min. bestelling @@ -165,6 +166,7 @@ nl: user: email: Email first_name: Voornaam + iban: IBAN last_activity: Laatst actief last_login: Laatste login last_name: Achternaam diff --git a/db/migrate/20161001000000_add_iban_to_supplier_and_user.rb b/db/migrate/20161001000000_add_iban_to_supplier_and_user.rb new file mode 100644 index 00000000..df9aaca1 --- /dev/null +++ b/db/migrate/20161001000000_add_iban_to_supplier_and_user.rb @@ -0,0 +1,6 @@ +class AddIbanToSupplierAndUser < ActiveRecord::Migration + def change + add_column :suppliers, :iban, :string + add_column :users, :iban, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 76e5e310..2419a0cc 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # 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| 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.datetime "deleted_at" t.string "shared_sync_method", limit: 255 + t.string "iban" end 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_activity" t.datetime "deleted_at" + t.string "iban" end add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree