erp_integration 0.3.3 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/erp_integration.gemspec +1 -1
- data/lib/erp_integration/configuration.rb +18 -9
- data/lib/erp_integration/fulfil/query_methods.rb +4 -4
- data/lib/erp_integration/fulfil/resources/product.rb +21 -0
- data/lib/erp_integration/fulfil/resources/{order.rb → sales_order.rb} +7 -8
- data/lib/erp_integration/fulfil/resources/{order_line.rb → sales_order_line.rb} +1 -1
- data/lib/erp_integration/fulfil/where_clause.rb +1 -1
- data/lib/erp_integration/product.rb +29 -0
- data/lib/erp_integration/resource.rb +2 -2
- data/lib/erp_integration/{order.rb → sales_order.rb} +2 -2
- data/lib/erp_integration/{order_line.rb → sales_order_line.rb} +2 -2
- data/lib/erp_integration/version.rb +1 -1
- data/lib/erp_integration.rb +4 -3
- metadata +22 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99b2b058b12b3b5d0b1212c9d077b9aaa224a9a20bc96f624dd7b5de3016bcaa
|
4
|
+
data.tar.gz: de266b8b0bb2c412866bf64ba0a28b75500faf79173e8d9bb1d56fd84c0a45b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09c9117df5560187b9c5010b56ec0cc9ce30b3313a801e687795a0d97bc1c8dd2acae6ebc1cba7b186e777c2198def26e4071b7dfc52f28a04be0265657c68e6'
|
7
|
+
data.tar.gz: 3da4be6f4775e272d118ccb93ecec41c9744702a73f328245f472032d66c69796cbec23bb70286bd034e7b2593734f6c169bcd8d6e32d13e089b60ddab3784bc
|
data/README.md
CHANGED
@@ -37,15 +37,15 @@ end
|
|
37
37
|
After configuring the gem, one can easily query all the available ERP resources from the connected third-parties.
|
38
38
|
|
39
39
|
```ruby
|
40
|
-
$ ErpIntegration::
|
41
|
-
=> #<ErpIntegration::Fulfil::Collection @items=[<ErpIntegration::
|
40
|
+
$ ErpIntegration::SalesOrder.where(reference: 'MT1000SKX')
|
41
|
+
=> #<ErpIntegration::Fulfil::Collection @items=[<ErpIntegration::SalesOrder @id=100 />] />
|
42
42
|
```
|
43
43
|
|
44
44
|
By default, only the `id` will be added to the found ERP resources. However, one can use the `select` method to include more fields.
|
45
45
|
|
46
46
|
```ruby
|
47
|
-
$ ErpIntegration::
|
48
|
-
=> #<ErpIntegration::Fulfil::Collection @items=[<ErpIntegration::
|
47
|
+
$ ErpIntegration::SalesOrder.select(:id, :reference).where(reference: 'MT1000SKX')
|
48
|
+
=> #<ErpIntegration::Fulfil::Collection @items=[<ErpIntegration::SalesOrder @id=100 @reference=MT1000SKX />] />
|
49
49
|
```
|
50
50
|
|
51
51
|
There are also other type of `where` queries available:
|
data/erp_integration.gemspec
CHANGED
@@ -33,7 +33,7 @@ Gem::Specification.new do |spec|
|
|
33
33
|
|
34
34
|
# Faraday is a HTTP/REST API client library to interact with third-party API vendors
|
35
35
|
spec.add_dependency 'faraday', '>= 0.17.3', '< 1.9.0'
|
36
|
-
spec.add_dependency 'faraday_middleware', '
|
36
|
+
spec.add_dependency 'faraday_middleware', '>= 0.14', '< 1.3'
|
37
37
|
|
38
38
|
# Development dependencies
|
39
39
|
spec.add_development_dependency 'byebug', '~> 11.0'
|
@@ -22,15 +22,20 @@ module ErpIntegration
|
|
22
22
|
# @return [String] The merchant ID for Fulfil.
|
23
23
|
attr_accessor :fulfil_merchant_id
|
24
24
|
|
25
|
-
# Allows configuring an adapter for the `
|
25
|
+
# Allows configuring an adapter for the `SalesOrder` resource. When none is
|
26
26
|
# configured, it will default to Fulfil.
|
27
|
-
# @return [Symbol] The configured adapter for the orders
|
28
|
-
attr_writer :
|
27
|
+
# @return [Symbol] The configured adapter for the sales orders
|
28
|
+
attr_writer :sales_order_adapter
|
29
29
|
|
30
|
-
# Allows configuring an adapter for the `
|
30
|
+
# Allows configuring an adapter for the `SalesOrderLine` resource. When none is
|
31
31
|
# configured, it will default to Fulfil.
|
32
32
|
# @return [Symbol] The configured adapter for the order lines.
|
33
|
-
attr_writer :
|
33
|
+
attr_writer :sales_order_line_adapter
|
34
|
+
|
35
|
+
# Allows configuring an adapter for the `Product` resource. When none is
|
36
|
+
# configured, it will default to Fulfil.
|
37
|
+
# @return [Symbol] The configured adapter for the products.
|
38
|
+
attr_writer :product_adapter
|
34
39
|
|
35
40
|
# Allows configuring an adapter for the `PurchaseOrder` resource. When none is
|
36
41
|
# configured, it will default to Fulfil.
|
@@ -53,12 +58,16 @@ module ErpIntegration
|
|
53
58
|
end
|
54
59
|
end
|
55
60
|
|
56
|
-
def
|
57
|
-
@
|
61
|
+
def sales_order_adapter
|
62
|
+
@sales_order_adapter || :fulfil
|
63
|
+
end
|
64
|
+
|
65
|
+
def sales_order_line_adapter
|
66
|
+
@sales_order_line_adapter || :fulfil
|
58
67
|
end
|
59
68
|
|
60
|
-
def
|
61
|
-
@
|
69
|
+
def product_adapter
|
70
|
+
@product_adapter || :fulfil
|
62
71
|
end
|
63
72
|
|
64
73
|
def purchase_order_adapter
|
@@ -13,14 +13,14 @@ module ErpIntegration
|
|
13
13
|
# selecting multiple fields at once.
|
14
14
|
#
|
15
15
|
# @example
|
16
|
-
# $ ErpIntegration::
|
16
|
+
# $ ErpIntegration::SalesOrder.select(:id, :name, 'product.name')
|
17
17
|
# # => <ErpIntegration::Fulfil::Resources::Order @selected_fields=[:id, :name, "product.name"] />
|
18
18
|
#
|
19
19
|
# When one calls the `all` method, it will fetch all the resources from Fulfil
|
20
20
|
# and it will return all the given fields (if available).
|
21
21
|
#
|
22
22
|
# @example
|
23
|
-
# $ ErpIntegration::
|
23
|
+
# $ ErpIntegration::SalesOrder.select(:id, :name, 'product.name').all
|
24
24
|
# # => <ErpIntegration::Fulfil::Collection @items=[...] />
|
25
25
|
#
|
26
26
|
# Both a list of Strings, Symbols or a combination of these can be passed
|
@@ -41,8 +41,8 @@ module ErpIntegration
|
|
41
41
|
# to query resources in Fulfil.
|
42
42
|
#
|
43
43
|
# @example
|
44
|
-
# $ ErpIntegration::
|
45
|
-
# # => <ErpIntegration::Fulfil::Collection @items=[<ErpIntegration::
|
44
|
+
# $ ErpIntegration::SalesOrder.where(id: 100).all
|
45
|
+
# # => <ErpIntegration::Fulfil::Collection @items=[<ErpIntegration::SalesOrder @id=100 />] />
|
46
46
|
#
|
47
47
|
# If one adds the `comparison_operator` key to the arguments, it will use
|
48
48
|
# that comparison operator to build the query to Fulfil.
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../api_resource'
|
4
|
+
|
5
|
+
module ErpIntegration
|
6
|
+
module Fulfil
|
7
|
+
module Resources
|
8
|
+
class Product < ApiResource
|
9
|
+
self.model_name = 'product.product'
|
10
|
+
|
11
|
+
# Checks whether a certain product is a BOM.
|
12
|
+
# @param sku [String] The product's SKU.
|
13
|
+
# @return [Boolean] Whether it's a BOM or not.
|
14
|
+
def bom?(sku)
|
15
|
+
select(:boms).where(code: sku).first.boms.any?
|
16
|
+
end
|
17
|
+
alias billing_of_materials? bom?
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -5,20 +5,14 @@ require_relative '../api_resource'
|
|
5
5
|
module ErpIntegration
|
6
6
|
module Fulfil
|
7
7
|
module Resources
|
8
|
-
class
|
8
|
+
class SalesOrder < ApiResource
|
9
9
|
self.model_name = 'sale.sale'
|
10
10
|
|
11
11
|
# Allows cancelling the entire sales order in Fulfil.
|
12
12
|
# @param id [Integer|String] The ID of the to be cancelled order.
|
13
13
|
# @return [boolean] Whether the sales order was cancelled successfully or not.
|
14
14
|
def cancel(id)
|
15
|
-
|
16
|
-
client.put("model/sale.sale/#{id}/cancel")
|
17
|
-
rescue Faraday::Error::ParsingError
|
18
|
-
# Workaround: Fulfil api does not return a json when status code is 200 (a.k.a. "Ok")
|
19
|
-
# and faraday is having an error when trying to parse it. Let's skip the parse error
|
20
|
-
# and move on.
|
21
|
-
end
|
15
|
+
client.put("model/sale.sale/#{id}/cancel")
|
22
16
|
true
|
23
17
|
|
24
18
|
# Fulfil will return an 400 (a.k.a. "Bad Request") status code when a sales order couldn't
|
@@ -28,6 +22,11 @@ module ErpIntegration
|
|
28
22
|
# https://developers.fulfil.io/rest_api/model/sale.sale/#cancel-a-sales-order
|
29
23
|
rescue ErpIntegration::HttpError::BadRequest
|
30
24
|
false
|
25
|
+
# Workaround: Fulfil api does not return a json when status code is 200 (a.k.a. "Ok")
|
26
|
+
# and faraday is having an error when trying to parse it. Let's skip the parse error
|
27
|
+
# and move on.
|
28
|
+
rescue Faraday::ParsingError
|
29
|
+
true
|
31
30
|
end
|
32
31
|
end
|
33
32
|
end
|
@@ -26,7 +26,7 @@ module ErpIntegration
|
|
26
26
|
def initialize(key:, value:, comparison_operator: DEFAULT_COMPARISON_OPERATOR)
|
27
27
|
@comparison_operator = verify_comparison_operator(comparison_operator)
|
28
28
|
@key = key.to_s
|
29
|
-
@value = value
|
29
|
+
@value = value
|
30
30
|
end
|
31
31
|
|
32
32
|
# Transforms the `WhereClause` into a filter object for Fulfil.
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ErpIntegration
|
4
|
+
# The `ErpIntegration::Product` exposes an uniformed API for interaction with
|
5
|
+
# third-party ERP vendors.
|
6
|
+
class Product < Resource
|
7
|
+
attr_accessor :id, :code, :cost_price, :cost_price_method, :quantity_available,
|
8
|
+
:quantity_buildable, :quantity_inbound, :quantity_on_hand, :salable,
|
9
|
+
:template, :variant_name, :abc_classification, :account_category,
|
10
|
+
:account_cogs_used, :account_expense_used, :account_revenue_used,
|
11
|
+
:account_stock_lost_found_used, :account_stock_production_used,
|
12
|
+
:account_stock_supplier_used, :account_stock_used, :active,
|
13
|
+
:asin, :attachments, :attribute_set, :attributes, :attributes_json,
|
14
|
+
:average_daily_consumed, :average_daily_sales, :average_monthly_consumed,
|
15
|
+
:average_monthly_sales, :average_price, :boms, :box_type, :brand, :channel_listings,
|
16
|
+
:consumable, :country_of_origin, :create_date, :create_uid, :customs_description,
|
17
|
+
:customs_value, :days_of_inventory_left, :default_uom, :default_uom_category,
|
18
|
+
:description, :dimensions_uom, :ean, :fulfil_strategy, :gc_max, :gc_min,
|
19
|
+
:gift_card_delivery_mode, :gift_card_prices, :google_product_category,
|
20
|
+
:gross_margin, :gross_profit, :height, :hs_code, :is_gift_card, :landed_cost,
|
21
|
+
:lead_time_in_days, :length, :list_price, :long_description, :metadata,
|
22
|
+
:next_shipping_date, :product_suppliers, :purchasable, :purchase_uom,
|
23
|
+
:quantity_on_confirmed_purchase_orders, :quantity_outbound, :quantity_returned,
|
24
|
+
:quantity_sold, :quantity_waiting_consumption, :quantity_wip, :safety_stock_days,
|
25
|
+
:sale_uom, :scan_required, :ship_from_stock_if_available, :type,
|
26
|
+
:upc, :use_name_as_customs_description, :weight, :weight_uom,
|
27
|
+
:width, :write_date, :write_uid
|
28
|
+
end
|
29
|
+
end
|
@@ -16,8 +16,8 @@ module ErpIntegration
|
|
16
16
|
# config.order_adapter = :fulfil
|
17
17
|
# end
|
18
18
|
#
|
19
|
-
# $ ErpIntegration::
|
20
|
-
# => #<ErpIntegration::
|
19
|
+
# $ ErpIntegration::SalesOrder.adapter
|
20
|
+
# => #<ErpIntegration::SalesOrders::FulfilOrder />
|
21
21
|
#
|
22
22
|
# To add a new resource, follow these steps:
|
23
23
|
# 1. Add a new `attr_writer` in the `ErpIntegration::Configuration` class.
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module ErpIntegration
|
4
|
-
# The `ErpIntegration::
|
4
|
+
# The `ErpIntegration::SalesOrder` exposes an uniformed API for interaction with
|
5
5
|
# third-party ERP vendors.
|
6
|
-
class
|
6
|
+
class SalesOrder < Resource
|
7
7
|
attr_accessor :id, :channel, :number, :party, :sale_date, :shipment_address,
|
8
8
|
:amount_invoiced, :attachments, :carrier, :carrier_service,
|
9
9
|
:channel_identifier, :comment, :company, :confirmation_time,
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module ErpIntegration
|
4
|
-
# The `ErpIntegration::
|
4
|
+
# The `ErpIntegration::SalesOrderLine` exposes an uniformed API for interaction with
|
5
5
|
# third-party ERP vendors.
|
6
|
-
class
|
6
|
+
class SalesOrderLine < Resource
|
7
7
|
attr_accessor :id, :product, :quantity, :unit, :unit_price, :amount, :attachments,
|
8
8
|
:channel_identifier, :create_date, :create_uid, :delivery_address,
|
9
9
|
:delivery_date, :delivery_mode, :description, :discount, :gift_message,
|
data/lib/erp_integration.rb
CHANGED
@@ -20,10 +20,11 @@ require_relative 'erp_integration/fulfil/client'
|
|
20
20
|
# The `ErpIntegration` integrates Mejuri with third-party ERP vendors.
|
21
21
|
module ErpIntegration
|
22
22
|
# Resources
|
23
|
-
autoload :
|
24
|
-
autoload :Order, 'erp_integration/order'
|
25
|
-
autoload :OrderLine, 'erp_integration/order_line'
|
23
|
+
autoload :Product, 'erp_integration/product'
|
26
24
|
autoload :PurchaseOrder, 'erp_integration/purchase_order'
|
27
25
|
autoload :PurchaseOrderLine, 'erp_integration/purchase_order_line'
|
28
26
|
autoload :PurchaseRequest, 'erp_integration/purchase_request'
|
27
|
+
autoload :Resource, 'erp_integration/resource'
|
28
|
+
autoload :SalesOrder, 'erp_integration/sales_order'
|
29
|
+
autoload :SalesOrderLine, 'erp_integration/sales_order_line'
|
29
30
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: erp_integration
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Vermaas
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-10-
|
11
|
+
date: 2021-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -48,16 +48,22 @@ dependencies:
|
|
48
48
|
name: faraday_middleware
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
|
-
- - "
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0.14'
|
54
|
+
- - "<"
|
52
55
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
56
|
+
version: '1.3'
|
54
57
|
type: :runtime
|
55
58
|
prerelease: false
|
56
59
|
version_requirements: !ruby/object:Gem::Requirement
|
57
60
|
requirements:
|
58
|
-
- - "
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0.14'
|
64
|
+
- - "<"
|
59
65
|
- !ruby/object:Gem::Version
|
60
|
-
version:
|
66
|
+
version: '1.3'
|
61
67
|
- !ruby/object:Gem::Dependency
|
62
68
|
name: byebug
|
63
69
|
requirement: !ruby/object:Gem::Requirement
|
@@ -218,7 +224,7 @@ dependencies:
|
|
218
224
|
- - '='
|
219
225
|
- !ruby/object:Gem::Version
|
220
226
|
version: 1.19.2
|
221
|
-
description:
|
227
|
+
description:
|
222
228
|
email:
|
223
229
|
- stefan@knowndecimal.com
|
224
230
|
executables: []
|
@@ -259,19 +265,21 @@ files:
|
|
259
265
|
- lib/erp_integration/fulfil/client.rb
|
260
266
|
- lib/erp_integration/fulfil/query.rb
|
261
267
|
- lib/erp_integration/fulfil/query_methods.rb
|
262
|
-
- lib/erp_integration/fulfil/resources/
|
263
|
-
- lib/erp_integration/fulfil/resources/order_line.rb
|
268
|
+
- lib/erp_integration/fulfil/resources/product.rb
|
264
269
|
- lib/erp_integration/fulfil/resources/purchase_order.rb
|
265
270
|
- lib/erp_integration/fulfil/resources/purchase_order_line.rb
|
266
271
|
- lib/erp_integration/fulfil/resources/purchase_request.rb
|
272
|
+
- lib/erp_integration/fulfil/resources/sales_order.rb
|
273
|
+
- lib/erp_integration/fulfil/resources/sales_order_line.rb
|
267
274
|
- lib/erp_integration/fulfil/where_clause.rb
|
268
275
|
- lib/erp_integration/middleware/error_handling.rb
|
269
|
-
- lib/erp_integration/
|
270
|
-
- lib/erp_integration/order_line.rb
|
276
|
+
- lib/erp_integration/product.rb
|
271
277
|
- lib/erp_integration/purchase_order.rb
|
272
278
|
- lib/erp_integration/purchase_order_line.rb
|
273
279
|
- lib/erp_integration/purchase_request.rb
|
274
280
|
- lib/erp_integration/resource.rb
|
281
|
+
- lib/erp_integration/sales_order.rb
|
282
|
+
- lib/erp_integration/sales_order_line.rb
|
275
283
|
- lib/erp_integration/version.rb
|
276
284
|
homepage: https://www.github.com/mejuri-inc/erp-integration
|
277
285
|
licenses:
|
@@ -281,7 +289,7 @@ metadata:
|
|
281
289
|
homepage_uri: https://www.github.com/mejuri-inc/erp-integration
|
282
290
|
source_code_uri: https://www.github.com/mejuri-inc/erp-integration
|
283
291
|
changelog_uri: https://www.github.com/mejuri-inc/erp-integration/blob/main/CHANGELOG.md
|
284
|
-
post_install_message:
|
292
|
+
post_install_message:
|
285
293
|
rdoc_options: []
|
286
294
|
require_paths:
|
287
295
|
- lib
|
@@ -297,7 +305,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
297
305
|
version: '0'
|
298
306
|
requirements: []
|
299
307
|
rubygems_version: 3.2.22
|
300
|
-
signing_key:
|
308
|
+
signing_key:
|
301
309
|
specification_version: 4
|
302
310
|
summary: Connects Mejuri with third-party ERP vendors
|
303
311
|
test_files: []
|