Add accounts and activities

This commit is contained in:
Martin Lensment 2015-04-13 15:17:34 +03:00
parent fb318e37cb
commit b5521594ce
8 changed files with 170 additions and 1 deletions

4
app/models/account.rb Normal file
View file

@ -0,0 +1,4 @@
class Account < ActiveRecord::Base
belongs_to :registrar
CASH = 'cash'
end

View file

@ -0,0 +1,4 @@
class AccountActivity < ActiveRecord::Base
belongs_to :account
end

View file

@ -0,0 +1,15 @@
class CreateAccounts < ActiveRecord::Migration
def change
create_table :accounts do |t|
t.integer :registrar_id
t.string :account_type
t.decimal :balance
t.timestamps
end
Registrar.all.each do |x|
Account.create(registrar_id: x.id, account_type: Account::CASH)
end
end
end

View file

@ -0,0 +1,13 @@
class CreateAccountActivities < ActiveRecord::Migration
def change
create_table :account_activites do |t|
t.integer :account_id
t.integer :invoice_id
t.decimal :amount
t.string :currency
t.integer :bank_transaction_id
t.timestamps
end
end
end

View file

@ -0,0 +1,22 @@
class CreateBankTransactions < ActiveRecord::Migration
def change
create_table :bank_transactions do |t|
t.integer :bank_statement_id
t.string :subject_code
# record_code # kirjetunnus - ei kasuta? # impordime ainult tehingud nagunii
t.string :bank_reference # panga viide
t.string :tr_code # tehingu liik (MK / MV)
t.string :iban # own bank account no.
t.string :currency
t.string :other_party_bank
t.string :other_party_name
t.string :doc_no
t.string :description
#tr_type # C/D # impordime ainult cre nagunii
t.decimal :amount
t.string :reference_no
t.timestamps
end
end
end

View file

@ -0,0 +1,14 @@
class CreateBankStatements < ActiveRecord::Migration
def change
create_table :bank_statements do |t|
t.string :subject_code
t.string :bank_code
t.string :account_number
t.date :date
t.time :time
t.string :import_file_path
t.timestamps
end
end
end

View file

@ -0,0 +1,27 @@
class CreateBanklinkTransactions < ActiveRecord::Migration
def change
create_table :banklink_transactions do |t|
t.string :vk_service
t.string :vk_version
t.string :vk_snd_id
t.string :vk_rec_id
t.string :vk_stamp
t.string :vk_t_no
t.decimal :vk_amount
t.string :vk_curr
t.string :vk_rec_acc
t.string :vk_rec_name
t.string :vk_snd_acc
t.string :vk_snd_name
t.string :vk_ref
t.string :vk_msg
t.datetime :vk_t_datetime
t.string :vk_mac
t.string :vk_encoding
t.string :vk_lang
t.string :vk_auto
t.timestamps
end
end
end

View file

@ -11,11 +11,29 @@
# #
# 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: 20150413140933) do ActiveRecord::Schema.define(version: 20150413115829) 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"
create_table "account_activites", force: :cascade do |t|
t.integer "account_id"
t.integer "invoice_id"
t.decimal "amount"
t.string "currency"
t.integer "bank_transaction_id"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "accounts", force: :cascade do |t|
t.integer "registrar_id"
t.string "account_type"
t.decimal "balance"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "addresses", force: :cascade do |t| create_table "addresses", force: :cascade do |t|
t.integer "contact_id" t.integer "contact_id"
t.string "city" t.string "city"
@ -45,6 +63,58 @@ ActiveRecord::Schema.define(version: 20150413140933) do
t.string "updator_str" t.string "updator_str"
end end
create_table "bank_statements", force: :cascade do |t|
t.string "subject_code"
t.string "bank_code"
t.string "account_number"
t.date "date"
t.time "time"
t.string "import_file_path"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "bank_transactions", force: :cascade do |t|
t.integer "bank_statement_id"
t.string "subject_code"
t.string "bank_reference"
t.string "tr_code"
t.string "iban"
t.string "currency"
t.string "other_party_bank"
t.string "other_party_name"
t.string "doc_no"
t.string "description"
t.decimal "amount"
t.string "reference_no"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "banklink_transactions", force: :cascade do |t|
t.string "vk_service"
t.string "vk_version"
t.string "vk_snd_id"
t.string "vk_rec_id"
t.string "vk_stamp"
t.string "vk_t_no"
t.decimal "vk_amount"
t.string "vk_curr"
t.string "vk_rec_acc"
t.string "vk_rec_name"
t.string "vk_snd_acc"
t.string "vk_snd_name"
t.string "vk_ref"
t.string "vk_msg"
t.datetime "vk_t_datetime"
t.string "vk_mac"
t.string "vk_encoding"
t.string "vk_lang"
t.string "vk_auto"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "cached_nameservers", id: false, force: :cascade do |t| create_table "cached_nameservers", id: false, force: :cascade do |t|
t.string "hostname", limit: 255 t.string "hostname", limit: 255
t.string "ipv4", limit: 255 t.string "ipv4", limit: 255