From 551e9e02ce0076912e49e1535f793af78fc42bb5 Mon Sep 17 00:00:00 2001 From: kfl62 Date: Fri, 30 Jan 2009 20:58:15 +0200 Subject: [PATCH] TrstPrtn table create and migrate --- app/models/trst_prtn.rb | 55 +++++++++++++++++++ .../20090130162621_create_trst_prtns.rb | 31 +++++++++++ db/schema.rb | 31 ++++++++++- test/fixtures/trst_prtns.yml | 7 +++ test/unit/trst_prtn_test.rb | 8 +++ 5 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 app/models/trst_prtn.rb create mode 100644 db/migrate/20090130162621_create_trst_prtns.rb create mode 100644 test/fixtures/trst_prtns.yml create mode 100644 test/unit/trst_prtn_test.rb diff --git a/app/models/trst_prtn.rb b/app/models/trst_prtn.rb new file mode 100644 index 0000000..8ab5dea --- /dev/null +++ b/app/models/trst_prtn.rb @@ -0,0 +1,55 @@ +#==Baza de date :Tabel => trst_prtns +#Tabelul care conţine evidenţa documentelor generate de sistem şi/sau utilizatori +#* Fişier migrare: RAILS_ROOT/db/migrate/xxx_create_trst_prtns +# create_table "trst_prtns", :force => true do |t| +# t.string "prefix", :limit => 10, :default => "", :null => false +# t.string "name", :limit => 100, :default => "", :null => false +# t.string "suffix", :limit => 10, :default => "", :null => false +# t.string "namesh", :limit => 10, :default => "", :null => false +# t.string "id_chamcom", :limit => 25, :default => "", :null => false +# t.string "id_fiscal", :limit => 15, :default => "", :null => false +# t.string "id_itm", :limit => 15, :default => "", :null => false +# t.string "id_account", :limit => 15, :default => "", :null => false +# t.string "id_internet", :limit => 15, :default => "", :null => false +# t.string "adress", :limit => 100, :default => "", :null => false +# t.string "city", :limit => 30, :default => "", :null => false +# t.string "zip", :limit => 30, :default => "", :null => false +# t.string "state", :limit => 30, :default => "", :null => false +# t.integer "id_country", :limit => 4, :default => 0, :null => false +# t.string "contactpers", :limit => 30, :default => "", :null => false +# t.string "contactpers_q", :limit => 25, :default => "", :null => false +# t.string "tel", :limit => 30, :default => "", :null => false +# t.string "fax", :limit => 30, :default => "", :null => false +# t.string "email", :limit => 30, :default => "", :null => false +# t.string "webadress", :limit => 30, :default => "", :null => false +# t.boolean "flag_clb", :default => false, :null => false +# t.trst +# end +#În afara de câmpurile de mai sus se generează automat câmpul t.integer "id" de tip autoincrement, +#care de fapt reprezintă indexul tabelului. +#Linia t.trsts generează câmpurile implicite, prezente în fiecare tabel al aplicaţiei +#(vezi. clasa ActiveRecord::ConnectionAdapters::TableDefinition). +#==Descrierea câmpurilor: +#Câmp +# Descriere +#==Relaţia cu alte tabele +#de tipul "habtm" (HasAndBelongsToMany), polimorfice etc... +# +# Dacă este cazul ... :) +#==Rolul tabelului +#Descriere .... + +class TrstPrtn < ActiveRecord::Base + + def self.per_page + 20 + end + + def name_long + prefix = self.prefix? ? self.prefix : 'S.C. ?' + name = self.name? ? self.name : '...?...' + suffix = self.suffix? ? self.suffix : 'S.R.L. ?' + return prefix + ' ' + name + ' ' + suffix + end + +end \ No newline at end of file diff --git a/db/migrate/20090130162621_create_trst_prtns.rb b/db/migrate/20090130162621_create_trst_prtns.rb new file mode 100644 index 0000000..55e0d7d --- /dev/null +++ b/db/migrate/20090130162621_create_trst_prtns.rb @@ -0,0 +1,31 @@ +class CreateTrstPrtns < ActiveRecord::Migration + def self.up + create_table :trst_prtns do |t| + t.string "prefix", :limit => 10, :default => "", :null => false + t.string "name", :limit => 100, :default => "", :null => false + t.string "suffix", :limit => 10, :default => "", :null => false + t.string "namesh", :limit => 10, :default => "", :null => false + t.string "id_chamcom", :limit => 25, :default => "", :null => false + t.string "id_fiscal", :limit => 15, :default => "", :null => false + t.string "id_itm", :limit => 15, :default => "", :null => false + t.string "id_account", :limit => 15, :default => "", :null => false + t.string "id_internet", :limit => 15, :default => "", :null => false + t.string "address", :limit => 100, :default => "", :null => false + t.string "city", :limit => 30, :default => "", :null => false + t.string "zip", :limit => 30, :default => "", :null => false + t.string "state", :limit => 30, :default => "", :null => false + t.integer "id_country", :limit => 4, :default => 0, :null => false + t.string "contactpers", :limit => 30, :default => "", :null => false + t.string "contactpers_q", :limit => 25, :default => "", :null => false + t.string "tel", :limit => 30, :default => "", :null => false + t.string "fax", :limit => 30, :default => "", :null => false + t.string "email", :limit => 30, :default => "", :null => false + t.string "webaddress", :limit => 30, :default => "", :null => false + t.trsts + end + end + + def self.down + drop_table :trst_prtns + end +end diff --git a/db/schema.rb b/db/schema.rb index d937c60..3596a2c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -9,7 +9,36 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20090123023025) do +ActiveRecord::Schema.define(:version => 20090130162621) do + + create_table "trst_prtns", :force => true do |t| + t.string "prefix", :limit => 10, :default => "", :null => false + t.string "name", :limit => 100, :default => "", :null => false + t.string "suffix", :limit => 10, :default => "", :null => false + t.string "namesh", :limit => 10, :default => "", :null => false + t.string "id_chamcom", :limit => 25, :default => "", :null => false + t.string "id_fiscal", :limit => 15, :default => "", :null => false + t.string "id_itm", :limit => 15, :default => "", :null => false + t.string "id_account", :limit => 15, :default => "", :null => false + t.string "id_internet", :limit => 15, :default => "", :null => false + t.string "adress", :limit => 100, :default => "", :null => false + t.string "city", :limit => 30, :default => "", :null => false + t.string "zip", :limit => 30, :default => "", :null => false + t.string "state", :limit => 30, :default => "", :null => false + t.integer "id_country", :limit => 4, :default => 0, :null => false + t.string "contactpers", :limit => 30, :default => "", :null => false + t.string "contactpers_q", :limit => 25, :default => "", :null => false + t.string "tel", :limit => 30, :default => "", :null => false + t.string "fax", :limit => 30, :default => "", :null => false + t.string "email", :limit => 30, :default => "", :null => false + t.string "webadress", :limit => 30, :default => "", :null => false + t.boolean "flag_clb", :default => false, :null => false + t.datetime "created_on" + t.integer "created_by", :limit => 6, :default => 0, :null => false + t.datetime "updated_on" + t.integer "updated_by", :limit => 6, :default => 0, :null => false + t.integer "approved_by", :limit => 6, :default => 0, :null => false + end create_table "trst_sys_menus", :force => true do |t| t.string "name", :limit => 15, :default => "Menu", :null => false diff --git a/test/fixtures/trst_prtns.yml b/test/fixtures/trst_prtns.yml new file mode 100644 index 0000000..5bf0293 --- /dev/null +++ b/test/fixtures/trst_prtns.yml @@ -0,0 +1,7 @@ +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html + +# one: +# column: value +# +# two: +# column: value diff --git a/test/unit/trst_prtn_test.rb b/test/unit/trst_prtn_test.rb new file mode 100644 index 0000000..7badbde --- /dev/null +++ b/test/unit/trst_prtn_test.rb @@ -0,0 +1,8 @@ +require 'test_helper' + +class TrstPrtnTest < ActiveSupport::TestCase + # Replace this with your real tests. + test "the truth" do + assert true + end +end