effective_qb_sync 1.1.5 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 357b14cee13610f77a1ce6db294b842eb1870778
4
- data.tar.gz: 2afe65aa9344c0ec0ab301b8176b2f7e558d031d
3
+ metadata.gz: abb025ece9f83664fc48e4373b7844bd26537f6f
4
+ data.tar.gz: 49bc39d12877b462f3c7bd034de5463a6067c3be
5
5
  SHA512:
6
- metadata.gz: d50312065f5de11a306ac1b20366b401de3e66e1483b7941f584c603f82f1be669aba24c4be8fafd2e2c94be0394e48b746f3dab1fa9700a55aed3db6e9e6429
7
- data.tar.gz: cdebb3a09b61ac63a07d92bea5ac39065dd383f76eb744a4b201ba96fe88ac671e145a35c6544b1add38ba9ef650ca50018c685bd23d791619a7495db9f23647
6
+ metadata.gz: 0c3aadb7bb349781904a08d0082e7a491cd7e7413432446660391baf662f4a287eff505b32fdf4b98ed2cf76a602a5778e5f875aeeb4796fc41fac4b91e40c57
7
+ data.tar.gz: 4f19589875ac5fa5a47f6ad318e10d1cca50cf6ca08e043aea26517721d1488f7cded108cf0eca4b5c9f91cec5b14f3376835e1416eb64d5ee073c522e1752f5
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2016 Code and Effect Inc.
1
+ Copyright 2018 Code and Effect Inc.
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -1,16 +1,12 @@
1
1
  module Admin
2
2
  class QbSyncsController < ApplicationController
3
- respond_to?(:before_action) ? before_action(:authenticate_user!) : before_filter(:authenticate_user!) # Devise
4
- respond_to?(:before_action) ? before_action(:restrict_access) : before_filter(:restrict_access)
3
+ before_action :authenticate_user!
4
+ before_action :restrict_access
5
5
 
6
6
  layout (EffectiveQbSync.layout.kind_of?(Hash) ? EffectiveQbSync.layout[:admin_qb_tickets] : EffectiveQbSync.layout)
7
7
 
8
8
  def index
9
- if Gem::Version.new(EffectiveDatatables::VERSION) < Gem::Version.new('3.0')
10
- @datatable = Effective::Datatables::QbSyncs.new()
11
- else
12
- @datatable = EffectiveQbSyncDatatable.new(self)
13
- end
9
+ @datatable = EffectiveQbSyncDatatable.new(self)
14
10
 
15
11
  @page_title = 'Quickbooks Synchronizations'
16
12
  end
@@ -50,10 +46,32 @@ module Admin
50
46
  render '/effective/qb_web_connector/quickbooks.qwc', layout: false
51
47
  end
52
48
 
49
+ def set_all_orders_finished
50
+ Effective::QbTicket.transaction do
51
+ begin
52
+ @qb_ticket = Effective::QbTicket.new(state: 'Finished')
53
+ @qb_ticket.qb_logs.build(message: 'Set all orders Finished')
54
+ @qb_ticket.save!
55
+
56
+ Effective::QbRequest.new_requests_for_unsynced_items.each do |qb_request|
57
+ qb_request.qb_ticket = @qb_ticket
58
+ qb_request.transition_to_finished
59
+ end
60
+
61
+ flash[:success] = 'Successfully set all orders finished'
62
+ rescue => e
63
+ flash[:danger] = "Unable to set all orders finished: #{e.message}"
64
+ raise ActiveRecord::Rollback
65
+ end
66
+ end
67
+
68
+ redirect_to effective_qb_sync.admin_qb_syncs_path
69
+ end
70
+
53
71
  private
54
72
 
55
73
  def restrict_access
56
- EffectiveQbSync.authorized?(self, :admin, :effective_qb_sync)
74
+ EffectiveQbSync.authorize!(self, :admin, :effective_qb_sync)
57
75
  end
58
76
 
59
77
  def permitted_qb_order_items_params
@@ -1,7 +1,7 @@
1
1
  module Effective
2
2
  class QbSyncController < ApplicationController
3
3
  skip_authorization_check if defined?(CanCan)
4
- respond_to?(:skip_before_action) ? skip_before_action(:verify_authenticity_token) : skip_before_filter(:verify_authenticity_token)
4
+ skip_before_action :verify_authenticity_token
5
5
 
6
6
  def api
7
7
  # respond successfully to a GET which some versions of the Web Connector send to verify the url
@@ -1,36 +1,34 @@
1
- unless Gem::Version.new(EffectiveDatatables::VERSION) < Gem::Version.new('3.0')
2
- class EffectiveQbSyncDatatable < Effective::Datatable
3
- datatable do
4
- order :created_at, :desc
1
+ class EffectiveQbSyncDatatable < Effective::Datatable
2
+ datatable do
3
+ order :created_at, :desc
5
4
 
6
- col :created_at
7
- col :state, search: { collection: Effective::QbTicket::STATES }
5
+ col :created_at
6
+ col :state, search: { collection: Effective::QbTicket::STATES }
8
7
 
9
- val :num_orders, visible: false do |qb_ticket|
10
- qb_ticket.qb_requests.length
11
- end
8
+ val :num_orders, visible: false do |qb_ticket|
9
+ qb_ticket.qb_requests.length
10
+ end
12
11
 
13
- val :orders, sort: false, as: :obfuscated_id do |qb_ticket|
14
- qb_ticket.qb_requests.select { |qb_request| qb_request.order.present? }
15
- end.format do |requests|
16
- requests.map { |qb_request| link_to "##{qb_request.order.to_param}", effective_orders.admin_order_path(qb_request.order) }
17
- .join('<br>').html_safe
18
- end.search do |collection, term, column, sql_column|
19
- order = Effective::Order.where(id: search_term).first
12
+ val :orders, sort: false, as: :obfuscated_id do |qb_ticket|
13
+ qb_ticket.qb_requests.select { |qb_request| qb_request.order.present? }
14
+ end.format do |requests|
15
+ requests.map { |qb_request| link_to "##{qb_request.order.to_param}", effective_orders.admin_order_path(qb_request.order) }
16
+ .join('<br>').html_safe
17
+ end.search do |collection, term, column, sql_column|
18
+ order = Effective::Order.where(id: search_term).first
20
19
 
21
- if order.present?
22
- collection.where(id: Effective::QbRequest.where(order_id: order.id).pluck(:qb_ticket_id))
23
- else
24
- collection.none
25
- end
20
+ if order.present?
21
+ collection.where(id: Effective::QbRequest.where(order_id: order.id).pluck(:qb_ticket_id))
22
+ else
23
+ collection.none
26
24
  end
27
-
28
- actions_col partial: 'admin/qb_syncs/actions', partial_as: :qb_sync
29
25
  end
30
26
 
31
- collection do
32
- Effective::QbTicket.includes(qb_requests: :order)
33
- end
27
+ actions_col partial: 'admin/qb_syncs/actions', partial_as: :qb_sync
28
+ end
34
29
 
30
+ collection do
31
+ Effective::QbTicket.includes(qb_requests: :order)
35
32
  end
33
+
36
34
  end
@@ -2,10 +2,9 @@ module Effective
2
2
  class QbLog < ActiveRecord::Base
3
3
  belongs_to :qb_ticket
4
4
 
5
- # structure do
6
- # message :text
7
- # timestamps
8
- # end
5
+ # Attributes
6
+ # message :text
7
+ # timestamps
9
8
 
10
9
  validates :qb_ticket, presence: true
11
10
  validates :message, presence: true
@@ -2,10 +2,9 @@ module Effective
2
2
  class QbOrderItem < ActiveRecord::Base
3
3
  belongs_to :order_item
4
4
 
5
- # structure do
6
- # name :string
7
- # timestamps
8
- # end
5
+ # Attributes
6
+ # name :string
7
+ # timestamps
9
8
 
10
9
  validates :order_item, presence: true
11
10
  validates :name, presence: true
@@ -3,26 +3,23 @@ module Effective
3
3
  belongs_to :qb_ticket
4
4
  belongs_to :order
5
5
 
6
- # NOTE: Anything that is 'raise' here finds its way to qb_ticket#error!
6
+ # NOTE: Anything that is 'raise' here finds its way to qb_ticket#error
7
7
 
8
8
  # these are the states that signal a request is finished
9
9
  COMPLETED_STATES = ['Finished', 'Error']
10
10
  PROCESSING_STATES = ['Processing', 'CustomerQuery', 'CreateCustomer', 'OrderSync']
11
11
 
12
- # structure do
13
- # request_qbxml :text
14
- # response_qbxml :text
12
+ # Attributes
13
+ # request_qbxml :text
14
+ # response_qbxml :text
15
15
 
16
- # request_sent_at :datetime
17
- # response_received_at :datetime
16
+ # request_sent_at :datetime
17
+ # response_received_at :datetime
18
18
 
19
- # state :string, :validates => [:presence, :inclusion => { :in => COMPLETED_STATES + PROCESSING_STATES}]
20
- # error :text
19
+ # state :string
20
+ # error :text
21
21
 
22
- # site_id :integer # ActsAsSiteSpecific
23
-
24
- # timestamps
25
- # end
22
+ # timestamps
26
23
 
27
24
  validates :state, inclusion: { in: COMPLETED_STATES + PROCESSING_STATES }
28
25
  validates :qb_ticket, presence: true
@@ -7,26 +7,23 @@ module Effective
7
7
 
8
8
  STATES = ['Ready', 'Authenticated', 'Processing', 'Finished', 'ConnectionError', 'RequestError']
9
9
 
10
- # structure do
11
- # username :string
12
- # company_file_name :string
13
- # country :string
10
+ # Attributes
11
+ # username :string
12
+ # company_file_name :string
13
+ # country :string
14
14
 
15
- # qbxml_major_version :string
16
- # qbxml_minor_version :string
15
+ # qbxml_major_version :string
16
+ # qbxml_minor_version :string
17
17
 
18
- # state :string, :default => 'Ready', :validates => [:presence, :inclusion => { :in => STATES}]
19
- # percent :integer, :default => 0
18
+ # state :string, default: 'Ready'
19
+ # percent :integer
20
20
 
21
- # hpc_response :text
22
- # connection_error_hresult :text
23
- # connection_error_message :text
24
- # last_error :text
21
+ # hpc_response :text
22
+ # connection_error_hresult :text
23
+ # connection_error_message :text
24
+ # last_error :text
25
25
 
26
- # site_id :integer # ActsAsSiteSpecific
27
-
28
- # timestamps
29
- # end
26
+ # timestamps
30
27
 
31
28
  validates :state, inclusion: { in: STATES }
32
29
 
@@ -42,7 +39,7 @@ module Effective
42
39
  to: EffectiveQbSync.error_email,
43
40
  subject: "Quickbooks failed to synchronize order ##{qb_request.try(:order).try(:to_param) || 'unknown'}",
44
41
  template: 'qb_sync_error'
45
- ).try(:deliver_now).try(:deliver)
42
+ ).public_send(EffectiveOrders.mailer[:deliver_method])
46
43
 
47
44
  self.update_attributes!(atts.reverse_merge({last_error: error}))
48
45
  end
@@ -51,5 +48,6 @@ module Effective
51
48
  def log(message)
52
49
  qb_logs.create(message: message, qb_ticket: self)
53
50
  end
51
+
54
52
  end
55
53
  end
@@ -1,2 +1,8 @@
1
- = link_to effective_qb_sync.admin_qb_sync_path(qb_sync), title: 'View' do
2
- %span.glyphicon.glyphicon-eye-open
1
+ - show_path = effective_qb_sync.admin_qb_sync_path(qb_sync)
2
+
3
+ - if defined?(EffectiveBootstrap)
4
+ = dropdown(variation: :dropleft) do
5
+ = dropdown_link_to 'View', show_path
6
+ - else
7
+ = link_to show_path, title: 'View' do
8
+ %span.glyphicon.glyphicon-eye-open
@@ -0,0 +1,19 @@
1
+ = effective_form_with(model: qb_order_items_form, url: effective_qb_sync.admin_qb_sync_path(qb_order_items_form)) do |f|
2
+ %table.table
3
+ %thead
4
+ %tr
5
+ %th Order
6
+ %th Order Item
7
+ %th Quickbooks Item Name
8
+ %tbody
9
+ - qb_ticket.orders.each do |order|
10
+ - order.order_items.each_with_index do |order_item, index|
11
+ %tr
12
+ %td= (link_to(('#' + order.to_param.to_s), effective_orders.admin_order_path(order)) if index == 0)
13
+ %td= order_item
14
+ %td
15
+ = f.fields_for :qb_order_items, order_item.qb_order_item do |foi|
16
+ = f.hidden_field :order_item_id, order_item.id
17
+ = foi.text_field :name, label: false, required: false
18
+
19
+ = effective_save(f, 'Save QuickBooks Item Names')
@@ -1,9 +1,6 @@
1
1
  %table.table
2
2
  %thead
3
3
  %th Quickbooks Item Name/Number
4
- -#%th Website object
5
4
  %tbody
6
- - ActsAsPurchasable.descendants.each do |klass|
7
- %tr
8
- %td= klass.new().try(:qb_item_name)
9
- -#%td= klass.name
5
+ %tr
6
+ %td
@@ -0,0 +1,19 @@
1
+ = simple_form_for qb_order_items_form, (EffectiveOrders.admin_simple_form_options || {}).merge(url: effective_qb_sync.admin_qb_sync_path(qb_order_items_form)) do |f|
2
+ %table.table
3
+ %thead
4
+ %tr
5
+ %th Order
6
+ %th Order Item
7
+ %th Quickbooks Item Name
8
+ %tbody
9
+ - qb_ticket.orders.each do |order|
10
+ - order.order_items.each_with_index do |order_item, index|
11
+ %tr
12
+ %td= (link_to(('#' + order.to_param.to_s), effective_orders.admin_order_path(order)) if index == 0)
13
+ %td= order_item
14
+ %td
15
+ = f.simple_fields_for :qb_order_items, order_item.qb_order_item do |foi|
16
+ = foi.input :order_item_id, as: :hidden, value: order_item.id
17
+ = foi.input :name, label: false, required: false
18
+
19
+ %p= f.button :submit, 'Save Quickbooks Item Names', data: { disable_with: 'Saving...' }
@@ -15,7 +15,4 @@
15
15
 
16
16
  %hr
17
17
 
18
- - if @datatable.present?
19
- = render_datatable(@datatable)
20
- - else
21
- %p There are no Quickbook Syncs present
18
+ = render_datatable(@datatable)
@@ -133,4 +133,15 @@
133
133
  %strong= EffectiveQbSync.error_email || EffectiveOrders.mailer[:admin_email]
134
134
  will receive an email with instructions on how to fix the error
135
135
 
136
+ %h3 6. Troubleshooting
137
+
138
+ %p
139
+ Don't actually use this, but click below to skip all unsynced orders.
140
+
141
+ %ul
142
+ %li This action will create a finished QbTicket containing all orders.
143
+ %li All orders will be considered already synced, and will not be sent to QuickBooks again.
144
+ %li You might need a developer's help to undo this.
145
+ - unsynced = Effective::QbRequest.new_requests_for_unsynced_items.length
146
+ %li= link_to "Mark all #{unsynced} unsynced orders as already synchronized", effective_qb_sync.set_all_orders_finished_admin_qb_syncs_path, 'data-method': :post, 'data-confirm': 'Are you sure?'
136
147
 
@@ -9,25 +9,10 @@
9
9
 
10
10
  %h3 Orders
11
11
 
12
- = simple_form_for @qb_order_items_form, (EffectiveOrders.admin_simple_form_options || {}).merge(url: effective_qb_sync.admin_qb_sync_path(@qb_order_items_form)) do |f|
13
- %table.table
14
- %thead
15
- %tr
16
- %th Order
17
- %th Order Item
18
- %th Quickbooks Item Name
19
- %tbody
20
- - @qb_ticket.orders.each do |order|
21
- - order.order_items.each_with_index do |order_item, index|
22
- %tr
23
- %td= (link_to(('#' + order.to_param.to_s), effective_orders.admin_order_path(order)) if index == 0)
24
- %td= order_item
25
- %td
26
- = f.simple_fields_for :qb_order_items, order_item.qb_order_item do |foi|
27
- = foi.input :order_item_id, as: :hidden, value: order_item.id
28
- = foi.input :name, label: false, required: false
29
-
30
- %p= f.button :submit, 'Save Quickbooks Item Names', data: { disable_with: 'Saving...' }
12
+ - if defined?(EffectiveBootstrap)
13
+ = render 'form', qb_order_items_form: @qb_order_items_form, qb_ticket: @qb_ticket
14
+ - else
15
+ = render 'simple_form', qb_order_items_form: @qb_order_items_form, qb_ticket: @qb_ticket
31
16
 
32
17
  %h3 Sync Log
33
18
 
data/config/routes.rb CHANGED
@@ -1,9 +1,5 @@
1
- Rails.application.routes.draw do
2
- mount EffectiveQbSync::Engine => '/', as: 'effective_qb_sync'
3
- end
4
-
5
1
  EffectiveQbSync::Engine.routes.draw do
6
- scope module: 'effective' do
2
+ scope :module => 'effective' do
7
3
  match 'quickbooks/api', to: 'qb_sync#api', as: 'qb_sync', via: :all
8
4
  end
9
5
 
@@ -11,6 +7,11 @@ EffectiveQbSync::Engine.routes.draw do
11
7
  resources :qb_syncs, only: [:index, :show, :update] do
12
8
  get :instructions, on: :collection
13
9
  get :qwc, on: :collection
10
+ post :set_all_orders_finished, on: :collection
14
11
  end
15
12
  end
16
13
  end
14
+
15
+ Rails.application.routes.draw do
16
+ mount EffectiveQbSync::Engine => '/', as: 'effective_qb_sync'
17
+ end
@@ -1,4 +1,4 @@
1
- class CreateEffectiveQbSync < ActiveRecord::Migration[3.2]
1
+ class CreateEffectiveQbSync < ActiveRecord::Migration[4.2]
2
2
  def self.up
3
3
  create_table <%= @qb_requests_table_name %> do |t|
4
4
  t.integer :order_id
@@ -1,4 +1,3 @@
1
- require 'simple_form'
2
1
  require 'effective_orders'
3
2
  require 'effective_qb_sync/engine'
4
3
  require 'effective_qb_sync/version'
@@ -26,10 +25,20 @@ module EffectiveQbSync
26
25
  end
27
26
 
28
27
  def self.authorized?(controller, action, resource)
29
- if authorization_method.respond_to?(:call) || authorization_method.kind_of?(Symbol)
30
- raise Effective::AccessDenied.new() unless (controller || self).instance_exec(controller, action, resource, &authorization_method)
28
+ @_exceptions ||= [Effective::AccessDenied, (CanCan::AccessDenied if defined?(CanCan)), (Pundit::NotAuthorizedError if defined?(Pundit))].compact
29
+
30
+ return !!authorization_method unless authorization_method.respond_to?(:call)
31
+ controller = controller.controller if controller.respond_to?(:controller)
32
+
33
+ begin
34
+ !!(controller || self).instance_exec((controller || self), action, resource, &authorization_method)
35
+ rescue *@_exceptions
36
+ false
31
37
  end
32
- true
38
+ end
39
+
40
+ def self.authorize!(controller, action, resource)
41
+ raise Effective::AccessDenied unless authorized?(controller, action, resource)
33
42
  end
34
43
 
35
44
  def self.permitted_params
@@ -9,19 +9,6 @@ module EffectiveQbSync
9
9
  eval File.read("#{config.root}/config/effective_qb_sync.rb")
10
10
  end
11
11
 
12
- # Ensure every acts_as_purchasable object responds to qb_item_name
13
- initializer 'effective_qb_sync.assert_qb_item_names_present' do |app|
14
- if Rails.env.development?
15
- ActiveSupport.on_load :active_record do
16
- invalids = (ActsAsPurchasable.descendants || []).reject { |klass| (klass.new().try(:qb_item_name).present? rescue false) }
17
-
18
- if invalids.present?
19
- puts "WARNING: (effective_qb_sync) expected acts_as_purchasable objects #{invalids.map(&:to_s).to_sentence} .qb_item_name() to be present."
20
- end
21
- end
22
- end
23
- end
24
-
25
12
  # Include acts_as_addressable concern and allow any ActiveRecord object to call it
26
13
  initializer 'effective_qb_sync.active_record' do |app|
27
14
  Rails.application.config.to_prepare do
@@ -31,7 +18,7 @@ module EffectiveQbSync
31
18
 
32
19
  # first or build
33
20
  def qb_item_name
34
- (qb_order_item || build_qb_order_item(name: purchasable.try(:qb_item_name))).name
21
+ (qb_order_item || build_qb_order_item(name: purchasable.qb_item_name)).name
35
22
  end
36
23
  end
37
24
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveQbSync
2
- VERSION = '1.1.5'.freeze
2
+ VERSION = '1.2.0'.freeze
3
3
  end
@@ -25,7 +25,7 @@ module EffectiveQbSync
25
25
  if mailer_preview_path.present?
26
26
  template 'effective_qb_sync_mailer_preview.rb', File.join(mailer_preview_path, 'effective_qb_sync_mailer_preview.rb')
27
27
  else
28
- puts "couldn't find action_mailer.preview_path. Skipping effective_qb_sync_mailer_preview."
28
+ puts "couldn't find action_mailer.preview_path. Skipping effective_qb_sync_mailer_preview."
29
29
  end
30
30
  end
31
31
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_qb_sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-01 00:00:00.000000000 Z
11
+ date: 2018-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -94,126 +94,14 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: simple_form
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :runtime
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
97
  - !ruby/object:Gem::Dependency
112
98
  name: effective_orders
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: 2.0.0
118
- type: :runtime
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: 2.0.0
125
- - !ruby/object:Gem::Dependency
126
- name: effective_datatables
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: 2.0.0
132
- type: :runtime
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: 2.0.0
139
- - !ruby/object:Gem::Dependency
140
- name: factory_girl_rails
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - ">="
144
- - !ruby/object:Gem::Version
145
- version: '0'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - ">="
151
- - !ruby/object:Gem::Version
152
- version: '0'
153
- - !ruby/object:Gem::Dependency
154
- name: rspec-rails
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - ">="
158
- - !ruby/object:Gem::Version
159
- version: '0'
160
- type: :development
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - ">="
165
- - !ruby/object:Gem::Version
166
- version: '0'
167
- - !ruby/object:Gem::Dependency
168
- name: sqlite3
169
- requirement: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - ">="
172
- - !ruby/object:Gem::Version
173
- version: '0'
174
- type: :development
175
- prerelease: false
176
- version_requirements: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - ">="
179
- - !ruby/object:Gem::Version
180
- version: '0'
181
- - !ruby/object:Gem::Dependency
182
- name: pry
183
- requirement: !ruby/object:Gem::Requirement
184
- requirements:
185
- - - ">="
186
- - !ruby/object:Gem::Version
187
- version: '0'
188
- type: :development
189
- prerelease: false
190
- version_requirements: !ruby/object:Gem::Requirement
191
- requirements:
192
- - - ">="
193
- - !ruby/object:Gem::Version
194
- version: '0'
195
- - !ruby/object:Gem::Dependency
196
- name: pry-stack_explorer
197
- requirement: !ruby/object:Gem::Requirement
198
- requirements:
199
- - - ">="
200
- - !ruby/object:Gem::Version
201
- version: '0'
202
- type: :development
203
- prerelease: false
204
- version_requirements: !ruby/object:Gem::Requirement
205
- requirements:
206
- - - ">="
207
- - !ruby/object:Gem::Version
208
- version: '0'
209
- - !ruby/object:Gem::Dependency
210
- name: pry-byebug
211
99
  requirement: !ruby/object:Gem::Requirement
212
100
  requirements:
213
101
  - - ">="
214
102
  - !ruby/object:Gem::Version
215
103
  version: '0'
216
- type: :development
104
+ type: :runtime
217
105
  prerelease: false
218
106
  version_requirements: !ruby/object:Gem::Requirement
219
107
  requirements:
@@ -233,7 +121,6 @@ files:
233
121
  - app/controllers/effective/qb_sync_controller.rb
234
122
  - app/datatables/effective_qb_sync_datatable.rb
235
123
  - app/models/effective/access_denied.rb
236
- - app/models/effective/datatables/qb_syncs.rb
237
124
  - app/models/effective/qb_log.rb
238
125
  - app/models/effective/qb_machine.rb
239
126
  - app/models/effective/qb_order_item.rb
@@ -242,7 +129,9 @@ files:
242
129
  - app/models/effective/qb_ticket.rb
243
130
  - app/models/effective/qbwc_supervisor.rb
244
131
  - app/views/admin/qb_syncs/_actions.html.haml
132
+ - app/views/admin/qb_syncs/_form.html.haml
245
133
  - app/views/admin/qb_syncs/_qb_item_names.html.haml
134
+ - app/views/admin/qb_syncs/_simple_form.html.haml
246
135
  - app/views/admin/qb_syncs/index.html.haml
247
136
  - app/views/admin/qb_syncs/instructions.html.haml
248
137
  - app/views/admin/qb_syncs/show.html.haml
@@ -338,7 +227,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
338
227
  version: '0'
339
228
  requirements: []
340
229
  rubyforge_project:
341
- rubygems_version: 2.4.6
230
+ rubygems_version: 2.4.5.1
342
231
  signing_key:
343
232
  specification_version: 4
344
233
  summary: Synchronize EffectiveOrders with QuickBooks Web Connector.
@@ -1,45 +0,0 @@
1
- if Gem::Version.new(EffectiveDatatables::VERSION) < Gem::Version.new('3.0')
2
- module Effective
3
- module Datatables
4
- class QbSyncs < Effective::Datatable
5
- datatable do
6
- default_order :created_at, :desc
7
-
8
- table_column :created_at
9
- table_column :state, filter: { values: QbTicket::STATES }
10
-
11
- array_column :num_orders, visible: false do |qb_ticket|
12
- qb_ticket.qb_requests.length
13
- end
14
-
15
- table_column :orders, sortable: false, as: :obfuscated_id do |qb_ticket|
16
- qb_ticket.qb_requests.select { |qb_request| qb_request.order.present? }
17
- .map { |qb_request| link_to "##{qb_request.order.to_param}", effective_orders.admin_order_path(qb_request.order) }
18
- .join('<br>').html_safe
19
- end
20
-
21
- actions_column partial: 'admin/qb_syncs/actions', partial_local: :qb_sync
22
- end
23
-
24
- def collection
25
- Effective::QbTicket.includes(qb_requests: :order)
26
- end
27
-
28
- def search_column(collection, table_column, search_term, sql_column)
29
- if table_column[:name] == 'orders'
30
- order = Effective::Order.where(id: search_term).first
31
-
32
- if order.present?
33
- collection.where(id: Effective::QbRequest.where(order_id: order.id).pluck(:qb_ticket_id))
34
- else
35
- collection.none
36
- end
37
- else
38
- super
39
- end
40
- end
41
-
42
- end
43
- end
44
- end
45
- end