comee_core 0.2.66 → 0.2.68

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: '08eafbd527a2e26dd5f2bbd1adf4b6193acd3db3d9e8a711c096569e250e53eb'
4
- data.tar.gz: 24fd5cc126138d563474c3496a0288f9fcea8e340c7dff77128727d8fcba9543
3
+ metadata.gz: ab2d82a34a3aad80165cbc56181be22e2715c189f1d6aecf3c474ca6110f458c
4
+ data.tar.gz: 4e0afeec82d9fb90448af1f50549ba94ea61c9dd6dc00484a55ab298f0194a0c
5
5
  SHA512:
6
- metadata.gz: 93639ac659fba9efd15d4f937d47a2eac80ad168766b6f9d64b9d6714dbe38f46102aa046557f319feaa417aecd3099adcae3a9917bfeeb22f2f01de7364a619
7
- data.tar.gz: b6247c68c810447b8780f3410ca71f0c019876637f22e1606ac681a1568ee56d102c5b99e383650a756ef86d65a8dadd69295333fafc78000d89ab4216f240c7
6
+ metadata.gz: b77c2dcbf7768677a83f38fc8008b4f85a3d7bab5491c78bfdffcfe3656adc6979c23ac1dd9700f96200832d52ed9991699f77a87f86da7af0396cb285764732
7
+ data.tar.gz: 4114959e1d7f60e86bd0abe1285448ba97f75e341185ba5db66cd4a26d405092afbe65815cb480205d718d5f05c209381e282d4167060168c448a59a8e39e4ac
@@ -0,0 +1,19 @@
1
+ module Comee
2
+ module Core
3
+ class ClientAddressesController < ApplicationController
4
+ include Common
5
+
6
+ def index
7
+ super do
8
+ ClientAddress.where(client_id: params[:id])
9
+ end
10
+ end
11
+
12
+ private
13
+
14
+ def model_params
15
+ params.require(:payload).permit(:client_id, :address_line1, :street, :city, :state, :country_id, :postal_code, :address_type)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -3,6 +3,11 @@ module Comee
3
3
  class LookupsController < ApplicationController
4
4
  include Common
5
5
 
6
+ def filter
7
+ lookups = Lookup.ransack(params[:q]).result
8
+ render_content(lookups)
9
+ end
10
+
6
11
  private
7
12
 
8
13
  def model_params
@@ -123,7 +123,7 @@ module Comee
123
123
  params.require(:payload).permit(:order_number, :order_date, :customer_order_id, :fulfillment_center_id, :client_id,
124
124
  :order_terms, :shipment_address, :delivery_address, :invoice_address, :destination,
125
125
  :handover_date, :shipping_date, :delivery_date, :consignee, :payment_term, :delivery_term,
126
- :payment_penalty, :status, :total_price, :amount_paid, :pallete_note, :remark,
126
+ :payment_penalty, :status, :purchase_status, :total_price, :amount_paid, :pallete_note, :remark,
127
127
  files: [])
128
128
  end
129
129
 
@@ -1,8 +1,6 @@
1
1
  module Comee
2
2
  module Core
3
3
  class Client < ApplicationRecord
4
- before_save -> { self.subsidiary = !parent.nil? }
5
-
6
4
  belongs_to :user, optional: true
7
5
  belongs_to :parent, class_name: "Comee::Core::Client", optional: true
8
6
  belongs_to :currency, optional: true
@@ -0,0 +1,17 @@
1
+ module Comee
2
+ module Core
3
+ class ClientAddress < ApplicationRecord
4
+ SHIPPING_ADDRESS = "Shipping Address".freeze
5
+ DELIVERY_ADDRESS = "Delivery Address".freeze
6
+ INVOICING_ADDRESS = "Invoicing Address".freeze
7
+
8
+ ADDRESS_TYPES = [SHIPPING_ADDRESS, DELIVERY_ADDRESS, INVOICING_ADDRESS].freeze
9
+
10
+ belongs_to :client
11
+ belongs_to :country, -> { where(lookup_type: :country) }, class_name: "Comee::Core::Lookup"
12
+
13
+ validates :address_line1, :address_type, presence: true
14
+ validates :address_type, inclusion: {in: ADDRESS_TYPES}
15
+ end
16
+ end
17
+ end
@@ -3,6 +3,19 @@ module Comee
3
3
  class Lookup < ApplicationRecord
4
4
  validates :code, :name, :lookup_type, presence: true
5
5
  validates :code, uniqueness: {scope: :lookup_type}
6
+
7
+ def self.ransackable_attributes(_auth_object = nil)
8
+ %w[
9
+ id
10
+ code
11
+ name
12
+ lookup_type
13
+ ]
14
+ end
15
+
16
+ def self.ransackable_associations(_auth_object = nil)
17
+ []
18
+ end
6
19
  end
7
20
  end
8
21
  end
@@ -2,6 +2,7 @@ module Comee
2
2
  module Core
3
3
  class SalesOrderItem < ApplicationRecord
4
4
  before_save :calculate_total_price
5
+ before_save :calculate_handover_date
5
6
  after_save :update_sales_order_purchase_status, if: proc { |item| item.fully_processed? }
6
7
 
7
8
  enum processing_status: {unprocessed: 0, partially_processed: 1, fully_processed: 2}
@@ -20,6 +21,12 @@ module Comee
20
21
 
21
22
  delegate(:po_number, to: :purchase_order_item, prefix: false, allow_nil: true)
22
23
 
24
+ def calculate_handover_date
25
+ return if handover_date
26
+
27
+ self.handover_date = sales_order.handover_date
28
+ end
29
+
23
30
  def calculate_total_price
24
31
  self.total_price = price * quantity
25
32
  end
@@ -0,0 +1,10 @@
1
+ module Comee
2
+ module Core
3
+ class ClientAddressSerializer < ActiveModel::Serializer
4
+ attributes :id, :address_line1, :street, :city, :state, :country_id, :postal_code, :address_type, :client_id
5
+
6
+ belongs_to :client
7
+ belongs_to :country
8
+ end
9
+ end
10
+ end
@@ -3,8 +3,8 @@ module Comee
3
3
  class SalesOrderSerializer < ActiveModel::Serializer
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
- :delivery_term, :payment_penalty, :status, :total_price, :amount_paid, :pallete_note, :remark, :created_by,
7
- :files_url
6
+ :delivery_term, :payment_penalty, :status, :purchase_status, :total_price, :amount_paid, :pallete_note,
7
+ :remark, :created_by, :files_url
8
8
  belongs_to :customer_order
9
9
  belongs_to :client
10
10
  belongs_to :fulfillment_center
@@ -190,6 +190,7 @@ module Comee
190
190
  price: price,
191
191
  total_price: quantity * price,
192
192
  delivery_date: item.delivery_date,
193
+ handover_date: order.handover_date,
193
194
  lead_time: master_price&.lead_time
194
195
  }
195
196
  end
data/config/routes.rb CHANGED
@@ -31,7 +31,11 @@ Comee::Core::Engine.routes.draw do
31
31
  end
32
32
  end
33
33
 
34
- resources :lookups
34
+ resources :lookups do
35
+ collection do
36
+ post "filter"
37
+ end
38
+ end
35
39
  resources :quotation_requests do
36
40
  collection do
37
41
  post "filter"
@@ -77,6 +81,7 @@ Comee::Core::Engine.routes.draw do
77
81
  end
78
82
  resources :unit_conversions
79
83
  resources :users
84
+ resources :client_addresses
80
85
  resources :clients do
81
86
  member do
82
87
  get "rfq_products", controller: :quotation_requests, action: :rfq_products_for_client
@@ -84,6 +89,7 @@ Comee::Core::Engine.routes.draw do
84
89
  get "consignees"
85
90
  get "agents"
86
91
  get "shipment_items", controller: :shipment_items, action: :filter_for_client
92
+ get "addresses", controller: :client_addresses, action: :index
87
93
  post "create_agent"
88
94
  post "create_contact"
89
95
  post "price", controller: :client_prices, action: :fetch_one
@@ -0,0 +1,22 @@
1
+ class CreateComeeCoreClientAddresses < ActiveRecord::Migration[7.1]
2
+ def change
3
+ create_table :comee_core_client_addresses do |t|
4
+ t.references :client,
5
+ null: false,
6
+ index: {name: "cl_on_ccca_indx"},
7
+ foreign_key: {to_table: :comee_core_clients}
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_ccca_indx"},
15
+ foreign_key: {to_table: :comee_core_lookups}
16
+ t.string :postal_code
17
+ t.string :address_type, null: false
18
+
19
+ t.timestamps
20
+ end
21
+ end
22
+ end
@@ -1,5 +1,5 @@
1
1
  module Comee
2
2
  module Core
3
- VERSION = "0.2.66".freeze
3
+ VERSION = "0.2.68".freeze
4
4
  end
5
5
  end
@@ -0,0 +1,12 @@
1
+ FactoryBot.define do
2
+ factory :client_address, class: "Comee::Core::ClientAddress" do
3
+ client
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
+ address_type { Comee::Core::ClientAddress::SHIPPING_ADDRESS }
11
+ end
12
+ end
@@ -4,4 +4,8 @@ FactoryBot.define do
4
4
  name { Faker::Lorem.word }
5
5
  lookup_type { Faker::Alphanumeric.alpha(number: 8) }
6
6
  end
7
+
8
+ factory :country, parent: :lookup do
9
+ lookup_type { :country }
10
+ end
7
11
  end
@@ -5,5 +5,6 @@ FactoryBot.define do
5
5
  delivery_date { Date.current.advance(days: 10) }
6
6
  remark { Faker::Lorem.sentence }
7
7
  status { Comee::Core::PurchaseRequisition.statuses[:draft] }
8
+ purchase_status { Comee::Core::PurchaseRequisition.purchase_statuses[:unprocessed] }
8
9
  end
9
10
  end
@@ -19,6 +19,7 @@ FactoryBot.define do
19
19
  delivery_term { Faker::Lorem.sentence }
20
20
  payment_penalty { 0 }
21
21
  status { Comee::Core::SalesOrder.statuses[:draft] }
22
+ purchase_status { Comee::Core::SalesOrder.purchase_statuses[:unprocessed] }
22
23
  total_price { 0 }
23
24
  amount_paid { 0 }
24
25
  pallete_note { Faker::Lorem.sentence }
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.2.66
4
+ version: 0.2.68
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-05-01 00:00:00.000000000 Z
11
+ date: 2024-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers
@@ -268,6 +268,7 @@ files:
268
268
  - app/controllers/comee/core/agents_controller.rb
269
269
  - app/controllers/comee/core/application_controller.rb
270
270
  - app/controllers/comee/core/back_orders_controller.rb
271
+ - app/controllers/comee/core/client_addresses_controller.rb
271
272
  - app/controllers/comee/core/client_prices_controller.rb
272
273
  - app/controllers/comee/core/client_warehouses_controller.rb
273
274
  - app/controllers/comee/core/clients_controller.rb
@@ -305,6 +306,7 @@ files:
305
306
  - app/models/comee/core/back_order.rb
306
307
  - app/models/comee/core/back_order_item.rb
307
308
  - app/models/comee/core/client.rb
309
+ - app/models/comee/core/client_address.rb
308
310
  - app/models/comee/core/client_order.rb
309
311
  - app/models/comee/core/client_price.rb
310
312
  - app/models/comee/core/client_warehouse.rb
@@ -358,6 +360,7 @@ files:
358
360
  - app/models/comee/core/user_application_role.rb
359
361
  - app/notifications/comee/core/back_order_notification.rb
360
362
  - app/serializers/comee/core/agent_serializer.rb
363
+ - app/serializers/comee/core/client_address_serializer.rb
361
364
  - app/serializers/comee/core/client_price_serializer.rb
362
365
  - app/serializers/comee/core/client_serializer.rb
363
366
  - app/serializers/comee/core/client_warehouse_serializer.rb
@@ -459,6 +462,7 @@ files:
459
462
  - db/migrate/20240328132921_create_comee_core_supplier_payments.rb
460
463
  - db/migrate/20240407083617_create_comee_core_email_settings.rb
461
464
  - db/migrate/20240425121701_add_purchase_status_to_sales_order_and_purchase_requisition.rb
465
+ - db/migrate/20240503040722_create_comee_core_client_addresses.rb
462
466
  - lib/comee/core.rb
463
467
  - lib/comee/core/engine.rb
464
468
  - lib/comee/core/version.rb
@@ -469,6 +473,7 @@ files:
469
473
  - spec/factories/comee/core/application_modules.rb
470
474
  - spec/factories/comee/core/back_order_items.rb
471
475
  - spec/factories/comee/core/back_orders.rb
476
+ - spec/factories/comee/core/client_addresses.rb
472
477
  - spec/factories/comee/core/client_orders.rb
473
478
  - spec/factories/comee/core/client_prices.rb
474
479
  - spec/factories/comee/core/client_warehouses.rb