Add SupplierCategory
This allows the categorization of suppliers. For a better reporting it is necessary to split the expenses of the invoices. E.g. we want to be able to generate independent sums of general cost like the rent or electricity and the cost of the bought articles.
This commit is contained in:
parent
f5bbe0d5ae
commit
d90d188dbf
11 changed files with 90 additions and 25 deletions
25
db/migrate/20181201000400_create_supplier_categories.rb
Normal file
25
db/migrate/20181201000400_create_supplier_categories.rb
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
class CreateSupplierCategories < ActiveRecord::Migration
|
||||
class FinancialTransactionClass < ActiveRecord::Base; end
|
||||
class SupplierCategory < ActiveRecord::Base; end
|
||||
class Supplier < ActiveRecord::Base; end
|
||||
|
||||
def change
|
||||
create_table :supplier_categories do |t|
|
||||
t.string :name, null: false
|
||||
t.string :description
|
||||
t.references :financial_transaction_class, null: false
|
||||
end
|
||||
|
||||
add_reference :suppliers, :supplier_category
|
||||
|
||||
reversible do |dir|
|
||||
dir.up do
|
||||
ftc = FinancialTransactionClass.first
|
||||
sc = SupplierCategory.create name: 'Other', financial_transaction_class_id: ftc.id
|
||||
Supplier.update_all supplier_category_id: sc.id
|
||||
end
|
||||
end
|
||||
|
||||
change_column_null :suppliers, :supplier_category_id, false
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue