Invoice migration improvements, invoice issuing

This commit is contained in:
Martin Lensment 2015-04-08 16:40:38 +03:00
parent 7fe851d480
commit 5c0e2be387
12 changed files with 187 additions and 34 deletions

View file

@ -3,16 +3,23 @@ class AddInvoiceColumns < ActiveRecord::Migration
# invoice info
# invoice number comes from id
add_column :invoices, :invoice_type, :string, null: false # CRE / DEB
add_column :invoices, :document_name, :string, null: false # Arve
# add_column :invoices, :document_name, :string, null: false # Invoice / credit invoice ...
add_column :invoices, :due_date, :datetime, null: false
add_column :invoices, :payment_term, :string # maksetingimus (free text)
add_column :invoices, :payment_term, :string # free text
add_column :invoices, :currency, :string, null: false
add_column :invoices, :description, :string, null: false # Selgitus
add_column :invoices, :reference_no, :string # Viitenumber
add_column :invoices, :total_sum, :decimal
add_column :invoices, :description, :string
add_column :invoices, :reference_no, :string
add_column :invoices, :vat_prc, :decimal
#add_column :invoices, :total_sum, :decimal # calculate on the fly
add_column :invoices, :paid_at, :datetime
# seller info
# add_column :invoices, :sellable_id, :integer # EIS is actually a registrar itself and invoice can belong to EIS
# add_column :invoices, :sellable_type, :string
add_column :invoices, :seller_id, :integer
add_column :invoices, :seller_name, :string, null: false
add_column :invoices, :seller_reg_no, :string
add_column :invoices, :seller_iban, :string, null: false
@ -20,6 +27,8 @@ class AddInvoiceColumns < ActiveRecord::Migration
add_column :invoices, :seller_swift, :string, null: false
add_column :invoices, :seller_vat_no, :string
add_column :invoices, :seller_country_code, :string
add_column :invoices, :seller_state, :string
add_column :invoices, :seller_street, :string
add_column :invoices, :seller_city, :string
add_column :invoices, :seller_zip, :string
@ -29,35 +38,24 @@ class AddInvoiceColumns < ActiveRecord::Migration
add_column :invoices, :seller_contact_name, :string
# payer info
add_column :invoices, :payer_name, :string, null: false
add_column :invoices, :payer_reg_no, :string, null: false
# buyer info
# add_column :invoices, :payable_id, :integer
# add_column :invoices, :payable_type, :string
add_column :invoices, :buyer_id, :integer
add_column :invoices, :payer_street, :string
add_column :invoices, :payer_city, :string
add_column :invoices, :payer_zip, :string
add_column :invoices, :payer_phone, :string
add_column :invoices, :payer_url, :string
add_column :invoices, :payer_email, :string
add_column :invoices, :buyer_name, :string, null: false
add_column :invoices, :buyer_reg_no, :string, null: false
# MIGRATION TO invoice_rows / invoice_items
# add_column :invoices, :serial_number, :string # kauba seeria kood
add_column :invoices, :product_code, :string # teenuse kood müüja süsteemis (sellerProductId)
add_column :invoices, :description, :string, null: false
add_column :invoices, :item_unit, :string
add_column :invoices, :item_amount, :integer
add_column :invoices, :item_price, :decimal # without taxes and discounts
add_column :invoices, :item_sum, :decimal # could calculate on the fly (amount * price) (without taxes and discounts)
add_column :invoices, :vat_sum, :decimal # could calculate on the fly
add_column :invoices, :item_total_sum, :decimal # could calculate on the fly (row's total sum with taxes)
add_column :invoices, :buyer_country_code, :string
add_column :invoices, :buyer_state, :string
add_column :invoices, :buyer_street, :string
add_column :invoices, :buyer_city, :string
add_column :invoices, :buyer_zip, :string
add_column :invoices, :buyer_phone, :string
add_column :invoices, :buyer_url, :string
add_column :invoices, :buyer_email, :string
###
add_column :invoices, :seller_address, :string
add_column :invoices, :seller_name, :string
add_column :invoices, :buyer_name, :string
add_column :invoices, :buyer_reg_no, :string
add_column :invoices, :buyer_contact_name, :string
end
end

View file

@ -0,0 +1,14 @@
class CreateInvoiceItems < ActiveRecord::Migration
def change
create_table :invoice_items do |t|
t.integer :invoice_id
# t.string :product_code
t.string :description, null: false
t.string :item_unit
t.integer :item_amount
t.decimal :item_price
t.timestamps
end
end
end

View file

@ -206,9 +206,55 @@ ActiveRecord::Schema.define(version: 20150413140933) do
add_index "epp_sessions", ["session_id"], name: "index_epp_sessions_on_session_id", unique: true, using: :btree
add_index "epp_sessions", ["updated_at"], name: "index_epp_sessions_on_updated_at", using: :btree
create_table "invoice_items", force: :cascade do |t|
t.integer "invoice_id"
t.string "description", null: false
t.string "item_unit"
t.integer "item_amount"
t.decimal "item_price"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "invoices", force: :cascade do |t|
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "invoice_type", null: false
t.datetime "due_date", null: false
t.string "payment_term"
t.string "currency", null: false
t.string "description"
t.string "reference_no"
t.decimal "vat_prc"
t.datetime "paid_at"
t.integer "seller_id"
t.string "seller_name", null: false
t.string "seller_reg_no"
t.string "seller_iban", null: false
t.string "seller_bank", null: false
t.string "seller_swift", null: false
t.string "seller_vat_no"
t.string "seller_country_code"
t.string "seller_state"
t.string "seller_street"
t.string "seller_city"
t.string "seller_zip"
t.string "seller_phone"
t.string "seller_url"
t.string "seller_email"
t.string "seller_contact_name"
t.integer "buyer_id"
t.string "buyer_name", null: false
t.string "buyer_reg_no", null: false
t.string "buyer_country_code"
t.string "buyer_state"
t.string "buyer_street"
t.string "buyer_city"
t.string "buyer_zip"
t.string "buyer_phone"
t.string "buyer_url"
t.string "buyer_email"
t.string "buyer_contact_name"
end
create_table "keyrelays", force: :cascade do |t|

View file

@ -84,3 +84,17 @@ ZonefileSetting.where({
}).first_or_create!
AdminUser.update_all(roles: ['admin'])
Registrar.where(
name: 'EIS',
reg_no: '90010019',
phone: '+372 727 1000',
country_code: 'EE',
vat_no: 'EE101286464',
email: 'info@internet.ee',
state: 'Harjumaa',
city: 'Tallinn',
street: 'Paldiski mnt 80',
zip: '10617',
url: 'www.internet.ee'
).first_or_create!