cats_core 1.4.5 → 1.4.8

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: 1f6f8e286a7968b1159a3b0a7c9cb6e99f1637179ceb1d283d6b00f8c7e04d0b
4
- data.tar.gz: a98a62f4250435c8611f1034e27e5dc0668ab1833ed8bdf42aa0b6ecdb47b4cd
3
+ metadata.gz: 626e9d30bfefd23124b2110a3b10c4a6dcf58ac6aeb660b50803843ececd2517
4
+ data.tar.gz: e59fa35f07c89486a5840e613389dd75ed6613077cb0ae3648295134dbff7ffe
5
5
  SHA512:
6
- metadata.gz: 5e8cfe8cacbf89d43b8a3552e2414d35081e2c4a92925f6c0a8678bc40822d34274961dd5bcb96c192e0b35ef6956cf709bea806676ff5dad7e84f73cae29888
7
- data.tar.gz: 8d4e6d29a50e7ebc4fb2fa78dca753ca9d11ba90453c421ba77f7cf57819649e5027a40e76a298b14cdf20959f74b8fae2d57a265360a24d91ffe2e44df9134b
6
+ metadata.gz: 440d92d2388b2816b1c76b0040d4c6d2a2fe0588b94e4ba134be56058cb74344ad55510e074a9d87ee04b1bf5336a705dd98bc7de5facc7250f3638f17e9ddfd
7
+ data.tar.gz: f3adb1d2cc5edd7cf7baf0eeb4b9624602f0987bea3cb5d1b7700af7b894ac43143fc2c0108daed5622e55e5581fc789ae97bd073a2246fdd02836bcb060784a
@@ -16,13 +16,26 @@ module Cats
16
16
  validates :status, presence: true, inclusion: { in: STATUSES }
17
17
 
18
18
  delegate(:full_name, to: :requested_by, prefix: 'requestor')
19
- delegate(:full_name, to: :approved_by, prefix: 'approver')
19
+ delegate(:full_name, to: :approved_by, prefix: 'approver', allow_nil: true)
20
20
  delegate(:abbreviation, to: :unit, prefix: true)
21
+ delegate(:reference_no, to: :dispatch_plan, prefix: true)
21
22
 
22
23
  def quantity
23
24
  quantities = transport_requisition_items.map { |item| UnitConversion.convert(item.unit, unit, item.quantity) }
24
25
  quantities.sum
25
26
  end
27
+
28
+ def approve
29
+ raise(StandardError, 'Transport requisition is already approved.') if status == APPROVED
30
+
31
+ if transport_requisition_items.count.zero?
32
+ raise(StandardError, 'Transport requisition has no requisition items.')
33
+ end
34
+
35
+ self.status = APPROVED
36
+ save!
37
+ self
38
+ end
26
39
  end
27
40
  end
28
41
  end
@@ -9,6 +9,14 @@ module Cats
9
9
 
10
10
  delegate(:reference_no, to: :transport_requisition, prefix: 'requisition')
11
11
  delegate(:abbreviation, to: :unit, prefix: true)
12
+
13
+ def commodity_name
14
+ dispatch_plan_item.commodity.source.commodity_category.name
15
+ end
16
+
17
+ def woreda
18
+ dispatch_plan_item.destination.name
19
+ end
12
20
  end
13
21
  end
14
22
  end
@@ -1,5 +1,5 @@
1
1
  module Cats
2
2
  module Core
3
- VERSION = '1.4.5'.freeze
3
+ VERSION = '1.4.8'.freeze
4
4
  end
5
5
  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.5
4
+ version: 1.4.8
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-04-17 00:00:00.000000000 Z
11
+ date: 2022-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers