Add short name to FinancialTransactionType

This commit is contained in:
Patrick Gansterer 2018-09-12 15:02:25 +02:00
parent 707501e3f8
commit 0bb0536903
6 changed files with 14 additions and 1 deletions

View file

@ -4,6 +4,7 @@ class FinancialTransactionType < ActiveRecord::Base
validates :name, presence: true
validates_uniqueness_of :name
validates_uniqueness_of :name_short, allow_blank: true, allow_nil: true
validates :financial_transaction_class, presence: true
before_destroy :restrict_deleting_last_financial_transaction_type

View file

@ -5,6 +5,7 @@
.modal-body
= f.input :name
= f.association :financial_transaction_class, :include_blank => false
= f.input :name_short
.modal-footer
= link_to t('ui.close'), '#', class: 'btn', data: {dismiss: 'modal'}
= f.submit class: 'btn btn-primary'

View file

@ -54,6 +54,7 @@ de:
financial_transaction_type:
name: Name
financial_transaction_class: Finanztransaktionsklasse
name_short: Kurzname
group_order:
ordergroup: Bestellgruppe
price: Bestellsumme

View file

@ -54,6 +54,7 @@ en:
financial_transaction_type:
name: Name
financial_transaction_class: Financial transaction class
name_short: Short Name
group_order:
ordergroup: Ordergroup
price: Order sum

View file

@ -0,0 +1,6 @@
class AddNameShortToFinancialTransactionType < ActiveRecord::Migration
def change
add_column :financial_transaction_types, :name_short, :string
add_index :financial_transaction_types, :name_short
end
end

View file

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20171111000000) do
ActiveRecord::Schema.define(version: 20171201000000) do
create_table "article_categories", force: :cascade do |t|
t.string "name", limit: 255, default: "", null: false
@ -123,8 +123,11 @@ ActiveRecord::Schema.define(version: 20171111000000) do
create_table "financial_transaction_types", force: :cascade do |t|
t.string "name", null: false
t.integer "financial_transaction_class_id", null: false
t.string "name_short"
end
add_index "financial_transaction_types", ["name_short"], name: "index_financial_transaction_types_on_name_short", using: :btree
create_table "financial_transactions", force: :cascade do |t|
t.integer "ordergroup_id", limit: 4, default: 0, null: false
t.decimal "amount", precision: 8, scale: 2, default: 0, null: false