comee_core 0.3.6 → 0.3.8
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/additional_services_controller.rb +24 -0
- data/app/controllers/comee/core/sales_orders_controller.rb +1 -1
- data/app/models/comee/core/additional_service.rb +30 -0
- data/app/models/comee/core/customer_order.rb +5 -1
- data/app/models/comee/core/sales_order.rb +14 -5
- data/app/serializers/comee/core/additional_service_serializer.rb +9 -0
- data/config/routes.rb +9 -1
- data/db/migrate/20240629065810_remove_address_field_from_supplier_and_client.rb +1 -1
- data/db/migrate/20240629135249_add_additional_fields_to_order.rb +2 -2
- data/db/migrate/20240630122016_create_comee_core_additional_services.rb +17 -0
- data/lib/comee/core/version.rb +1 -1
- data/spec/factories/comee/core/additional_services.rb +10 -0
- data/spec/factories/comee/core/customer_orders.rb +1 -1
- data/spec/factories/comee/core/sales_orders.rb +1 -1
- metadata +6 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d50f09b407c09781cabe411155b912767ec73af304b20810a58a9632eb13e46
|
4
|
+
data.tar.gz: e0e7bb2f1540a1b922088327e04786589da49cf8b6f9f3e5e37d172a5f462643
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ce44d97aed3a16468341eeda2d707d93c92c776a062491ecb204327b9877892bc812b5ab5e9bc6ba655f25e3f16aa710da2bde7104b624bff07948e29eeeac8
|
7
|
+
data.tar.gz: 193244d3ff7f49f941cfa77c3165af55180437ad3b2837fe358e42aebe62072259e1d91a6ae9623fc250477a146081a072946ad131b153ea723c54c3b9822cb4
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Comee
|
2
|
+
module Core
|
3
|
+
class AdditionalServicesController < ApplicationController
|
4
|
+
include Common
|
5
|
+
|
6
|
+
def index
|
7
|
+
super do
|
8
|
+
AdditionalService.where(sales_order_id: params[:id])
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def filter
|
13
|
+
services = AdditionalService.includes(:sales_order).ransack(params[:q]).result
|
14
|
+
render_content(services)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def model_params
|
20
|
+
params.require(:payload).permit(:sales_order_id, :name, :unit, :quantity, :price)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -125,7 +125,7 @@ module Comee
|
|
125
125
|
:client_id, :order_terms, :shipment_address, :delivery_address, :invoice_address,
|
126
126
|
:destination, :handover_date, :shipping_date, :delivery_date, :consignee, :payment_term,
|
127
127
|
:delivery_term, :payment_penalty, :status, :purchase_status, :total_price, :amount_paid,
|
128
|
-
:pallete_note, :remark, files: [])
|
128
|
+
:consolidator_date, :voyage_no, :shipping_arrangement, :pallete_note, :remark, files: [])
|
129
129
|
end
|
130
130
|
|
131
131
|
def back_order_params
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Comee
|
2
|
+
module Core
|
3
|
+
class AdditionalService < ApplicationRecord
|
4
|
+
before_save :calculate_total_price
|
5
|
+
after_save :update_sales_order
|
6
|
+
|
7
|
+
belongs_to :sales_order
|
8
|
+
|
9
|
+
validates :name, :unit, presence: true
|
10
|
+
validates :quantity, :price, presence: true, numericality: {greater_than: 0}
|
11
|
+
|
12
|
+
def calculate_total_price
|
13
|
+
self.total_price = (price * quantity).round(2)
|
14
|
+
end
|
15
|
+
|
16
|
+
def update_sales_order
|
17
|
+
sales_order.calculate_total_price
|
18
|
+
sales_order.calculate_vat
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.ransackable_attributes(_auth_object = nil)
|
22
|
+
%w[id name sales_order_id]
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.ransackable_associations(_auth_object = nil)
|
26
|
+
%w[sales_order]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -1,14 +1,18 @@
|
|
1
1
|
module Comee
|
2
2
|
module Core
|
3
3
|
class CustomerOrder < ApplicationRecord
|
4
|
+
OWN = "Own".freeze
|
5
|
+
AGENT = "Agent".freeze
|
6
|
+
SHIPPING_ARRANGEMENTS = [OWN, AGENT].freeze
|
7
|
+
|
4
8
|
belongs_to :client
|
5
9
|
has_many :customer_order_items
|
6
10
|
has_one_attached :file
|
7
11
|
|
8
12
|
enum :status, {draft: 0, submitted: 1, awaiting_confirmation: 2, accepted: 3, canceled: 4}
|
9
|
-
enum :shipping_arrangement, {own: 0, agent: 1}
|
10
13
|
|
11
14
|
validates :order_number, :order_date, :delivery_address, :invoice_address, :status, presence: true
|
15
|
+
validates :shipping_arrangement, inclusion: {in: SHIPPING_ARRANGEMENTS}, allow_nil: true
|
12
16
|
|
13
17
|
def self.ransackable_attributes(_auth_object = nil)
|
14
18
|
%w[id client_id delivery_address invoice_address order_number status final_destination consignee]
|
@@ -1,6 +1,10 @@
|
|
1
1
|
module Comee
|
2
2
|
module Core
|
3
3
|
class SalesOrder < ApplicationRecord
|
4
|
+
OWN = "Own".freeze
|
5
|
+
AGENT = "Agent".freeze
|
6
|
+
SHIPPING_ARRANGEMENTS = [OWN, AGENT].freeze
|
7
|
+
|
4
8
|
before_validation :generate_order_number, if: proc { |so| so.order_number.nil? }
|
5
9
|
|
6
10
|
before_save :set_parent_client_name
|
@@ -9,17 +13,17 @@ module Comee
|
|
9
13
|
belongs_to :fulfillment_center, optional: true
|
10
14
|
belongs_to :client
|
11
15
|
has_many :sales_order_items
|
16
|
+
has_many :additional_services
|
12
17
|
has_many_attached :files
|
13
18
|
has_one :customs_detail
|
14
19
|
|
15
20
|
enum :status, {draft: 0, submitted: 1, confirmed: 2, accepted: 3, canceled: 4}
|
16
21
|
enum :purchase_status, {unprocessed: 0, processed: 1}
|
17
|
-
enum :shipping_arrangement, {own: 0, agent: 1}
|
18
22
|
|
19
23
|
validates :order_number, presence: true, uniqueness: true
|
20
24
|
validates :order_date, :status, :purchase_status, presence: true
|
21
25
|
validates :payment_penalty, numericality: {greater_than_or_equal_to: 0, less_than_or_equal_to: 100}, allow_nil: true
|
22
|
-
|
26
|
+
validates :shipping_arrangement, inclusion: {in: SHIPPING_ARRANGEMENTS}, allow_nil: true
|
23
27
|
validates :amount_paid,
|
24
28
|
presence: true,
|
25
29
|
numericality: {greater_than_or_equal_to: 0},
|
@@ -27,12 +31,17 @@ module Comee
|
|
27
31
|
|
28
32
|
def calculate_total_price
|
29
33
|
sales_order_items = SalesOrderItem.where(sales_order_id: id)
|
30
|
-
|
34
|
+
additional_services = AdditionalService.where(sales_order_id: id)
|
35
|
+
self.total_price = sales_order_items.sum(&:total_price) + additional_services.sum(&:total_price)
|
31
36
|
end
|
32
37
|
|
33
38
|
def calculate_vat
|
34
|
-
|
35
|
-
|
39
|
+
return unless client.tax_code == "Inland"
|
40
|
+
|
41
|
+
sales_order_items = SalesOrderItem.where(sales_order_id: id)
|
42
|
+
additional_services = AdditionalService.where(sales_order_id: id)
|
43
|
+
total_price = sales_order_items.sum(&:total_price) + additional_services.sum(&:total_price)
|
44
|
+
self.vat = (total_price * 0.19).round(2)
|
36
45
|
end
|
37
46
|
|
38
47
|
def set_parent_client_name
|
data/config/routes.rb
CHANGED
@@ -147,9 +147,16 @@ Comee::Core::Engine.routes.draw do
|
|
147
147
|
post "filter"
|
148
148
|
end
|
149
149
|
end
|
150
|
-
|
150
|
+
|
151
|
+
resources :additional_services do
|
152
|
+
collection do
|
153
|
+
post "filter"
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
151
157
|
resources :sales_orders do
|
152
158
|
collection do
|
159
|
+
post "filter"
|
153
160
|
post "create_back_order", action: :create_back_order
|
154
161
|
end
|
155
162
|
member do
|
@@ -158,6 +165,7 @@ Comee::Core::Engine.routes.draw do
|
|
158
165
|
post "confirm"
|
159
166
|
post "accept"
|
160
167
|
post "cancel"
|
168
|
+
get "services", controller: :additional_services, action: :index
|
161
169
|
end
|
162
170
|
end
|
163
171
|
|
@@ -2,6 +2,6 @@ class RemoveAddressFieldFromSupplierAndClient < ActiveRecord::Migration[7.1]
|
|
2
2
|
def change
|
3
3
|
remove_column :comee_core_clients, :address, :string
|
4
4
|
remove_column :comee_core_suppliers, :address, :string
|
5
|
-
remove_column :comee_core_clients, :shipment_addresses, array: true
|
5
|
+
remove_column :comee_core_clients, :shipment_addresses, :string, array: true
|
6
6
|
end
|
7
7
|
end
|
@@ -4,7 +4,7 @@ class AddAdditionalFieldsToOrder < ActiveRecord::Migration[7.1]
|
|
4
4
|
add_column :comee_core_sales_orders, :consolidator_date, :date
|
5
5
|
add_column :comee_core_customer_orders, :voyage_no, :string
|
6
6
|
add_column :comee_core_sales_orders, :voyage_no, :string
|
7
|
-
add_column :comee_core_customer_orders, :shipping_arrangement, :
|
8
|
-
add_column :comee_core_sales_orders, :shipping_arrangement, :
|
7
|
+
add_column :comee_core_customer_orders, :shipping_arrangement, :string
|
8
|
+
add_column :comee_core_sales_orders, :shipping_arrangement, :string
|
9
9
|
end
|
10
10
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class CreateComeeCoreAdditionalServices < ActiveRecord::Migration[7.1]
|
2
|
+
def change
|
3
|
+
create_table :comee_core_additional_services do |t|
|
4
|
+
t.references :sales_order,
|
5
|
+
null: false,
|
6
|
+
index: {name: "so_on_ccas_indx"},
|
7
|
+
foreign_key: {to_table: :comee_core_sales_orders}
|
8
|
+
t.string :name, null: false
|
9
|
+
t.float :quantity, null: false
|
10
|
+
t.string :unit, null: false
|
11
|
+
t.float :price, null: false
|
12
|
+
t.float :total_price, null: false
|
13
|
+
|
14
|
+
t.timestamps
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/comee/core/version.rb
CHANGED
@@ -15,6 +15,6 @@ FactoryBot.define do
|
|
15
15
|
status { 0 }
|
16
16
|
consolidator_date { Date.current }
|
17
17
|
voyage_no { Faker::Alphanumeric.alpha(number: 10) }
|
18
|
-
shipping_arrangement { Comee::Core::CustomerOrder
|
18
|
+
shipping_arrangement { Comee::Core::CustomerOrder::OWN }
|
19
19
|
end
|
20
20
|
end
|
@@ -21,7 +21,7 @@ FactoryBot.define do
|
|
21
21
|
status { Comee::Core::SalesOrder.statuses[:draft] }
|
22
22
|
consolidator_date { Date.current }
|
23
23
|
voyage_no { Faker::Alphanumeric.alpha(number: 10) }
|
24
|
-
shipping_arrangement { Comee::Core::SalesOrder
|
24
|
+
shipping_arrangement { Comee::Core::SalesOrder::OWN }
|
25
25
|
purchase_status { Comee::Core::SalesOrder.purchase_statuses[:unprocessed] }
|
26
26
|
total_price { 0 }
|
27
27
|
amount_paid { 0 }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henock L.
|
@@ -279,6 +279,7 @@ files:
|
|
279
279
|
- README.md
|
280
280
|
- Rakefile
|
281
281
|
- app/controllers/comee/core/access_controller.rb
|
282
|
+
- app/controllers/comee/core/additional_services_controller.rb
|
282
283
|
- app/controllers/comee/core/agents_controller.rb
|
283
284
|
- app/controllers/comee/core/application_controller.rb
|
284
285
|
- app/controllers/comee/core/application_modules_controller.rb
|
@@ -323,6 +324,7 @@ files:
|
|
323
324
|
- app/mailers/comee/core/notification_mailer.rb
|
324
325
|
- app/mailers/comee/core/supplier_mailer.rb
|
325
326
|
- app/models/comee/core/additional_item.rb
|
327
|
+
- app/models/comee/core/additional_service.rb
|
326
328
|
- app/models/comee/core/address.rb
|
327
329
|
- app/models/comee/core/agent.rb
|
328
330
|
- app/models/comee/core/application_module.rb
|
@@ -394,6 +396,7 @@ files:
|
|
394
396
|
- app/models/comee/core/user.rb
|
395
397
|
- app/models/comee/core/user_application_role.rb
|
396
398
|
- app/notifications/comee/core/back_order_notification.rb
|
399
|
+
- app/serializers/comee/core/additional_service_serializer.rb
|
397
400
|
- app/serializers/comee/core/agent_serializer.rb
|
398
401
|
- app/serializers/comee/core/application_module_serializer.rb
|
399
402
|
- app/serializers/comee/core/client_address_serializer.rb
|
@@ -528,12 +531,14 @@ files:
|
|
528
531
|
- db/migrate/20240629170409_add_vat_to_sales_orders.rb
|
529
532
|
- db/migrate/20240630063656_add_aliases_field_to_product_lookup.rb
|
530
533
|
- db/migrate/20240630083042_add_agent_to_pickup_schedule.rb
|
534
|
+
- db/migrate/20240630122016_create_comee_core_additional_services.rb
|
531
535
|
- lib/comee/core.rb
|
532
536
|
- lib/comee/core/engine.rb
|
533
537
|
- lib/comee/core/version.rb
|
534
538
|
- lib/comee_core.rb
|
535
539
|
- lib/tasks/comee_core_tasks.rake
|
536
540
|
- spec/factories/comee/core/additional_items.rb
|
541
|
+
- spec/factories/comee/core/additional_services.rb
|
537
542
|
- spec/factories/comee/core/agents.rb
|
538
543
|
- spec/factories/comee/core/application_modules.rb
|
539
544
|
- spec/factories/comee/core/back_order_items.rb
|