File tree Expand file tree Collapse file tree 1 file changed +9
-11
lines changed
rails_application/app/processes/processes Expand file tree Collapse file tree 1 file changed +9
-11
lines changed Original file line number Diff line number Diff line change @@ -108,17 +108,15 @@ def placed?
108108 end
109109
110110 def apply_discounts_to_lines
111- total_discount_percentage = self.total_discount_percentage
112- final_discount_percentage = [total_discount_percentage, 100].min
113- discount_multiplier = (1 - final_discount_percentage / 100.0)
114-
115- updated_lines = lines.map do |line|
116- base_price = line.fetch(:base_price)
117- discounted_price = base_price * discount_multiplier
118- line.merge(price: discounted_price)
119- end
120-
121- with(lines: updated_lines)
111+ with(lines: lines.map { |line| apply_discount_to_line(line) })
112+ end
113+
114+ def apply_discount_to_line(line)
115+ line.merge(price: line.fetch(:base_price) * discount_multiplier)
116+ end
117+
118+ def discount_multiplier
119+ 1 - (final_discount_percentage / 100.0)
122120 end
123121
124122 def sub_amounts_total
You can’t perform that action at this time.
0 commit comments