erp_integration 0.5.2 → 0.6.0

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: ca1bd38eb31b94933e07d32c1dfb1878b734fef2d001a84e56cf788697afe666
4
- data.tar.gz: ed521ad8c1b95896aa152cbd113b63eda01ab49c47888270a4bfc5d6bf7b6662
3
+ metadata.gz: 346594300ff75a2d7f21a9e226287fe43b8b4765105d80d73840e4ff8fd9c355
4
+ data.tar.gz: 67b680a54fec9cb91866b6d9658dc7eeb4a63168f76826a7bba421148c0a77a5
5
5
  SHA512:
6
- metadata.gz: 0ef6a74cf99711e42a3d64c30e44ff2cd65a445ed0f714c6a60fba6a56f895103e51fc74cbb767f719bab90af73dda54120607d41a16a63599b7dacb80b04c07
7
- data.tar.gz: 818024cb6d381c71f883c8f5811eae27bfc29f9f2e245383c4600718651710abbc91f6021005182795e564a58f08fb4f825c1b957fd285e718363adcb3f36e28
6
+ metadata.gz: 5e36d2c2d1b0c5f231cef0477a5154fe4a101f262d9171f20cbb3fc051df8feff4655dcd9f5265634f241056a35a8562ca2caa580488b49d6c4c865fa4456aa1
7
+ data.tar.gz: b6dcd7aa6843c5e8686a2489ea88ba80c3a2ba543b941d00f652ef0621b0a6feaebc93c4ae9dcbab78f199e139fa7900060b46c7b812a96cffa0022821f3f36f
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ErpIntegration
4
+ # The `ErpIntegration::BillOfMaterial` exposes an uniformed API for interaction with
5
+ # third-party ERP vendors.
6
+ class BillOfMaterial < Resource
7
+ attr_accessor :active, :attachments, :cost, :create_date, :create_uid, :id,
8
+ :inputs, :instructions, :is_built_on_the_fly, :location, :messages,
9
+ :metadata, :name, :output_products, :outputs, :private_notes, :products,
10
+ :public_notes, :quantity_buildable, :quantity_expected, :rec_blurb,
11
+ :rec_name, :routing, :state, :supervisor, :version, :warehouse, :work_center,
12
+ :write_date, :write_uid
13
+ end
14
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ErpIntegration
4
+ # The `ErpIntegration::BillOfMaterialInput` exposes an uniformed API for interaction with
5
+ # third-party ERP vendors.
6
+ class BillOfMaterialInput < Resource
7
+ attr_accessor :attachments, :bom, :create_date, :create_uid, :id, :messages,
8
+ :metadata, :private_notes, :product, :public_notes, :quantity,
9
+ :rec_blurb, :rec_name, :sequence, :to_location, :unit_digits,
10
+ :uom, :uom_category, :warehouse, :write_date, :write_uid
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ErpIntegration
4
+ # The `ErpIntegration::BillOfMaterialOutput` exposes an uniformed API for interaction with
5
+ # third-party ERP vendors.
6
+ class BillOfMaterialOutput < Resource
7
+ attr_accessor :attachments, :bom, :create_date, :create_uid, :id, :messages,
8
+ :metadata, :private_notes, :product, :public_notes, :quantity,
9
+ :rec_blurb, :rec_name, :sequence, :to_location, :unit_digits,
10
+ :uom, :uom_category, :warehouse, :write_date, :write_uid
11
+ end
12
+ end
@@ -22,11 +22,31 @@ 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 `BillOfMaterial` resource. When
26
+ # none is configured, it will default to Fulfil.
27
+ # @return [Symbol] The configured adapter for the bill_of_material.
28
+ attr_writer :bill_of_material_adapter
29
+
30
+ # Allows configuring an adapter for the `BillOfMaterialInput` resource. When
31
+ # none is configured, it will default to Fulfil.
32
+ # @return [Symbol] The configured adapter for the Bill of Material's input.
33
+ attr_writer :bill_of_material_input_adapter
34
+
35
+ # Allows configuring an adapter for the `BillOfMaterialOutput` resource. When
36
+ # none is configured, it will default to Fulfil.
37
+ # @return [Symbol] The configured adapter for the bill_of_material.
38
+ attr_writer :bill_of_material_output_adapter
39
+
25
40
  # Allows configuring an adapter for the `Product` resource. When none is
26
41
  # configured, it will default to Fulfil.
27
42
  # @return [Symbol] The configured adapter for the products.
28
43
  attr_writer :product_adapter
29
44
 
45
+ # Allows configuring an adapter for the `ProductionOrder` resource. When
46
+ # none is configured, it will default to Fulfil.
47
+ # @return [Symbol] The configured adapter for the production_order.
48
+ attr_writer :production_order_adapter
49
+
30
50
  # Allows configuring an adapter for the `PurchaseOrder` resource. When none is
31
51
  # configured, it will default to Fulfil.
32
52
  # @return [Symbol] The configured adapter for the purchase orders.
@@ -68,10 +88,26 @@ module ErpIntegration
68
88
  end
69
89
  end
70
90
 
91
+ def bill_of_material_adapter
92
+ @bill_of_material_adapter || :fulfil
93
+ end
94
+
95
+ def bill_of_material_input_adapter
96
+ @bill_of_material_input_adapter || :fulfil
97
+ end
98
+
99
+ def bill_of_material_output_adapter
100
+ @bill_of_material_output_adapter || :fulfil
101
+ end
102
+
71
103
  def product_adapter
72
104
  @product_adapter || :fulfil
73
105
  end
74
106
 
107
+ def production_order_adapter
108
+ @production_order_adapter || :fulfil
109
+ end
110
+
75
111
  def purchase_order_adapter
76
112
  @purchase_order_adapter || :fulfil
77
113
  end
@@ -17,6 +17,12 @@ module ErpIntegration
17
17
  end
18
18
  end
19
19
 
20
+ class ResourceNotFound < Error
21
+ def initialize
22
+ super "[ERP Integration] Couldn't find the requested resource."
23
+ end
24
+ end
25
+
20
26
  class HttpError < Faraday::Error
21
27
  class BadRequest < HttpError; end
22
28
  class AuthorizationRequired < HttpError; end
@@ -1,11 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'finder_methods'
3
4
  require_relative 'query_methods'
4
5
 
5
6
  module ErpIntegration
6
7
  module Fulfil
7
8
  class ApiResource
8
9
  include Enumerable
10
+ include FinderMethods
9
11
  include QueryMethods
10
12
 
11
13
  attr_accessor :resource_klass
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ErpIntegration
4
+ module Fulfil
5
+ # The `FinderMethods` add various, simplistic lookup methods to find API resources.
6
+ # These methods should be the last method in the chain as it will invoke the HTTP
7
+ # request to Fulfil immediately.
8
+ #
9
+ # If you need more attributes than the default ID attribute for an ApiResource
10
+ # to be returned, add the `select` method before the finder method is being called
11
+ # in your application code.
12
+ #
13
+ # @example
14
+ # $ ErpIntegration::SalesOrder.select(:id, :product).find(100)
15
+ # => <ErpIntegration::SalesOrder @id=100 @product=10 />
16
+ module FinderMethods
17
+ # Looks up an individual resource based on resource's ID.
18
+ #
19
+ # @example
20
+ # $ ErpIntegration::SalesOrder.find(100)
21
+ # => <ErpIntegration::SalesOrder @id=100 />
22
+ #
23
+ # @param id [Integer] The ID of the API resource.
24
+ # @return [ApiResource] The found resource in Fulfil.
25
+ def find(id)
26
+ find_by!(id: id) || raise(ResourceNotFound)
27
+ end
28
+
29
+ # Looks up an individual resource based on the given attributes.
30
+ #
31
+ # @example
32
+ # $ ErpIntegration::SalesOrder.find_by(product: 10)
33
+ # => <ErpIntegration::SalesOrder @id=100 />
34
+ #
35
+ # @return [ApiResource|nil] The found resource in Fulfil.
36
+ def find_by(args)
37
+ where(args).first
38
+ end
39
+
40
+ # Looks up an individual resource based on the given attributes and raises
41
+ # an `ErpIntegration::ResourceNotFound` when the resource doesn't exist.
42
+ #
43
+ # @example
44
+ # $ ErpIntegration::SalesOrder.find_by!(product: 10)
45
+ # => ErpIntegration::ResourceNotFound
46
+ #
47
+ # @return [ApiResource|nil] The found resource in Fulfil.
48
+ def find_by!(args)
49
+ find_by(args) || raise(ResourceNotFound)
50
+ end
51
+ end
52
+ end
53
+ 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 BillOfMaterial < ApiResource
9
+ self.model_name = 'production.bom'
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 BillOfMaterialInput < ApiResource
9
+ self.model_name = 'production.bom.input'
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 BillOfMaterialOutput < ApiResource
9
+ self.model_name = 'production.bom.output'
10
+ end
11
+ end
12
+ end
13
+ end
@@ -12,7 +12,7 @@ module ErpIntegration
12
12
  # @param sku [String] The product's SKU.
13
13
  # @return [Boolean] Whether it's a BOM or not.
14
14
  def bom?(sku)
15
- select(:boms).where(code: sku).first.boms.any?
15
+ select(:boms).find_by!(code: sku).boms.any?
16
16
  end
17
17
  alias billing_of_materials? bom?
18
18
  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 ProductionOrder < ApiResource
9
+ self.model_name = 'production'
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ErpIntegration
4
+ # The `ErpIntegration::ProductionOrder` exposes an uniformed API for interaction with
5
+ # third-party ERP vendors.
6
+ class ProductionOrder < Resource
7
+ attr_accessor :allow_partial_done, :attachments, :bom, :byproduct_cost, :company,
8
+ :company_currency_digits, :cost, :create_date, :create_uid, :effective_date,
9
+ :effective_start_date, :from_location, :inputs, :inventory_cost, :inventory_cost_cache,
10
+ :labor_cost, :labor_cost_cache, :last_modification, :location, :messages, :metadata, :number,
11
+ :on_hold, :origin, :outputs, :outsourced_work_cost, :outsourced_work_cost_cache, :picked_at,
12
+ :picker, :picking_status, :planned_date, :planned_start_date, :priority, :private_notes, :product,
13
+ :product_code, :production_batch, :public_notes, :purchase_lines, :quantity, :quantity_done,
14
+ :quantity_remaining, :rec_blurb, :description, :id, :subtitle, :thumbnail, :title, :rec_name,
15
+ :reference, :reporting_date, :routing, :sales_order_number, :sales_order_reference, :shipments,
16
+ :state, :supervisor, :to_location, :tsv, :unit_digits, :uom, :uom_category, :warehouse, :work_center,
17
+ :works, :write_date, :write_uid
18
+ end
19
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ErpIntegration
4
- VERSION = '0.5.2'
4
+ VERSION = '0.6.0'
5
5
  end
@@ -20,7 +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 :BillOfMaterial, 'erp_integration/bill_of_material'
24
+ autoload :BillOfMaterialInput, 'erp_integration/bill_of_material_input'
25
+ autoload :BillOfMaterialOutput, 'erp_integration/bill_of_material_output'
23
26
  autoload :Product, 'erp_integration/product'
27
+ autoload :ProductionOrder, 'erp_integration/production_order'
24
28
  autoload :PurchaseOrder, 'erp_integration/purchase_order'
25
29
  autoload :PurchaseOrderLine, 'erp_integration/purchase_order_line'
26
30
  autoload :PurchaseRequest, 'erp_integration/purchase_request'
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.5.2
4
+ version: 0.6.0
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-26 00:00:00.000000000 Z
11
+ date: 2021-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -259,13 +259,21 @@ files:
259
259
  - bin/setup
260
260
  - erp_integration.gemspec
261
261
  - lib/erp_integration.rb
262
+ - lib/erp_integration/bill_of_material.rb
263
+ - lib/erp_integration/bill_of_material_input.rb
264
+ - lib/erp_integration/bill_of_material_output.rb
262
265
  - lib/erp_integration/configuration.rb
263
266
  - lib/erp_integration/errors.rb
264
267
  - lib/erp_integration/fulfil/api_resource.rb
265
268
  - lib/erp_integration/fulfil/client.rb
269
+ - lib/erp_integration/fulfil/finder_methods.rb
266
270
  - lib/erp_integration/fulfil/query.rb
267
271
  - lib/erp_integration/fulfil/query_methods.rb
272
+ - lib/erp_integration/fulfil/resources/bill_of_material.rb
273
+ - lib/erp_integration/fulfil/resources/bill_of_material_input.rb
274
+ - lib/erp_integration/fulfil/resources/bill_of_material_output.rb
268
275
  - lib/erp_integration/fulfil/resources/product.rb
276
+ - lib/erp_integration/fulfil/resources/production_order.rb
269
277
  - lib/erp_integration/fulfil/resources/purchase_order.rb
270
278
  - lib/erp_integration/fulfil/resources/purchase_order_line.rb
271
279
  - lib/erp_integration/fulfil/resources/purchase_request.rb
@@ -276,6 +284,7 @@ files:
276
284
  - lib/erp_integration/fulfil/where_clause.rb
277
285
  - lib/erp_integration/middleware/error_handling.rb
278
286
  - lib/erp_integration/product.rb
287
+ - lib/erp_integration/production_order.rb
279
288
  - lib/erp_integration/purchase_order.rb
280
289
  - lib/erp_integration/purchase_order_line.rb
281
290
  - lib/erp_integration/purchase_request.rb