erp_integration 0.3.2 → 0.5.1

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
  SHA256:
3
- metadata.gz: b64aeb4d27d23459820866bdac9a989d461f745abfb3790a0bd7b4a2a384c637
4
- data.tar.gz: 4affdf46ec9cdffd57027f0e97d8e226bcc9d82c8b382b80c7bdf26e0fbc5a69
3
+ metadata.gz: 86d28936152c0532ae9dd25cd52d40c8d66dca44eccd4323fb230c8f97d204e8
4
+ data.tar.gz: 223e971efbe294909519af5c6ae1a5a8590a7c189b30e7de06a27de40e118e4b
5
5
  SHA512:
6
- metadata.gz: c76fa52a52650b0d3510ecb758545fd17cd9b7ccfc7b2371172498f2c9c93a9112078391d540416183474cccb2d62adee45513ced1f60bca130c91f01373730f
7
- data.tar.gz: aacd6f248f1045e8cc68bffb07152d877cc0a2bf203ad08d2cc99e1e021a91510638cfd0e0a0ad47f9bf2aa40dfc59da0bc6dfe80b784745d38b6e4c414780c5
6
+ metadata.gz: 607e179b5d3e2c1eef9b8dc00b6b8a290412b5e58843570b627dcc6f428c057e84c7a7916d0b1b72df5aae0eadda8effec1bf51f6a5b0abf4e9141a8be508a61
7
+ data.tar.gz: 4814277a9b1df732e3c31ff72c066d4b6becebd02917328ab04404d060757c3d2fa89055c5a138c1226d9911933377862a2534ce9d28f6ecbe04d9e0aba999b7
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::Order.where(reference: 'MT1000SKX')
41
- => #<ErpIntegration::Fulfil::Collection @items=[<ErpIntegration::Order @id=100 />] />
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::Order.select(:id, :reference).where(reference: 'MT1000SKX')
48
- => #<ErpIntegration::Fulfil::Collection @items=[<ErpIntegration::Order @id=100 @reference=MT1000SKX />] />
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/bin/prerelease CHANGED
@@ -17,4 +17,4 @@ git push origin "release_v.$VERSION"
17
17
 
18
18
  # Tag the new gem version.
19
19
  git tag v$VERSION
20
- git push --tags
20
+ git push origin v$VERSION
@@ -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', '~> 0.14.0'
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,10 @@ 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 `Order` resource. When none is
25
+ # Allows configuring an adapter for the `Product` resource. When none is
26
26
  # configured, it will default to Fulfil.
27
- # @return [Symbol] The configured adapter for the orders
28
- attr_writer :order_adapter
29
-
30
- # Allows configuring an adapter for the `OrderLine` resource. When none is
31
- # configured, it will default to Fulfil.
32
- # @return [Symbol] The configured adapter for the order lines.
33
- attr_writer :order_line_adapter
27
+ # @return [Symbol] The configured adapter for the products.
28
+ attr_writer :product_adapter
34
29
 
35
30
  # Allows configuring an adapter for the `PurchaseOrder` resource. When none is
36
31
  # configured, it will default to Fulfil.
@@ -47,18 +42,34 @@ module ErpIntegration
47
42
  # @return [Symbol] The configured adapter for the purchase request.
48
43
  attr_writer :purchase_request_adapter
49
44
 
45
+ # Allows configuring an adapter for the `SalesOrder` resource. When none is
46
+ # configured, it will default to Fulfil.
47
+ # @return [Symbol] The configured adapter for the sales orders
48
+ attr_writer :sales_order_adapter
49
+
50
+ # Allows configuring an adapter for the `SalesOrderLine` resource. When none is
51
+ # configured, it will default to Fulfil.
52
+ # @return [Symbol] The configured adapter for the order lines.
53
+ attr_writer :sales_order_line_adapter
54
+
55
+ # Allows configuring an adapter for the `SupplierShipment` resource. When
56
+ # none is configured, it will default to Fulfil.
57
+ # @return [Symbol] The configured adapter for the supplier shipment.
58
+ attr_writer :supplier_shipment_adapter
59
+
60
+ # Allows configuring an adapter for the `StockMove` resource. When
61
+ # none is configured, it will default to Fulfil.
62
+ # @return [Symbol] The configured adapter for the stock move.
63
+ attr_writer :stock_move_adapter
64
+
50
65
  def initialize(**options)
51
66
  options.each_pair do |key, value|
52
67
  public_send("#{key}=", value) if respond_to?("#{key}=")
53
68
  end
54
69
  end
55
70
 
56
- def order_adapter
57
- @order_adapter || :fulfil
58
- end
59
-
60
- def order_line_adapter
61
- @order_line_adapter || :fulfil
71
+ def product_adapter
72
+ @product_adapter || :fulfil
62
73
  end
63
74
 
64
75
  def purchase_order_adapter
@@ -72,6 +83,22 @@ module ErpIntegration
72
83
  def purchase_request_adapter
73
84
  @purchase_request_adapter || :fulfil
74
85
  end
86
+
87
+ def sales_order_line_adapter
88
+ @sales_order_line_adapter || :fulfil
89
+ end
90
+
91
+ def sales_order_adapter
92
+ @sales_order_adapter || :fulfil
93
+ end
94
+
95
+ def supplier_shipment_adapter
96
+ @supplier_shipment_adapter || :fulfil
97
+ end
98
+
99
+ def stock_move_adapter
100
+ @stock_move_adapter || :fulfil
101
+ end
75
102
  end
76
103
 
77
104
  # Returns ERP Integration's configuration.
@@ -13,14 +13,14 @@ module ErpIntegration
13
13
  # selecting multiple fields at once.
14
14
  #
15
15
  # @example
16
- # $ ErpIntegration::Order.select(:id, :name, 'product.name')
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::Order.select(:id, :name, 'product.name').all
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::Order.where(id: 100).all
45
- # # => <ErpIntegration::Fulfil::Collection @items=[<ErpIntegration::Order @id=100 />] />
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.
@@ -74,10 +74,26 @@ module ErpIntegration
74
74
  where(args.merge(comparison_operator: 'in'))
75
75
  end
76
76
 
77
+ def where_less_than(args)
78
+ where(args.merge(comparison_operator: '<'))
79
+ end
80
+
81
+ def where_less_or_equal_to(args)
82
+ where(args.merge(comparison_operator: '<='))
83
+ end
84
+
77
85
  def where_like(args)
78
86
  where(args.merge(comparison_operator: 'like'))
79
87
  end
80
88
 
89
+ def where_more_than(args)
90
+ where(args.merge(comparison_operator: '>'))
91
+ end
92
+
93
+ def where_more_or_equal_to(args)
94
+ where(args.merge(comparison_operator: '>='))
95
+ end
96
+
81
97
  def where_not(args)
82
98
  where(args.merge(comparison_operator: '!='))
83
99
  end
@@ -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,7 +5,7 @@ require_relative '../api_resource'
5
5
  module ErpIntegration
6
6
  module Fulfil
7
7
  module Resources
8
- class Order < ApiResource
8
+ class SalesOrder < ApiResource
9
9
  self.model_name = 'sale.sale'
10
10
 
11
11
  # Allows cancelling the entire sales order in Fulfil.
@@ -22,6 +22,11 @@ module ErpIntegration
22
22
  # https://developers.fulfil.io/rest_api/model/sale.sale/#cancel-a-sales-order
23
23
  rescue ErpIntegration::HttpError::BadRequest
24
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
25
30
  end
26
31
  end
27
32
  end
@@ -5,7 +5,7 @@ require_relative '../api_resource'
5
5
  module ErpIntegration
6
6
  module Fulfil
7
7
  module Resources
8
- class OrderLine < ApiResource
8
+ class SalesOrderLine < ApiResource
9
9
  self.model_name = 'sale.line'
10
10
  end
11
11
  end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../api_resource'
4
+
5
+ module ErpIntegration
6
+ module Fulfil
7
+ module Resources
8
+ class StockMove < ApiResource
9
+ self.model_name = 'stock.move'
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../api_resource'
4
+
5
+ module ErpIntegration
6
+ module Fulfil
7
+ module Resources
8
+ class SupplierShipment < ApiResource
9
+ self.model_name = 'stock.shipment.in'
10
+ end
11
+ end
12
+ end
13
+ end
@@ -18,7 +18,7 @@ module ErpIntegration
18
18
  # # => <WhereClause @key="id" value="100" comparison_operator="=" />
19
19
  class WhereClause
20
20
  COMPARISON_OPERATORS = [
21
- '=', '!=', '<', '<=', '=>', '>', 'like', 'ilike', 'in', 'not in'
21
+ '=', '!=', '<', '<=', '>=', '>', 'like', 'ilike', 'in', 'not in'
22
22
  ].freeze
23
23
 
24
24
  DEFAULT_COMPARISON_OPERATOR = '='
@@ -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.to_s
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::Order.adapter
20
- # => #<ErpIntegration::Orders::FulfilOrder />
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::Order` exposes an uniformed API for interaction with
4
+ # The `ErpIntegration::SalesOrder` exposes an uniformed API for interaction with
5
5
  # third-party ERP vendors.
6
- class Order < Resource
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,
@@ -15,5 +15,9 @@ module ErpIntegration
15
15
  :tax_amount, :total_amount, :total_quantity, :total_shipment_cost,
16
16
  :untaxed_amount, :warehouse, :weight, :weight_uom, :write_date,
17
17
  :write_uid
18
+
19
+ def cancel
20
+ self.class.adapter.cancel(id)
21
+ end
18
22
  end
19
23
  end
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ErpIntegration
4
- # The `ErpIntegration::OrderLine` exposes an uniformed API for interaction with
4
+ # The `ErpIntegration::SalesOrderLine` exposes an uniformed API for interaction with
5
5
  # third-party ERP vendors.
6
- class OrderLine < Resource
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,
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ErpIntegration
4
+ class StockMove < Resource
5
+ attr_accessor :attachments, :children, :company, :cost_price, :create_date,
6
+ :create_uid, :currency, :effective_date, :from_location,
7
+ :from_sublocation, :id, :internal_quantity, :journal_entry,
8
+ :metadata, :planned_date, :quantity, :quantity_available,
9
+ :reference, :shipment, :state, :to_location, :unit_price, :uom,
10
+ :write_date, :write_uid
11
+ end
12
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ErpIntegration
4
+ class SupplierShipment < Resource
5
+ attr_accessor :acknowledged_by_3pl_at, :attachments, :carrier, :carrier_service,
6
+ :company, :contact_address, :cost, :cost_currency, :create_date,
7
+ :create_uidcustomer_shipments, :effective_date, :id, :incoming_moves,
8
+ :inventory_moves, :metadata, :moves, :number, :packages, :planned_date,
9
+ :reference, :sent_to_3pl_at, :shipping_instructions, :shipping_manifest,
10
+ :sscc_code, :state, :supplier, :supplier_location, :total_quantity,
11
+ :tpl_status, :tracking_number, :warehouse, :weight, :weight_uom,
12
+ :write_date, :write_uid
13
+ end
14
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ErpIntegration
4
- VERSION = '0.3.2'
4
+ VERSION = '0.5.1'
5
5
  end
@@ -20,10 +20,13 @@ 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 :Resource, 'erp_integration/resource'
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'
30
+ autoload :StockMove, 'erp_integration/stock_move'
31
+ autoload :SupplierShipment, 'erp_integration/supplier_shipment'
29
32
  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.3.2
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Vermaas
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-13 00:00:00.000000000 Z
11
+ date: 2021-10-21 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: 0.14.0
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: 0.14.0
66
+ version: '1.3'
61
67
  - !ruby/object:Gem::Dependency
62
68
  name: byebug
63
69
  requirement: !ruby/object:Gem::Requirement
@@ -259,19 +265,25 @@ 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/order.rb
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
274
+ - lib/erp_integration/fulfil/resources/stock_move.rb
275
+ - lib/erp_integration/fulfil/resources/supplier_shipment.rb
267
276
  - lib/erp_integration/fulfil/where_clause.rb
268
277
  - lib/erp_integration/middleware/error_handling.rb
269
- - lib/erp_integration/order.rb
270
- - lib/erp_integration/order_line.rb
278
+ - lib/erp_integration/product.rb
271
279
  - lib/erp_integration/purchase_order.rb
272
280
  - lib/erp_integration/purchase_order_line.rb
273
281
  - lib/erp_integration/purchase_request.rb
274
282
  - lib/erp_integration/resource.rb
283
+ - lib/erp_integration/sales_order.rb
284
+ - lib/erp_integration/sales_order_line.rb
285
+ - lib/erp_integration/stock_move.rb
286
+ - lib/erp_integration/supplier_shipment.rb
275
287
  - lib/erp_integration/version.rb
276
288
  homepage: https://www.github.com/mejuri-inc/erp-integration
277
289
  licenses: