mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 09:57:23 +02:00
Merge branch 'master' of github.com:domify/registry
This commit is contained in:
commit
ac886fb4cb
8 changed files with 64 additions and 52 deletions
|
@ -39,6 +39,7 @@ class Admin::PricelistsController < AdminController
|
||||||
end
|
end
|
||||||
|
|
||||||
def pricelist_params
|
def pricelist_params
|
||||||
params.require(:pricelist).permit(:category, :name, :duration, :price, :valid_from, :valid_to)
|
params.require(:pricelist).permit(:operation_category, :category, :price_category,
|
||||||
|
:duration, :price, :valid_from, :valid_to)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,9 +3,11 @@ class Pricelist < ActiveRecord::Base
|
||||||
|
|
||||||
monetize :price_cents
|
monetize :price_cents
|
||||||
|
|
||||||
validates :price_cents, :price_currency, :valid_from, :category, presence: true
|
validates :price_cents, :price_currency, :price,
|
||||||
|
:valid_from, :category, :operation_category, :duration, presence: true
|
||||||
|
|
||||||
CATEGORIES = %w(ee com.ee fie.ee pri.ee med.ee)
|
CATEGORIES = %w(ee pri.ee fie.ee med.ee com.ee)
|
||||||
|
OPERATION_CATEGORIES = %w(new renew)
|
||||||
DURATIONS = %w(1year 2years 3years)
|
DURATIONS = %w(1year 2years 3years)
|
||||||
|
|
||||||
after_initialize :init_values
|
after_initialize :init_values
|
||||||
|
@ -13,4 +15,8 @@ class Pricelist < ActiveRecord::Base
|
||||||
return unless new_record?
|
return unless new_record?
|
||||||
self.valid_from = Time.zone.now.beginning_of_year
|
self.valid_from = Time.zone.now.beginning_of_year
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def name
|
||||||
|
"#{operation_category} #{category}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,12 +3,12 @@
|
||||||
|
|
||||||
.row
|
.row
|
||||||
.col-md-6
|
.col-md-6
|
||||||
|
.form-group
|
||||||
|
= f.label :operation_category
|
||||||
|
= f.select(:operation_category, Pricelist::OPERATION_CATEGORIES, {}, { class: 'form-control' })
|
||||||
.form-group
|
.form-group
|
||||||
= f.label :category, t(:category)
|
= f.label :category, t(:category)
|
||||||
= f.select(:category, Pricelist::CATEGORIES, {}, { class: 'form-control' })
|
= f.select(:category, Pricelist::CATEGORIES, {}, { class: 'form-control' })
|
||||||
.form-group
|
|
||||||
= f.label :name
|
|
||||||
= f.text_field(:name, class: 'form-control')
|
|
||||||
.form-group
|
.form-group
|
||||||
= f.label :duration
|
= f.label :duration
|
||||||
= f.select(:duration, Pricelist::DURATIONS, {}, { class: 'form-control' })
|
= f.select(:duration, Pricelist::DURATIONS, {}, { class: 'form-control' })
|
||||||
|
|
|
@ -5,20 +5,6 @@
|
||||||
%h2.text-right.text-center-xs
|
%h2.text-right.text-center-xs
|
||||||
= link_to(t(:new), new_admin_pricelist_path, class: 'btn btn-primary')
|
= link_to(t(:new), new_admin_pricelist_path, class: 'btn btn-primary')
|
||||||
|
|
||||||
%hr
|
|
||||||
-# .row
|
|
||||||
-# .col-md-12
|
|
||||||
-# = form_tag admin_pricelists_path, html: { class: 'form-horizontal' } do
|
|
||||||
-# .col-md-11
|
|
||||||
-# .form-group
|
|
||||||
-# = search_field_tag :name_cont, class: 'form-control'
|
|
||||||
-# .col-md-1.text-right.text-center-xs
|
|
||||||
-# .form-group
|
|
||||||
-# %button.btn.btn-primary
|
|
||||||
-#
|
|
||||||
-# %span.glyphicon.glyphicon-search
|
|
||||||
-#
|
|
||||||
|
|
||||||
%hr
|
%hr
|
||||||
.row
|
.row
|
||||||
.col-md-12
|
.col-md-12
|
||||||
|
@ -29,9 +15,9 @@
|
||||||
%th{class: 'col-xs-2'}
|
%th{class: 'col-xs-2'}
|
||||||
= sort_link(@q, 'category', t(:category))
|
= sort_link(@q, 'category', t(:category))
|
||||||
%th{class: 'col-xs-2'}
|
%th{class: 'col-xs-2'}
|
||||||
= sort_link(@q, 'duration', t(:duration))
|
= sort_link(@q, 'operation_category', t(:operation))
|
||||||
%th{class: 'col-xs-2'}
|
%th{class: 'col-xs-2'}
|
||||||
= sort_link(@q, 'name', t(:name))
|
= sort_link(@q, 'duration', t(:duration))
|
||||||
%th{class: 'col-xs-2'}
|
%th{class: 'col-xs-2'}
|
||||||
= sort_link(@q, 'price', t(:price))
|
= sort_link(@q, 'price', t(:price))
|
||||||
%th{class: 'col-xs-2'}
|
%th{class: 'col-xs-2'}
|
||||||
|
@ -45,8 +31,8 @@
|
||||||
- @pricelists.each do |pricelist|
|
- @pricelists.each do |pricelist|
|
||||||
%tr
|
%tr
|
||||||
%td= pricelist.category
|
%td= pricelist.category
|
||||||
|
%td= pricelist.operation_category
|
||||||
%td= pricelist.duration
|
%td= pricelist.duration
|
||||||
%td= pricelist.name
|
|
||||||
%td= pricelist.price
|
%td= pricelist.price
|
||||||
%td= l(pricelist.valid_from, format: :ydate)
|
%td= l(pricelist.valid_from, format: :ydate)
|
||||||
%td= l(pricelist.valid_to, format: :ydate)
|
%td= l(pricelist.valid_to, format: :ydate)
|
||||||
|
|
6
db/migrate/20150609103333_update_pricelist_chema.rb
Normal file
6
db/migrate/20150609103333_update_pricelist_chema.rb
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
class UpdatePricelistChema < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :pricelists, :operation_category, :string
|
||||||
|
rename_column :pricelists, :name, :desc
|
||||||
|
end
|
||||||
|
end
|
47
db/schema.rb
47
db/schema.rb
|
@ -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: 20150603212659) do
|
ActiveRecord::Schema.define(version: 20150609103333) 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"
|
||||||
|
@ -19,7 +19,7 @@ ActiveRecord::Schema.define(version: 20150603212659) do
|
||||||
create_table "account_activities", force: :cascade do |t|
|
create_table "account_activities", force: :cascade do |t|
|
||||||
t.integer "account_id"
|
t.integer "account_id"
|
||||||
t.integer "invoice_id"
|
t.integer "invoice_id"
|
||||||
t.decimal "sum", precision: 8, scale: 2
|
t.decimal "sum", precision: 10, scale: 2
|
||||||
t.string "currency"
|
t.string "currency"
|
||||||
t.integer "bank_transaction_id"
|
t.integer "bank_transaction_id"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
|
@ -36,7 +36,7 @@ ActiveRecord::Schema.define(version: 20150603212659) do
|
||||||
create_table "accounts", force: :cascade do |t|
|
create_table "accounts", force: :cascade do |t|
|
||||||
t.integer "registrar_id"
|
t.integer "registrar_id"
|
||||||
t.string "account_type"
|
t.string "account_type"
|
||||||
t.decimal "balance", precision: 8, scale: 2, default: 0.0, null: false
|
t.decimal "balance", precision: 10, scale: 2, default: 0.0, null: false
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
t.string "currency"
|
t.string "currency"
|
||||||
|
@ -98,7 +98,7 @@ ActiveRecord::Schema.define(version: 20150603212659) do
|
||||||
t.string "buyer_name"
|
t.string "buyer_name"
|
||||||
t.string "document_no"
|
t.string "document_no"
|
||||||
t.string "description"
|
t.string "description"
|
||||||
t.decimal "sum", precision: 8, scale: 2
|
t.decimal "sum", precision: 10, scale: 2
|
||||||
t.string "reference_no"
|
t.string "reference_no"
|
||||||
t.datetime "paid_at"
|
t.datetime "paid_at"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
|
@ -114,7 +114,7 @@ ActiveRecord::Schema.define(version: 20150603212659) do
|
||||||
t.string "vk_rec_id"
|
t.string "vk_rec_id"
|
||||||
t.string "vk_stamp"
|
t.string "vk_stamp"
|
||||||
t.string "vk_t_no"
|
t.string "vk_t_no"
|
||||||
t.decimal "vk_amount", precision: 8, scale: 2
|
t.decimal "vk_amount", precision: 10, scale: 2
|
||||||
t.string "vk_curr"
|
t.string "vk_curr"
|
||||||
t.string "vk_rec_acc"
|
t.string "vk_rec_acc"
|
||||||
t.string "vk_rec_name"
|
t.string "vk_rec_name"
|
||||||
|
@ -328,10 +328,10 @@ ActiveRecord::Schema.define(version: 20150603212659) do
|
||||||
|
|
||||||
create_table "invoice_items", force: :cascade do |t|
|
create_table "invoice_items", force: :cascade do |t|
|
||||||
t.integer "invoice_id"
|
t.integer "invoice_id"
|
||||||
t.string "description", null: false
|
t.string "description", null: false
|
||||||
t.string "unit"
|
t.string "unit"
|
||||||
t.integer "amount"
|
t.integer "amount"
|
||||||
t.decimal "price", precision: 8, scale: 2
|
t.decimal "price", precision: 10, scale: 2
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
t.string "creator_str"
|
t.string "creator_str"
|
||||||
|
@ -341,20 +341,20 @@ ActiveRecord::Schema.define(version: 20150603212659) do
|
||||||
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
|
||||||
|
|
||||||
create_table "invoices", force: :cascade do |t|
|
create_table "invoices", force: :cascade do |t|
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
t.string "invoice_type", null: false
|
t.string "invoice_type", null: false
|
||||||
t.datetime "due_date", null: false
|
t.datetime "due_date", null: false
|
||||||
t.string "payment_term"
|
t.string "payment_term"
|
||||||
t.string "currency", null: false
|
t.string "currency", null: false
|
||||||
t.string "description"
|
t.string "description"
|
||||||
t.string "reference_no"
|
t.string "reference_no"
|
||||||
t.decimal "vat_prc", precision: 8, scale: 2, null: false
|
t.decimal "vat_prc", precision: 10, scale: 2, null: false
|
||||||
t.datetime "paid_at"
|
t.datetime "paid_at"
|
||||||
t.integer "seller_id"
|
t.integer "seller_id"
|
||||||
t.string "seller_name", null: false
|
t.string "seller_name", null: false
|
||||||
t.string "seller_reg_no"
|
t.string "seller_reg_no"
|
||||||
t.string "seller_iban", null: false
|
t.string "seller_iban", null: false
|
||||||
t.string "seller_bank"
|
t.string "seller_bank"
|
||||||
t.string "seller_swift"
|
t.string "seller_swift"
|
||||||
t.string "seller_vat_no"
|
t.string "seller_vat_no"
|
||||||
|
@ -368,7 +368,7 @@ ActiveRecord::Schema.define(version: 20150603212659) do
|
||||||
t.string "seller_email"
|
t.string "seller_email"
|
||||||
t.string "seller_contact_name"
|
t.string "seller_contact_name"
|
||||||
t.integer "buyer_id"
|
t.integer "buyer_id"
|
||||||
t.string "buyer_name", null: false
|
t.string "buyer_name", null: false
|
||||||
t.string "buyer_reg_no"
|
t.string "buyer_reg_no"
|
||||||
t.string "buyer_country_code"
|
t.string "buyer_country_code"
|
||||||
t.string "buyer_state"
|
t.string "buyer_state"
|
||||||
|
@ -382,7 +382,7 @@ ActiveRecord::Schema.define(version: 20150603212659) do
|
||||||
t.string "updator_str"
|
t.string "updator_str"
|
||||||
t.integer "number"
|
t.integer "number"
|
||||||
t.datetime "cancelled_at"
|
t.datetime "cancelled_at"
|
||||||
t.decimal "sum_cache", precision: 8, scale: 2
|
t.decimal "sum_cache", precision: 10, scale: 2
|
||||||
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
|
||||||
|
@ -886,17 +886,18 @@ ActiveRecord::Schema.define(version: 20150603212659) do
|
||||||
add_index "people", ["reset_password_token"], name: "index_people_on_reset_password_token", unique: true, using: :btree
|
add_index "people", ["reset_password_token"], name: "index_people_on_reset_password_token", unique: true, using: :btree
|
||||||
|
|
||||||
create_table "pricelists", force: :cascade do |t|
|
create_table "pricelists", force: :cascade do |t|
|
||||||
t.string "name"
|
t.string "desc"
|
||||||
t.string "category"
|
t.string "category"
|
||||||
t.decimal "price_cents", precision: 8, scale: 2, default: 0.0, null: false
|
t.decimal "price_cents", precision: 8, scale: 2, default: 0.0, null: false
|
||||||
t.string "price_currency", default: "EUR", null: false
|
t.string "price_currency", default: "EUR", null: false
|
||||||
t.datetime "valid_from"
|
t.datetime "valid_from"
|
||||||
t.datetime "valid_to"
|
t.datetime "valid_to"
|
||||||
t.string "creator_str"
|
t.string "creator_str"
|
||||||
t.string "updator_str"
|
t.string "updator_str"
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
t.string "duration"
|
t.string "duration"
|
||||||
|
t.string "operation_category"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "registrant_verifications", force: :cascade do |t|
|
create_table "registrant_verifications", force: :cascade do |t|
|
||||||
|
@ -982,7 +983,7 @@ ActiveRecord::Schema.define(version: 20150603212659) do
|
||||||
t.text "crt"
|
t.text "crt"
|
||||||
t.string "type"
|
t.string "type"
|
||||||
t.string "registrant_ident"
|
t.string "registrant_ident"
|
||||||
t.string "encrypted_password", default: "", null: false
|
t.string "encrypted_password", default: ""
|
||||||
t.datetime "remember_created_at"
|
t.datetime "remember_created_at"
|
||||||
t.integer "failed_attempts", default: 0, null: false
|
t.integer "failed_attempts", default: 0, null: false
|
||||||
t.datetime "locked_at"
|
t.datetime "locked_at"
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
Fabricator(:pricelist) do
|
Fabricator(:pricelist) do
|
||||||
active_from 1.year.ago
|
valid_from 1.year.ago
|
||||||
active_until 1.year.since
|
valid_to 1.year.since
|
||||||
category '.ee'
|
category '.ee'
|
||||||
|
duration '1year'
|
||||||
|
operation_category 'new'
|
||||||
|
price 10
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,9 +15,9 @@ describe Pricelist do
|
||||||
it 'should not be valid' do
|
it 'should not be valid' do
|
||||||
@pricelist.valid?
|
@pricelist.valid?
|
||||||
@pricelist.errors.full_messages.should match_array([
|
@pricelist.errors.full_messages.should match_array([
|
||||||
"Valid from is missing",
|
"Category is missing",
|
||||||
"Active until is missing",
|
"Duration is missing",
|
||||||
"Category is missing"
|
"Operation category is missing"
|
||||||
])
|
])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -32,6 +32,11 @@ describe Pricelist do
|
||||||
it 'should not have any versions' do
|
it 'should not have any versions' do
|
||||||
@pricelist.versions.should == []
|
@pricelist.versions.should == []
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should not have name' do
|
||||||
|
@pricelist.name.should == ' '
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with valid attributes' do
|
context 'with valid attributes' do
|
||||||
|
@ -50,10 +55,14 @@ describe Pricelist do
|
||||||
@pricelist.errors.full_messages.should match_array([])
|
@pricelist.errors.full_messages.should match_array([])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should have name' do
|
||||||
|
@pricelist.name.should == 'new .ee'
|
||||||
|
end
|
||||||
|
|
||||||
it 'should have one version' do
|
it 'should have one version' do
|
||||||
with_versioning do
|
with_versioning do
|
||||||
@pricelist.versions.reload.should == []
|
@pricelist.versions.reload.should == []
|
||||||
@pricelist.name = 'New name'
|
@pricelist.price = 11
|
||||||
@pricelist.save
|
@pricelist.save
|
||||||
@pricelist.errors.full_messages.should match_array([])
|
@pricelist.errors.full_messages.should match_array([])
|
||||||
@pricelist.versions.size.should == 1
|
@pricelist.versions.size.should == 1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue