comee_core 0.1.91 → 0.1.92

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: 14e262013c470d553126a6ecad9eb449dc01732b39cf3b683b4b7e6089f6cea4
4
- data.tar.gz: bf5cca3975a004dbea56eab907497cc6d1006a7ae941ff0a9d7e4bd5578f8e79
3
+ metadata.gz: 99b4856ac17d221660c2a0af2589f3e26d5f40930097788982e327bf3f9daa1e
4
+ data.tar.gz: e81f18ec5013e7c4aa47a815c2f607d1b6398fc0c616975932c5ed9bad8f7903
5
5
  SHA512:
6
- metadata.gz: 49c812d17aaee3068d9b677f814cc1b3d5b8da0f6e5313e6289a7942f6ea040a8a012d477fc9ed9d540aead752c3bfe650a29b110c2af30b7c6ea0fcf3cf5e0e
7
- data.tar.gz: 5886c9b99451ba968ac667d77d130ea25740c57149edc9b28a3591eb8d2841bc963a97aa118257013e4a954ef608431c53a4b67e530173e19e63afab706300ff
6
+ metadata.gz: 40e5ad66e287dde54881d839c4c6d9074c5ef0f7429073615faee3c9a4c2fdfa05eb29b1945747797564a407b253a348f5ce9846414c690ca2d9ca2547b7c21e
7
+ data.tar.gz: ce2a3221e2cd6bd668145a50afc0d765c92846f3447322ab33c2c4bc3475b6c6a5631d48c8f07535b8e7d6c1b0c354c73f96e91dad0ed5f048a61af073fe2d73
@@ -1,7 +1,7 @@
1
1
  module Comee
2
2
  module Core
3
3
  class ApplicationController < ActionController::API
4
- include Comee::Core::Pagination
4
+ include Pagination
5
5
 
6
6
  before_action :authenticate
7
7
 
@@ -1,20 +1,20 @@
1
1
  module Comee
2
2
  module Core
3
3
  class ClientPricesController < ApplicationController
4
- include Comee::Core::Common
4
+ include Common
5
5
 
6
6
  def index
7
7
  super do
8
- client_prices = Comee::Core::ClientPrice.all
8
+ client_prices = ClientPrice.all
9
9
  client_prices.then(&paginate)
10
10
  end
11
11
  end
12
12
 
13
13
  def fetch_for_client
14
- client = Comee::Core::Client.find(params[:id])
14
+ client = Client.find(params[:id])
15
15
  client_id = client.parent_id || client.id
16
- prices = Comee::Core::ClientPrice.includes(:client, :product, :unit, :product_lookup)
17
- .where(client_id: client_id)
16
+ prices = ClientPrice.includes(:client, :product, :unit, :product_lookup)
17
+ .where(client_id: client_id)
18
18
  total = prices.count
19
19
  prices = prices.then(&paginate)
20
20
 
@@ -22,8 +22,8 @@ module Comee
22
22
  end
23
23
 
24
24
  def filter
25
- prices = Comee::Core::ClientPrice.includes(:client, :product, :unit, :product_lookup)
26
- .ransack(params[:q]).result
25
+ prices = ClientPrice.includes(:client, :product, :unit, :product_lookup)
26
+ .ransack(params[:q]).result
27
27
  total = prices.count
28
28
  prices = prices.then(&paginate)
29
29
 
@@ -15,10 +15,17 @@ module Comee
15
15
  render json: {success: false, error: e.message}
16
16
  end
17
17
 
18
+ def shipment_addresses
19
+ client = Comee::Core::Client.find(params[:id])
20
+ render json: {success: true, data: client.shipment_addresses}
21
+ rescue StandardError => e
22
+ render json: {success: false, error: e.message}
23
+ end
24
+
18
25
  private
19
26
 
20
27
  def model_params
21
- params.require(:payload).permit(:code, :name, :address, :locale, :user_id, :parent_id, consignees: [])
28
+ params.require(:payload).permit(:code, :name, :address, :locale, :user_id, :parent_id, consignees: [], shipment_addresses: [])
22
29
  end
23
30
  end
24
31
  end
@@ -25,7 +25,7 @@ module Comee
25
25
  end
26
26
 
27
27
  def accept
28
- order = @service.accept(params[:id])
28
+ order = @service.accept(params[:id], current_user.name)
29
29
  render json: {success: true, data: serialize(order)}
30
30
  rescue StandardError => e
31
31
  render json: {success: false, error: e.message}
@@ -48,16 +48,17 @@ module Comee
48
48
  def model_params
49
49
  params.require(:payload)
50
50
  .permit(
51
- :order_number, :order_date, :order_terms, :consignee, :final_destination, :final_delivery_date, :handover_date,
52
- :shipping_date, :delivery_address, :invoice_address, :status, :client_id, :file
51
+ :order_number, :order_date, :order_terms, :consignee, :shipment_address, :final_destination,
52
+ :final_delivery_date, :handover_date, :shipping_date, :delivery_address, :invoice_address, :status,
53
+ :client_id, :file
53
54
  )
54
55
  end
55
56
 
56
57
  def create_with_item_params
57
58
  params.require(:payload)
58
59
  .permit(
59
- :order_number, :order_date, :order_terms, :consignee, :final_destination, :final_delivery_date, :handover_date,
60
- :shipping_date, :delivery_address, :invoice_address, :status, :client_id,
60
+ :order_number, :order_date, :order_terms, :consignee, :shipment_address, :final_destination,
61
+ :final_delivery_date, :handover_date, :shipping_date, :delivery_address, :invoice_address, :status, :client_id,
61
62
  items: %i[customer_item_no product_id quantity price unit_id delivery_date]
62
63
  )
63
64
  end
@@ -3,9 +3,17 @@ module Comee
3
3
  class SuppliersController < ApplicationController
4
4
  include Common
5
5
 
6
+ def index
7
+ super do
8
+ Supplier.all.then(&paginate)
9
+ end
10
+ end
11
+
6
12
  def filter
7
- @supplier = Comee::Core::Supplier.ransack(params[:q]).result
8
- render json: {success: true, data: serialize(@supplier)}
13
+ suppliers = Comee::Core::Supplier.ransack(params[:q]).result
14
+ total = suppliers.count
15
+ suppliers = suppliers.then(&paginate)
16
+ render json: {success: true, data: serialize(suppliers), page: params[:page], total: total}
9
17
  end
10
18
 
11
19
  private
@@ -2,6 +2,7 @@ module Comee
2
2
  module Core
3
3
  class SalesOrder < ApplicationRecord
4
4
  before_save :total_price
5
+ before_save :set_parent_client_name
5
6
 
6
7
  belongs_to :customer_order
7
8
  belongs_to :fulfillment_center, optional: true
@@ -29,6 +30,10 @@ module Comee
29
30
  self.total_price = total_price
30
31
  end
31
32
 
33
+ def set_parent_client_name
34
+ self.parent_client_name = client.parent&.name
35
+ end
36
+
32
37
  def self.ransackable_attributes(_auth_object = nil)
33
38
  %w[
34
39
  id
@@ -1,7 +1,8 @@
1
1
  module Comee
2
2
  module Core
3
3
  class ClientSerializer < ActiveModel::Serializer
4
- attributes :id, :code, :name, :address, :locale, :user_id, :user_name, :parent_id, :consignees
4
+ attributes :id, :code, :name, :address, :locale, :user_id, :user_name, :consignees, :shipment_addresses
5
+ belongs_to :parent
5
6
  end
6
7
  end
7
8
  end
@@ -1,8 +1,9 @@
1
1
  module Comee
2
2
  module Core
3
3
  class CustomerOrderSerializer < ActiveModel::Serializer
4
- attributes :id, :order_number, :order_date, :order_terms, :consignee, :final_destination, :final_delivery_date, :handover_date,
5
- :shipping_date, :delivery_address, :invoice_address, :status, :file_url
4
+ attributes :id, :order_number, :order_date, :order_terms, :consignee, :shipment_address, :final_destination,
5
+ :final_delivery_date, :handover_date, :shipping_date, :delivery_address, :invoice_address, :status,
6
+ :file_url
6
7
 
7
8
  belongs_to :client
8
9
  has_many :customer_order_items
@@ -2,7 +2,7 @@ module Comee
2
2
  module Core
3
3
  class SalesOrderSerializer < ActiveModel::Serializer
4
4
  attributes :id, :order_number, :payment_penalty, :status, :total_price, :payment_term, :delivery_term, :amount_paid, :pallete_note,
5
- :handover_date, :remark, :files_url, :customs_detail
5
+ :handover_date, :remark, :parent_client_name, :created_by, :files_url, :customs_detail
6
6
  belongs_to :customer_order
7
7
  belongs_to :client
8
8
  belongs_to :fulfillment_center
@@ -112,7 +112,7 @@ module Comee
112
112
  order
113
113
  end
114
114
 
115
- def accept(id)
115
+ def accept(id, accepted_by = nil)
116
116
  order = CustomerOrder.find_by(id: id)
117
117
  raise(StandardError, "Customer order with id `#{id}` not found.") unless order
118
118
 
@@ -136,7 +136,8 @@ module Comee
136
136
  order_number: order.order_number,
137
137
  customer_order: order,
138
138
  status: SalesOrder.statuses[:draft],
139
- client: order.client
139
+ client: order.client,
140
+ created_by: accepted_by || ""
140
141
  )
141
142
  order_items = order.customer_order_items.includes(:product, :unit)
142
143
  client_id = order.client.parent_id || order.client_id
data/config/routes.rb CHANGED
@@ -82,6 +82,7 @@ Comee::Core::Engine.routes.draw do
82
82
  get "rfq_products", controller: :quotation_requests, action: :rfq_products_for_client
83
83
  get "prices", controller: :client_prices, action: :fetch_for_client
84
84
  get "consignees"
85
+ get "shipment_addresses"
85
86
  get "shipment_items", controller: :shipment_items, action: :filter_for_client
86
87
  end
87
88
  collection do
@@ -14,6 +14,7 @@ class CreateComeeCoreClients < ActiveRecord::Migration[7.0]
14
14
  index: {name: "so_on_ccc_indx"},
15
15
  foreign_key: {to_table: :comee_core_clients}
16
16
  t.string :consignees, array: true, default: []
17
+ t.string :shipment_addresses, array: true, default: []
17
18
 
18
19
  t.timestamps
19
20
  end
@@ -9,6 +9,7 @@ class CreateComeeCoreCustomerOrders < ActiveRecord::Migration[7.1]
9
9
  foreign_key: {to_table: :comee_core_clients}
10
10
  t.string :order_terms
11
11
  t.string :consignee
12
+ t.string :shipment_address
12
13
  t.string :final_destination
13
14
  t.date :final_delivery_date
14
15
  t.date :handover_date
@@ -14,6 +14,7 @@ class CreateComeeCoreSalesOrders < ActiveRecord::Migration[7.0]
14
14
  null: false,
15
15
  index: {name: "client_on_ccso_indx"},
16
16
  foreign_key: {to_table: :comee_core_clients}
17
+ t.string :parent_client_name
17
18
  t.string :payment_term
18
19
  t.string :delivery_term
19
20
  t.float :payment_penalty, null: false, default: 0.0
@@ -23,6 +24,7 @@ class CreateComeeCoreSalesOrders < ActiveRecord::Migration[7.0]
23
24
  t.string :pallete_note
24
25
  t.date :handover_date
25
26
  t.string :remark
27
+ t.string :created_by
26
28
 
27
29
  t.timestamps
28
30
  end
@@ -1,5 +1,5 @@
1
1
  module Comee
2
2
  module Core
3
- VERSION = "0.1.91".freeze
3
+ VERSION = "0.1.92".freeze
4
4
  end
5
5
  end
@@ -7,5 +7,6 @@ FactoryBot.define do
7
7
  locale { "en" }
8
8
  parent { nil }
9
9
  consignees { [] }
10
+ shipment_addresses { [] }
10
11
  end
11
12
  end
@@ -5,6 +5,7 @@ FactoryBot.define do
5
5
  client
6
6
  order_terms { Faker::Lorem.sentence }
7
7
  consignee { Faker::Name.name }
8
+ shipment_address { Faker::Address.full_address }
8
9
  final_destination { Faker::Address.full_address }
9
10
  final_delivery_date { Faker::Date.between(from: Date.current.advance(days: 20), to: Date.current.advance(months: 2)) }
10
11
  handover_date { final_delivery_date.advance(days: -10) }
@@ -12,5 +12,7 @@ FactoryBot.define do
12
12
  status { Comee::Core::SalesOrder.statuses[:draft] }
13
13
  pallete_note { Faker::Lorem.sentence }
14
14
  remark { Faker::Lorem.sentence }
15
+ parent_client_name { Faker::Name.name }
16
+ created_by { Faker::Name.name }
15
17
  end
16
18
  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.91
4
+ version: 0.1.92
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-01-15 00:00:00.000000000 Z
11
+ date: 2024-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers