diff --git a/app/models/qbo_customers.rb b/app/models/qbo_customers.rb index ff64af8..294aeeb 100644 --- a/app/models/qbo_customers.rb +++ b/app/models/qbo_customers.rb @@ -12,6 +12,7 @@ class QboCustomers < ActiveRecord::Base unloadable has_many :issues attr_accessible :name + validates_presence_of :id, :name def self.update_all qbo = Qbo.first @@ -20,6 +21,7 @@ class QboCustomers < ActiveRecord::Base # Update the customer table service.all.each { |customer| qbo_customer = QboCustomers.find_or_create_by(id: customer.id) + qbo_customer.id = customer.id qbo_customer.name = customer.display_name qbo_customer.save! } diff --git a/app/models/qbo_employee.rb b/app/models/qbo_employee.rb index 181e1d8..9eaef83 100644 --- a/app/models/qbo_employee.rb +++ b/app/models/qbo_employee.rb @@ -11,6 +11,7 @@ class QboEmployee < ActiveRecord::Base unloadable attr_accessible :name + validates_presence_of :id, :name def self.update_all qbo = Qbo.first @@ -19,7 +20,8 @@ class QboEmployee < ActiveRecord::Base # Update the item table service.all.each { |employee| qbo_employee = QboEmployee.find_or_create_by(id: employee.id) - qbo_employee.name = employee.display_name + qbo_employee.name = employee.display_name + qbo_employee.id = employee.id qbo_employee.save! } end diff --git a/app/models/qbo_item.rb b/app/models/qbo_item.rb index e5f3a35..d21c128 100644 --- a/app/models/qbo_item.rb +++ b/app/models/qbo_item.rb @@ -11,6 +11,7 @@ class QboItem < ActiveRecord::Base unloadable attr_accessible :name + validates_presence_of :id, :name def self.update_all qbo = Qbo.first @@ -20,6 +21,7 @@ class QboItem < ActiveRecord::Base service.all.each { |item| qbo_item = QboItem.find_or_create_by(id: item.id) qbo_item.name = item.name + qbo_item.id = item.id qbo_item.save! } end diff --git a/app/views/qbo/index.html.erb b/app/views/qbo/index.html.erb index 8fc4227..7ce02ad 100644 --- a/app/views/qbo/index.html.erb +++ b/app/views/qbo/index.html.erb @@ -11,14 +11,11 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI --> -

Redmine Quickbooks

- - Customer Count: <%= @qbo_customer_count %> - Item Count: <%= @qbo_item_count %> - Employee Count: <%= @qbo_employee_count %> +

Customer Count: <%= @qbo_customer_count %>

+

Item Count: <%= @qbo_item_count %>

+

Employee Count: <%= @qbo_employee_count %>



<%= link_to "Sync", qbo_sync_path %> - diff --git a/db/migrate/002_create_qbo_customers.rb b/db/migrate/002_create_qbo_customers.rb index ab8cb32..4357584 100644 --- a/db/migrate/002_create_qbo_customers.rb +++ b/db/migrate/002_create_qbo_customers.rb @@ -10,7 +10,8 @@ class CreateQboCustomers < ActiveRecord::Migration def change - create_table :qbo_customers do |t| + create_table :qbo_customers, id: false do |t| + t.integer :id, :options => 'PRIMARY KEY' t.string :name end end diff --git a/db/migrate/004_create_qbo_items.rb b/db/migrate/004_create_qbo_items.rb index d1817f9..c434bb7 100644 --- a/db/migrate/004_create_qbo_items.rb +++ b/db/migrate/004_create_qbo_items.rb @@ -1,6 +1,17 @@ +#The MIT License (MIT) +# +#Copyright (c) 2016 rick barrette +# +#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +# +#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +# +#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + class CreateQboItems < ActiveRecord::Migration def change - create_table :qbo_items do |t| + create_table :qbo_items, id: false do |t| + t.integer :id, :options => 'PRIMARY KEY' t.string :name end end diff --git a/db/migrate/005_create_qbo_employees.rb b/db/migrate/005_create_qbo_employees.rb index 65fd3a8..9798882 100644 --- a/db/migrate/005_create_qbo_employees.rb +++ b/db/migrate/005_create_qbo_employees.rb @@ -1,6 +1,17 @@ +#The MIT License (MIT) +# +#Copyright (c) 2016 rick barrette +# +#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +# +#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +# +#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + class CreateQboEmployees < ActiveRecord::Migration def change - create_table :qbo_employees do |t| + create_table :qbo_employees, id: false do |t| + t.integer :id, :options => 'PRIMARY KEY' t.string :name end end