comee_core 0.1.56 → 0.1.58
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/comee/core/order_source.rb +16 -0
- data/db/migrate/20230929115336_create_comee_core_order_sources.rb +1 -0
- data/lib/comee/core/version.rb +1 -1
- data/spec/factories/comee/core/order_sources.rb +14 -0
- metadata +2 -5
- data/app/models/comee/core/field_mapping.rb +0 -9
- data/db/migrate/20230929120051_create_comee_core_field_mappings.rb +0 -15
- data/spec/factories/comee/core/field_mappings.rb +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c1ab21501ec9e7dc8a68ab5bde8797d3cf224c5ffcc18777e9e8fdea9fc20f6
|
4
|
+
data.tar.gz: ab88ed5fa5e8905c6a4d00cb4b0b2104b3c56844bb5994bf339a19de39627372
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e14a39305accdef097595d2cc9dd9173d7a355cb094e4f3332d9e28091be587e25eb6463646cd298ac3fff3fb018838e7fbfafb880fa5f724c022e0537dcbbda
|
7
|
+
data.tar.gz: 810bf9d239709215543739222b4555ded5a008109c6373f1320a912b81e14ab738f0e3995fb6ed7219f4f05533b80ecfceb290fad43b97b12f01f89d1a886b69
|
@@ -3,6 +3,22 @@ module Comee
|
|
3
3
|
class OrderSource < ApplicationRecord
|
4
4
|
has_many :field_mappings
|
5
5
|
validates :base_url, :name, presence: true
|
6
|
+
validate :validate_field_mapping
|
7
|
+
|
8
|
+
def validate_field_mapping
|
9
|
+
return unless field_mapping
|
10
|
+
|
11
|
+
mappings = field_mapping.map(&:with_indifferent_access)
|
12
|
+
order_fields = %w[order_number order_date delivery_address invoice_address]
|
13
|
+
item_fields = %w[product_code product_name unit_code quantity price delivery_date]
|
14
|
+
order_dest = mappings.select { |mapping| mapping[:level] == "order" }.map { |m| m[:destination] }
|
15
|
+
item_dest = mappings.select { |mapping| mapping[:level] == "item" }.map { |m| m[:destination] }
|
16
|
+
order_diff = order_fields - order_dest
|
17
|
+
item_diff = item_fields - item_dest
|
18
|
+
errors.add(:field_mapping, "has fields #{order_diff} missing at order level.") if order_diff.count.positive?
|
19
|
+
|
20
|
+
errors.add(:field_mapping, "has fields #{item_diff} missing at item level.") if item_diff.count.positive?
|
21
|
+
end
|
6
22
|
end
|
7
23
|
end
|
8
24
|
end
|
data/lib/comee/core/version.rb
CHANGED
@@ -2,5 +2,19 @@ FactoryBot.define do
|
|
2
2
|
factory :order_source, class: "Comee::Core::OrderSource" do
|
3
3
|
base_url { Faker::Internet.url }
|
4
4
|
name { Faker::Name.name }
|
5
|
+
field_mapping do
|
6
|
+
[
|
7
|
+
{source: "order_number", destination: "order_number", level: :order},
|
8
|
+
{source: "order_date", destination: "order_date", level: :order},
|
9
|
+
{source: "delivery_address", destination: "delivery_address", level: :order},
|
10
|
+
{source: "invoice_address", destination: "invoice_address", level: :order},
|
11
|
+
{source: "product_code", destination: "product_code", level: :item},
|
12
|
+
{source: "product_name", destination: "product_name", level: :item},
|
13
|
+
{source: "unit_code", destination: "unit_code", level: :item},
|
14
|
+
{source: "quantity", destination: "quantity", level: :item},
|
15
|
+
{source: "price", destination: "price", level: :item},
|
16
|
+
{source: "delivery_date", destination: "delivery_date", level: :item}
|
17
|
+
]
|
18
|
+
end
|
5
19
|
end
|
6
20
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: comee_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.58
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henock L.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-12-
|
11
|
+
date: 2023-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|
@@ -319,7 +319,6 @@ files:
|
|
319
319
|
- app/models/comee/core/customs_detail.rb
|
320
320
|
- app/models/comee/core/edi_order.rb
|
321
321
|
- app/models/comee/core/external_rfq.rb
|
322
|
-
- app/models/comee/core/field_mapping.rb
|
323
322
|
- app/models/comee/core/fulfillment_center.rb
|
324
323
|
- app/models/comee/core/inventory.rb
|
325
324
|
- app/models/comee/core/invoice.rb
|
@@ -401,7 +400,6 @@ files:
|
|
401
400
|
- db/migrate/20230915205522_create_comee_core_invoices.rb
|
402
401
|
- db/migrate/20230915205648_create_comee_core_invoice_items.rb
|
403
402
|
- db/migrate/20230929115336_create_comee_core_order_sources.rb
|
404
|
-
- db/migrate/20230929120051_create_comee_core_field_mappings.rb
|
405
403
|
- db/migrate/20230929130910_create_comee_core_client_orders.rb
|
406
404
|
- db/migrate/20231003073316_create_comee_core_inventories.rb
|
407
405
|
- db/migrate/20231003080017_create_comee_core_warehouse_shipments.rb
|
@@ -432,7 +430,6 @@ files:
|
|
432
430
|
- spec/factories/comee/core/customs_details.rb
|
433
431
|
- spec/factories/comee/core/edi_orders.rb
|
434
432
|
- spec/factories/comee/core/external_rfqs.rb
|
435
|
-
- spec/factories/comee/core/field_mappings.rb
|
436
433
|
- spec/factories/comee/core/fulfillment_centers.rb
|
437
434
|
- spec/factories/comee/core/inventories.rb
|
438
435
|
- spec/factories/comee/core/invoice_items.rb
|
@@ -1,15 +0,0 @@
|
|
1
|
-
class CreateComeeCoreFieldMappings < ActiveRecord::Migration[7.0]
|
2
|
-
def change
|
3
|
-
create_table :comee_core_field_mappings do |t|
|
4
|
-
t.string :source, null: false
|
5
|
-
t.string :destination, null: false
|
6
|
-
t.integer :level, null: false, default: 0
|
7
|
-
t.references :order_source,
|
8
|
-
null: false,
|
9
|
-
index: {name: "order_source_on_cfm_indx"},
|
10
|
-
foreign_key: {to_table: :comee_core_order_sources}
|
11
|
-
|
12
|
-
t.timestamps
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|