Add versioning to billing

This commit is contained in:
Martin Lensment 2015-04-17 12:39:09 +03:00
parent 7c846c4550
commit f514e50628
16 changed files with 258 additions and 13 deletions

View file

@ -1,4 +1,5 @@
class Account < ActiveRecord::Base class Account < ActiveRecord::Base
include Versions
belongs_to :registrar belongs_to :registrar
has_many :account_activities has_many :account_activities

View file

@ -1,4 +1,5 @@
class AccountActivity < ActiveRecord::Base class AccountActivity < ActiveRecord::Base
include Versions
belongs_to :account belongs_to :account
belongs_to :bank_transaction belongs_to :bank_transaction
belongs_to :invoice belongs_to :invoice

View file

@ -1,4 +1,5 @@
class BankStatement < ActiveRecord::Base class BankStatement < ActiveRecord::Base
include Versions
has_many :bank_transactions has_many :bank_transactions
attr_accessor :th6_file attr_accessor :th6_file

View file

@ -1,4 +1,5 @@
class BankTransaction < ActiveRecord::Base class BankTransaction < ActiveRecord::Base
include Versions
belongs_to :bank_statement belongs_to :bank_statement
has_one :account_activity has_one :account_activity

View file

@ -1,4 +1,5 @@
class Invoice < ActiveRecord::Base class Invoice < ActiveRecord::Base
include Versions
belongs_to :seller, class_name: 'Registrar' belongs_to :seller, class_name: 'Registrar'
belongs_to :buyer, class_name: 'Registrar' belongs_to :buyer, class_name: 'Registrar'
has_many :invoice_items has_many :invoice_items

View file

@ -1,4 +1,5 @@
class InvoiceItem < ActiveRecord::Base class InvoiceItem < ActiveRecord::Base
include Versions
belongs_to :invoice belongs_to :invoice
def item_sum_without_vat def item_sum_without_vat

View file

@ -0,0 +1,4 @@
class AccountActivityVersion < PaperTrail::Version
self.table_name = :log_account_activities
self.sequence_name = :log_account_activities_id_seq
end

View file

@ -0,0 +1,4 @@
class AccountVersion < PaperTrail::Version
self.table_name = :log_accounts
self.sequence_name = :log_accounts_id_seq
end

View file

@ -0,0 +1,4 @@
class BankStatementVersion < PaperTrail::Version
self.table_name = :log_bank_statements
self.sequence_name = :log_bank_statements_id_seq
end

View file

@ -0,0 +1,4 @@
class BankTransactionVersion < PaperTrail::Version
self.table_name = :log_bank_transactions
self.sequence_name = :log_bank_transactions_id_seq
end

View file

@ -0,0 +1,4 @@
class InvoiceItemVersion < PaperTrail::Version
self.table_name = :log_invoice_items
self.sequence_name = :log_invoice_items_id_seq
end

View file

@ -0,0 +1,4 @@
class InvoiceVersion < PaperTrail::Version
self.table_name = :log_invoices
self.sequence_name = :log_invoices_id_seq
end

View file

@ -722,3 +722,4 @@ en:
admin_head_title_sufix: ' - Estonian Internet Foundation' admin_head_title_sufix: ' - Estonian Internet Foundation'
registrar_head_title: 'EIS Registrar' registrar_head_title: 'EIS Registrar'
admin_head_title: 'Estonian Internet Foundation' admin_head_title: 'Estonian Internet Foundation'
bind_manually: 'Bind manually'

View file

@ -0,0 +1,112 @@
class CreateVersionsForBilling < ActiveRecord::Migration
def change
add_column :account_activities, :creator_str, :string
add_column :account_activities, :updator_str, :string
add_column :accounts, :creator_str, :string
add_column :accounts, :updator_str, :string
add_column :bank_statements, :creator_str, :string
add_column :bank_statements, :updator_str, :string
add_column :bank_transactions, :creator_str, :string
add_column :bank_transactions, :updator_str, :string
add_column :invoices, :creator_str, :string
add_column :invoices, :updator_str, :string
add_column :invoice_items, :creator_str, :string
add_column :invoice_items, :updator_str, :string
create_table "log_account_activities", force: :cascade do |t|
t.string "item_type", null: false
t.integer "item_id", null: false
t.string "event", null: false
t.string "whodunnit"
t.json "object"
t.json "object_changes"
t.datetime "created_at"
t.string "session"
t.json "children"
end
add_index "log_account_activities", ["item_type", "item_id"], name: "index_log_account_activities_on_item_type_and_item_id", using: :btree
add_index "log_account_activities", ["whodunnit"], name: "index_log_account_activities_on_whodunnit", using: :btree
create_table "log_accounts", force: :cascade do |t|
t.string "item_type", null: false
t.integer "item_id", null: false
t.string "event", null: false
t.string "whodunnit"
t.json "object"
t.json "object_changes"
t.datetime "created_at"
t.string "session"
t.json "children"
end
add_index "log_accounts", ["item_type", "item_id"], name: "index_log_accounts_on_item_type_and_item_id", using: :btree
add_index "log_accounts", ["whodunnit"], name: "index_log_accounts_on_whodunnit", using: :btree
create_table "log_bank_statements", force: :cascade do |t|
t.string "item_type", null: false
t.integer "item_id", null: false
t.string "event", null: false
t.string "whodunnit"
t.json "object"
t.json "object_changes"
t.datetime "created_at"
t.string "session"
t.json "children"
end
add_index "log_bank_statements", ["item_type", "item_id"], name: "index_log_bank_statements_on_item_type_and_item_id", using: :btree
add_index "log_bank_statements", ["whodunnit"], name: "index_log_bank_statements_on_whodunnit", using: :btree
create_table "log_bank_transactions", force: :cascade do |t|
t.string "item_type", null: false
t.integer "item_id", null: false
t.string "event", null: false
t.string "whodunnit"
t.json "object"
t.json "object_changes"
t.datetime "created_at"
t.string "session"
t.json "children"
end
add_index "log_bank_transactions", ["item_type", "item_id"], name: "index_log_bank_transactions_on_item_type_and_item_id", using: :btree
add_index "log_bank_transactions", ["whodunnit"], name: "index_log_bank_transactions_on_whodunnit", using: :btree
create_table "log_invoices", force: :cascade do |t|
t.string "item_type", null: false
t.integer "item_id", null: false
t.string "event", null: false
t.string "whodunnit"
t.json "object"
t.json "object_changes"
t.datetime "created_at"
t.string "session"
t.json "children"
end
add_index "log_invoices", ["item_type", "item_id"], name: "index_log_invoices_on_item_type_and_item_id", using: :btree
add_index "log_invoices", ["whodunnit"], name: "index_log_invoices_on_whodunnit", using: :btree
create_table "log_invoice_items", force: :cascade do |t|
t.string "item_type", null: false
t.integer "item_id", null: false
t.string "event", null: false
t.string "whodunnit"
t.json "object"
t.json "object_changes"
t.datetime "created_at"
t.string "session"
t.json "children"
end
add_index "log_invoice_items", ["item_type", "item_id"], name: "index_log_invoice_items_on_item_type_and_item_id", using: :btree
add_index "log_invoice_items", ["whodunnit"], name: "index_log_invoice_items_on_whodunnit", using: :btree
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: 20150416094704) do ActiveRecord::Schema.define(version: 20150417082723) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
@ -25,6 +25,8 @@ ActiveRecord::Schema.define(version: 20150416094704) do
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.string "description" t.string "description"
t.string "creator_str"
t.string "updator_str"
end end
add_index "account_activities", ["account_id"], name: "index_account_activities_on_account_id", using: :btree add_index "account_activities", ["account_id"], name: "index_account_activities_on_account_id", using: :btree
@ -38,6 +40,8 @@ ActiveRecord::Schema.define(version: 20150416094704) do
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.string "currency" t.string "currency"
t.string "creator_str"
t.string "updator_str"
end end
add_index "accounts", ["registrar_id"], name: "index_accounts_on_registrar_id", using: :btree add_index "accounts", ["registrar_id"], name: "index_accounts_on_registrar_id", using: :btree
@ -80,6 +84,8 @@ ActiveRecord::Schema.define(version: 20150416094704) do
t.datetime "queried_at" t.datetime "queried_at"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.string "creator_str"
t.string "updator_str"
end end
create_table "bank_transactions", force: :cascade do |t| create_table "bank_transactions", force: :cascade do |t|
@ -97,6 +103,8 @@ ActiveRecord::Schema.define(version: 20150416094704) do
t.datetime "paid_at" t.datetime "paid_at"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.string "creator_str"
t.string "updator_str"
end end
create_table "banklink_transactions", force: :cascade do |t| create_table "banklink_transactions", force: :cascade do |t|
@ -313,6 +321,8 @@ ActiveRecord::Schema.define(version: 20150416094704) do
t.decimal "price" t.decimal "price"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.string "creator_str"
t.string "updator_str"
end end
add_index "invoice_items", ["invoice_id"], name: "index_invoice_items_on_invoice_id", using: :btree add_index "invoice_items", ["invoice_id"], name: "index_invoice_items_on_invoice_id", using: :btree
@ -355,6 +365,8 @@ ActiveRecord::Schema.define(version: 20150416094704) do
t.string "buyer_phone" t.string "buyer_phone"
t.string "buyer_url" t.string "buyer_url"
t.string "buyer_email" t.string "buyer_email"
t.string "creator_str"
t.string "updator_str"
end end
add_index "invoices", ["buyer_id"], name: "index_invoices_on_buyer_id", using: :btree add_index "invoices", ["buyer_id"], name: "index_invoices_on_buyer_id", using: :btree
@ -395,6 +407,36 @@ ActiveRecord::Schema.define(version: 20150416094704) do
add_index "legal_documents", ["documentable_type", "documentable_id"], name: "index_legal_documents_on_documentable_type_and_documentable_id", using: :btree add_index "legal_documents", ["documentable_type", "documentable_id"], name: "index_legal_documents_on_documentable_type_and_documentable_id", using: :btree
create_table "log_account_activities", force: :cascade do |t|
t.string "item_type", null: false
t.integer "item_id", null: false
t.string "event", null: false
t.string "whodunnit"
t.json "object"
t.json "object_changes"
t.datetime "created_at"
t.string "session"
t.json "children"
end
add_index "log_account_activities", ["item_type", "item_id"], name: "index_log_account_activities_on_item_type_and_item_id", using: :btree
add_index "log_account_activities", ["whodunnit"], name: "index_log_account_activities_on_whodunnit", using: :btree
create_table "log_accounts", force: :cascade do |t|
t.string "item_type", null: false
t.integer "item_id", null: false
t.string "event", null: false
t.string "whodunnit"
t.json "object"
t.json "object_changes"
t.datetime "created_at"
t.string "session"
t.json "children"
end
add_index "log_accounts", ["item_type", "item_id"], name: "index_log_accounts_on_item_type_and_item_id", using: :btree
add_index "log_accounts", ["whodunnit"], name: "index_log_accounts_on_whodunnit", using: :btree
create_table "log_addresses", force: :cascade do |t| create_table "log_addresses", force: :cascade do |t|
t.string "item_type", null: false t.string "item_type", null: false
t.integer "item_id", null: false t.integer "item_id", null: false
@ -425,6 +467,36 @@ ActiveRecord::Schema.define(version: 20150416094704) do
add_index "log_api_users", ["item_type", "item_id"], name: "index_log_api_users_on_item_type_and_item_id", using: :btree add_index "log_api_users", ["item_type", "item_id"], name: "index_log_api_users_on_item_type_and_item_id", using: :btree
add_index "log_api_users", ["whodunnit"], name: "index_log_api_users_on_whodunnit", using: :btree add_index "log_api_users", ["whodunnit"], name: "index_log_api_users_on_whodunnit", using: :btree
create_table "log_bank_statements", force: :cascade do |t|
t.string "item_type", null: false
t.integer "item_id", null: false
t.string "event", null: false
t.string "whodunnit"
t.json "object"
t.json "object_changes"
t.datetime "created_at"
t.string "session"
t.json "children"
end
add_index "log_bank_statements", ["item_type", "item_id"], name: "index_log_bank_statements_on_item_type_and_item_id", using: :btree
add_index "log_bank_statements", ["whodunnit"], name: "index_log_bank_statements_on_whodunnit", using: :btree
create_table "log_bank_transactions", force: :cascade do |t|
t.string "item_type", null: false
t.integer "item_id", null: false
t.string "event", null: false
t.string "whodunnit"
t.json "object"
t.json "object_changes"
t.datetime "created_at"
t.string "session"
t.json "children"
end
add_index "log_bank_transactions", ["item_type", "item_id"], name: "index_log_bank_transactions_on_item_type_and_item_id", using: :btree
add_index "log_bank_transactions", ["whodunnit"], name: "index_log_bank_transactions_on_whodunnit", using: :btree
create_table "log_certificates", force: :cascade do |t| create_table "log_certificates", force: :cascade do |t|
t.string "item_type", null: false t.string "item_type", null: false
t.integer "item_id", null: false t.integer "item_id", null: false
@ -563,6 +635,36 @@ ActiveRecord::Schema.define(version: 20150416094704) do
add_index "log_domains", ["item_type", "item_id"], name: "index_log_domains_on_item_type_and_item_id", using: :btree add_index "log_domains", ["item_type", "item_id"], name: "index_log_domains_on_item_type_and_item_id", using: :btree
add_index "log_domains", ["whodunnit"], name: "index_log_domains_on_whodunnit", using: :btree add_index "log_domains", ["whodunnit"], name: "index_log_domains_on_whodunnit", using: :btree
create_table "log_invoice_items", force: :cascade do |t|
t.string "item_type", null: false
t.integer "item_id", null: false
t.string "event", null: false
t.string "whodunnit"
t.json "object"
t.json "object_changes"
t.datetime "created_at"
t.string "session"
t.json "children"
end
add_index "log_invoice_items", ["item_type", "item_id"], name: "index_log_invoice_items_on_item_type_and_item_id", using: :btree
add_index "log_invoice_items", ["whodunnit"], name: "index_log_invoice_items_on_whodunnit", using: :btree
create_table "log_invoices", force: :cascade do |t|
t.string "item_type", null: false
t.integer "item_id", null: false
t.string "event", null: false
t.string "whodunnit"
t.json "object"
t.json "object_changes"
t.datetime "created_at"
t.string "session"
t.json "children"
end
add_index "log_invoices", ["item_type", "item_id"], name: "index_log_invoices_on_item_type_and_item_id", using: :btree
add_index "log_invoices", ["whodunnit"], name: "index_log_invoices_on_whodunnit", using: :btree
create_table "log_keyrelays", force: :cascade do |t| create_table "log_keyrelays", force: :cascade do |t|
t.string "item_type", null: false t.string "item_type", null: false
t.integer "item_id", null: false t.integer "item_id", null: false

View file

@ -17,9 +17,9 @@ describe BankStatement do
]) ])
end end
# it 'should not have any versions' do it 'should not have any versions' do
# @bank_statement.versions.should == [] @bank_statement.versions.should == []
# end end
end end
context 'with valid attributes' do context 'with valid attributes' do
@ -99,14 +99,14 @@ describe BankStatement do
bs.not_binded?.should == true bs.not_binded?.should == true
end end
# it 'should have one version' do it 'should have one version' do
# with_versioning do with_versioning do
# @bank_statement.versions.should == [] @bank_statement.versions.should == []
# @bank_statement.body = 'New body' @bank_statement.bank_code = 'new_code'
# @bank_statement.save @bank_statement.save
# @bank_statement.errors.full_messages.should match_array([]) @bank_statement.errors.full_messages.should match_array([])
# @bank_statement.versions.size.should == 1 @bank_statement.versions.size.should == 1
# end end
# end end
end end
end end