comee_core 0.1.87 → 0.1.89

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: fcd01686f33365c1ac6f9b6a0263da7df0d5952a4b7aa6a65f330d57fed4d6c3
4
- data.tar.gz: eb7d575093c1faf0a60d3a16eff3d00049d23c689ac5701c0a019599b5397fbb
3
+ metadata.gz: d2215fbbb3c1a9e0c836eb20902ea9c9871e473d08bb17c0659ca6c20236daeb
4
+ data.tar.gz: a546d3c21ef0b354c9ff61159309919145de3335e16639d9674a6ae1f2414824
5
5
  SHA512:
6
- metadata.gz: 5deb9e48f2e06484c6a695d4395cb0b0053925657d92854f9194aafb63ca5c7504871689a6c22a7bf71841eb04901d897a0ab7da0b235ccf4ef655d56f934117
7
- data.tar.gz: 0bce465e2462ad3c330a7ca0c80f2bd17166d58373abd6d9552dda3df5101885f787696fa03c9228748403b3220582e7ef0b0f11180e6bd87ddef70309820af4
6
+ metadata.gz: e00d19d0c5d47518505c4a4b5f7ef3a336807966795d933cff8ce7f133dfe32aebc50d76cb2d8dbd78b1010e89d271be9cf3dd6d1b30175b1405f50024108559
7
+ data.tar.gz: 5a9d63dd29c4ec4ed87b555dc7cb7b316d1fb69f97dbbc59f14dbc6cc638fd34ca0291103cb355078903276963911bd7953be094daeb3be86fd91157c7fc4039
@@ -25,39 +25,12 @@ module Comee
25
25
  render json: {success: true}
26
26
  end
27
27
 
28
- # def filter_with_status
29
- # items = SalesOrderItem.includes(:sales_order, :product, :unit)
30
- # .ransack(params[:q]).result
31
- # statuses = ItemStatus.where(sales_order_item_id: items.map(&:id))
32
- # .select("MAX(id) AS max_id, sales_order_item_id")
33
- # .group(:sales_order_item_id)
34
- # .all
35
- # ids = statuses.map(&:max_id)
36
- # statuses = ItemStatus.where(id: ids).each_with_object({}) { |status, res| res[status.sales_order_item_id] = status }
37
- # result = items.each_with_object([]) do |item, res|
38
- # status = statuses[item.id]
39
- # data = {
40
- # sales_order_no: item.sales_order.order_number,
41
- # customer_item_no: item.customer_item_no,
42
- # product_code: item.product.code,
43
- # unit: item.unit.code,
44
- # quantity: item.quantity,
45
- # delivery_date: item.delivery_date,
46
- # handover_date: item.sales_order.handover_date,
47
- # po_reference: item.po_reference,
48
- # status: status&.status
49
- # }
50
- # res << data.merge(status&.details)
51
- # end
52
- # render json: {success: true, data: result}
53
- # end
54
-
55
28
  private
56
29
 
57
30
  def model_params
58
31
  params.require(:payload).permit(:sales_order_id, :customer_order_item_id, :product_id, :unit_id, :quantity, :quantity_delivered,
59
- :customer_item_no, :price, :delivery_date, :eb_number, :lead_time, :comment, :action_note,
60
- :po_reference, :pallet_no, :source_id)
32
+ :customer_item_no, :price, :handover_date, :delivery_date, :eb_number, :lead_time, :comment,
33
+ :action_note, :po_reference, :pallet_no, :source_id)
61
34
  end
62
35
  end
63
36
  end
@@ -3,6 +3,11 @@ module Comee
3
3
  class UnitsController < ApplicationController
4
4
  include Common
5
5
 
6
+ def filter
7
+ units = Unit.ransack(params[:q]).result
8
+ render json: {success: true, data: serialize(units)}
9
+ end
10
+
6
11
  private
7
12
 
8
13
  def model_params
@@ -2,6 +2,7 @@ module Comee
2
2
  module Core
3
3
  class Pod < ApplicationRecord
4
4
  enum :status, {draft: 0, confirmed: 1, signed: 2}
5
+ has_many :shipment_instruction_items
5
6
 
6
7
  validates :reference_no, :status, presence: true
7
8
  end
@@ -1,8 +1,20 @@
1
1
  module Comee
2
2
  module Core
3
3
  class TransportAvailability < ApplicationRecord
4
+ before_save :compute_weekday
5
+
6
+ has_many :time_slots
7
+
4
8
  validates :availability_date, presence: true, uniqueness: true
5
- validates :weekday, :weekday_short, presence: true
9
+
10
+ def compute_weekday
11
+ self.weekday = availability_date.strftime("%A")
12
+ self.weekday_short = availability_date.strftime("%a")
13
+ end
14
+
15
+ def self.ransackable_attributes(_auth_object = nil)
16
+ %w[availability_date weekday weekday_short]
17
+ end
6
18
  end
7
19
  end
8
20
  end
@@ -13,6 +13,10 @@ module Comee
13
13
 
14
14
  aliases.map(&:downcase!)
15
15
  end
16
+
17
+ def self.ransackable_attributes(_auth_object = nil)
18
+ %w[code name unit_type]
19
+ end
16
20
  end
17
21
  end
18
22
  end
@@ -1,8 +1,8 @@
1
1
  module Comee
2
2
  module Core
3
3
  class SalesOrderItemSerializer < ActiveModel::Serializer
4
- attributes :id, :customer_item_no, :quantity, :quantity_delivered, :price, :delivery_date, :eb_number, :lead_time, :comment,
5
- :action_note, :po_reference
4
+ attributes :id, :customer_item_no, :quantity, :quantity_delivered, :price, :handover_date, :delivery_date, :eb_number,
5
+ :lead_time, :comment, :action_note, :po_reference
6
6
 
7
7
  belongs_to :sales_order
8
8
  belongs_to :customer_order_item
data/config/routes.rb CHANGED
@@ -66,7 +66,11 @@ Comee::Core::Engine.routes.draw do
66
66
  end
67
67
  end
68
68
  resources :currencies
69
- resources :units
69
+ resources :units do
70
+ collection do
71
+ post "filter"
72
+ end
73
+ end
70
74
  resources :unit_conversions
71
75
  resources :users
72
76
  post "/purchase_orders/filter", controller: :purchase_orders, action: :filter
data/config/spring.rb CHANGED
@@ -1 +1 @@
1
- Spring.application_root = "spec/dummy"
1
+ Spring.application_root = "./spec/dummy"
@@ -1,5 +1,5 @@
1
1
  module Comee
2
2
  module Core
3
- VERSION = "0.1.87".freeze
3
+ VERSION = "0.1.89".freeze
4
4
  end
5
5
  end
@@ -1,7 +1,7 @@
1
1
  FactoryBot.define do
2
2
  factory :transport_availability, class: "Comee::Core::TransportAvailability" do
3
3
  availability_date do
4
- d = Date.current
4
+ d = Faker::Date.between(from: Date.current, to: Date.current.advance(months: 6))
5
5
  d.advance(days: 1) if d.wday == 7
6
6
  d.advance(days: 2) if d.wday == 6
7
7
  d
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.87
4
+ version: 0.1.89
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-11 00:00:00.000000000 Z
11
+ date: 2024-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers