smerp-quotation 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.release_history.yml +2 -0
- data/Gemfile.lock +2 -2
- data/lib/smerp/quotation/ar_model/quotation_item.rb +24 -5
- data/lib/smerp/quotation/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2cb34cdeb9ad8ef119a801316aa9d874cbd0565f8ad246e91a5311fcae2a8af
|
4
|
+
data.tar.gz: 944120a5dca8e07e6b1b3f9dcf7724e32c5ca586ffe18fc84bb6a394bf59c4ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9b447f31c94f7fe6ec928556f2e92a85af3569eebc459a0b5efee5041ecab2c70ba8a1c34bc8be9b832839698b0840e1d83bd3f5e0e39ec81ec1236b2cef9fe
|
7
|
+
data.tar.gz: 1f08fe39a26bd4f74a6598ff4a2d699acd3eee5d431e9e4b9923f418a766cf57516e9378f9f062f1a88d319ca8e9f743695392092845d1417bbfa6286115c450
|
data/.release_history.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
smerp-quotation (0.2.
|
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.
|
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(:
|
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
|
-
|
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
|
-
|
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.
|
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)
|