smerp-quotation 0.2.0 → 0.2.1

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: 9b31b97876363a1e89cf5bfd87e092f304d3a0d873d222a28ac9669473ed53c9
4
- data.tar.gz: 758df4aba6b9319126334fd2d8b7af834bd1f582ef77c5bb14ab8180008c5c09
3
+ metadata.gz: c2cb34cdeb9ad8ef119a801316aa9d874cbd0565f8ad246e91a5311fcae2a8af
4
+ data.tar.gz: 944120a5dca8e07e6b1b3f9dcf7724e32c5ca586ffe18fc84bb6a394bf59c4ed
5
5
  SHA512:
6
- metadata.gz: 0a465d9ce3167cb1d782f9fbdf8d277be35fe554238da074c431b2235c7a446522ccec29d4a4afe3d8555c0a22999ad7282e5aefcc969ab7e1900ddb684af6ab
7
- data.tar.gz: c4b6557dc0e7fe67c3daa382d0a147e968f5b4dab7e5a3a8a9fbaa53dff2bb5e6aeed47a74d5ee15a2db181a8861e4637b64983937a1811f7074135d805bccd4
6
+ metadata.gz: c9b447f31c94f7fe6ec928556f2e92a85af3569eebc459a0b5efee5041ecab2c70ba8a1c34bc8be9b832839698b0840e1d83bd3f5e0e39ec81ec1236b2cef9fe
7
+ data.tar.gz: 1f08fe39a26bd4f74a6598ff4a2d699acd3eee5d431e9e4b9923f418a766cf57516e9378f9f062f1a88d319ca8e9f743695392092845d1417bbfa6286115c450
data/.release_history.yml CHANGED
@@ -2,3 +2,5 @@
2
2
  smerp-quotation:
3
3
  - :version: 0.1.0
4
4
  :timestamp: 1664514502.3722005
5
+ - :version: 0.2.0
6
+ :timestamp: 1664783292.2046304
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- smerp-quotation (0.2.0)
4
+ smerp-quotation (0.2.1)
5
5
  acts_as_list
6
6
  acts_as_tree
7
7
  ca-data_store
@@ -148,7 +148,7 @@ GEM
148
148
  tzinfo (2.0.5)
149
149
  concurrent-ruby (~> 1.0)
150
150
  wisper (2.0.1)
151
- zeitwerk (2.6.0)
151
+ zeitwerk (2.6.1)
152
152
 
153
153
  PLATFORMS
154
154
  x86_64-linux
@@ -173,6 +173,7 @@ module Smerp
173
173
  if self.parent.quantity > 0
174
174
  # for children item that has a parent
175
175
  # update parent line_total
176
+ self.parent.line_total = self.parent.children.sum(:line_total)
176
177
  self.parent.consolidated_line_total = self.parent.children.sum(:consolidated_line_total)
177
178
 
178
179
  # update unit_price since line_total is sum of children's line_total
@@ -207,7 +208,7 @@ module Smerp
207
208
  # calculate if I'm the source to be embedded into other items
208
209
  recalculate_total_to_destination_quotation_items
209
210
 
210
- self.quotation.total = self.quotation.quotation_items.where(["parent_id is null"]).sum(:consolidated_line_total)
211
+ self.quotation.total = self.quotation.quotation_items.where(["parent_id is null"]).sum(:line_total)
211
212
  self.quotation.total_discount = self.quotation.quotation_items.where(["parent_id is null"]).sum(:discount)
212
213
  self.quotation.total_after_discount = self.quotation.quotation_items.where(["parent_id is null"]).sum(:line_total_after_discount)
213
214
  self.quotation.total_tax = self.quotation.quotation_items.where(["parent_id is null"]).sum(:tax)
@@ -224,7 +225,7 @@ module Smerp
224
225
  self.line_total = self.quantity * self.unit_price
225
226
  # reset consolidated total and calculate again
226
227
  self.consolidated_line_total = self.line_total
227
- calculate_incoming_distribution
228
+ recalculate_total_from_source_quotation_items
228
229
  end
229
230
 
230
231
  if self.discount_changed?
@@ -233,6 +234,16 @@ module Smerp
233
234
 
234
235
  end
235
236
 
237
+ def is_consolidation_destination_item?
238
+ self.source_quotation_items_link.reload
239
+ self.source_quotation_items_link.count > 0
240
+ end
241
+
242
+ def is_consolidation_source_item?
243
+ self.quotation_item_distributions.reload
244
+ self.quotation_item_distributions.count > 0
245
+ end
246
+
236
247
  # recalculate becauase destionation line_total changed
237
248
  # triggered before_save
238
249
  def recalculate_total_from_source_quotation_items
@@ -251,7 +262,11 @@ module Smerp
251
262
 
252
263
  teLogger.debug "Distribution calculation : #{cal.result}"
253
264
 
254
- ttl += cal.result[Smerp::Quotation::DistributionCalculator::DistributedAmount]
265
+ distAmt = cal.result[Smerp::Quotation::DistributionCalculator::DistributedAmount]
266
+
267
+ ttl += distAmt
268
+
269
+ srcItm.consolidated_line_total -= distAmt
255
270
 
256
271
  iqi.distribution_calculations = YAML.dump(cal.for_storage)
257
272
  iqi.save
@@ -259,6 +274,10 @@ module Smerp
259
274
  end
260
275
 
261
276
  self.consolidated_line_total = ttl
277
+ # if there is discount calculator defined
278
+ # this value shall be reset
279
+ # If there is none, this value should be same as consolidated_line_total
280
+ self.line_total_after_discount = ttl
262
281
 
263
282
  end
264
283
 
@@ -546,10 +565,10 @@ module Smerp
546
565
 
547
566
 
548
567
  def distribute_to(distTo, val)
549
-
568
+
550
569
  dist = QuotationItemDistribution.new
551
570
  dist.quotation_item = self
552
- dist.distributed_quotation_item_id = distTo.quotation_item.id
571
+ dist.distributed_quotation_item = distTo
553
572
  cal = Smerp::Quotation::DistributionCalculator.new(val)
554
573
  cal.input_field = :consolidated_line_total
555
574
  dist.distribution_calculations = YAML.dump(cal.for_storage)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Smerp
4
4
  module Quotation
5
- VERSION = "0.2.0"
5
+ VERSION = "0.2.1"
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.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian