cats_core 1.3.32 → 1.3.36

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: 5ac9b1b8f8a818f2992adf7b2d3fc5ce78340ae1f3ad092c05c90211c52a2d38
4
- data.tar.gz: 4e2a4269952f62ac0293ac354fe2d84ca4e894b326a8bce6b65b00aa534242ba
3
+ metadata.gz: f7d2738616bb04e122c03cb503fe91bb1d8cb818c2ef909516d2e506efcad01c
4
+ data.tar.gz: 7363415368111fa228b7d552f030bdce90009940c62365a27b9408d29745a21b
5
5
  SHA512:
6
- metadata.gz: 26fbde7964902e432c4c08ce116466052732a66d6b592139426276fd33ab872d8ad8431cd86652d3026a7faa7c2799952f2ffa30ae7a2599c8e49f2e89a0d217
7
- data.tar.gz: a2097e28a69ea6cdd93f38c58eb8fe7a41e92c2fa5cb0c816e5def3cf7233c53a7d03c7830fa254e17481537be3e82685795f215e50e6ecbed6b949cccb11a01
6
+ metadata.gz: c04a0d21b349fe67c2367204df7dc876bd0ec250753124873583b387f035fe1290a7bb503f8aad9184dd8df6fddd787aaa785fd0f1e281e12c4b0f2a6320871f
7
+ data.tar.gz: d0104ee1c25f2fa50e196c0daa671c30fbed484cb370116919bc01403e68d736595a0ab17c83f2b2f0921bff87d319840035f99ee6cfd3d20c55d93817a29595
@@ -16,6 +16,10 @@ module Cats
16
16
 
17
17
  private
18
18
 
19
+ def serialize(data)
20
+ ActiveModelSerializers::SerializableResource.new(data)
21
+ end
22
+
19
23
  def token
20
24
  return nil if request.env['HTTP_AUTHORIZATION'].nil?
21
25
 
@@ -9,6 +9,11 @@ module Cats
9
9
  render json: { success: true, data: data }
10
10
  end
11
11
 
12
+ def root
13
+ data = Cats::Core::CommodityCategory.roots
14
+ render json: { success: true, data: serialize(data) }
15
+ end
16
+
12
17
  def show
13
18
  data = ActiveModelSerializers::SerializableResource.new(@commodity_category)
14
19
  render json: { success: true, data: data }
@@ -0,0 +1,16 @@
1
+ module Cats
2
+ module Core
3
+ class LostCommoditiesController < ApplicationController
4
+ include Common
5
+
6
+ def index
7
+ data = LostCommodity.where(receipt_id: params[:id])
8
+ render json: { success: true, data: serialize(data) }
9
+ end
10
+
11
+ def model_params
12
+ params.require(:payload).permit(:receipt_id, :quantity, :commodity_status, :remark)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,10 @@
1
+ module Cats
2
+ module Core
3
+ class LostCommodity < ApplicationRecord
4
+ belongs_to :receipt
5
+
6
+ validates :quantity, presence: true
7
+ validates :commodity_status, presence: true, inclusion: { in: Commodity::COMMODITY_STATUSES }
8
+ end
9
+ end
10
+ end
@@ -5,6 +5,10 @@ module Cats
5
5
  belongs_to :monthly_ration
6
6
 
7
7
  validates :amount, presence: true, numericality: { greater_than: 0 }
8
+
9
+ delegate(:commodity_category_name, to: :monthly_ration)
10
+ delegate(:unit_of_measure_abbreviation, to: :monthly_ration)
11
+ delegate(:no_of_days, to: :monthly_ration)
8
12
  end
9
13
  end
10
14
  end
@@ -0,0 +1,7 @@
1
+ module Cats
2
+ module Core
3
+ class LostCommoditySerializer < ActiveModel::Serializer
4
+ attributes :id, :receipt_id, :quantity, :commodity_status, :remark
5
+ end
6
+ end
7
+ end
data/config/routes.rb CHANGED
@@ -59,6 +59,7 @@ Cats::Core::Engine.routes.draw do
59
59
  as: :store_space,
60
60
  defaults: { level: Cats::Core::SpaceService::STORE }
61
61
 
62
+ get '/commodity_categories/roots', to: 'commodity_categories#root', as: :commodity_category_roots
62
63
  resources :commodity_categories, except: %i[destroy] do
63
64
  member do
64
65
  get 'children'
@@ -102,9 +103,11 @@ Cats::Core::Engine.routes.draw do
102
103
  resources :receipts, except: %i[index new edit destroy] do
103
104
  member do
104
105
  get 'transactions', controller: :receipt_transactions, action: :index
106
+ get 'lost', controller: :lost_commodities, action: :index
105
107
  post 'start_stacking'
106
108
  post 'finish_stacking'
107
109
  end
108
110
  end
109
111
  resources :receipt_transactions, except: %i[index new edit destroy]
112
+ resources :lost_commodities, except: %i[index destroy]
110
113
  end
@@ -0,0 +1,15 @@
1
+ class CreateCatsCoreLostCommodities < ActiveRecord::Migration[7.0]
2
+ def change
3
+ create_table :cats_core_lost_commodities do |t|
4
+ t.references :receipt,
5
+ null: false,
6
+ index: { name: 'lc_on_receipt_indx' },
7
+ foreign_key: { to_table: :cats_core_receipts }
8
+ t.float :quantity, null: false
9
+ t.string :commodity_status, null: false
10
+ t.string :remark
11
+
12
+ t.timestamps
13
+ end
14
+ end
15
+ end
@@ -1,5 +1,5 @@
1
1
  module Cats
2
2
  module Core
3
- VERSION = '1.3.32'.freeze
3
+ VERSION = '1.3.36'.freeze
4
4
  end
5
5
  end
@@ -0,0 +1,8 @@
1
+ FactoryBot.define do
2
+ factory :lost_commodity, class: 'Cats::Core::LostCommodity' do
3
+ receipt
4
+ quantity { 100 }
5
+ commodity_status { Cats::Core::Commodity::DAMAGED }
6
+ remark { FFaker::Name.name }
7
+ end
8
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cats_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.32
4
+ version: 1.3.36
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henock L.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-18 00:00:00.000000000 Z
11
+ date: 2022-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers
@@ -239,6 +239,7 @@ files:
239
239
  - app/controllers/cats/core/dispatch_transactions_controller.rb
240
240
  - app/controllers/cats/core/dispatches_controller.rb
241
241
  - app/controllers/cats/core/locations_controller.rb
242
+ - app/controllers/cats/core/lost_commodities_controller.rb
242
243
  - app/controllers/cats/core/menus_controller.rb
243
244
  - app/controllers/cats/core/notifications_controller.rb
244
245
  - app/controllers/cats/core/receipt_transactions_controller.rb
@@ -269,6 +270,7 @@ files:
269
270
  - app/models/cats/core/gift_certificate.rb
270
271
  - app/models/cats/core/hub_authorization.rb
271
272
  - app/models/cats/core/location.rb
273
+ - app/models/cats/core/lost_commodity.rb
272
274
  - app/models/cats/core/menu.rb
273
275
  - app/models/cats/core/menu_item.rb
274
276
  - app/models/cats/core/monthly_plan.rb
@@ -320,6 +322,7 @@ files:
320
322
  - app/serializers/cats/core/dispatch_serializer.rb
321
323
  - app/serializers/cats/core/dispatch_transaction_serializer.rb
322
324
  - app/serializers/cats/core/location_serializer.rb
325
+ - app/serializers/cats/core/lost_commodity_serializer.rb
323
326
  - app/serializers/cats/core/receipt_serializer.rb
324
327
  - app/serializers/cats/core/receipt_transaction_serializer.rb
325
328
  - app/serializers/cats/core/role_menu_serializer.rb
@@ -393,6 +396,7 @@ files:
393
396
  - db/migrate/20220107125025_create_cats_core_monthly_plan_items.rb
394
397
  - db/migrate/20220107132433_create_cats_core_monthly_plan_item_details.rb
395
398
  - db/migrate/20220209083928_create_cats_core_hub_authorizations.rb
399
+ - db/migrate/20220221041505_create_cats_core_lost_commodities.rb
396
400
  - lib/cats/core.rb
397
401
  - lib/cats/core/engine.rb
398
402
  - lib/cats/core/version.rb
@@ -415,6 +419,7 @@ files:
415
419
  - spec/factories/cats/core/gift_certificates.rb
416
420
  - spec/factories/cats/core/hub_authorizations.rb
417
421
  - spec/factories/cats/core/locations.rb
422
+ - spec/factories/cats/core/lost_commodities.rb
418
423
  - spec/factories/cats/core/menu_items.rb
419
424
  - spec/factories/cats/core/menus.rb
420
425
  - spec/factories/cats/core/monthly_plan_item_details.rb