effective_qb_online 0.3.6 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +1 -1
- data/app/models/effective/qb_api.rb +11 -17
- data/app/models/effective/qb_sales_receipt.rb +1 -1
- data/config/effective_qb_online.rb +0 -4
- data/db/migrate/{01_create_effective_qb_online.rb.erb → 101_create_effective_qb_online.rb} +5 -5
- data/lib/effective_qb_online/version.rb +1 -1
- data/lib/generators/effective_qb_online/install_generator.rb +1 -5
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57216dcf3ae7c167d41dad7c56b0f6f625b428646efccfe7d3c03149377276f3
|
4
|
+
data.tar.gz: 8a6174d2268d4301a432a52b1dac6ff0fce077f7e3eb830b42899a17a5d810e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd06c85052e13213874e0e70d6830b35b2e3f6c34f670eb289e0d2ac0ab712b24b47fd1f9eee199d61c6c1e8250d5f3c74ac676204cc2bf1856d65e5b70db945
|
7
|
+
data.tar.gz: e6d6c68c7354f14b8bd951d6f203e6a4e1f2ab9901f1f58b790004da95a2ec95bbff6de9f89c3666c0e6a16c19b2a6d0c8223ff32ff1dff582a1d4aedd2664a1
|
data/MIT-LICENSE
CHANGED
@@ -97,36 +97,30 @@ module Effective
|
|
97
97
|
payment_methods.sort_by(&:name).map { |payment_method| [payment_method.name, payment_method.id] }
|
98
98
|
end
|
99
99
|
|
100
|
-
def find_or_create_customer(
|
101
|
-
find_customer(
|
100
|
+
def find_or_create_customer(order:)
|
101
|
+
find_customer(order: order) || create_customer(order: order)
|
102
102
|
end
|
103
103
|
|
104
|
-
def find_customer(
|
105
|
-
raise('expected
|
104
|
+
def find_customer(order:)
|
105
|
+
raise('expected an Effective::Order') unless order.kind_of?(Effective::Order)
|
106
106
|
|
107
107
|
with_service('Customer') do |service|
|
108
108
|
# Find by email
|
109
|
-
customer = service.find_by(:PrimaryEmailAddr,
|
110
|
-
|
111
|
-
# Find by given name and family name
|
112
|
-
customer ||= if user.respond_to?(:first_name) && user.respond_to?(:last_name)
|
113
|
-
service.query("SELECT * FROM Customer WHERE GivenName LIKE '#{scrub(user.first_name, sql: true)}' AND FamilyName LIKE '#{scrub(user.last_name, sql: true)}'")&.first
|
114
|
-
end
|
109
|
+
customer = service.find_by(:PrimaryEmailAddr, order.email)&.first
|
115
110
|
|
116
111
|
# Find by display name
|
117
|
-
customer || service.find_by(:display_name, scrub(
|
112
|
+
customer || service.find_by(:display_name, scrub(order.billing_name))&.first
|
118
113
|
end
|
119
114
|
end
|
120
115
|
|
121
|
-
|
122
|
-
|
116
|
+
# https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/customer#create-a-customer
|
117
|
+
def create_customer(order:)
|
118
|
+
raise('expected an Effective::Order') unless order.kind_of?(Effective::Order)
|
123
119
|
|
124
120
|
with_service('Customer') do |service|
|
125
121
|
customer = Quickbooks::Model::Customer.new(
|
126
|
-
primary_email_address: Quickbooks::Model::EmailAddress.new(
|
127
|
-
display_name: scrub(
|
128
|
-
given_name: scrub(user.try(:first_name)),
|
129
|
-
family_name: scrub(user.try(:last_name))
|
122
|
+
primary_email_address: Quickbooks::Model::EmailAddress.new(order.email),
|
123
|
+
display_name: scrub(order.billing_name)
|
130
124
|
)
|
131
125
|
|
132
126
|
service.create(customer)
|
@@ -1,8 +1,4 @@
|
|
1
1
|
EffectiveQbOnline.setup do |config|
|
2
|
-
config.qb_realms_table_name = :qb_realms
|
3
|
-
config.qb_receipts_table_name = :qb_receipts
|
4
|
-
config.qb_receipt_items_table_name = :qb_receipt_items
|
5
|
-
|
6
2
|
# Layout Settings
|
7
3
|
# Configure the Layout per controller, or all at once
|
8
4
|
# config.layout = { application: 'application', admin: 'admin' }
|
@@ -1,6 +1,6 @@
|
|
1
|
-
class CreateEffectiveQbOnline < ActiveRecord::Migration[6.
|
1
|
+
class CreateEffectiveQbOnline < ActiveRecord::Migration[6.0]
|
2
2
|
def change
|
3
|
-
create_table
|
3
|
+
create_table :qb_realms do |t|
|
4
4
|
t.string :realm_id
|
5
5
|
|
6
6
|
t.integer :deposit_to_account_id
|
@@ -15,7 +15,7 @@ class CreateEffectiveQbOnline < ActiveRecord::Migration[6.1]
|
|
15
15
|
t.timestamps
|
16
16
|
end
|
17
17
|
|
18
|
-
create_table
|
18
|
+
create_table :qb_receipts do |t|
|
19
19
|
t.integer :order_id
|
20
20
|
t.integer :customer_id
|
21
21
|
|
@@ -27,9 +27,9 @@ class CreateEffectiveQbOnline < ActiveRecord::Migration[6.1]
|
|
27
27
|
t.timestamps
|
28
28
|
end
|
29
29
|
|
30
|
-
add_index
|
30
|
+
add_index :qb_receipts, :order_id
|
31
31
|
|
32
|
-
create_table
|
32
|
+
create_table :qb_receipt_items_name do |t|
|
33
33
|
t.integer :qb_receipt_id
|
34
34
|
t.integer :order_item_id
|
35
35
|
|
@@ -20,11 +20,7 @@ module EffectiveQbOnline
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def create_migration_file
|
23
|
-
|
24
|
-
@qb_receipts_table_name = ':' + EffectiveQbOnline.qb_receipts_table_name.to_s
|
25
|
-
@qb_receipt_items_table_name = ':' + EffectiveQbOnline.qb_receipt_items_table_name.to_s
|
26
|
-
|
27
|
-
migration_template ('../' * 3) + 'db/migrate/01_create_effective_qb_online.rb.erb', 'db/migrate/create_effective_qb_online.rb'
|
23
|
+
migration_template ('../' * 3) + 'db/migrate/101_create_effective_qb_online.rb', 'db/migrate/create_effective_qb_online.rb'
|
28
24
|
end
|
29
25
|
|
30
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_qb_online
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.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: 2023-
|
11
|
+
date: 2023-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -137,7 +137,7 @@ dependencies:
|
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
|
-
name: haml
|
140
|
+
name: haml
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
143
|
- - ">="
|
@@ -231,7 +231,7 @@ files:
|
|
231
231
|
- app/views/admin/qb_receipts/new.html.haml
|
232
232
|
- config/effective_qb_online.rb
|
233
233
|
- config/routes.rb
|
234
|
-
- db/migrate/
|
234
|
+
- db/migrate/101_create_effective_qb_online.rb
|
235
235
|
- db/seeds.rb
|
236
236
|
- lib/effective_qb_online.rb
|
237
237
|
- lib/effective_qb_online/engine.rb
|
@@ -258,7 +258,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
258
258
|
- !ruby/object:Gem::Version
|
259
259
|
version: '0'
|
260
260
|
requirements: []
|
261
|
-
rubygems_version: 3.
|
261
|
+
rubygems_version: 3.3.7
|
262
262
|
signing_key:
|
263
263
|
specification_version: 4
|
264
264
|
summary: Create QuickBooks Online SalesReceipts for purchased effective orders
|