comee_core 0.3.4 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/comee/core/agents_controller.rb +3 -1
- data/app/controllers/comee/core/client_addresses_controller.rb +1 -1
- data/app/controllers/comee/core/clients_controller.rb +5 -3
- data/app/controllers/comee/core/customer_orders_controller.rb +6 -3
- data/app/controllers/comee/core/product_lookups_controller.rb +1 -1
- data/app/controllers/comee/core/supplier_addresses_controller.rb +21 -0
- data/app/controllers/comee/core/suppliers_controller.rb +1 -1
- data/app/models/comee/core/address.rb +20 -0
- data/app/models/comee/core/agent.rb +2 -0
- data/app/models/comee/core/client.rb +2 -1
- data/app/models/comee/core/client_address.rb +9 -8
- data/app/models/comee/core/customer_order.rb +1 -0
- data/app/models/comee/core/pickup_schedule.rb +2 -0
- data/app/models/comee/core/product_lookup.rb +1 -1
- data/app/models/comee/core/sales_order.rb +7 -2
- data/app/models/comee/core/sales_order_item.rb +7 -0
- data/app/models/comee/core/supplier.rb +2 -1
- data/app/models/comee/core/supplier_address.rb +24 -0
- data/app/serializers/comee/core/agent_serializer.rb +3 -1
- data/app/serializers/comee/core/client_address_serializer.rb +1 -1
- data/app/serializers/comee/core/client_serializer.rb +3 -2
- data/app/serializers/comee/core/customer_order_serializer.rb +1 -1
- data/app/serializers/comee/core/product_lookup_serializer.rb +1 -1
- data/app/serializers/comee/core/sales_order_serializer.rb +1 -1
- data/app/serializers/comee/core/supplier_address_serializer.rb +11 -0
- data/app/serializers/comee/core/supplier_serializer.rb +2 -1
- data/app/services/comee/core/beo_service.rb +41 -36
- data/app/services/comee/core/customer_order_service.rb +2 -1
- data/config/routes.rb +7 -0
- data/db/migrate/20240629044824_create_comee_core_supplier_addresses.rb +23 -0
- data/db/migrate/20240629065810_remove_address_field_from_supplier_and_client.rb +7 -0
- data/db/migrate/20240629135249_add_additional_fields_to_order.rb +10 -0
- data/db/migrate/20240629145738_add_telephone_and_email_to_address.rb +8 -0
- data/db/migrate/20240629160357_add_more_address_fields_to_agent.rb +14 -0
- data/db/migrate/20240629170409_add_vat_to_sales_orders.rb +5 -0
- data/db/migrate/20240630063656_add_aliases_field_to_product_lookup.rb +5 -0
- data/db/migrate/20240630083042_add_agent_to_pickup_schedule.rb +8 -0
- data/lib/comee/core/version.rb +1 -1
- data/spec/factories/comee/core/agents.rb +7 -2
- data/spec/factories/comee/core/client_addresses.rb +2 -0
- data/spec/factories/comee/core/clients.rb +1 -2
- data/spec/factories/comee/core/customer_orders.rb +3 -0
- data/spec/factories/comee/core/pickup_schedules.rb +1 -0
- data/spec/factories/comee/core/product_lookups.rb +1 -0
- data/spec/factories/comee/core/sales_orders.rb +3 -0
- data/spec/factories/comee/core/supplier_addresses.rb +15 -0
- data/spec/factories/comee/core/suppliers.rb +0 -1
- metadata +15 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 904aacbb433502ee95c7973c9ff1f50d5fe9698998a7600dcb84a038068f5125
|
4
|
+
data.tar.gz: a943ec5bd2893b7d1cff862f12695f193013740ff3c09606320306dbd252e2a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c14eda451d86694be060e733b8fdc3cf903872faf587b9c74349663bf0badb23ae6cb8dfc7103b8109ea5da3e457eb36b1b6a0b7cb4773697899d144ca0abed1
|
7
|
+
data.tar.gz: ad1835d0bf82d0002b9f710b5f7439cb218abf4223cbbfa46229d1793e7f6f806107deb2a8334906ca7e4a5d2259d7c80497ea006f980d2d3c6475db9ecf5e2d
|
@@ -6,7 +6,9 @@ module Comee
|
|
6
6
|
private
|
7
7
|
|
8
8
|
def model_params
|
9
|
-
params.require(:payload).permit(
|
9
|
+
params.require(:payload).permit(
|
10
|
+
:name, :address_line1, :street, :city, :state, :country_id, :postal_code, :email, :telephone
|
11
|
+
)
|
10
12
|
end
|
11
13
|
end
|
12
14
|
end
|
@@ -56,12 +56,14 @@ module Comee
|
|
56
56
|
private
|
57
57
|
|
58
58
|
def model_params
|
59
|
-
params.require(:payload).permit(:code, :name, :match_code, :
|
60
|
-
:
|
59
|
+
params.require(:payload).permit(:code, :name, :match_code, :locale, :user_id, :parent_id, :currency, :subsidiary,
|
60
|
+
:country_id, :tax_code, :vat_number, :print_details, consignees: [])
|
61
61
|
end
|
62
62
|
|
63
63
|
def agent_params
|
64
|
-
params.require(:payload).permit(
|
64
|
+
params.require(:payload).permit(
|
65
|
+
:name, :address_line1, :street, :city, :state, :country_id, :postal_code, :email, :telephone
|
66
|
+
)
|
65
67
|
end
|
66
68
|
|
67
69
|
def contact_params
|
@@ -68,16 +68,19 @@ module Comee
|
|
68
68
|
.permit(
|
69
69
|
:order_number, :order_date, :order_terms, :consignee, :shipment_address, :final_destination,
|
70
70
|
:final_delivery_date, :handover_date, :shipping_date, :delivery_address, :invoice_address, :status,
|
71
|
-
:client_id, :file
|
71
|
+
:client_id, :consolidator_date, :voyage_no, :shipping_arrangement, :file
|
72
72
|
)
|
73
73
|
end
|
74
74
|
|
75
75
|
def create_with_item_params
|
76
76
|
params.require(:payload)
|
77
77
|
.permit(
|
78
|
-
:order_number, :order_date, :order_terms, :consignee, :shipment_address, :final_destination,
|
78
|
+
:order_number, :order_date, :order_terms, :consignee, :shipment_address, :final_destination, :voyage_no,
|
79
79
|
:final_delivery_date, :handover_date, :shipping_date, :delivery_address, :invoice_address, :status, :client_id,
|
80
|
-
|
80
|
+
:consolidator_date, :shipping_arrangement,
|
81
|
+
items: %i[
|
82
|
+
serial_no customer_item_no customer_item_description product_id quantity price total_price unit_id delivery_date
|
83
|
+
]
|
81
84
|
)
|
82
85
|
end
|
83
86
|
|
@@ -31,7 +31,7 @@ module Comee
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def model_params
|
34
|
-
params.required(:payload).permit(:code, :itemable_id, :itemable_type, :item_description, :product_id)
|
34
|
+
params.required(:payload).permit(:code, :itemable_id, :itemable_type, :item_description, :product_id, :aliases)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Comee
|
2
|
+
module Core
|
3
|
+
class SupplierAddressesController < ApplicationController
|
4
|
+
include Common
|
5
|
+
|
6
|
+
def index
|
7
|
+
super do
|
8
|
+
SupplierAddress.where(supplier_id: params[:id])
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def model_params
|
15
|
+
params.require(:payload)
|
16
|
+
.permit(:supplier_id, :address_line1, :street, :city, :state, :country_id, :postal_code, :address_type,
|
17
|
+
:email, :telephone, :default)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -17,7 +17,7 @@ module Comee
|
|
17
17
|
private
|
18
18
|
|
19
19
|
def model_params
|
20
|
-
params.require(:payload).permit(:code, :name, :
|
20
|
+
params.require(:payload).permit(:code, :name, :locale, :payment_terms, :currency_id, :vat_number, :tax_code)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Comee
|
2
|
+
module Core
|
3
|
+
class Address < ApplicationRecord
|
4
|
+
self.abstract_class = true
|
5
|
+
|
6
|
+
BASIC_ADDRESS = "Basic Address".freeze
|
7
|
+
SHIPPING_ADDRESS = "Shipping Address".freeze
|
8
|
+
DELIVERY_ADDRESS = "Delivery Address".freeze
|
9
|
+
INVOICING_ADDRESS = "Invoicing Address".freeze
|
10
|
+
|
11
|
+
ADDRESS_TYPES = [BASIC_ADDRESS, SHIPPING_ADDRESS, DELIVERY_ADDRESS, INVOICING_ADDRESS].freeze
|
12
|
+
|
13
|
+
belongs_to :country, -> { where(lookup_type: :country) }, class_name: "Comee::Core::Lookup"
|
14
|
+
|
15
|
+
validates :address_line1, :address_type, presence: true
|
16
|
+
validates :address_type, inclusion: {in: ADDRESS_TYPES}
|
17
|
+
validates :email, format: {with: URI::MailTo::EMAIL_REGEXP}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -8,8 +8,9 @@ module Comee
|
|
8
8
|
has_and_belongs_to_many :contacts, join_table: :comee_core_clients_contacts
|
9
9
|
has_and_belongs_to_many :agents, join_table: :comee_core_clients_agents
|
10
10
|
has_many :client_warehouses
|
11
|
+
has_many :client_addresses
|
11
12
|
|
12
|
-
validates :code, :name, :match_code, :
|
13
|
+
validates :code, :name, :match_code, :locale, presence: true
|
13
14
|
validates :code, uniqueness: true
|
14
15
|
|
15
16
|
delegate(:name, to: :user, prefix: true, allow_nil: true)
|
@@ -1,17 +1,18 @@
|
|
1
1
|
module Comee
|
2
2
|
module Core
|
3
|
-
class ClientAddress <
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
class ClientAddress < Address
|
4
|
+
# BASIC_ADDRESS = "Basic Address".freeze
|
5
|
+
# SHIPPING_ADDRESS = "Shipping Address".freeze
|
6
|
+
# DELIVERY_ADDRESS = "Delivery Address".freeze
|
7
|
+
# INVOICING_ADDRESS = "Invoicing Address".freeze
|
7
8
|
|
8
|
-
ADDRESS_TYPES = [SHIPPING_ADDRESS, DELIVERY_ADDRESS, INVOICING_ADDRESS].freeze
|
9
|
+
# ADDRESS_TYPES = [BASIC_ADDRESS, SHIPPING_ADDRESS, DELIVERY_ADDRESS, INVOICING_ADDRESS].freeze
|
9
10
|
|
10
11
|
belongs_to :client
|
11
|
-
belongs_to :country, -> { where(lookup_type: :country) }, class_name: "Comee::Core::Lookup"
|
12
|
+
# belongs_to :country, -> { where(lookup_type: :country) }, class_name: "Comee::Core::Lookup"
|
12
13
|
|
13
|
-
validates :name,
|
14
|
-
validates :address_type, inclusion: {in: ADDRESS_TYPES}
|
14
|
+
validates :name, presence: true
|
15
|
+
# validates :address_type, inclusion: {in: ADDRESS_TYPES}
|
15
16
|
|
16
17
|
validate :validate_default
|
17
18
|
|
@@ -6,6 +6,7 @@ module Comee
|
|
6
6
|
has_one_attached :file
|
7
7
|
|
8
8
|
enum :status, {draft: 0, submitted: 1, awaiting_confirmation: 2, accepted: 3, canceled: 4}
|
9
|
+
enum :shipping_arrangement, {own: 0, agent: 1}
|
9
10
|
|
10
11
|
validates :order_number, :order_date, :delivery_address, :invoice_address, :status, presence: true
|
11
12
|
|
@@ -9,7 +9,7 @@ module Comee
|
|
9
9
|
validates :code, uniqueness: {scope: %i[product_id itemable_id itemable_type]}
|
10
10
|
|
11
11
|
def self.ransackable_attributes(_auth_object = nil)
|
12
|
-
%w[id code item_description itemable_id itemable_type product_id]
|
12
|
+
%w[id code item_description itemable_id itemable_type product_id alias]
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.ransackable_associations(_auth_object = nil)
|
@@ -3,7 +3,6 @@ module Comee
|
|
3
3
|
class SalesOrder < ApplicationRecord
|
4
4
|
before_validation :generate_order_number, if: proc { |so| so.order_number.nil? }
|
5
5
|
|
6
|
-
before_save :total_price
|
7
6
|
before_save :set_parent_client_name
|
8
7
|
|
9
8
|
belongs_to :customer_order
|
@@ -15,6 +14,7 @@ module Comee
|
|
15
14
|
|
16
15
|
enum :status, {draft: 0, submitted: 1, confirmed: 2, accepted: 3, canceled: 4}
|
17
16
|
enum :purchase_status, {unprocessed: 0, processed: 1}
|
17
|
+
enum :shipping_arrangement, {own: 0, agent: 1}
|
18
18
|
|
19
19
|
validates :order_number, presence: true, uniqueness: true
|
20
20
|
validates :order_date, :status, :purchase_status, presence: true
|
@@ -25,11 +25,16 @@ module Comee
|
|
25
25
|
numericality: {greater_than_or_equal_to: 0},
|
26
26
|
allow_nil: true
|
27
27
|
|
28
|
-
def
|
28
|
+
def calculate_total_price
|
29
29
|
sales_order_items = SalesOrderItem.where(sales_order_id: id)
|
30
30
|
self.total_price = sales_order_items.sum(&:total_price)
|
31
31
|
end
|
32
32
|
|
33
|
+
def calculate_vat
|
34
|
+
total_price = SalesOrderItem.where(sales_order_id: id).sum(&:total_price)
|
35
|
+
self.vat = (total_price * 0.19).round(2) if client.tax_code == "Inland"
|
36
|
+
end
|
37
|
+
|
33
38
|
def set_parent_client_name
|
34
39
|
self.parent_client_name = client.parent&.name
|
35
40
|
end
|
@@ -5,7 +5,9 @@ module Comee
|
|
5
5
|
|
6
6
|
before_save :calculate_total_price
|
7
7
|
before_save :calculate_handover_date
|
8
|
+
after_save :update_sales_order
|
8
9
|
after_save :update_sales_order_purchase_status, if: proc { |item| item.fully_processed? }
|
10
|
+
after_destroy :update_sales_order
|
9
11
|
|
10
12
|
enum processing_status: {unprocessed: 0, partially_processed: 1, fully_processed: 2}
|
11
13
|
|
@@ -34,6 +36,11 @@ module Comee
|
|
34
36
|
self.total_price = (price * quantity).round(2)
|
35
37
|
end
|
36
38
|
|
39
|
+
def update_sales_order
|
40
|
+
sales_order.calculate_total_price
|
41
|
+
sales_order.calculate_vat
|
42
|
+
end
|
43
|
+
|
37
44
|
def quantity_remaining
|
38
45
|
quantity - (quantity_delivered + quantity_canceled)
|
39
46
|
end
|
@@ -3,10 +3,11 @@ module Comee
|
|
3
3
|
class Supplier < ApplicationRecord
|
4
4
|
belongs_to :user, optional: true
|
5
5
|
belongs_to :currency, optional: true
|
6
|
+
has_many :supplier_addresses
|
6
7
|
has_and_belongs_to_many :contacts, join_table: :comee_core_suppliers_contacts
|
7
8
|
|
8
9
|
validates :code, presence: true, uniqueness: true
|
9
|
-
validates :name, :
|
10
|
+
validates :name, :locale, :payment_terms, presence: true
|
10
11
|
|
11
12
|
def self.ransackable_attributes(_auth_object = nil)
|
12
13
|
%w[id user_id code name address locale]
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Comee
|
2
|
+
module Core
|
3
|
+
class SupplierAddress < Address
|
4
|
+
belongs_to :supplier
|
5
|
+
|
6
|
+
validate :validate_default
|
7
|
+
|
8
|
+
def validate_default
|
9
|
+
return unless supplier && address_type && default
|
10
|
+
|
11
|
+
default_count = if new_record?
|
12
|
+
SupplierAddress.where(address_type: address_type, supplier: supplier, default: true).count
|
13
|
+
else
|
14
|
+
SupplierAddress.where(address_type: address_type, supplier: supplier, default: true)
|
15
|
+
.where.not(id: id).count
|
16
|
+
end
|
17
|
+
|
18
|
+
return if default_count.zero?
|
19
|
+
|
20
|
+
errors.add(:default, "cannot be set to true. There is already a default address for this supplier and address type.")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
module Comee
|
2
2
|
module Core
|
3
3
|
class AgentSerializer < ActiveModel::Serializer
|
4
|
-
attributes :id, :name, :
|
4
|
+
attributes :id, :name, :address_line1, :street, :city, :state, :country_id, :postal_code, :email, :telephone
|
5
|
+
|
6
|
+
belongs_to :country
|
5
7
|
end
|
6
8
|
end
|
7
9
|
end
|
@@ -2,7 +2,7 @@ module Comee
|
|
2
2
|
module Core
|
3
3
|
class ClientAddressSerializer < ActiveModel::Serializer
|
4
4
|
attributes :id, :name, :address_line1, :street, :city, :state, :country_id, :postal_code, :address_type,
|
5
|
-
:client_id, :default
|
5
|
+
:email, :telephone, :client_id, :default
|
6
6
|
|
7
7
|
belongs_to :client
|
8
8
|
belongs_to :country
|
@@ -1,13 +1,14 @@
|
|
1
1
|
module Comee
|
2
2
|
module Core
|
3
3
|
class ClientSerializer < ActiveModel::Serializer
|
4
|
-
attributes :id, :code, :name, :match_code, :
|
5
|
-
:
|
4
|
+
attributes :id, :code, :name, :match_code, :locale, :user_id, :user_name, :parent_id, :consignees, :tax_code,
|
5
|
+
:vat_number, :currency, :print_details
|
6
6
|
belongs_to :parent
|
7
7
|
belongs_to :country
|
8
8
|
has_many :agents
|
9
9
|
has_many :contacts
|
10
10
|
has_many :client_warehouses
|
11
|
+
has_many :client_addresses
|
11
12
|
end
|
12
13
|
end
|
13
14
|
end
|
@@ -3,7 +3,7 @@ module Comee
|
|
3
3
|
class CustomerOrderSerializer < ActiveModel::Serializer
|
4
4
|
attributes :id, :order_number, :order_date, :order_terms, :consignee, :shipment_address, :final_destination,
|
5
5
|
:final_delivery_date, :handover_date, :shipping_date, :delivery_address, :invoice_address, :status,
|
6
|
-
:file_url
|
6
|
+
:consolidator_date, :voyage_no, :shipping_arrangement, :file_url
|
7
7
|
|
8
8
|
belongs_to :client
|
9
9
|
has_many :customer_order_items
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Comee
|
2
2
|
module Core
|
3
3
|
class ProductLookupSerializer < ActiveModel::Serializer
|
4
|
-
attributes :id, :code, :itemable_id, :itemable_type, :item_description
|
4
|
+
attributes :id, :code, :itemable_id, :itemable_type, :item_description, :aliases
|
5
5
|
belongs_to :product
|
6
6
|
end
|
7
7
|
end
|
@@ -4,7 +4,7 @@ module Comee
|
|
4
4
|
attributes :id, :order_number, :order_date, :order_terms, :shipment_address, :delivery_address, :invoice_address,
|
5
5
|
:destination, :handover_date, :shipping_date, :delivery_date, :consignee, :parent_client_name, :payment_term,
|
6
6
|
:delivery_term, :payment_penalty, :status, :purchase_status, :total_price, :amount_paid, :pallete_note,
|
7
|
-
:remark, :created_by, :files_url, :created_at
|
7
|
+
:consolidator_date, :voyage_no, :shipping_arrangement, :remark, :created_by, :files_url, :created_at
|
8
8
|
belongs_to :customer_order
|
9
9
|
belongs_to :client
|
10
10
|
belongs_to :fulfillment_center
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Comee
|
2
|
+
module Core
|
3
|
+
class SupplierAddressSerializer < ActiveModel::Serializer
|
4
|
+
attributes :id, :address_line1, :street, :city, :state, :country_id, :postal_code, :address_type, :email, :telephone,
|
5
|
+
:supplier_id, :default
|
6
|
+
|
7
|
+
belongs_to :supplier
|
8
|
+
belongs_to :country
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -1,8 +1,9 @@
|
|
1
1
|
module Comee
|
2
2
|
module Core
|
3
3
|
class SupplierSerializer < ActiveModel::Serializer
|
4
|
-
attributes :id, :code, :name, :
|
4
|
+
attributes :id, :code, :name, :locale, :user_id, :payment_terms, :tax_code, :vat_number
|
5
5
|
belongs_to :currency
|
6
|
+
has_many :supplier_addresses
|
6
7
|
end
|
7
8
|
end
|
8
9
|
end
|
@@ -42,22 +42,27 @@ module Comee
|
|
42
42
|
@package_type = packaging_types.count == 1 && packaging_types.first == "PX" ? "PX" : "PK"
|
43
43
|
@total_weight = @line_items.sum do |line_item|
|
44
44
|
if xml
|
45
|
-
|
45
|
+
xml_line = Comee::Core::ShipmentInstructionItem.where(shipment_item_id: Comee::Core::ShipmentItem
|
46
|
+
.find_by(sales_order_item_id: line_item.id).id).first
|
47
|
+
(xml_line.quantity * xml_line.weight).round(2)
|
46
48
|
else
|
47
|
-
(line_item.
|
49
|
+
(line_item.quantity * line_item.weight).round(2)
|
48
50
|
end
|
49
51
|
end
|
50
52
|
|
51
53
|
raise(StandardError, "No customs detail filed for sales order") unless @customs_details.present?
|
52
54
|
|
53
|
-
@address = @customs_details[0].sales_order.
|
54
|
-
@customs_details[0].transportation_route.
|
55
|
-
|
55
|
+
@address = Comee::Core::ClientAddress.find(@customs_details[0].sales_order.delivery_address.to_i)
|
56
|
+
@customs_details[0].transportation_route.each_with_index do |tr, index|
|
57
|
+
if xml
|
58
|
+
@transportation_routes << tr["route"][0, 2]
|
59
|
+
else
|
60
|
+
@transportation_routes << tr["route"][0, 2] unless index.zero?
|
61
|
+
end
|
56
62
|
end
|
57
63
|
|
58
64
|
@data = xml ? generate_xml : prepare_data
|
59
65
|
end
|
60
|
-
|
61
66
|
xml ? @data : JSON(@data)
|
62
67
|
end
|
63
68
|
|
@@ -73,10 +78,10 @@ module Comee
|
|
73
78
|
position_items << {
|
74
79
|
"warePositionsnummer": index + 1,
|
75
80
|
"wareWarennummerKN8": si.sales_order_item.product.hs_code,
|
76
|
-
"wareWarenbezeichnung": si.sales_order_item.product.
|
81
|
+
"wareWarenbezeichnung": si.sales_order_item.product.customs_description,
|
77
82
|
"wareRegistriernummerFremdsystem": customs_detail.sales_order.customer_order.order_number,
|
78
|
-
"wareUrsprungsbundesland": mp.state_of_origin,
|
79
|
-
"wareEigenmasse":
|
83
|
+
"wareUrsprungsbundesland": mp.state_of_origin.split(" ")[0],
|
84
|
+
"wareEigenmasse": line_item.weight * line_item.quantity,
|
80
85
|
"wareRohmasse": index.zero? ? @total_weight : 0,
|
81
86
|
"ausfuhrLand": "DE",
|
82
87
|
"ursprungsland": mp.country_of_origin.code,
|
@@ -85,7 +90,7 @@ module Comee
|
|
85
90
|
"zusatzlichesVerfahren": "F61",
|
86
91
|
"aussenhandelsstatistikMenge": si.sales_order_item.quantity,
|
87
92
|
"aussenhandelsstatistikWert": (si.sales_order_item.quantity *
|
88
|
-
si.sales_order_item.price * 1.05).round(2),
|
93
|
+
si.sales_order_item.price * 1.05).round(2).to_i,
|
89
94
|
"packstuck": [
|
90
95
|
{
|
91
96
|
"packstuckNummer": index + 1,
|
@@ -119,17 +124,17 @@ module Comee
|
|
119
124
|
"kopf": {
|
120
125
|
"eoriNiederlassungsnummer": "DE47897410000",
|
121
126
|
"artderAnmeldung": @customs_details[0].registration_type.split(" ")[0],
|
122
|
-
"artderAnmeldungAusfuhr": @customs_details[0].export_declaration_type,
|
127
|
+
"artderAnmeldungAusfuhr": @customs_details[0].export_declaration_type.split(" ")[0],
|
123
128
|
"ausfuhrLand": "DE",
|
124
129
|
"beteiligtenKonstellation": @customs_details[0].participant_constellation.split(" ")[0],
|
125
130
|
"sicherheit": @customs_details[0].registration_type.split(" ")[0] == "CO" ? 0 : 2,
|
126
131
|
"container": @customs_details[0].containerized == true ? 1 : 0,
|
127
|
-
"bestimmungsLand": @customs_details[0].destination_country,
|
132
|
+
"bestimmungsLand": @customs_details[0].destination_country.split(" ")[0],
|
128
133
|
"referenznummerUCR": @customs_details.map(&:sales_order).map(&:customer_order).map(&:consignee).join(" "),
|
129
134
|
"lrn": @customs_details.map(&:sales_order).map(&:customer_order).map(&:order_number).join(" "),
|
130
|
-
"beforderungsmittelImInlandVerkehrszweig": @customs_details[0].mode_of_transport,
|
131
|
-
"beforderungsmittelderGrenzeVerkehrszweig": @customs_details[0].mode_of_transport_at_border,
|
132
|
-
"beforderungsmittelderGrenzeArt": @customs_details[0].mode_of_transport_type,
|
135
|
+
"beforderungsmittelImInlandVerkehrszweig": @customs_details[0].mode_of_transport.split(" ")[0],
|
136
|
+
"beforderungsmittelderGrenzeVerkehrszweig": @customs_details[0].mode_of_transport_at_border.split(" ")[0],
|
137
|
+
"beforderungsmittelderGrenzeArt": @customs_details[0].mode_of_transport_type.split(" ")[0],
|
133
138
|
"beforderungsmittelderGrenzeKennzeichen": "UNBEKANNT",
|
134
139
|
"beforderungsmittelderGrenzeStaatszugehorigkeit": @customs_details[0].mode_of_transport_nationality.split(" ")[0],
|
135
140
|
"gesamtRohmasse": @total_weight,
|
@@ -137,7 +142,7 @@ module Comee
|
|
137
142
|
{
|
138
143
|
"sequenznummer": "1",
|
139
144
|
"artderIdentifikation": @customs_details[0].type_of_identification.split(" ")[0],
|
140
|
-
"kennzeichen":
|
145
|
+
"kennzeichen": "UNBEKANNT",
|
141
146
|
"staatszugehorigkeit": @customs_details[0].nationality.split(" ")[0]
|
142
147
|
}
|
143
148
|
],
|
@@ -148,17 +153,17 @@ module Comee
|
|
148
153
|
"geschaftsvorgangWahrung": "EUR",
|
149
154
|
"beforderungsroute": {
|
150
155
|
"ausgewahlteLander": @transportation_routes,
|
151
|
-
"beforderungsVon":
|
152
|
-
"beforderungsBis": @customs_details[0].
|
156
|
+
"beforderungsVon": "DE",
|
157
|
+
"beforderungsBis": @customs_details[0].destination_country.split(" ")[0]
|
153
158
|
},
|
154
159
|
"empfanger": {
|
155
160
|
"tin": "",
|
156
161
|
"niederlassungsNummer": "",
|
157
162
|
"name": @customs_details[0].sales_order.customer_order.client.name,
|
158
|
-
"strasse": @address
|
159
|
-
"plz": @address
|
160
|
-
"ort":
|
161
|
-
"land": @address
|
163
|
+
"strasse": @address.street,
|
164
|
+
"plz": @address.postal_code,
|
165
|
+
"ort": @address.city,
|
166
|
+
"land": @address.country.code
|
162
167
|
},
|
163
168
|
"warenortArtdesOrtes": "B",
|
164
169
|
"warenortArtDerOrtsbestimmung": "Y",
|
@@ -194,10 +199,10 @@ module Comee
|
|
194
199
|
|
195
200
|
xml.Position do
|
196
201
|
xml.Positionsnummer (index + 1).to_s
|
197
|
-
xml.Warenbezeichnung line_item.product.
|
202
|
+
xml.Warenbezeichnung line_item.product.customs_description
|
198
203
|
xml.Registriernummer_Fremdsystem customs_detail.sales_order.customer_order.order_number
|
199
204
|
xml.Kennnummer_der_Sendung @customs_details.map(&:sales_order).map(&:customer_order).map(&:consignee).join(" ")
|
200
|
-
xml.Ursprungsbundesland mp.state_of_origin
|
205
|
+
xml.Ursprungsbundesland mp.state_of_origin.split(" ")[0]
|
201
206
|
xml.Ursprungsland mp.country_of_origin.code
|
202
207
|
xml.Eigenmasse line_item.product.weight * line_item.quantity
|
203
208
|
xml.Rohmasse index.zero? ? @total_weight : 0
|
@@ -212,7 +217,7 @@ module Comee
|
|
212
217
|
xml.Aussenhandelsstatistik do
|
213
218
|
xml.Menge line_item.quantity
|
214
219
|
xml.Wert (line_item.quantity *
|
215
|
-
line_item.price * 1.05).round(2)
|
220
|
+
line_item.price * 1.05).round(2).to_i
|
216
221
|
end
|
217
222
|
xml.Vorpapier do
|
218
223
|
xml.Typ
|
@@ -250,28 +255,28 @@ module Comee
|
|
250
255
|
xml.Nachrichten_Typ "DEXPDF"
|
251
256
|
xml.BEO_Atlas_KundenID
|
252
257
|
xml.Anwendung
|
253
|
-
xml.Name "
|
258
|
+
xml.Name "MAVEKO"
|
254
259
|
end
|
255
260
|
xml.Kopf do
|
256
261
|
xml.EORI_Number "DE47897410000"
|
257
|
-
xml.Art_der_Ausfuhranmeldung @customs_details[0].export_declaration_type
|
262
|
+
xml.Art_der_Ausfuhranmeldung @customs_details[0].export_declaration_type.split(" ")[0]
|
258
263
|
xml.Ausfuhrland "DE"
|
259
|
-
xml.Bestimmungsland @customs_details[0].destination_country
|
264
|
+
xml.Bestimmungsland @customs_details[0].destination_country.split(" ")[0]
|
260
265
|
xml.Container @customs_details[0].containerized == true ? 1 : 0
|
261
266
|
xml.send("Beteiligten-Konstellation", @customs_details[0].participant_constellation.split(" ")[0])
|
262
267
|
xml.send("Gesamt-Rohmasse", @total_weight)
|
263
268
|
xml.Kennnummer_der_Sendung @customs_details.map(&:sales_order).map(&:customer_order).map(&:consignee).join(" ")
|
264
269
|
xml.Bezugsnummer @customs_details.map(&:sales_order).map(&:customer_order).map(&:order_number).join(" ")
|
265
|
-
xml.inlandischerVerkehrszweig @customs_details[0].mode_of_transport
|
266
|
-
xml.verkehrszweigAnDerGrenze @customs_details[0].mode_of_transport_at_border
|
270
|
+
xml.inlandischerVerkehrszweig @customs_details[0].mode_of_transport.split(" ")[0]
|
271
|
+
xml.verkehrszweigAnDerGrenze @customs_details[0].mode_of_transport_at_border.split(" ")[0]
|
267
272
|
xml.Befoerderungsmittel_an_der_Grenze do
|
268
|
-
xml.Art @customs_details[0].mode_of_transport_type
|
273
|
+
xml.Art @customs_details[0].mode_of_transport_type.split(" ")[0]
|
269
274
|
xml.Kennzeichen "UNBEKANNT"
|
270
275
|
end
|
271
276
|
xml.Befoerderungsmittel_am_Abgang do
|
272
277
|
xml.sequenznummer "1"
|
273
278
|
xml.Art @customs_details[0].type_of_identification.split(" ")[0]
|
274
|
-
xml.Kennzeichen
|
279
|
+
xml.Kennzeichen "UNBEKANNT"
|
275
280
|
xml.Staatszugehoerigkeit @customs_details[0].nationality.split(" ")[0]
|
276
281
|
end
|
277
282
|
xml.Ausfuhrzollstelle do
|
@@ -295,10 +300,10 @@ module Comee
|
|
295
300
|
xml.TIN
|
296
301
|
xml.Niederlassungsnummer
|
297
302
|
xml.Name @customs_details[0].sales_order.customer_order.client.name
|
298
|
-
xml.Strasse @address
|
299
|
-
xml.PLZ @address
|
300
|
-
xml.Ort
|
301
|
-
xml.Land @address
|
303
|
+
xml.Strasse @address.street
|
304
|
+
xml.PLZ @address.postal_code
|
305
|
+
xml.Ort @address.city
|
306
|
+
xml.Land @address.country.code
|
302
307
|
end
|
303
308
|
xml.Lieferbedingung do
|
304
309
|
xml.send("Incoterm-Code", @customs_details[0].delivery_term_code[0, 3])
|
@@ -218,7 +218,8 @@ module Comee
|
|
218
218
|
supplier_id: master_price.supplier_id,
|
219
219
|
supplier_name: master_price.supplier.name,
|
220
220
|
supplier_item_no: product_lookup.code,
|
221
|
-
supplier_description: product_lookup.item_description
|
221
|
+
supplier_description: product_lookup.item_description,
|
222
|
+
country_of_origin: master_price.country_of_origin.name
|
222
223
|
}
|
223
224
|
}
|
224
225
|
end
|
data/config/routes.rb
CHANGED
@@ -12,11 +12,18 @@ Comee::Core::Engine.routes.draw do
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
resources :contacts
|
15
|
+
|
16
|
+
resources :supplier_addresses
|
15
17
|
resources :suppliers do
|
16
18
|
collection do
|
17
19
|
post "filter"
|
18
20
|
end
|
21
|
+
|
22
|
+
member do
|
23
|
+
get "addresses", controller: :supplier_addresses, action: :index
|
24
|
+
end
|
19
25
|
end
|
26
|
+
|
20
27
|
resources :products do
|
21
28
|
collection do
|
22
29
|
post "master_prices"
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class CreateComeeCoreSupplierAddresses < ActiveRecord::Migration[7.1]
|
2
|
+
def change
|
3
|
+
create_table :comee_core_supplier_addresses do |t|
|
4
|
+
t.references :supplier,
|
5
|
+
null: false,
|
6
|
+
index: {name: "supplier_on_ccsa_indx"},
|
7
|
+
foreign_key: {to_table: :comee_core_suppliers}
|
8
|
+
t.string :address_line1, null: false
|
9
|
+
t.string :street
|
10
|
+
t.string :city
|
11
|
+
t.string :state
|
12
|
+
t.references :country,
|
13
|
+
null: false,
|
14
|
+
index: {name: "country_on_ccsa_indx"},
|
15
|
+
foreign_key: {to_table: :comee_core_lookups}
|
16
|
+
t.string :postal_code
|
17
|
+
t.string :address_type, null: false
|
18
|
+
t.boolean :default, default: false
|
19
|
+
|
20
|
+
t.timestamps
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
class RemoveAddressFieldFromSupplierAndClient < ActiveRecord::Migration[7.1]
|
2
|
+
def change
|
3
|
+
remove_column :comee_core_clients, :address, :string
|
4
|
+
remove_column :comee_core_suppliers, :address, :string
|
5
|
+
remove_column :comee_core_clients, :shipment_addresses, array: true
|
6
|
+
end
|
7
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
class AddAdditionalFieldsToOrder < ActiveRecord::Migration[7.1]
|
2
|
+
def change
|
3
|
+
add_column :comee_core_customer_orders, :consolidator_date, :date
|
4
|
+
add_column :comee_core_sales_orders, :consolidator_date, :date
|
5
|
+
add_column :comee_core_customer_orders, :voyage_no, :string
|
6
|
+
add_column :comee_core_sales_orders, :voyage_no, :string
|
7
|
+
add_column :comee_core_customer_orders, :shipping_arrangement, :integer
|
8
|
+
add_column :comee_core_sales_orders, :shipping_arrangement, :integer
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
class AddTelephoneAndEmailToAddress < ActiveRecord::Migration[7.1]
|
2
|
+
def change
|
3
|
+
add_column :comee_core_client_addresses, :telephone, :string
|
4
|
+
add_column :comee_core_supplier_addresses, :telephone, :string
|
5
|
+
add_column :comee_core_client_addresses, :email, :string
|
6
|
+
add_column :comee_core_supplier_addresses, :email, :string
|
7
|
+
end
|
8
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class AddMoreAddressFieldsToAgent < ActiveRecord::Migration[7.1]
|
2
|
+
def change
|
3
|
+
remove_column :comee_core_agents, :address, :string
|
4
|
+
add_column :comee_core_agents, :address_line1, :string
|
5
|
+
add_column :comee_core_agents, :street, :string
|
6
|
+
add_column :comee_core_agents, :city, :string
|
7
|
+
add_column :comee_core_agents, :state, :string
|
8
|
+
add_reference :comee_core_agents,
|
9
|
+
:country,
|
10
|
+
index: {name: "country_on_cca_indx"},
|
11
|
+
foreign_key: {to_table: :comee_core_lookups}
|
12
|
+
add_column :comee_core_agents, :postal_code, :string
|
13
|
+
end
|
14
|
+
end
|
data/lib/comee/core/version.rb
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
FactoryBot.define do
|
2
2
|
factory :agent, class: "Comee::Core::Agent" do
|
3
3
|
name { Faker::Name.name }
|
4
|
-
|
5
|
-
|
4
|
+
address_line1 { Faker::Address.street_address }
|
5
|
+
street { Faker::Address.street_name }
|
6
|
+
city { Faker::Address.city }
|
7
|
+
state { Faker::Address.state }
|
8
|
+
country
|
9
|
+
postal_code { Faker::Address.postcode }
|
6
10
|
telephone { Faker::PhoneNumber.phone_number }
|
11
|
+
email { Faker::Internet.email }
|
7
12
|
end
|
8
13
|
end
|
@@ -8,6 +8,8 @@ FactoryBot.define do
|
|
8
8
|
state { Faker::Address.state }
|
9
9
|
country
|
10
10
|
postal_code { Faker::Address.postcode }
|
11
|
+
telephone { Faker::PhoneNumber.phone_number }
|
12
|
+
email { Faker::Internet.email }
|
11
13
|
address_type { Comee::Core::ClientAddress::SHIPPING_ADDRESS }
|
12
14
|
default { false }
|
13
15
|
end
|
@@ -4,13 +4,12 @@ FactoryBot.define do
|
|
4
4
|
sequence(:code) { |n| "#{Faker::Alphanumeric.unique.alpha(number: 8)}-#{n}" }
|
5
5
|
name { Faker::Name.name }
|
6
6
|
match_code { Faker::Name.name }
|
7
|
-
address { Faker::Address.full_address }
|
8
7
|
locale { "en" }
|
9
8
|
parent { nil }
|
10
9
|
consignees { [] }
|
11
|
-
shipment_addresses { [] }
|
12
10
|
currency
|
13
11
|
subsidiary { false }
|
12
|
+
tax_code { "Inland" }
|
14
13
|
print_details { false }
|
15
14
|
end
|
16
15
|
end
|
@@ -13,5 +13,8 @@ FactoryBot.define do
|
|
13
13
|
delivery_address { Faker::Address.full_address }
|
14
14
|
invoice_address { Faker::Address.full_address }
|
15
15
|
status { 0 }
|
16
|
+
consolidator_date { Date.current }
|
17
|
+
voyage_no { Faker::Alphanumeric.alpha(number: 10) }
|
18
|
+
shipping_arrangement { Comee::Core::CustomerOrder.shipping_arrangements[:own] }
|
16
19
|
end
|
17
20
|
end
|
@@ -19,6 +19,9 @@ FactoryBot.define do
|
|
19
19
|
delivery_term { Faker::Lorem.sentence }
|
20
20
|
payment_penalty { 0 }
|
21
21
|
status { Comee::Core::SalesOrder.statuses[:draft] }
|
22
|
+
consolidator_date { Date.current }
|
23
|
+
voyage_no { Faker::Alphanumeric.alpha(number: 10) }
|
24
|
+
shipping_arrangement { Comee::Core::SalesOrder.shipping_arrangements[:own] }
|
22
25
|
purchase_status { Comee::Core::SalesOrder.purchase_statuses[:unprocessed] }
|
23
26
|
total_price { 0 }
|
24
27
|
amount_paid { 0 }
|
@@ -0,0 +1,15 @@
|
|
1
|
+
FactoryBot.define do
|
2
|
+
factory :supplier_address, class: "Comee::Core::SupplierAddress" do
|
3
|
+
supplier
|
4
|
+
address_line1 { Faker::Address.street_address }
|
5
|
+
street { Faker::Address.street_name }
|
6
|
+
city { Faker::Address.city }
|
7
|
+
state { Faker::Address.state }
|
8
|
+
country
|
9
|
+
postal_code { Faker::Address.postcode }
|
10
|
+
telephone { Faker::PhoneNumber.phone_number }
|
11
|
+
email { Faker::Internet.email }
|
12
|
+
address_type { Comee::Core::SupplierAddress::BASIC_ADDRESS }
|
13
|
+
default { false }
|
14
|
+
end
|
15
|
+
end
|
@@ -2,7 +2,6 @@ FactoryBot.define do
|
|
2
2
|
factory :supplier, class: "Comee::Core::Supplier" do
|
3
3
|
sequence(:code) { |n| "#{Faker::Alphanumeric.alpha(number: 8)}-#{n}" }
|
4
4
|
name { Faker::Name.name }
|
5
|
-
address { Faker::Address.full_address }
|
6
5
|
locale { "en" }
|
7
6
|
payment_terms { Faker::Lorem.word }
|
8
7
|
vat_number { Faker::Alphanumeric.alpha(number: 8) }
|
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.3.
|
4
|
+
version: 0.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henock L.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-06-
|
11
|
+
date: 2024-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|
@@ -310,6 +310,7 @@ files:
|
|
310
310
|
- app/controllers/comee/core/stock_transfer_requests_controller.rb
|
311
311
|
- app/controllers/comee/core/store_items_controller.rb
|
312
312
|
- app/controllers/comee/core/stores_controller.rb
|
313
|
+
- app/controllers/comee/core/supplier_addresses_controller.rb
|
313
314
|
- app/controllers/comee/core/suppliers_controller.rb
|
314
315
|
- app/controllers/comee/core/unit_conversions_controller.rb
|
315
316
|
- app/controllers/comee/core/units_controller.rb
|
@@ -322,6 +323,7 @@ files:
|
|
322
323
|
- app/mailers/comee/core/notification_mailer.rb
|
323
324
|
- app/mailers/comee/core/supplier_mailer.rb
|
324
325
|
- app/models/comee/core/additional_item.rb
|
326
|
+
- app/models/comee/core/address.rb
|
325
327
|
- app/models/comee/core/agent.rb
|
326
328
|
- app/models/comee/core/application_module.rb
|
327
329
|
- app/models/comee/core/application_record.rb
|
@@ -382,6 +384,7 @@ files:
|
|
382
384
|
- app/models/comee/core/store.rb
|
383
385
|
- app/models/comee/core/store_item.rb
|
384
386
|
- app/models/comee/core/supplier.rb
|
387
|
+
- app/models/comee/core/supplier_address.rb
|
385
388
|
- app/models/comee/core/supplier_invoice.rb
|
386
389
|
- app/models/comee/core/supplier_payment.rb
|
387
390
|
- app/models/comee/core/time_slot.rb
|
@@ -425,6 +428,7 @@ files:
|
|
425
428
|
- app/serializers/comee/core/stock_transfer_request_serializer.rb
|
426
429
|
- app/serializers/comee/core/store_item_serializer.rb
|
427
430
|
- app/serializers/comee/core/store_serializer.rb
|
431
|
+
- app/serializers/comee/core/supplier_address_serializer.rb
|
428
432
|
- app/serializers/comee/core/supplier_serializer.rb
|
429
433
|
- app/serializers/comee/core/unit_conversion_serializer.rb
|
430
434
|
- app/serializers/comee/core/unit_serializer.rb
|
@@ -516,6 +520,14 @@ files:
|
|
516
520
|
- db/migrate/20240407083617_create_comee_core_email_settings.rb
|
517
521
|
- db/migrate/20240503040722_create_comee_core_client_addresses.rb
|
518
522
|
- db/migrate/20240628205454_add_print_details_field_to_customer.rb
|
523
|
+
- db/migrate/20240629044824_create_comee_core_supplier_addresses.rb
|
524
|
+
- db/migrate/20240629065810_remove_address_field_from_supplier_and_client.rb
|
525
|
+
- db/migrate/20240629135249_add_additional_fields_to_order.rb
|
526
|
+
- db/migrate/20240629145738_add_telephone_and_email_to_address.rb
|
527
|
+
- db/migrate/20240629160357_add_more_address_fields_to_agent.rb
|
528
|
+
- db/migrate/20240629170409_add_vat_to_sales_orders.rb
|
529
|
+
- db/migrate/20240630063656_add_aliases_field_to_product_lookup.rb
|
530
|
+
- db/migrate/20240630083042_add_agent_to_pickup_schedule.rb
|
519
531
|
- lib/comee/core.rb
|
520
532
|
- lib/comee/core/engine.rb
|
521
533
|
- lib/comee/core/version.rb
|
@@ -579,6 +591,7 @@ files:
|
|
579
591
|
- spec/factories/comee/core/stock_transfer_requests.rb
|
580
592
|
- spec/factories/comee/core/store_items.rb
|
581
593
|
- spec/factories/comee/core/stores.rb
|
594
|
+
- spec/factories/comee/core/supplier_addresses.rb
|
582
595
|
- spec/factories/comee/core/supplier_invoices.rb
|
583
596
|
- spec/factories/comee/core/supplier_payments.rb
|
584
597
|
- spec/factories/comee/core/suppliers.rb
|