effective_qb_sync 1.3.1 → 1.3.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 319c4615761c91d7f339bc221173660689d618c93d31a97eb0fda7c0fd1c4119
4
- data.tar.gz: bb82bd7bfdaf8e996f901c96e682a3e03be6da829fd85f298365f9632cdc27bc
3
+ metadata.gz: bd0557466e309a81b913eecd1970ef494d071c3c01d03e004a537ea466345fa9
4
+ data.tar.gz: 5c84e45ed198cf35fe3ac792fd4076efadb45d161803aedc12d6823118fb0a76
5
5
  SHA512:
6
- metadata.gz: dddb2b8fdd4a0087891534bdf96adff2e40c3020661051dc86c46da444b502d8ceae333f517ae356928e3ec22dc4e91067312b23cd04c70e5a4a5ce245911357
7
- data.tar.gz: 3a749c4afe9031557d936c5f76aedf40a7331098bbd16d3a9ab0271043bb1bfc89dd3a1e662dd14a26a7e7f503d8029c88c5127759862486d6bdb280060cf3bd
6
+ metadata.gz: 8ec10245d4723b3e6debaa9a3958094c45365a03c348a9fac7a2df9ccd1c4c49f9f8a45f0ffe53acc8d79eaacc1db51eb29616b1d7596f7346c244a139fb493f
7
+ data.tar.gz: ae9643278ae801730b9d2d7c21b3552eb9b7d1726a3ed54d298c56c3e69a8fcf2c2938cfcae7d36d2221a85cd22d92fd9d96cc79eeca55c58d23d478a4c57ad0
@@ -9,20 +9,7 @@ class EffectiveQbSyncDatatable < Effective::Datatable
9
9
  qb_ticket.qb_requests.length
10
10
  end
11
11
 
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
19
-
20
- if order.present?
21
- collection.where(id: Effective::QbRequest.where(order_id: order.id).pluck(:qb_ticket_id))
22
- else
23
- collection.none
24
- end
25
- end
12
+ col :orders
26
13
 
27
14
  actions_col do |qb_ticket|
28
15
  dropdown_link_to 'Show', effective_qb_sync.admin_qb_sync_path(qb_ticket)
@@ -31,7 +18,7 @@ class EffectiveQbSyncDatatable < Effective::Datatable
31
18
  end
32
19
 
33
20
  collection do
34
- Effective::QbTicket.deep.all
21
+ Effective::QbTicket.deep.includes(:orders).all
35
22
  end
36
23
 
37
24
  end
@@ -27,17 +27,17 @@ module Effective
27
27
 
28
28
  unless authentication_valid?(username, password)
29
29
  log "Authentication failed for user #{username}"
30
- @ticket.update_attributes!(username: username, state: 'Finished', last_error: @last_log_message)
30
+ @ticket.update!(username: username, state: 'Finished', last_error: @last_log_message)
31
31
  return 'nvu' # not valid user
32
32
  end
33
33
 
34
34
  if has_work?
35
35
  log "Authentication successful. Reporting to QuickBooks that there is work to be done."
36
- @ticket.update_attributes!(username: username, state: 'Authenticated')
36
+ @ticket.update!(username: username, state: 'Authenticated')
37
37
  '' # "Any other string value = use this name for company file"
38
38
  else
39
39
  log "Authentication successful, but there is no work to be done"
40
- @ticket.update_attributes!(username: username, state: 'Finished')
40
+ @ticket.update!(username: username, state: 'Finished')
41
41
  'none'
42
42
  end
43
43
  end
@@ -58,7 +58,7 @@ module Effective
58
58
  return '' unless valid?
59
59
 
60
60
  # update the ticket with the metadata sent at the first request for XML (i.e. if not blank)
61
- @ticket.update_attributes!(
61
+ @ticket.update!(
62
62
  hpc_response: (@ticket.hpc_response || params[:hcpresponse]),
63
63
  company_file_name: (@ticket.company_file_name || params[:company]),
64
64
  country: (@ticket.country || params[:country]),
@@ -82,13 +82,13 @@ module Effective
82
82
  # if we don't have a request, then we are done.
83
83
  unless request
84
84
  log "There is no more work to be done. Marking ticket state as finished"
85
- @ticket.update_attributes!(state: 'Finished')
85
+ @ticket.update!(state: 'Finished')
86
86
  return ''
87
87
  end
88
88
 
89
- request.update_attributes!(qb_ticket: @ticket, request_sent_at: Time.zone.now)
89
+ request.update!(qb_ticket: @ticket, request_sent_at: Time.zone.now)
90
90
  qb_xml = request.to_qb_xml
91
- request.update_attributes!(request_qbxml: qb_xml)
91
+ request.update!(request_qbxml: qb_xml)
92
92
 
93
93
  # set the ticket into a Processing state
94
94
  @ticket.state = 'Processing'
@@ -134,7 +134,7 @@ module Effective
134
134
 
135
135
  # also update the request if it is able to be found
136
136
  request = find_outstanding_request(responseXML)
137
- request.update_attributes!(response_qbxml: responseXML, state: 'Error') if request
137
+ request.update!(response_qbxml: responseXML, state: 'Error') if request
138
138
 
139
139
  return -1
140
140
  end
@@ -161,12 +161,12 @@ module Effective
161
161
  unless request.consume_response_xml(responseXML)
162
162
  # this request for some reason did not succeeed. Update the request and the ticket
163
163
  log "Request [#{request.state}] could not process the QuickBooks response: #{request.error}"
164
- request.update_attributes!(response_qbxml: responseXML, state: 'Error')
164
+ request.update!(response_qbxml: responseXML, state: 'Error')
165
165
  @ticket.error! @last_log_message
166
166
  return -1
167
167
  end
168
168
 
169
- request.update_attributes!(response_qbxml: responseXML) # This was changed for effective_qb_sync
169
+ request.update!(response_qbxml: responseXML) # This was changed for effective_qb_sync
170
170
 
171
171
  # the request has processed the response XML. if it does not have any more work to do, then detach it
172
172
 
@@ -174,7 +174,7 @@ module Effective
174
174
  log "Request [#{request.state}] has more work to do on the next request"
175
175
  else
176
176
  # detach the current request
177
- @ticket.update_attributes!(qb_request: nil)
177
+ @ticket.update!(qb_request: nil)
178
178
  log "Request [#{request.state}] has completed its work"
179
179
  end
180
180
 
@@ -214,7 +214,7 @@ module Effective
214
214
  def op_close_connection
215
215
  return 'Close error: invalid ticket' unless valid?
216
216
 
217
- @ticket.update_attributes!(state: 'Finished') unless ['ConnectionError', 'RequestError'].include?(@ticket.state)
217
+ @ticket.update!(state: 'Finished') unless ['ConnectionError', 'RequestError'].include?(@ticket.state)
218
218
  log "Closed connection with QuickBooks"
219
219
 
220
220
  'OK'
@@ -63,7 +63,7 @@ module Effective
63
63
  # parses the response XML and processes it.
64
64
  # returns true if the responseXML indicates success, false otherwise
65
65
  def consume_response_xml(xml)
66
- update_attributes!(response_qbxml: xml)
66
+ update!(response_qbxml: xml)
67
67
  handle_response_xml(xml)
68
68
  end
69
69
 
@@ -116,7 +116,7 @@ module Effective
116
116
  # transitions the request state and also outputs a log statement
117
117
  def transition_state(state)
118
118
  old_state = self.state
119
- update_attributes!(state: state)
119
+ update!(state: state)
120
120
  log "Transitioned request state from [#{old_state}] to [#{state}]"
121
121
  end
122
122
 
@@ -1,6 +1,6 @@
1
1
  module Effective
2
2
  class QbTicket < ActiveRecord::Base
3
- belongs_to :qb_request # the current request
3
+ belongs_to :qb_request, optional: true # the current request. Only optional when set_all_orders_finished
4
4
  has_many :qb_requests
5
5
  has_many :orders, through: :qb_requests
6
6
  has_many :qb_logs
@@ -15,7 +15,7 @@ module Effective
15
15
  qbxml_major_version :string
16
16
  qbxml_minor_version :string
17
17
 
18
- state :string, default: 'Ready'
18
+ state :string # , default: 'Ready'
19
19
  percent :integer
20
20
 
21
21
  hpc_response :text
@@ -31,7 +31,7 @@ module Effective
31
31
  validates :state, inclusion: { in: STATES }
32
32
 
33
33
  def request_error!(error, atts={})
34
- self.error!(error, atts.reverse_merge({state: 'RequestError'}))
34
+ self.error!(error, atts.reverse_merge(state: 'RequestError'))
35
35
  end
36
36
 
37
37
  # This is the entry point for a standard error.
@@ -42,9 +42,9 @@ module Effective
42
42
  to: EffectiveQbSync.error_email,
43
43
  subject: "Quickbooks failed to synchronize order ##{qb_request.try(:order).try(:to_param) || 'unknown'}",
44
44
  template: 'qb_sync_error'
45
- ).public_send(EffectiveOrders.mailer[:deliver_method])
45
+ ).deliver_now
46
46
 
47
- self.update_attributes!(atts.reverse_merge({last_error: error}))
47
+ update!(atts.reverse_merge(last_error: error))
48
48
  end
49
49
 
50
50
  # persists a new log message to this ticket
@@ -15,11 +15,16 @@
15
15
  %strong= Array(EffectiveQbSync.quickbooks_username).join('</strong> or <strong>').html_safe
16
16
  and password:
17
17
  %strong= Array(EffectiveQbSync.quickbooks_password).join('</strong> or <strong>').html_safe
18
+ - elsif EffectiveQbSync.quickbooks_username.blank? && EffectiveQbSync.quickbooks_password.present?
19
+ %li
20
+ Add a Quickbooks user any username, and password:
21
+ %strong= Array(EffectiveQbSync.quickbooks_password).join('</strong> or <strong>').html_safe
18
22
  - else
19
23
  %li
20
24
  (developer) Add a quickbooks_username and quickbooks_password to the config/initializers/effective_qb_sync.rb file
21
25
  %ul
22
26
  %li Add a Quickbooks user with that same username and password
27
+
23
28
  %li Access for user: "Selected areas of Quickbooks"
24
29
  %li Sales and Accounts Receivable "Selective Access - Create transactions only"
25
30
  %li Purchases and Accounts Payable "No Access"
@@ -1,3 +1,3 @@
1
1
  module EffectiveQbSync
2
- VERSION = '1.3.1'.freeze
2
+ VERSION = '1.3.5'.freeze
3
3
  end
@@ -209,7 +209,7 @@ describe Effective::QbMachine, "Sending Request qbXML to QuickBooks (op_send_req
209
209
  end
210
210
 
211
211
  it "should transition ticket to the RequestError state if the ticket is not in the Authenticated or Processing states" do
212
- @qb_machine.ticket.update_attributes!(state: 'Finished')
212
+ @qb_machine.ticket.update!(state: 'Finished')
213
213
  @qb_machine.op_send_request_xml(@default_request_params)
214
214
  @qb_machine.ticket.state.should eql('RequestError')
215
215
  end
@@ -314,25 +314,25 @@ describe Effective::QbMachine, "Receiving response qbXML from QuickBooks (op_rec
314
314
  end
315
315
 
316
316
  it "should return -1 to indicate error if the ticket state is not in the Processing state" do
317
- @qb_machine.ticket.update_attributes! :state=>'Finished'
317
+ @qb_machine.ticket.update! :state=>'Finished'
318
318
  result = @qb_machine.op_receive_response_xml(@default_response_params)
319
319
  result.should eql(-1)
320
320
  end
321
321
 
322
322
  it "should set the ticket state to RequestError if the ticket state was previously Authenticated" do
323
- @qb_machine.ticket.update_attributes! :state=>'Authenticated'
323
+ @qb_machine.ticket.update! :state=>'Authenticated'
324
324
  @qb_machine.op_receive_response_xml(@default_response_params)
325
325
  @qb_machine.ticket.state.should eql('RequestError')
326
326
  end
327
327
 
328
328
  it "should set the ticket state to RequestError if the ticket state was previously Ready" do
329
- @qb_machine.ticket.update_attributes! :state=>'Ready'
329
+ @qb_machine.ticket.update! :state=>'Ready'
330
330
  @qb_machine.op_receive_response_xml(@default_response_params)
