comee_core 0.1.69 → 0.1.71

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: e220664513363d940d77f8312b831a2c3468376a73cc4ec5b13a9b6c58fa7790
4
- data.tar.gz: 6a96dfd1144056e9a4d0978c682c4af3541a999485b835d31356bf66b5f7e1f7
3
+ metadata.gz: af05a9a39c3e49d30c92aee06f9e27fbe4e02c7c1678a417df369fb88a6bf47b
4
+ data.tar.gz: a36ab5dcdaea7c2e22d8c41bbfc37d533a42b3472e83494124da6fe5bd9d311e
5
5
  SHA512:
6
- metadata.gz: 6f48f16596d28fea625a7aef27b1b9d49c153f86a2af245c919392ee51d4cad138f7bf773dba1a32f32c3834cf2b6dc7d84ec7a5e70abf3ab3d902496ca68dbc
7
- data.tar.gz: 2f52a6c778dcb8ef814b415e8a2c900e4edbda8e9d8c99979511efa6c1c9b0d35adf2146742c6f07d018dc4c8d7f66f057bf71683c8b743560103a215bc1bce2
6
+ metadata.gz: 3adaf0714c2d01b384b240884fe6dd94047cfa04b2f29d0271d97147b94708a8d35312b062b47fa18802e51720cda21e5a844b6e66045e6873287dbee6b93942
7
+ data.tar.gz: 9df735b384d02638be87742ac3d11f32eac8be43672c1d428d5ff66510b34308eb54f523b6c40717287a1000ed3ebaba74b50c76edff0d288dbccdfbb49aac1a
@@ -11,9 +11,47 @@ module Comee
11
11
  end
12
12
 
13
13
  def filter
14
- @client_prices = Comee::Core::ClientPrice.ransack(params[:q]).result
14
+ @client_prices = Comee::Core::ClientPrice.includes(:client, :product, :unit).ransack(params[:q]).result
15
15
  @client_prices = @client_prices.then(&paginate)
16
- render json: {success: true, data: serialize(@client_prices)}
16
+ queries = @client_prices.map { |cp| {itemable_id: cp.client_id, product_id: cp.product_id, itemable_type: "Comee::Core::Client"} }
17
+
18
+ lookups = queries.inject(Comee::Core::ProductLookup.none) do |conditions, condition|
19
+ conditions.or(Comee::Core::ProductLookup.where(condition))
20
+ end
21
+ result = @client_prices.each_with_object([]) do |obj, res|
22
+ item = {
23
+ id: obj.id,
24
+ valid_from: obj.valid_from,
25
+ valid_to: obj.valid_to,
26
+ price: obj.price,
27
+ status: obj.status,
28
+ margin: obj.margin,
29
+ margin_type: obj.margin_type,
30
+ client_code: obj.client.code,
31
+ client_name: obj.client.name,
32
+ client_address: obj.client.address,
33
+ product_code: obj.product.code,
34
+ product_name: obj.product.name,
35
+ product_description: obj.product.description,
36
+ product_preferred_units: obj.product.preferred_units,
37
+ product_weight: obj.product.weight,
38
+ product_weight_unit: obj.product.weight_unit,
39
+ product_dimensions: obj.product.dimensions,
40
+ product_hs_code: obj.product.hs_code,
41
+ product_hs_description: obj.product.hs_description,
42
+ product_image: obj.product.thumbnail_image_url,
43
+ unit_code: obj.unit.code,
44
+ unit_name: obj.unit.name
45
+ }
46
+ lkp = lookups.select { |lookup| lookup.itemable_id == obj.client_id && lookup.product_id == obj.product_id }
47
+ if lkp.count.positive?
48
+ item[:client_product_code] = lkp[0].code
49
+ item[:client_product_name] = lkp[0].item_description
50
+ end
51
+ res << item
52
+ end
53
+
54
+ render json: {success: true, data: result}
17
55
  end
18
56
 
19
57
  private
@@ -3,6 +3,11 @@ module Comee
3
3
  class ShipmentItemsController < ApplicationController
4
4
  include Common
5
5
 
6
+ def filter
7
+ @shipment_item = Comee::Core::ShipmentItem.ransack(params[:q]).result
8
+ render json: {success: true, data: serialize(@shipment_item)}
9
+ end
10
+
6
11
  def filter_with_status
7
12
  items = ShipmentItem.includes(sales_order_item: %i[sales_order product unit])
8
13
  .ransack(params[:q]).result
@@ -7,6 +7,7 @@ module Comee
7
7
  belongs_to :fulfillment_center, optional: true
8
8
  has_many :sales_order_items
9
9
  has_many_attached :files
10
+ has_one :customs_detail
10
11
 
11
12
  enum :status, {draft: 0, submitted: 1, confirmed: 2, canceled: 3}
12
13
 
@@ -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
5
+ :handover_date, :remark, :files_url, :customs_detail
6
6
  belongs_to :customer_order
7
7
  belongs_to :fulfillment_center
8
8
  has_many :sales_order_items
data/config/routes.rb CHANGED
@@ -86,10 +86,10 @@ Comee::Core::Engine.routes.draw do
86
86
  get "suggest", controller: :sales_order_items, action: :suggest_values
87
87
  end
88
88
  end
89
-
90
89
  resources :shipment_items do
91
90
  collection do
92
91
  post "filter_with_status"
92
+ post "filter"
93
93
  end
94
94
  end
95
95
  post "/sales_orders/filter", controller: :sales_orders, action: :filter
@@ -1,5 +1,5 @@
1
1
  module Comee
2
2
  module Core
3
- VERSION = "0.1.69".freeze
3
+ VERSION = "0.1.71".freeze
4
4
  end
5
5
  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.69
4
+ version: 0.1.71
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-30 00:00:00.000000000 Z
11
+ date: 2024-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers