smerp-quotation 0.1.0 → 0.2.1

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: f8b69d99e96beaa0d81e513065d9671cfafa11b57c91ff1d5e1ba782fe380c35
4
- data.tar.gz: b85cba78f3e87c7edb171dc3da9120613b1464ee94f9fe4c6e87612cd1137052
3
+ metadata.gz: c2cb34cdeb9ad8ef119a801316aa9d874cbd0565f8ad246e91a5311fcae2a8af
4
+ data.tar.gz: 944120a5dca8e07e6b1b3f9dcf7724e32c5ca586ffe18fc84bb6a394bf59c4ed
5
5
  SHA512:
6
- metadata.gz: f9e49a67d5fabd72016b5181cba6882965a94cf96a5a32df959ddd2422be90c0a5e1ed5ad352342b204cec9878d3731eefff8330aee3ced28140e566a7e39234
7
- data.tar.gz: '081ba3ccd3a13a92f0e4f2d51646454704e2c2b51bc4f9f9001ebc26ac676720351083e4c23d24b67859fc886d13a0321d3733ef1f77a3dbeacdd43cd934a523'
6
+ metadata.gz: c9b447f31c94f7fe6ec928556f2e92a85af3569eebc459a0b5efee5041ecab2c70ba8a1c34bc8be9b832839698b0840e1d83bd3f5e0e39ec81ec1236b2cef9fe
7
+ data.tar.gz: 1f08fe39a26bd4f74a6598ff4a2d699acd3eee5d431e9e4b9923f418a766cf57516e9378f9f062f1a88d319ca8e9f743695392092845d1417bbfa6286115c450
@@ -0,0 +1,6 @@
1
+ ---
2
+ smerp-quotation:
3
+ - :version: 0.1.0
4
+ :timestamp: 1664514502.3722005
5
+ - :version: 0.2.0
6
+ :timestamp: 1664783292.2046304
data/Gemfile.lock CHANGED
@@ -1,11 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- smerp-quotation (0.1.0)
4
+ smerp-quotation (0.2.1)
5
5
  acts_as_list
6
6
  acts_as_tree
7
7
  ca-data_store
8
8
  ca-data_store-ar
9
+ smerp-common
9
10
  state_machines-activerecord
10
11
  teLogger
11
12
  toolrack
@@ -13,25 +14,25 @@ PATH
13
14
  GEM
14
15
  remote: https://rubygems.org/
15
16
  specs:
16
- actionpack (7.0.3.1)
17
- actionview (= 7.0.3.1)
18
- activesupport (= 7.0.3.1)
17
+ actionpack (7.0.4)
18
+ actionview (= 7.0.4)
19
+ activesupport (= 7.0.4)
19
20
  rack (~> 2.0, >= 2.2.0)
20
21
  rack-test (>= 0.6.3)
21
22
  rails-dom-testing (~> 2.0)
22
23
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
23
- actionview (7.0.3.1)
24
- activesupport (= 7.0.3.1)
24
+ actionview (7.0.4)
25
+ activesupport (= 7.0.4)
25
26
  builder (~> 3.1)
26
27
  erubi (~> 1.4)
27
28
  rails-dom-testing (~> 2.0)
28
29
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
29
- activemodel (7.0.3.1)
30
- activesupport (= 7.0.3.1)
31
- activerecord (7.0.3.1)
32
- activemodel (= 7.0.3.1)
33
- activesupport (= 7.0.3.1)
34
- activesupport (7.0.3.1)
30
+ activemodel (7.0.4)
31
+ activesupport (= 7.0.4)
32
+ activerecord (7.0.4)
33
+ activemodel (= 7.0.4)
34
+ activesupport (= 7.0.4)
35
+ activesupport (7.0.4)
35
36
  concurrent-ruby (~> 1.0, >= 1.0.2)
36
37
  i18n (>= 1.6, < 2)
37
38
  minitest (>= 5.1)
@@ -45,7 +46,7 @@ GEM
45
46
  ca-data_store (0.1.0)
46
47
  teLogger
47
48
  toolrack
48
- ca-data_store-ar (0.1.0)
49
+ ca-data_store-ar (0.1.1)
49
50
  activerecord
50
51
  activesupport
51
52
  ca-data_store
@@ -94,9 +95,9 @@ GEM
94
95
  nokogiri (>= 1.6)
95
96
  rails-html-sanitizer (1.4.3)
96
97
  loofah (~> 2.3)
97
- railties (7.0.3.1)
98
- actionpack (= 7.0.3.1)
99
- activesupport (= 7.0.3.1)
98
+ railties (7.0.4)
99
+ actionpack (= 7.0.4)
100
+ activesupport (= 7.0.4)
100
101
  method_source
101
102
  rake (>= 12.2)
102
103
  thor (~> 1.0)
@@ -108,14 +109,17 @@ GEM
108
109
  rspec-mocks (~> 3.11.0)
109
110
  rspec-core (3.11.0)
110
111
  rspec-support (~> 3.11.0)
111
- rspec-expectations (3.11.0)
112
+ rspec-expectations (3.11.1)
112
113
  diff-lcs (>= 1.2.0, < 2.0)
113
114
  rspec-support (~> 3.11.0)
114
115
  rspec-mocks (3.11.1)
115
116
  diff-lcs (>= 1.2.0, < 2.0)
116
117
  rspec-support (~> 3.11.0)
117
- rspec-support (3.11.0)
118
- sqlite3 (1.4.4)
118
+ rspec-support (3.11.1)
119
+ smerp-common (0.1.0)
120
+ teLogger
121
+ toolrack
122
+ sqlite3 (1.5.1-x86_64-linux)
119
123
  standalone_migrations (7.1.0)
120
124
  activerecord (>= 4.2.7, < 7.1.0, != 5.2.3.rc1, != 5.2.3)
121
125
  railties (>= 4.2.7, < 7.1.0, != 5.2.3.rc1, != 5.2.3)
@@ -144,7 +148,7 @@ GEM
144
148
  tzinfo (2.0.5)
145
149
  concurrent-ruby (~> 1.0)
146
150
  wisper (2.0.1)
147
- zeitwerk (2.6.0)
151
+ zeitwerk (2.6.1)
148
152
 
149
153
  PLATFORMS
150
154
  x86_64-linux
@@ -44,6 +44,9 @@ class CreateQuotationItems < ActiveRecord::Migration[7.0]
44
44
 
45
45
  # value stored for display
46
46
  t.decimal :line_total, default: 0.0, precision: 25, scale: 2
47
+
48
+ # total including the distributed items included
49
+ t.decimal :consolidated_line_total, default: 0.0, precision: 25, scale: 2
47
50
 
48
51
  t.decimal :discount, precision: 25, scale: 2, default: 0.0
49
52
  # yaml hash structure indicate the discount is
@@ -0,0 +1,22 @@
1
+
2
+ class CreateQuotationItemDistribution < ActiveRecord::Migration[7.0]
3
+ def change
4
+ create_table :quotation_item_distributions do |t|
5
+
6
+ t.string :quotation_item_id
7
+ t.string :distributed_quotation_item_id
8
+ t.text :distribution_calculations
9
+
10
+ t.decimal :distributed_line_total, default: 0.0
11
+
12
+ t.decimal :distributed_discount, default: 0.0
13
+ t.decimal :distributed_line_total_after_discount, default: 0.0
14
+
15
+ t.decimal :distributed_tax, default: 0.0
16
+ t.decimal :distributed_line_total_with_tax, default: 0.0
17
+
18
+ t.timestamps
19
+
20
+ end
21
+ end
22
+ end
@@ -22,23 +22,40 @@ module Smerp
22
22
  # polymorphic on model of products / resources
23
23
  # has_many :quotation_items, as: :quotable
24
24
 
25
+ # sel-reflecting relationship
26
+ # This item splited into how many items?
27
+ has_many :quotation_item_distributions
28
+ has_many :destination_quotation_items, through: :quotation_item_distributions, source: :distributed_quotation_item
29
+
30
+ # This item is included distribution from which item?
31
+ has_many :source_quotation_items_link, class_name: "QuotationItemDistribution", foreign_key: "distributed_quotation_item_id"
32
+ has_many :source_quotation_items, through: :source_quotation_items_link, source: :quotation_item
33
+
25
34
  belongs_to :quotation_item_group, optional: true
26
35
 
27
36
  before_save :update_total
28
37
  after_save :update_group_total, :update_quotation_total
29
38
 
30
39
  before_destroy :update_total
31
- after_destroy :update_group_total, :update_quotation_total
40
+ after_destroy :update_group_total, :update_quotation_total, :remove_total_from_destination_quotation_items
32
41
 
33
42
  def update_total
34
43
 
35
- if children.length == 0
44
+ if self.children.length == 0
36
45
  self.line_total = self.quantity * self.unit_price if self.quantity_changed? or self.unit_price_changed?
37
46
  self.line_total_after_discount = self.line_total
38
47
  self.line_total_with_tax = self.line_total
48
+
49
+ #teLogger.debug "sync consolidated #{self.inspect} to line_total #{self.line_total.to_i}"
50
+ self.consolidated_line_total = self.line_total if self.new_record?
51
+ #teLogger.debug "sync consolidated #{self.inspect} to line_total #{self.line_total.to_i}"
52
+
53
+ else
54
+ #teLogger.debug "#{self.inspect} has children : #{self.children}"
39
55
  end
40
56
 
41
57
  if self.quantity_changed?
58
+ teLogger.debug "Quantity changed"
42
59
  # Change unit_price for record that has children
43
60
  # since unit_price is 'derived' from children's line_total
44
61
  if self.quantity > 0
@@ -49,6 +66,17 @@ module Smerp
49
66
  end
50
67
  end
51
68
 
69
+ #teLogger.debug "Before recalculate : #{self.inspect}"
70
+ ## Calculate consolidated line total
71
+ # Calculate line total of each item that push to this parent item
72
+ if not self.new_record?
73
+ recalculate_total_from_source_quotation_items
74
+ end
75
+ #teLogger.debug "After recalculate : #{self.inspect}"
76
+
77
+ #
78
+ # Start trigger defined calculators
79
+ #
52
80
  res = { local: [], quotation: [] }
53
81
  extCals = { local: [], quotation: [] }
54
82
  if not_empty?(self.extended_calculators)
@@ -112,7 +140,9 @@ module Smerp
112
140
  }
113
141
 
114
142
  self.extended_calculators = YAML.dump(res)
143
+ ## Calculator execution completed
115
144
 
145
+ teLogger.debug "before save done : #{self.inspect}"
116
146
  end
117
147
 
118
148
  def update_group_total
@@ -120,7 +150,7 @@ module Smerp
120
150
  grp = self.quotation_item_group
121
151
  if not grp.nil?
122
152
  # update total
123
- grp.group_total = grp.children.sum(:group_total) + grp.quotation_items.sum(:line_total)
153
+ grp.group_total = grp.children.sum(:group_total) + grp.quotation_items.sum(:consolidated_line_total)
124
154
  grp.group_discount = grp.children.sum(:group_discount) + grp.quotation_items.sum(:discount)
125
155
  grp.group_tax = grp.children.sum(:group_tax) + grp.quotation_items.sum(:tax)
126
156
  grp.save
@@ -144,20 +174,22 @@ module Smerp
144
174
  # for children item that has a parent
145
175
  # update parent line_total
146
176
  self.parent.line_total = self.parent.children.sum(:line_total)
177
+ self.parent.consolidated_line_total = self.parent.children.sum(:consolidated_line_total)
147
178
 
148
179
  # update unit_price since line_total is sum of children's line_total
149
- self.parent.unit_price = self.parent.line_total / self.parent.quantity
180
+ self.parent.unit_price = self.parent.consolidated_line_total / self.parent.quantity
150
181
 
151
182
  self.parent.discount = self.parent.children.sum(:discount)
152
183
  self.parent.line_total_after_discount = self.parent.children.sum(:line_total_after_discount)
153
184
  self.parent.tax = self.parent.children.sum(:tax)
154
185
  self.parent.line_total_with_tax = self.parent.children.sum(:line_total_with_tax)
155
186
 
156
- teLogger.debug "After update from children : #{self.parent.inspect}"
187
+ #teLogger.debug "After update from children : #{self.parent.inspect}"
157
188
 
158
189
  else
159
190
 
160
191
  self.parent.line_total = 0.0
192
+ self.parent.consolidated_line_total = 0.0
161
193
  self.parent.unit_price = 0.0
162
194
  self.parent.discount = 0.0
163
195
  self.parent.line_total_after_discount = 0.0
@@ -171,7 +203,10 @@ module Smerp
171
203
  teLogger.debug "Parent #{self.parent.inspect} is NOT children linked. Skipping children update to parent."
172
204
  end
173
205
 
174
- end
206
+ end # if parent exist
207
+
208
+ # calculate if I'm the source to be embedded into other items
209
+ recalculate_total_to_destination_quotation_items
175
210
 
176
211
  self.quotation.total = self.quotation.quotation_items.where(["parent_id is null"]).sum(:line_total)
177
212
  self.quotation.total_discount = self.quotation.quotation_items.where(["parent_id is null"]).sum(:discount)
@@ -180,6 +215,7 @@ module Smerp
180
215
  self.quotation.total_with_tax = self.quotation.quotation_items.where(["parent_id is null"]).sum(:line_total_with_tax)
181
216
 
182
217
  self.quotation.save
218
+
183
219
  end
184
220
 
185
221
 
@@ -187,6 +223,9 @@ module Smerp
187
223
 
188
224
  if self.quantity_changed? or self.unit_price_changed?
189
225
  self.line_total = self.quantity * self.unit_price
226
+ # reset consolidated total and calculate again
227
+ self.consolidated_line_total = self.line_total
228
+ recalculate_total_from_source_quotation_items
190
229
  end
191
230
 
192
231
  if self.discount_changed?
@@ -195,24 +234,139 @@ module Smerp
195
234
 
196
235
  end
197
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
+
247
+ # recalculate becauase destionation line_total changed
248
+ # triggered before_save
249
+ def recalculate_total_from_source_quotation_items
250
+
251
+ #self.reload
252
+ ttl = self.line_total
253
+ self.source_quotation_items_link.each do |iqi|
254
+
255
+ srcItm = iqi.quotation_item
256
+
257
+ next if srcItm.nil?
258
+
259
+ #teLogger.debug "Calculating using source item : #{srcItm.inspect}"
260
+ cal = YAML.load(iqi.distribution_calculations)
261
+ cal.calculate(srcItm)
262
+
263
+ teLogger.debug "Distribution calculation : #{cal.result}"
264
+
265
+ distAmt = cal.result[Smerp::Quotation::DistributionCalculator::DistributedAmount]
266
+
267
+ ttl += distAmt
268
+
269
+ srcItm.consolidated_line_total -= distAmt
270
+
271
+ iqi.distribution_calculations = YAML.dump(cal.for_storage)
272
+ iqi.save
273
+
274
+ end
275
+
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
281
+
282
+ end
283
+
284
+ # recalculate because the source item line_total changed
285
+ # trigger after_save
286
+ def recalculate_total_to_destination_quotation_items
287
+
288
+ #teLogger.debug "before get in : #{self.inspect}"
289
+ self.quotation_item_distributions.each do |qid|
290
+
291
+ citm = qid.distributed_quotation_item
292
+
293
+ # for some reasons when one of the item is deleted first
294
+ # but the connection is not reloaded.
295
+ # Reload before coming in doesn't really solve the issue
296
+ next if citm.nil?
297
+
298
+ #teLogger.debug "citm : #{citm.inspect}"
299
+ cal = YAML.load(qid.distribution_calculations)
300
+ # get the old figure
301
+ oldRes = cal.result.clone
302
+ teLogger.debug "oldRes : #{oldRes}"
303
+ # calculate base on
304
+ #teLogger.debug "Self is : #{self.inspect}"
305
+ cal.calculate(self)
306
+ newRes = cal.result
307
+ teLogger.debug "newRes : #{newRes}"
308
+
309
+ #teLogger.debug "citm before process : #{citm.consolidated_line_total}"
310
+ citm.consolidated_line_total = (citm.consolidated_line_total - oldRes[Smerp::Quotation::DistributionCalculator::DistributedAmount] + newRes[Smerp::Quotation::DistributionCalculator::DistributedAmount])
311
+ #teLogger.debug "citm after process : #{citm.consolidated_line_total}"
312
+
313
+ qid.distribution_calculations = YAML.dump(cal.for_storage)
314
+ qid.save
315
+
316
+ # trigger other calculations
317
+ citm.save
318
+
319
+ end
320
+
321
+ end
322
+
323
+ # item that is being distributed to other
324
+ # quotation items is being destroyed
325
+ # Remove those portion from each and every items
326
+ def remove_total_from_destination_quotation_items
327
+
328
+ self.quotation_item_distributions.each do |qid|
329
+
330
+ citm = qid.distributed_quotation_item
331
+
332
+ next if citm.nil?
333
+
334
+ cal = YAML.load(qid.distribution_calculations)
335
+ extRes = cal.result.clone
336
+
337
+ #teLogger.debug "before citm #{citm.inspect} / #{citm.consolidated_line_total}"
338
+ citm.consolidated_line_total = (citm.consolidated_line_total - extRes[Smerp::Quotation::DistributionCalculator::DistributedAmount])
339
+ #teLogger.debug "after deduction citm #{citm.inspect} / #{citm.consolidated_line_total}"
340
+
341
+ #teLogger.debug "qid : #{qid.inspect}"
342
+ qid.destroy
343
+
344
+ citm.source_quotation_items_link.reload
345
+
346
+ citm.save
347
+ #teLogger.debug "after citm #{citm.inspect} / #{citm.consolidated_line_total}"
348
+
349
+ end
350
+
351
+ end
352
+
353
+ def total_distributed
354
+
355
+ ttl = 0.0
356
+ self.quotation_item_distributions.each do |qid|
357
+ cal = YAML.load(qid.distribution_calculations)
358
+ ttl += cal.result[Smerp::Quotation::DistributionCalculator::DistributedAmount]
359
+ end
360
+
361
+ ttl
362
+
363
+ end
364
+
365
+ def balance_after_distribution
366
+ bal = self.line_total - self.total_distributed
367
+ { balance_amount: bal, balance_percentage: bal.percent_of(self.line_total) }
368
+ end
198
369
 
199
- #def children
200
- # if @_children.nil?
201
- # @_children = QuotationItem.where(["parent_id = ?",self.id])
202
- # end
203
- # @_children
204
- #end
205
-
206
- #def parent
207
- # if self.parent_id.nil?
208
- # nil
209
- # else
210
- # if @_parent.nil?
211
- # @_parent = QuotationItem.find(self.parent_id)
212
- # end
213
- # @_parent
214
- # end
215
- #end
216
370
 
217
371
  def break_children_link
218
372
 
@@ -410,6 +564,23 @@ module Smerp
410
564
  end
411
565
 
412
566
 
567
+ def distribute_to(distTo, val)
568
+
569
+ dist = QuotationItemDistribution.new
570
+ dist.quotation_item = self
571
+ dist.distributed_quotation_item = distTo
572
+ cal = Smerp::Quotation::DistributionCalculator.new(val)
573
+ cal.input_field = :consolidated_line_total
574
+ dist.distribution_calculations = YAML.dump(cal.for_storage)
575
+ dist.save
576
+
577
+ # trigger the calculator and distribution calculations
578
+ distTo.save
579
+ distTo.reload
580
+
581
+ end
582
+
583
+
413
584
  end
414
585
  end
415
586
  end
@@ -0,0 +1,31 @@
1
+
2
+
3
+ module Smerp
4
+ module Quotation
5
+ module ArModel
6
+
7
+ class QuotationItemDistribution < Ca::DataStore::Ar::Model
8
+ include TR::CondUtils
9
+
10
+ belongs_to :quotation_item
11
+ belongs_to :distributed_quotation_item, class_name: 'QuotationItem'
12
+
13
+
14
+ #after_save :distribute
15
+
16
+ #def distribute
17
+
18
+ # cal = YAML.load(self.distribution_calculators)
19
+ # cal.calculate(self.quotation_item)
20
+
21
+ # self.distributed_quotation_item.consolidated_line_total += cal.result[Smerp::Quotation::DistributionCalculator::DistributedValue]
22
+
23
+ # self.distributed_quotation_item.save
24
+
25
+ #end
26
+
27
+ end
28
+
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,73 @@
1
+
2
+
3
+
4
+ module Smerp
5
+ module Quotation
6
+ class DistributionCalculator
7
+ include ExtendedCalculator
8
+ include TR::CondUtils
9
+
10
+ include TeLogger::TeLogHelper
11
+ teLogger_tag :distributionCal
12
+
13
+ DistributedAmount = :distributed_amount
14
+ ValueWithDistribution = :value_with_distribution
15
+
16
+
17
+ def calculate(mdl)
18
+
19
+ srcVal = mdl.send(@input_field)
20
+ if not_empty?(srcVal)
21
+
22
+ srcVal = srcVal.to_f
23
+
24
+ res = { input: @input_field, input_value: srcVal }
25
+ case @params
26
+ when Smerp::Common::FinUtils::Percent
27
+ res[DistributedAmount] = srcVal * @params.rep_value
28
+ when Smerp::Common::FinUtils::RawValue
29
+ res[DistributedAmount] = @params.rep_value
30
+ else
31
+ res[DistributedAmount] = @params.to_f
32
+ end
33
+
34
+ res[ValueWithDistribution] = srcVal + res[DistributedAmount]
35
+
36
+ #if not_empty?(@output_field) and not outMdl.nil?
37
+
38
+ # case @output_field
39
+ # when Array
40
+ # @output_field.each do |of|
41
+ # of.each do |f, v|
42
+ # outMdl.send("#{f}=", res[v])
43
+ # end
44
+ # end
45
+ # when Hash
46
+ # @output_field.each do |f,v|
47
+ # outMdl.send("#{f}=", res[v])
48
+ # end
49
+ # when Symbol
50
+ # outMdl.send("#{@output_field}=", res[DistributedAmount])
51
+ # end
52
+
53
+ # res[:output] = @output_field
54
+ # res[:output_model] = outMdl
55
+ # outMdl.recalculate
56
+
57
+ #end # if @output_field not empty
58
+
59
+ @result = res
60
+
61
+ trigger_listener(:after_calculation, mdl)
62
+
63
+ teLogger.debug "Distribution calculation log : #{res}"
64
+
65
+ @result
66
+
67
+ end
68
+
69
+ end
70
+
71
+ end
72
+ end
73
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Smerp
4
4
  module Quotation
5
- VERSION = "0.1.0"
5
+ VERSION = "0.2.1"
6
6
  end
7
7
  end
data/schema.rb CHANGED
@@ -10,7 +10,20 @@
10
10
  #
11
11
  # It's strongly recommended that you check this file into your version control system.
12
12
 
13
- ActiveRecord::Schema[7.0].define(version: 20220922121503548314) do
13
+ ActiveRecord::Schema[7.0].define(version: 2022_09_30_231854) do
14
+ create_table "quotation_item_distributions", force: :cascade do |t|
15
+ t.string "quotation_item_id"
16
+ t.string "distributed_quotation_item_id"
17
+ t.text "distribution_calculations"
18
+ t.decimal "distributed_line_total", default: "0.0"
19
+ t.decimal "distributed_discount", default: "0.0"
20
+ t.decimal "distributed_line_total_after_discount", default: "0.0"
21
+ t.decimal "distributed_tax", default: "0.0"
22
+ t.decimal "distributed_line_total_with_tax", default: "0.0"
23
+ t.datetime "created_at", null: false
24
+ t.datetime "updated_at", null: false
25
+ end
26
+
14
27
  create_table "quotation_item_groups", force: :cascade do |t|
15
28
  t.string "name"
16
29
  t.string "quotation_id"
@@ -35,10 +48,11 @@ ActiveRecord::Schema[7.0].define(version: 20220922121503548314) do
35
48
  t.text "notes"
36
49
  t.integer "children_link", limit: 1, default: 1
37
50
  t.decimal "quantity", default: "0.0"
38
- t.string "unit", default: "unit(s)"
51
+ t.string "unit", default: "Unit(s)"
39
52
  t.decimal "unit_price", precision: 25, scale: 2, default: "0.0"
40
53
  t.string "price_currency"
41
54
  t.decimal "line_total", precision: 25, scale: 2, default: "0.0"
55
+ t.decimal "consolidated_line_total", precision: 25, scale: 2, default: "0.0"
42
56
  t.decimal "discount", precision: 25, scale: 2, default: "0.0"
43
57
  t.decimal "line_total_after_discount", precision: 25, scale: 2, default: "0.0"
44
58
  t.decimal "tax", default: "0.0"
@@ -37,6 +37,7 @@ Gem::Specification.new do |spec|
37
37
  spec.add_dependency 'acts_as_tree'
38
38
  spec.add_dependency 'acts_as_list'
39
39
 
40
+ spec.add_dependency 'smerp-common'
40
41
  spec.add_dependency 'ca-data_store'
41
42
  spec.add_dependency 'ca-data_store-ar'
42
43
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smerp-quotation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-30 00:00:00.000000000 Z
11
+ date: 2022-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: toolrack
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: smerp-common
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: ca-data_store
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -143,6 +157,7 @@ executables: []
143
157
  extensions: []
144
158
  extra_rdoc_files: []
145
159
  files:
160
+ - ".release_history.yml"
146
161
  - ".rspec"
147
162
  - Gemfile
148
163
  - Gemfile.lock
@@ -156,12 +171,15 @@ files:
156
171
  - db/migrate/20220901033007_create_quotation_items.rb
157
172
  - db/migrate/20220918121051_create_quotation_item_groups.rb
158
173
  - db/migrate/20220922121503_create_tax_category.rb
174
+ - db/migrate/20220930231854_create_quotation_item_distribution.rb
159
175
  - lib/smerp/quotation.rb
160
176
  - lib/smerp/quotation/ar_model/quotation.rb
161
177
  - lib/smerp/quotation/ar_model/quotation_item.rb
178
+ - lib/smerp/quotation/ar_model/quotation_item_distribution.rb
162
179
  - lib/smerp/quotation/ar_model/quotation_item_group.rb
163
180
  - lib/smerp/quotation/ar_model/tax_category.rb
164
181
  - lib/smerp/quotation/calculators/discount_calculator.rb
182
+ - lib/smerp/quotation/calculators/distribution_calculator.rb
165
183
  - lib/smerp/quotation/calculators/round_up_calculator.rb
166
184
  - lib/smerp/quotation/calculators/tax_calculator.rb
167
185
  - lib/smerp/quotation/extended_calculator.rb