comee_core 0.1.19 → 0.1.21

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: 7659e487a4838aaf803b76be4f32172a1ecedf0f5bf55b380e133a765ce9e9ef
4
- data.tar.gz: 6278ea6edfdfefd40b1689674d9eceed30d0613cc1434bb2bb5342950c1db39b
3
+ metadata.gz: 4110e9f1c5556d8d519e9c4853886b4bdc836aee47a8e01f990f7d640f5a7144
4
+ data.tar.gz: bd9a6c43ddd0d57a46cf57518fa21afe77430844a29923b0815d34de8ad9f80b
5
5
  SHA512:
6
- metadata.gz: db7dc2e14014bd7a566ddae2aa6ab67113af21a3720bf8b6aee1936790df8a8152f28d650fbde967081f812ddef318df1336319277485084e5ad579d389fab48
7
- data.tar.gz: 19bb8c819706df7294acadc083aeda56cf6a7ea8e7ec7c0e5ed309db2b0ae4a9112a7b75809d37952e7b655c670f7be49a3668fc47ff68a721aac0900fd580a5
6
+ metadata.gz: 2f9c11ca22065eff7004b72ca5494381469256775c2b4d3d391fc5d35640fe1a7e1fc64ef7a51f9d5f94f78281b350dd9fe21f62753a93fa648ca5e235f1d796
7
+ data.tar.gz: 482433b0bf10ee4450ad5e93e811ae5c2db81461a991abd3c34a8bc49e0f57a8112a1e8294110d7bb695528d16376d2ade64ecef8e9bfd8e416f59727b937a5e
@@ -0,0 +1,18 @@
1
+ module Comee
2
+ module Core
3
+ class ClientPricesController < ApplicationController
4
+ include Comee::Core::Common
5
+
6
+ def filter
7
+ @client_prices = Comee::Core::ClientPrice.ransack(params[:q]).result
8
+ render json: {success: true, data: serialize(@client_prices)}
9
+ end
10
+
11
+ private
12
+
13
+ def model_params
14
+ params.require(:payload).permit(:valid_from, :valid_to, :price, :status, :product_id, :discount, :client_id, :previous_price)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -23,6 +23,21 @@ module Comee
23
23
  []
24
24
  end
25
25
 
26
+ def confirm
27
+ raise "Order already confirmed." if BackOrder.statuses[status] == BackOrder.statuses[:confirmed]
28
+
29
+ raise "Order should be in submitted state first." if BackOrder.statuses[status] != BackOrder.statuses[:submitted]
30
+
31
+ self.status = BackOrder.statuses[:confirmed]
32
+ back_order_items.each do |item|
33
+ if item.supplier_unit_price == item.requested_unit_price
34
+ self.price_changed = true
35
+ break
36
+ end
37
+ end
38
+ save!
39
+ end
40
+
26
41
  private
27
42
 
28
43
  def notify_supplier
@@ -0,0 +1,7 @@
1
+ module Comee
2
+ module Core
3
+ class ClientPriceSerializer < ActiveModel::Serializer
4
+ attributes :id, :valid_from, :valid_to, :price, :status, :product, :client, :previous_price
5
+ end
6
+ end
7
+ end
data/config/routes.rb CHANGED
@@ -19,4 +19,6 @@ Comee::Core::Engine.routes.draw do
19
19
  resources :units
20
20
  resources :users
21
21
  resources :clients
22
+ post "/client_prices/filter", controller: :client_prices, action: :filter
23
+ resources :client_prices
22
24
  end
@@ -12,6 +12,7 @@ class CreateComeeCoreBackOrders < ActiveRecord::Migration[7.0]
12
12
  t.string :delivery_address, null: false
13
13
  t.string :invoice_address, null: false
14
14
  t.integer :status, null: false, default: 0
15
+ t.boolean :price_changed, null: false, default: false
15
16
  t.string :remark
16
17
 
17
18
  t.timestamps
@@ -1,5 +1,5 @@
1
1
  module Comee
2
2
  module Core
3
- VERSION = "0.1.19"
3
+ VERSION = "0.1.21"
4
4
  end
5
5
  end
@@ -8,6 +8,7 @@ FactoryBot.define do
8
8
  delivery_address { Faker::Address.full_address }
9
9
  invoice_address { Faker::Address.full_address }
10
10
  status { Comee::Core::BackOrder.statuses[:draft] }
11
+ price_changed { false }
11
12
  remark { Faker::Lorem.sentence }
12
13
  end
13
14
  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.19
4
+ version: 0.1.21
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-10-07 00:00:00.000000000 Z
11
+ date: 2023-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers
@@ -232,6 +232,7 @@ files:
232
232
  - Rakefile
233
233
  - app/controllers/comee/core/access_controller.rb
234
234
  - app/controllers/comee/core/application_controller.rb
235
+ - app/controllers/comee/core/client_prices_controller.rb
235
236
  - app/controllers/comee/core/clients_controller.rb
236
237
  - app/controllers/comee/core/currencies_controller.rb
237
238
  - app/controllers/comee/core/notifications_controller.rb
@@ -266,6 +267,7 @@ files:
266
267
  - app/models/comee/core/unit.rb
267
268
  - app/models/comee/core/user.rb
268
269
  - app/notifications/comee/core/new_order_notification.rb
270
+ - app/serializers/comee/core/client_price_serializer.rb
269
271
  - app/serializers/comee/core/client_serializer.rb
270
272
  - app/serializers/comee/core/currency_serializer.rb
271
273
  - app/serializers/comee/core/product_serializer.rb