331
331
  @qb_machine.ticket.state.should eql('RequestError')
332
332
  end
333
333
 
334
334
  it "should set the ticket state to RequestError if the ticket state was previously Finished" do
335
- @qb_machine.ticket.update_attributes! :state=>'Finished'
335
+ @qb_machine.ticket.update! :state=>'Finished'
336
336
  @qb_machine.op_receive_response_xml(@default_response_params)
337
337
  @qb_machine.ticket.state.should eql('RequestError')
338
338
  end
@@ -487,7 +487,7 @@ describe Effective::QbMachine, "Receiving a request from the QBWC to provide the
487
487
  before :each do
488
488
  @qb_machine = Effective::QbMachine.new
489
489
  @last_error = 'What?'
490
- @qb_machine.ticket.update_attributes! :last_error=>@last_error
490
+ @qb_machine.ticket.update! :last_error=>@last_error
491
491
  end
492
492
 
493
493
  it "should return the last error" do
@@ -495,11 +495,11 @@ describe Effective::QbMachine, "Receiving a request from the QBWC to provide the
495
495
  end
496
496
 
497
497
  it "should return '' if the last error is blank" do
498
- @qb_machine.ticket.update_attributes! :last_error=>nil
498
+ @qb_machine.ticket.update! :last_error=>nil
499
499
  error = @qb_machine.op_last_error
500
500
  error.should eql('')
501
501
 
502
- @qb_machine.ticket.update_attributes! :last_error=>''
502
+ @qb_machine.ticket.update! :last_error=>''
503
503
  error = @qb_machine.op_last_error
504
504
  error.should eql('')
505
505
  end
@@ -513,42 +513,40 @@ describe Effective::QbMachine, "Closing the connection (op_close_connection)" do
513
513
  end
514
514
 
515
515
  it "should not transition ticket state on close_connection if state is Finished" do
516
- @qb_machine.ticket.update_attributes! :state=>'Finished'
516
+ @qb_machine.ticket.update! :state=>'Finished'
517
517
  @qb_machine.op_close_connection
518
518
  @qb_machine.ticket.state.should eql('Finished')
519
519
  end
520
520
 
521
521
  it "should not transition ticket state on close_connection if state is ConnectionError" do
522
- @qb_machine.ticket.update_attributes! :state=>'ConnectionError'
522
+ @qb_machine.ticket.update! :state=>'ConnectionError'
523
523
  @qb_machine.op_close_connection
524
524
  @qb_machine.ticket.state.should eql('ConnectionError')
525
525
  end
526
526
 
527
527
  it "should not transition ticket state on close_connection if state is RequestError" do
528
- @qb_machine.ticket.update_attributes! :state=>'RequestError'
528
+ @qb_machine.ticket.update! :state=>'RequestError'
529
529
  @qb_machine.op_close_connection
530
530
  @qb_machine.ticket.state.should eql('RequestError')
531
531
  end
532
532
 
533
533
  it "should transition ticket state to Finished if state is Ready " do
534
- @qb_machine.ticket.update_attributes! :state=>'Ready'
534
+ @qb_machine.ticket.update! :state=>'Ready'
535
535
  @qb_machine.op_close_connection
536
536
  @qb_machine.ticket.state.should eql('Finished')
537
537
  end
538
538
 
539
539
  it "should transition ticket state to Finished if state is Authenticated" do
540
- @qb_machine.ticket.update_attributes! :state=>'Authenticated'
540
+ @qb_machine.ticket.update! :state=>'Authenticated'
541
541
  @qb_machine.op_close_connection
542
542
  @qb_machine.ticket.state.should eql('Finished')
543
543
  end
544
544
 
545
545
  it "should transition ticket state to Finished if state is Processing" do
546
- @qb_machine.ticket.update_attributes! :state=>'Processing'
546
+ @qb_machine.ticket.update! :state=>'Processing'
547
547
  @qb_machine.op_close_connection
548
548
  @qb_machine.ticket.state.should eql('Finished')
549
549
  end
550
550
 
551
551
 
552
552
  end
553
-
554
-
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.3.1
4
+ version: 1.3.5
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: 2021-03-25 00:00:00.000000000 Z
11
+ date: 2022-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails