cats_core 1.4.19 → 1.4.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4f2cc951417c8b5c1586ad4deb540c51e54177eac53c54a689f31c35bfbfbb67
4
- data.tar.gz: f25cbb325f2eb8b8c9081ec0660b3c3028fe45ee0b7f003c40e96c91cdfebd15
3
+ metadata.gz: d78b456ef9b9082680246207509f81b33ba4c9584136bafc00ac1dd9085e77cb
4
+ data.tar.gz: f1138cb24c4f94d7c42dd84b15916762c1f27c321531b1057f2b9e96a2da5c75
5
5
  SHA512:
6
- metadata.gz: 610169114a8fd878d1fd47b771f55a5bfef3e79c3d660b8148642a8fd9def6e018f4cea2b6cda50ee381970f2bee3e9e98ff5d5f0a3f66436d340b8334e4bf75
7
- data.tar.gz: b0d90834aba82fd86dfb53bd6b51a875ff1131c4a3096813d6132efc860915e89ea4dd63c7272518158af8c0d21b355557e055b86d08938e82f063ce743a8f0a
6
+ metadata.gz: 74b5f1fc12c9851dd07224c07b6a00912d44012f2347f87b3264cad20882f5950b9d27d9820c3c0b1526e26f32dfb83ee16263d77b4bcf2efdcd8f5ca30aaef9
7
+ data.tar.gz: 349b6c6a81040bf195ea723e9920f97711be1dce7c4257a5c7f03459d4b0cebd3d59ae650265ed952791c85330891df00d51c621c81c4948c85819f30ce07903
@@ -59,7 +59,7 @@ module Cats
59
59
  # Commit transactions
60
60
  dispatch_transactions.each(&:commit)
61
61
  self.quantity = total_quantity
62
- self.dispatch_status = Dispatch::APPROVED
62
+ self.dispatch_status = APPROVED
63
63
  save!
64
64
  end
65
65
  end
@@ -67,7 +67,7 @@ module Cats
67
67
  def start
68
68
  raise(StandardError, 'Dispatch has to be approved first.') unless dispatch_status == Dispatch::APPROVED
69
69
 
70
- self.dispatch_status = Dispatch::STARTED
70
+ self.dispatch_status = STARTED
71
71
  save!
72
72
  end
73
73
 
@@ -83,12 +83,32 @@ module Cats
83
83
  end
84
84
 
85
85
  Dispatch.transaction do
86
- self.dispatch_status = Dispatch::RECEIVED
86
+ self.dispatch_status = RECEIVED
87
87
  receipts.each { |r| r.status = Receipt::CONFIRMED }
88
88
  save!
89
89
  receipts.each(&:save!)
90
90
  end
91
91
  end
92
+
93
+ def self.search_commodity(batch_no)
94
+ commodity = Commodity.find_by(batch_no: batch_no)
95
+ dispatches = Dispatch.includes(:dispatch_transactions)
96
+ .joins(:transporter)
97
+ .where(
98
+ dispatch_status: [APPROVED, STARTED, ARRIVED, UNLOADED]
99
+ )
100
+ dispatches.map do |dispatch|
101
+ {
102
+ batch_no: batch_no,
103
+ commodity_name: commodity.name,
104
+ quantity: dispatch.total_quantity,
105
+ unit: commodity.unit_abbreviation,
106
+ location: dispatch.transporter.name,
107
+ location_detail: "Plate No.: #{dispatch.plate_no}, Driver: #{dispatch.driver_name}",
108
+ stack: ''
109
+ }
110
+ end
111
+ end
92
112
  end
93
113
  end
94
114
  end
@@ -146,6 +146,25 @@ module Cats
146
146
 
147
147
  store.save
148
148
  end
149
+
150
+ def self.search_commodity(batch_no)
151
+ commodity = Commodity.find_by(batch_no: batch_no)
152
+ stacks = Stack.joins(:commodity, store: :warehouse).where(
153
+ commodity: { batch_no: batch_no },
154
+ stack_status: Stack::ALLOCATED
155
+ )
156
+ stacks.map do |stack|
157
+ {
158
+ batch_no: batch_no,
159
+ commodity_name: commodity.name,
160
+ quantity: stack.quantity,
161
+ unit: commodity.unit_abbreviation,
162
+ location: stack.store.warehouse.name,
163
+ location_detail: stack.store.name,
164
+ stack: stack.code
165
+ }
166
+ end
167
+ end
149
168
  end
150
169
  end
151
170
  end
@@ -36,7 +36,7 @@ module Cats
36
36
 
37
37
  errors.add(:status, 'cannot be set to "APPROVED" because the order has no items.') if status == APPROVED
38
38
  end
39
-
39
+
40
40
  def approve(user)
41
41
  raise(StandardError, 'Transport order is already approved.') if status == APPROVED
42
42
 
@@ -1,5 +1,5 @@
1
1
  module Cats
2
2
  module Core
3
- VERSION = '1.4.19'.freeze
3
+ VERSION = '1.4.20'.freeze
4
4
  end
5
5
  end
@@ -3,6 +3,6 @@ FactoryBot.define do
3
3
  region factory: :location
4
4
  source factory: :woreda
5
5
  destination factory: :woreda
6
- name { "#{source.name} - #{destination.name}"}
6
+ name { "#{source.name} - #{destination.name}" }
7
7
  end
8
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.4.19
4
+ version: 1.4.20
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-05-16 00:00:00.000000000 Z
11
+ date: 2022-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers