erp_invoicing 3.0.6 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. data/app/models/billing_account.rb +5 -3
  2. data/app/models/calculate_balance_strategy_type.rb +2 -0
  3. data/app/models/invoice.rb +2 -0
  4. data/app/models/invoice_item.rb +1 -0
  5. data/app/models/invoice_item_type.rb +1 -0
  6. data/app/models/invoice_party_role.rb +1 -0
  7. data/app/models/invoice_payment_strategy_type.rb +2 -0
  8. data/app/models/invoice_payment_term.rb +2 -0
  9. data/app/models/invoice_payment_term_set.rb +2 -0
  10. data/app/models/invoice_payment_term_type.rb +2 -0
  11. data/app/models/invoice_type.rb +1 -0
  12. data/app/models/payment_application.rb +2 -1
  13. data/app/models/recurring_payment.rb +2 -0
  14. data/db/migrate/20111121000000_invoicing_services.rb +13 -1
  15. data/lib/erp_invoicing/version.rb +2 -2
  16. data/lib/erp_invoicing.rb +4 -0
  17. data/public/javascripts/erp_app/desktop/applications/invoice_management/billing_accounts_panel.js +0 -1
  18. data/public/javascripts/erp_app/shared/invoices_grid_panel.js +1 -1
  19. data/spec/dummy/config/application.rb +6 -0
  20. data/spec/dummy/config/environments/spec.rb +3 -0
  21. data/spec/dummy/db/data_migrations/20101011152441_payment_gateway_actions.erp_commerce.rb +28 -0
  22. data/spec/dummy/db/data_migrations/20101014142230_financial_txn_types.erp_txns_and_accts.rb +16 -0
  23. data/spec/dummy/db/data_migrations/20110109173616_create_capability_scope_types.erp_tech_svcs.rb +15 -0
  24. data/spec/dummy/db/data_migrations/20110324010232_product_role_types.erp_products.rb +24 -0
  25. data/spec/dummy/db/data_migrations/20110509223702_add_publisher_role.knitkit.rb +22 -0
  26. data/spec/dummy/db/data_migrations/20110525001935_add_usd_currency.erp_base_erp_svcs.rb +12 -0
  27. data/spec/dummy/db/data_migrations/20110527160807_add_default_prod_avail_types.erp_products.rb +27 -0
  28. data/spec/dummy/db/data_migrations/20110605231556_create_order_party_roles.erp_orders.rb +24 -0
  29. data/spec/dummy/db/data_migrations/20110608185830_create_default_dynamic_models_and_forms.erp_forms.rb +33 -0
  30. data/spec/dummy/db/data_migrations/20110609150135_add_iso_codes.erp_base_erp_svcs.rb +19 -0
  31. data/spec/dummy/db/data_migrations/20110728201729_erp_app_setup.erp_app.rb +252 -0
  32. data/spec/dummy/db/data_migrations/20110728201730_create_desktop_app_product_manager.erp_products.rb +26 -0
  33. data/spec/dummy/db/data_migrations/20110728201731_create_desktop_app_order_manager.erp_orders.rb +26 -0
  34. data/spec/dummy/db/data_migrations/20110728201732_create_organizer_app_order_management.erp_orders.rb +15 -0
  35. data/spec/dummy/db/data_migrations/20110728201733_update_preferences.erp_app.rb +53 -0
  36. data/spec/dummy/db/data_migrations/20110802200222_schedule_delete_expired_sessions_job.erp_tech_svcs.rb +16 -0
  37. data/spec/dummy/db/data_migrations/20110816153456_add_knitkit_application.knitkit.rb +32 -0
  38. data/spec/dummy/db/data_migrations/20110816161238_create_desktop_app_audit_log_viewer.erp_app.rb +21 -0
  39. data/spec/dummy/db/data_migrations/20110817160743_add_file_manager_application.erp_app.rb +32 -0
  40. data/spec/dummy/db/data_migrations/20110828190913_create_desktop_app_dynamic_forms.erp_forms.rb +19 -0
  41. data/spec/dummy/db/data_migrations/20110913145838_setup_compass_ae_instance.erp_base_erp_svcs.rb +12 -0
  42. data/spec/dummy/db/data_migrations/20111108183739_add_default_capabilities.erp_app.rb +23 -0
  43. data/spec/dummy/db/data_migrations/20111108183740_add_new_contact_widgets.erp_app.rb +42 -0
  44. data/spec/dummy/db/data_migrations/20111111144706_setup_audit_log_types.erp_tech_svcs.rb +22 -0
  45. data/spec/dummy/db/data_migrations/20111118182910_setup_knitkit_capabilities.knitkit.rb +128 -0
  46. data/spec/dummy/db/data_migrations/20111121153349_create_bill_pay_organizer_application.erp_invoicing.rb +15 -0
  47. data/spec/dummy/db/data_migrations/20120109173616_create_download_capability_type.erp_tech_svcs.rb +14 -0
  48. data/spec/dummy/db/data_migrations/20120118181839_create_invoice_management_desktop_application.erp_invoicing.rb +27 -0
  49. data/spec/dummy/db/data_migrations/20120127144444_create_website_role_types.knitkit.rb +14 -0
  50. data/spec/dummy/db/data_migrations/20120127150505_create_website_default_configuration.knitkit.rb +73 -0
  51. data/spec/dummy/db/data_migrations/20120127150506_add_primary_host_to_website_configuration.knitkit.rb +34 -0
  52. data/spec/dummy/db/data_migrations/20120229160222_add_userinfo_widget.erp_app.rb +29 -0
  53. data/spec/dummy/db/data_migrations/20120229174322_add_billpay_widget.erp_invoicing.rb +27 -0
  54. data/spec/dummy/db/data_migrations/20120229174343_add_orders_widget.erp_orders.rb +29 -0
  55. data/spec/dummy/db/data_migrations/20120316150424_add_is_template_to_default_website_config.knitkit.rb +17 -0
  56. data/spec/dummy/db/data_migrations/20120405193721_create_party_and_role_type_for_communication_events.erp_app.rb +11 -0
  57. data/spec/dummy/db/data_migrations/20120411180756_create_user_management_mobile_application.erp_app.rb +19 -0
  58. data/spec/dummy/db/data_migrations/20120418164215_create_configuration_management_desktop_application.erp_app.rb +23 -0
  59. data/spec/dummy/db/data_migrations/20120605154637_add_calculate_balance_strategy_types.erp_invoicing.rb +21 -0
  60. data/spec/dummy/db/data_migrations/20120809020508_update_website_and_configuration.knitkit.rb +78 -0
  61. data/spec/dummy/db/data_migrations/20120824013449_create_ticket_form.erp_forms.rb +67 -0
  62. data/spec/dummy/db/data_migrations/20121026013449_update_ticket_form.erp_forms.rb +65 -0
  63. data/spec/dummy/db/data_migrations/20121026191738_update_contact_form.erp_forms.rb +27 -0
  64. data/spec/dummy/db/data_migrations/20121116155018_create_group_relationship_and_role_types.erp_tech_svcs.rb +20 -0
  65. data/spec/dummy/db/data_migrations/20121129185611_upgrade_website_role_iid.knitkit.rb +21 -0
  66. data/spec/dummy/db/data_migrations/20121130201859_upgrade_remove_system_mgmt_app.erp_app.rb +16 -0
  67. data/spec/dummy/db/data_migrations/20121130212146_note_capabilities.erp_tech_svcs.rb +24 -0
  68. data/spec/dummy/db/data_migrations/20121218175028_create_security_management_desktop_application.erp_app.rb +23 -0
  69. data/spec/dummy/db/migrate/20121214000230_base_erp_services.erp_base_erp_svcs.rb +461 -0
  70. data/spec/dummy/db/migrate/20121214000231_base_tech_services.erp_tech_svcs.rb +255 -0
  71. data/spec/dummy/db/migrate/20121214000232_create_has_attribute_tables.erp_tech_svcs.rb +39 -0
  72. data/spec/dummy/db/migrate/20121214000233_base_app_framework.erp_app.rb +276 -0
  73. data/spec/dummy/db/migrate/20121214000234_dynamic_forms.erp_forms.rb +95 -0
  74. data/spec/dummy/db/migrate/20121214000235_create_tickets.erp_forms.rb +19 -0
  75. data/spec/dummy/db/migrate/20121214000236_upgrade_dynamic_forms_table.erp_forms.rb +32 -0
  76. data/spec/dummy/db/migrate/20121214000237_setup_knitkit.knitkit.rb +316 -0
  77. data/spec/dummy/db/migrate/20121214000238_invoicing_services.erp_invoicing.rb +277 -0
  78. data/spec/dummy/db/migrate/20121214000239_base_inventory.erp_inventory.rb +91 -0
  79. data/spec/dummy/db/migrate/20121214000240_base_inventory_indexes.erp_inventory.rb +48 -0
  80. data/spec/dummy/db/migrate/20121214000241_base_txns_and_accts.erp_txns_and_accts.rb +364 -0
  81. data/spec/dummy/db/migrate/20121214000242_agreements_services.erp_agreements.rb +160 -0
  82. data/spec/dummy/db/migrate/20121214000243_agreements_services_indexes.erp_agreements.rb +52 -0
  83. data/spec/dummy/db/migrate/20121214000244_base_orders.erp_orders.rb +178 -0
  84. data/spec/dummy/db/migrate/20121214000245_base_products.erp_products.rb +234 -0
  85. data/spec/dummy/db/migrate/20121214000246_base_products_indexes.erp_products.rb +59 -0
  86. data/spec/dummy/db/migrate/20121214000247_erp_commerce_base.erp_commerce.rb +442 -0
  87. data/spec/dummy/db/migrate/20121214000248_base_work_efforts.erp_work_effort.rb +211 -0
  88. data/spec/dummy/db/migrate/20130107181155_create_groups.erp_tech_svcs.rb +19 -0
  89. data/spec/dummy/db/migrate/20130107181156_upgrade_security.erp_tech_svcs.rb +54 -0
  90. data/spec/dummy/db/migrate/20130107181157_upgrade_security2.erp_tech_svcs.rb +270 -0
  91. data/spec/dummy/db/schema.rb +2569 -0
  92. data/spec/dummy/db/spec.sqlite3 +0 -0
  93. data/spec/dummy/log/spec.log +64744 -0
  94. data/spec/models/billing_account_spec.rb +1 -7
  95. data/spec/models/invoice_spec.rb +2 -1
  96. data/spec/models/payment_application_spec.rb +1 -1
  97. data/spec/spec_helper.rb +18 -10
  98. metadata +203 -20
  99. data/db/migrate/20120228184317_add_text_to_pay_to_recurring_payments.rb +0 -13
  100. data/db/migrate/20120301155722_add_billing_date_to_billing_account.rb +0 -13
  101. data/db/migrate/20120605144227_create_calcuate_balance_strategy_type.rb +0 -18
  102. data/db/migrate/20120605144900_add_calculate_balance_strategy_to_billing_account.rb +0 -7
  103. data/db/migrate/20120605150425_add_balance_to_invoice.rb +0 -9
