smerp-quotation 0.2.3 → 0.2.4

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: 3e42c00897ec17d8b63b419e3ed0ac415c067474de1dbf1e9c058a20ff2b79d5
4
- data.tar.gz: eae98863ae3ca0604e35181283df1a38977f55b1d80428fd5a9ed61974c9b19a
3
+ metadata.gz: 0a18dda7b56228271c1032e1a27ef4c0a1dabfa1ed8d44c219ba4b88a9ae4d5a
4
+ data.tar.gz: bd4083071f2cdf271a4eab01422282ad51fc5a55959e40f65514ba8af06e6c2d
5
5
  SHA512:
6
- metadata.gz: 92f27ab04cb522e2aa3c61e76d1aa231245e40c54969de1e23a57b2d6ede741f5b330fabdd88bbf1ed926164d5ab60e16d95f14304ce94a75e049028d81583a2
7
- data.tar.gz: ac6611999cf8a7c8ec1b0e22f192083ebdfa800fdbd999b49f5bdb18909f453ecc3610ec6a3cf2c7632c74e56cdcd899750dbd396523da2e09c984e42261a2cd
6
+ metadata.gz: f52d9a81d3f337e75eb8abcb9087adc0faf6850b743ffe8378578dcaaa8550f118ae6085992dfb3631cb8c071971a7b9fefe97615787be4092ac7bd24fe6fb3d
7
+ data.tar.gz: cb3e06001da8068f511261852688f6c19aa2b3716b1db7ca6e99c1420f101e9134faf9014b060939127fbb5fd2dfde7975fdeb86070197a6e39950bb9b45d321
data/.release_history.yml CHANGED
@@ -8,3 +8,5 @@ smerp-quotation:
8
8
  :timestamp: 1664817326.603613
9
9
  - :version: 0.2.2
10
10
  :timestamp: 1664874428.3551033
11
+ - :version: 0.2.3
12
+ :timestamp: 1664880291.384937
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- smerp-quotation (0.2.3)
4
+ smerp-quotation (0.2.4)
5
5
  acts_as_list
6
6
  acts_as_tree
7
7
  ca-data_store
@@ -73,7 +73,7 @@ module Smerp
73
73
  #teLogger.debug "Before recalculate : #{self.inspect}"
74
74
  ## Calculate consolidated line total
75
75
  # Calculate line total of each item that push to this parent item
76
- if not self.new_record?
76
+ if self.is_consolidation_destination_item? and not self.new_record?
77
77
  recalculate_total_from_source_quotation_items
78
78
  end
79
79
  #teLogger.debug "After recalculate : #{self.inspect}"
@@ -184,6 +184,8 @@ module Smerp
184
184
 
185
185
  if not pa.nil?
186
186
 
187
+ #pa.reload
188
+
187
189
  if pa.is_children_linked?
188
190
 
189
191
  teLogger.debug "Parent #{pa.inspect} IS children linked"
@@ -196,13 +198,17 @@ module Smerp
196
198
  # has changed its parent to other parent
197
199
  pa.children.reload
198
200
 
201
+
202
+ teLogger.debug "Before setting any price : #{pa.inspect}"
199
203
  # for children item that has a parent
200
204
  # update parent line_total
201
205
  pa.line_total = pa.children.sum(:line_total)
202
206
  pa.consolidated_line_total = pa.children.sum(:consolidated_line_total)
203
207
 
208
+ teLogger.debug "Before resetting unit price : #{pa.inspect}"
204
209
  # update unit_price since line_total is sum of children's line_total
205
210
  pa.unit_price = pa.consolidated_line_total / pa.quantity
211
+ teLogger.debug "After resetting unit price : #{pa.inspect}"
206
212
 
207
213
  pa.discount = pa.children.sum(:discount)
208
214
  pa.line_total_after_discount = pa.children.sum(:line_total_after_discount)
@@ -222,8 +228,16 @@ module Smerp
222
228
  pa.line_total_with_tax = 0.0
223
229
  end
224
230
 
231
+ teLogger.debug "Before save parent #{pa.changes}"
225
232
  pa.save
226
233
 
234
+ #pobj = QuotationItem.find(pa.id)
235
+ #p pobj
236
+ #pa.changes.each do |k,v|
237
+ # pobj.send("#{k}=", v[1])
238
+ #end
239
+ #pobj.save
240
+
227
241
  else
228
242
  teLogger.debug "Parent #{pa.inspect} is NOT children linked. Skipping children update to parent."
229
243
  end
@@ -232,7 +246,7 @@ module Smerp
232
246
  end
233
247
 
234
248
  # calculate if I'm the source to be embedded into other items
235
- recalculate_total_to_destination_quotation_items
249
+ recalculate_total_to_destination_quotation_items if self.is_consolidation_source_item?
236
250
 
237
251
  #self.quotation.update_total_from_children
238
252
 
@@ -7,10 +7,40 @@ module Smerp
7
7
  class QuotationItemDistribution < Ca::DataStore::Ar::Model
8
8
  include TR::CondUtils
9
9
 
10
+ include TeLogger::TeLogHelper
11
+ teLogger_tag :qiDist
12
+
10
13
  belongs_to :quotation_item
11
14
  belongs_to :distributed_quotation_item, class_name: 'QuotationItem'
12
15
 
13
16
 
17
+ around_destroy :update_link_total
18
+
19
+ def update_link_total
20
+
21
+ src = self.quotation_item
22
+ dest = self.distributed_quotation_item
23
+ cal = YAML.load(self.distribution_calculations)
24
+
25
+ ##
26
+ # Deleted
27
+ ##
28
+ yield
29
+
30
+
31
+ teLogger.debug "Result : #{cal.result}"
32
+ distVal = cal.result[Smerp::Quotation::DistributionCalculator::DistributedAmount]
33
+
34
+ #teLogger.debug "Source : #{src.inspect}"
35
+ #src.consolidated_line_total += distVal
36
+ #src.save
37
+
38
+ teLogger.debug "Dest : #{dest.inspect}"
39
+ dest.consolidated_line_total -= distVal
40
+ dest.save
41
+
42
+ end
43
+
14
44
  #after_save :distribute
15
45
 
16
46
  #def distribute
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Smerp
4
4
  module Quotation
5
- VERSION = "0.2.3"
5
+ VERSION = "0.2.4"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smerp-quotation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian