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 +4 -4
- data/lib/erp_integration/bill_of_material.rb +14 -0
- data/lib/erp_integration/bill_of_material_input.rb +12 -0
- data/lib/erp_integration/bill_of_material_output.rb +12 -0
- data/lib/erp_integration/configuration.rb +36 -0
- data/lib/erp_integration/errors.rb +6 -0
- data/lib/erp_integration/fulfil/api_resource.rb +2 -0
- data/lib/erp_integration/fulfil/finder_methods.rb +53 -0
- data/lib/erp_integration/fulfil/resources/bill_of_material.rb +13 -0
- data/lib/erp_integration/fulfil/resources/bill_of_material_input.rb +13 -0
- data/lib/erp_integration/fulfil/resources/bill_of_material_output.rb +13 -0
- data/lib/erp_integration/fulfil/resources/product.rb +1 -1
- data/lib/erp_integration/fulfil/resources/production_order.rb +13 -0
- data/lib/erp_integration/production_order.rb +19 -0
- data/lib/erp_integration/version.rb +1 -1
- data/lib/erp_integration.rb +4 -0
- metadata +11 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 346594300ff75a2d7f21a9e226287fe43b8b4765105d80d73840e4ff8fd9c355
|
4
|
+
data.tar.gz: 67b680a54fec9cb91866b6d9658dc7eeb4a63168f76826a7bba421148c0a77a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
@@ -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).
|
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,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
|
data/lib/erp_integration.rb
CHANGED
@@ -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.
|
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-
|
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
|