@@ -0,0 +1,160 @@
1
+ # This migration comes from erp_agreements (originally 20080805000070)
2
+ class AgreementsServices < ActiveRecord::Migration
3
+ def self.up
4
+
5
+ # Create agreements
6
+ unless table_exists?(:agreements)
7
+ create_table :agreements do |t|
8
+ t.column :description, :string
9
+ t.column :agreement_type_id, :integer
10
+ t.column :agreement_status, :string
11
+ t.column :product_id, :integer
12
+ t.column :agreement_date, :date
13
+ t.column :from_date, :date
14
+ t.column :thru_date, :date
15
+ t.column :external_identifier, :string
16
+ t.column :external_id_source, :string
17
+
18
+ t.timestamps
19
+ end
20
+ end
21
+
22
+ # Create agreement types
23
+ unless table_exists?(:agreement_types)
24
+ create_table :agreement_types do |t|
25
+ t.column :parent_id, :integer
26
+ t.column :lft, :integer
27
+ t.column :rgt, :integer
28
+
29
+ #custom columns go here
30
+ t.column :description, :string
31
+ t.column :comments, :string
32
+ t.column :internal_identifier, :string
33
+ t.column :external_identifier, :string
34
+ t.column :external_id_source, :string
35
+
36
+ t.timestamps
37
+ end
38
+ end
39
+
40
+ # Create agreement items
41
+ unless table_exists?(:agreement_items)
42
+ create_table :agreement_items do |t|
43
+ t.column :agreement_id, :integer
44
+ t.column :agreement_item_type_id, :integer
45
+ t.column :agreement_item_value, :string
46
+ t.column :description, :string
47
+ t.column :agreement_item_rule_string, :string
48
+
49
+ t.timestamps
50
+ end
51
+ end
52
+
53
+ # Create agreement item types
54
+ unless table_exists?(:agreement_item_types)
55
+ create_table :agreement_item_types do |t|
56
+ t.column :parent_id, :integer
57
+ t.column :lft, :integer
58
+ t.column :rgt, :integer
59
+
60
+ #custom columns go here
61
+ t.column :description, :string
62
+ t.column :comments, :string
63
+ t.column :internal_identifier, :string
64
+ t.column :external_identifier, :string
65
+ t.column :external_id_source, :string
66
+
67
+ t.timestamps
68
+ end
69
+ end
70
+
71
+ # Create agreement_party_roles
72
+ unless table_exists?(:agreement_party_roles)
73
+ create_table :agreement_party_roles do |t|
74
+ t.column :description, :string
75
+ t.column :agreement_id, :integer
76
+ t.column :party_id, :integer
77
+ t.column :role_type_id, :integer
78
+ t.column :external_identifier, :string
79
+ t.column :external_id_source, :string
80
+
81
+ t.timestamps
82
+ end
83
+ end
84
+
85
+ unless table_exists?(:agreement_relationships)
86
+ create_table :agreement_relationships do |t|
87
+ t.column :agreement_reln_type_id, :integer
88
+ t.column :description, :string
89
+ t.column :agreement_id_from, :integer
90
+ t.column :agreement_id_to, :integer
91
+ t.column :role_type_id_from, :integer
92
+ t.column :role_type_id_to, :integer
93
+ t.column :status_type_id, :integer
94
+ t.column :from_date, :date
95
+ t.column :thru_date, :date
96
+
97
+ t.timestamps
98
+ end
99
+ end
100
+
101
+ unless table_exists?(:agreement_reln_types)
102
+ create_table :agreement_reln_types do |t|
103
+ t.column :parent_id, :integer
104
+ t.column :lft, :integer
105
+ t.column :rgt, :integer
106
+ #custom columns go here
107
+ t.column :valid_from_role_type_id, :integer
108
+ t.column :valid_to_role_type_id, :integer
109
+ t.column :name, :string
110
+ t.column :description, :string
111
+ t.column :internal_identifier, :string
112
+ t.column :external_identifier, :string
113
+ t.column :external_id_source, :string
114
+
115
+ t.timestamps
116
+ end
117
+ end
118
+
119
+ unless table_exists?(:agreement_role_types)
120
+ create_table :agreement_role_types do |t|
121
+
122
+ t.column :parent_id, :integer
123
+ t.column :lft, :integer
124
+ t.column :rgt, :integer
125
+ #custom columns go here
126
+ t.column :description, :string
127
+ t.column :comments, :string
128
+ t.column :internal_identifier, :string
129
+ t.column :external_identifier, :string
130
+ t.column :external_id_source, :string
131
+
132
+ t.timestamps
133
+ end
134
+ end
135
+
136
+ unless table_exists?(:loyalty_program_codes)
137
+ create_table :loyalty_program_codes do |t|
138
+ t.string :identifier
139
+ t.string :name
140
+ t.string :description
141
+
142
+ t.timestamps
143
+ end
144
+ end
145
+
146
+ end
147
+
148
+ def self.down
149
+ [
150
+ :loyalty_program_codes, :agreement_role_types, :agreement_reln_types,
151
+ :agreement_relationships, :agreement_party_roles, :agreement_item_types,
152
+ :agreement_items, :agreements
153
+ ].each do |tbl|
154
+ if table_exists?(tbl)
155
+ drop_table tbl
156
+ end
157
+ end
158
+
159
+ end
160
+ end
@@ -0,0 +1,52 @@
1
+ # This migration comes from erp_agreements (originally 20080805000071)
2
+ class AgreementsServicesIndexes < ActiveRecord::Migration
3
+ def self.up
4
+ add_index :agreements, :agreement_type_id
5
+ add_index :agreements, :product_id
6
+
7
+ add_index :agreement_types, :parent_id
8
+
9
+ add_index :agreement_items, :agreement_id
10
+ add_index :agreement_items, :agreement_item_type_id
11
+
12
+ add_index :agreement_item_types, :parent_id
13
+
14
+ add_index :agreement_party_roles, :agreement_id
15
+ add_index :agreement_party_roles, :party_id
16
+ add_index :agreement_party_roles, :role_type_id
17
+
18
+ add_index :agreement_relationships, :agreement_reln_type_id
19
+ add_index :agreement_relationships, :status_type_id
20
+
21
+ add_index :agreement_reln_types, :parent_id
22
+ add_index :agreement_reln_types, :valid_from_role_type_id
23
+ add_index :agreement_reln_types, :valid_to_role_type_id
24
+
25
+ add_index :agreement_role_types, :parent_id
26
+ end
27
+
28
+ def self.down
29
+ remove_index :agreements, :agreement_type_id
30
+ remove_index :agreements, :product_id
31
+
32
+ remove_index :agreement_types, :parent_id
33
+
34
+ remove_index :agreement_items, :agreement_id
35
+ remove_index :agreement_items, :agreement_item_type_id
36
+
37
+ remove_index :agreement_item_types, :parent_id
38
+
39
+ remove_index :agreement_party_roles, :agreement_id
40
+ remove_index :agreement_party_roles, :party_id
41
+ remove_index :agreement_party_roles, :role_type_id
42
+
43
+ remove_index :agreement_relationships, :agreement_reln_type_id
44
+ remove_index :agreement_relationships, :status_type_id
45
+
46
+ remove_index :agreement_reln_types, :parent_id
47
+ remove_index :agreement_reln_types, :valid_from_role_type_id
48
+ remove_index :agreement_reln_types, :valid_to_role_type_id
49
+
50
+ remove_index :agreement_role_types, :parent_id
51
+ end
52
+ end
@@ -0,0 +1,178 @@
1
+ # This migration comes from erp_orders (originally 20080805000060)
2
+ class BaseOrders < ActiveRecord::Migration
3
+ def self.up
4
+
5
+ unless table_exists?(:order_txns)
6
+ create_table :order_txns do |t|
7
+ t.column :state_machine, :string
8
+ t.column :description, :string
9
+ t.column :order_txn_type_id, :integer
10
+ # Multi-table inheritance info
11
+ # MTI implemented using Rails' polymorphic associations
12
+ # Contact Information
13
+ t.column :email, :string
14
+ t.column :phone_number, :string
15
+ # Shipping Address
16
+ t.column :ship_to_first_name, :string
17
+ t.column :ship_to_last_name, :string
18
+ t.column :ship_to_address_line_1, :string
19
+ t.column :ship_to_address_line_2, :string
20
+ t.column :bill_to_address_line_1, :string
21
+ t.column :bill_to_address_line_2, :string
22
+ t.column :ship_to_city, :string
23
+ t.column :ship_to_state, :string
24
+ t.column :ship_to_postal_code, :string
25
+ t.column :ship_to_country, :string
26
+ # Private parts
27
+ t.column :customer_ip, :string
28
+ t.column :order_number, :integer
29
+ t.column :status, :string
30
+ t.column :error_message, :string
31
+ t.column :order_txn_record_id, :integer
32
+ t.column :order_txn_record_type, :string
33
+ t.timestamps
34
+ end
35
+
36
+ add_index :order_txns, :order_txn_type_id
37
+ add_index :order_txns, [:order_txn_record_id, :order_txn_record_type], :name => 'order_txn_record_idx'
38
+ end
39
+
40
+ unless table_exists?(:order_txn_types)
41
+ create_table :order_txn_types do |t|
42
+ t.column :parent_id, :integer
43
+ t.column :lft, :integer
44
+ t.column :rgt, :integer
45
+ #custom columns go here
46
+ t.column :description, :string
47
+ t.column :comments, :string
48
+ t.column :internal_identifier, :string
49
+ t.column :external_identifier, :string
50
+ t.column :external_id_source, :string
51
+ t.timestamps
52
+ end
53
+
54
+ add_index :order_txn_types, :parent_id
55
+ end
56
+
57
+
58
+ unless table_exists?(:order_line_items)
59
+ create_table :order_line_items do |t|
60
+ t.column :order_txn_id, :integer
61
+ t.column :order_line_item_type_id, :integer
62
+ t.column :product_id, :integer
63
+ t.column :product_description, :string
64
+ t.column :product_instance_id, :integer
65
+ t.column :product_instance_description, :string
66
+ t.column :product_type_id, :integer
67
+ t.column :product_type_description, :string
68
+ t.column :sold_price, :decimal, :precision => 8, :scale => 2
69
+ t.column :sold_price_uom, :integer
70
+ t.column :sold_amount, :integer
71
+ t.column :sold_amount_uom, :integer
72
+ t.column :product_offer_id, :integer
73
+ t.timestamps
74
+ end
75
+
76
+ add_index :order_line_items, :order_txn_id
77
+ add_index :order_line_items, :order_line_item_type_id
78
+ add_index :order_line_items, :product_id
79
+ add_index :order_line_items, :product_instance_id
80
+ add_index :order_line_items, :product_type_id
81
+ add_index :order_line_items, :product_offer_id
82
+ end
83
+
84
+ unless table_exists?(:order_line_item_types)
85
+ create_table :order_line_item_types do |t|
86
+ t.column :parent_id, :integer
87
+ t.column :lft, :integer
88
+ t.column :rgt, :integer
89
+ #custom columns go here
90
+ t.column :description, :string
91
+ t.column :comments, :string
92
+ t.column :internal_identifier, :string
93
+ t.column :external_identifier, :string
94
+ t.column :external_id_source, :string
95
+ t.timestamps
96
+ end
97
+
98
+ add_index :order_line_item_types, :parent_id
99
+ end
100
+
101
+ unless table_exists?(:order_line_item_pty_roles)
102
+ create_table :order_line_item_pty_roles do |t|
103
+ t.column :description, :string
104
+ t.column :order_line_item_id, :integer
105
+ t.column :party_id, :integer
106
+ t.column :line_item_role_type_id, :integer
107
+ t.column :biz_txn_acct_root_id, :integer #optional for splitting orders across accounts
108
+ t.timestamps
109
+ end
110
+
111
+ add_index :order_line_item_pty_roles, :order_line_item_id
112
+ add_index :order_line_item_pty_roles, :party_id
113
+ add_index :order_line_item_pty_roles, :line_item_role_type_id
114
+ add_index :order_line_item_pty_roles, :biz_txn_acct_root_id
115
+ end
116
+
117
+ unless table_exists?(:line_item_role_types)
118
+ create_table :line_item_role_types do |t|
119
+ t.column :parent_id, :integer
120
+ t.column :lft, :integer
121
+ t.column :rgt, :integer
122
+ #custom columns go here
123
+ t.column :description, :string
124
+ t.column :comments, :string
125
+ t.column :internal_identifier, :string
126
+ t.column :external_identifier, :string
127
+ t.column :external_id_source, :string
128
+ t.timestamps
129
+ end
130
+
131
+ add_index :line_item_role_types, :parent_id
132
+ end
133
+
134
+ unless table_exists?(:charge_lines)
135
+ create_table :charge_lines do |t|
136
+ t.string :sti_type
137
+ t.references :money
138
+ t.string :description #could be expanded to include type information, etc.
139
+ t.string :external_identifier
140
+ t.string :external_id_source
141
+
142
+ #polymorphic
143
+ t.references :charged_item, :polymorphic => true
144
+
145
+ t.timestamps
146
+ end
147
+
148
+ add_index :charge_lines, [:charged_item_id, :charged_item_type], :name => 'charged_item_idx'
149
+ end
150
+
151
+ unless table_exists?(:charge_line_payment_txns)
152
+ create_table :charge_line_payment_txns do |t|
153
+ t.column :charge_line_id, :integer
154
+
155
+ #polymorphic
156
+ t.references :payment_txn, :polymorphic => true
157
+
158
+ t.timestamps
159
+ end
160
+
161
+ add_index :charge_line_payment_txns, [:payment_txn_id, :payment_txn_type], :name => 'payment_txn_idx'
162
+ add_index :charge_line_payment_txns, :charge_line_id
163
+ end
164
+ end
165
+
166
+ def self.down
167
+ [
168
+ :charge_lines, :charge_line_payment_txns, :line_item_role_types, :order_line_item_pty_roles,
169
+ :order_line_item_types, :order_line_items, :order_txn_types,
170
+ :order_txns
171
+ ].each do |tbl|
172
+ if table_exists?(tbl)
173
+ drop_table tbl
174
+ end
175
+ end
176
+ end
177
+
178
+ end
@@ -0,0 +1,234 @@
1
+ # This migration comes from erp_products (originally 20080805000040)
2
+ class BaseProducts < ActiveRecord::Migration
3
+ def self.up
4
+
5
+ unless table_exists?(:product_types)
6
+ create_table :product_types do |t|
7
+ #these columns are required to support the behavior of the plugin 'better_nested_set'
8
+ #ALL products have the ability to act as packages in a nested set-type structure
9
+ #
10
+ #The package behavior is treated differently from other product_relationship behavior
11
+ #which is implemented using a standard relationship structure.
12
+ #
13
+ #This is to allow quick construction of highly nested product types.
14
+ t.column :parent_id, :integer
15
+ t.column :lft, :integer
16
+ t.column :rgt, :integer
17
+
18
+ #custom columns go here
19
+ t.column :description, :string
20
+ t.column :product_type_record_id, :integer
21
+ t.column :product_type_record_type, :string
22
+ t.column :external_identifier, :string
23
+ t.column :internal_identifier, :string
24
+ t.column :external_id_source, :string
25
+ t.column :default_image_url, :string
26
+ t.column :list_view_image_id, :integer
27
+ t.timestamps
28
+ end
29
+ end
30
+
31
+ unless table_exists?(:product_instances)
32
+ create_table :product_instances do |t|
33
+ #these columns are required to support the behavior of the plugin 'better_nested_set'
34
+ #ALL products have the ability to act as packages in a nested set-type structure
35
+ #
36
+ #The package behavior is treated differently from other product_relationship behavior
37
+ #which is implemented using a standard relationship structure.
38
+ #
39
+ #This is to allow quick construction of highly nested product types.
40
+ t.column :parent_id, :integer
41
+ t.column :lft, :integer
42
+ t.column :rgt, :integer
43
+
44
+ #custom columns go here
45
+ t.column :description, :string
46
+ t.column :product_instance_record_id, :integer
47
+ t.column :product_instance_record_type, :string
48
+ t.column :external_identifier, :string
49
+ t.column :external_id_source, :string
50
+ t.column :product_type_id, :integer
51
+ t.column :type, :string
52
+
53
+ t.references :prod_availability_status_type
54
+
55
+ t.timestamps
56
+ end
57
+ end
58
+
59
+ unless table_exists?(:product_offers)
60
+ create_table :product_offers do |t|
61
+ t.column :description, :string
62
+ t.column :product_offer_record_id, :integer
63
+ t.column :product_offer_record_type, :string
64
+ t.column :external_identifier, :string
65
+ t.column :external_id_source, :string
66
+ t.timestamps
67
+ end
68
+ end
69
+
70
+ unless table_exists?(:simple_product_offers)
71
+ create_table :simple_product_offers do |t|
72
+ t.column :description, :string
73
+ t.column :product_id, :integer
74
+ t.column :base_price, :decimal, :precision => 8, :scale => 2
75
+ t.column :uom, :integer
76
+ t.timestamps
77
+ end
78
+ end
79
+
80
+ unless table_exists?(:prod_instance_reln_types)
81
+ create_table :prod_instance_reln_types do |t|
82
+ t.column :parent_id, :integer
83
+ t.column :lft, :integer
84
+ t.column :rgt, :integer
85
+
86
+ #custom columns go here
87
+ t.column :description, :string
88
+ t.column :comments, :string
89
+ t.column :internal_identifier, :string
90
+ t.column :external_identifier, :string
91
+ t.column :external_id_source, :string
92
+ t.timestamps
93
+ end
94
+ end
95
+
96
+ unless table_exists?(:prod_instance_role_types)
97
+ create_table :prod_instance_role_types do |t|
98
+ t.column :parent_id, :integer
99
+ t.column :lft, :integer
100
+ t.column :rgt, :integer
101
+ #custom columns go here
102
+ t.column :description, :string
103
+ t.column :comments, :string
104
+ t.column :internal_identifier, :string
105
+ t.column :external_identifier, :string
106
+ t.column :external_id_source, :string
107
+ t.timestamps
108
+ end
109
+ end
110
+
111
+ unless table_exists?(:prod_instance_relns)
112
+ create_table :prod_instance_relns do |t|
113
+ t.column :prod_instance_reln_type_id, :integer
114
+ t.column :description, :string
115
+ t.column :prod_instance_id_from, :integer
116
+ t.column :prod_instance_id_to, :integer
117
+ t.column :role_type_id_from, :integer
118
+ t.column :role_type_id_to, :integer
119
+ t.column :status_type_id, :integer
120
+ t.column :from_date, :date
121
+ t.column :thru_date, :date
122
+ t.timestamps
123
+ end
124
+ end
125
+
126
+ unless table_exists?(:prod_type_reln_types)
127
+ create_table :prod_type_reln_types do |t|
128
+ t.column :parent_id, :integer
129
+ t.column :lft, :integer
130
+ t.column :rgt, :integer
131
+ #custom columns go here
132
+ t.column :description, :string
133
+ t.column :comments, :string
134
+ t.column :internal_identifier, :string
135
+ t.column :external_identifier, :string
136
+ t.column :external_id_source, :string
137
+ t.timestamps
138
+ end
139
+ end
140
+
141
+ unless table_exists?(:prod_type_role_types)
142
+ create_table :prod_type_role_types do |t|
143
+ t.column :parent_id, :integer
144
+ t.column :lft, :integer
145
+ t.column :rgt, :integer
146
+ #custom columns go here
147
+ t.column :description, :string
148
+ t.column :comments, :string
149
+ t.column :internal_identifier, :string
150
+ t.column :external_identifier, :string
151
+ t.column :external_id_source, :string
152
+ t.timestamps
153
+ end
154
+ end
155
+
156
+ unless table_exists?(:prod_type_relns)
157
+ create_table :prod_type_relns do |t|
158
+ t.column :prod_type_reln_type_id, :integer
159
+ t.column :description, :string
160
+ t.column :prod_type_id_from, :integer
161
+ t.column :prod_type_id_to, :integer
162
+ t.column :role_type_id_from, :integer
163
+ t.column :role_type_id_to, :integer
164
+ t.column :status_type_id, :integer
165
+ t.column :from_date, :date
166
+ t.column :thru_date, :date
167
+ t.timestamps
168
+ end
169
+ end
170
+
171
+ unless table_exists?(:product_instance_status_types)
172
+ create_table :product_instance_status_types do |t|
173
+ #better nested set colummns
174
+ t.column :parent_id, :integer
175
+ t.column :lft, :integer
176
+ t.column :rgt, :integer
177
+
178
+ t.column :description, :string
179
+ t.column :internal_identifier, :string
180
+ t.column :external_identifier, :string
181
+ t.column :external_id_source, :string
182
+
183
+ t.timestamps
184
+ end
185
+ end
186
+
187
+ unless table_exists?(:prod_availability_status_types)
188
+ create_table :prod_availability_status_types do |t|
189
+ #better nested set colummns
190
+ t.column :parent_id, :integer
191
+ t.column :lft, :integer
192
+ t.column :rgt, :integer
193
+
194
+ t.column :description, :string
195
+ t.column :internal_identifier, :string
196
+ t.column :external_identifier, :string
197
+ t.column :external_id_source, :string
198
+
199
+ t.timestamps
200
+ end
201
+ end
202
+
203
+ unless table_exists?(:prod_availability_status_types)
204
+ create_table :prod_availability_status_types do |t|
205
+ #better nested set colummns
206
+ t.column :parent_id, :integer
207
+ t.column :lft, :integer
208
+ t.column :rgt, :integer
209
+
210
+ t.column :description, :string
211
+ t.column :internal_identifier, :string
212
+ t.column :external_identifier, :string
213
+ t.column :external_id_source, :string
214
+
215
+ t.timestamps
216
+ end
217
+ end
218
+
219
+
220
+ end
221
+
222
+ def self.down
223
+ [
224
+ :prod_type_relns, :prod_type_role_types, :prod_type_reln_types,
225
+ :prod_instance_relns, :prod_instance_role_types, :prod_instance_reln_types,
226
+ :simple_product_offers, :product_offers, :product_instances,
227
+ :product_types,:prod_availability_status_types
228
+ ].each do |tbl|
229
+ if table_exists?(tbl)
230
+ drop_table tbl
231
+ end
232
+ end
233
+ end
234
+ end