File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -174,6 +174,10 @@ invoice.add_line_item do |line_item|
174174 # Clear all taxes
175175 # line_item.clear_taxes
176176
177+ # Add discounts
178+ line_item.discount_rate = 0.1 # 10% discount
179+ # line_item.discount = 15.0 # Fixed discount amount (takes priority over discount_rate)
180+
177181 # Add surcharges (naknade)
178182 line_item.add_surcharge(name: " Refundable deposit" , amount: 2.50 )
179183 line_item.add_surcharge do |surcharge |
@@ -188,11 +192,11 @@ invoice.add_line_item do |line_item|
188192 # line_item.clear_surcharges
189193end
190194
191- invoice.subtotal # => BigDecimal("200 .00")
192- invoice.tax # => BigDecimal("62.50")
195+ invoice.subtotal # => BigDecimal("180 .00") # 200.00 - 20.00 discount (10% )
196+ invoice.tax # => BigDecimal("59.00") # Tax calculated on discounted amount: 180.00 * 0.25 + 180.00 * 0.05
193197invoice.surcharge # => BigDecimal("3.75")
194- invoice.total # => BigDecimal("266.25 ")
195- invoice.total_cents # => 26625
198+ invoice.total # => BigDecimal("242.75 ")
199+ invoice.total_cents # => 24275
196200
197201invoice.number # => "64/HQ1/123"
198202
You can’t perform that action at this time.
0 commit comments