From 1e0d809db9e6d5a28d670da3be68e39e69c06dbc Mon Sep 17 00:00:00 2001 From: Sylvain Date: Thu, 11 Aug 2016 13:44:42 +0200 Subject: [PATCH] handle coupon in refunds --- app/models/invoice.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/models/invoice.rb b/app/models/invoice.rb index 3cd7c92cb..d51533a77 100644 --- a/app/models/invoice.rb +++ b/app/models/invoice.rb @@ -147,6 +147,11 @@ class Invoice < ActiveRecord::Base avoir.total += avoir_ii.amount end end + # handle coupon + unless avoir.coupon_id.nil? + discount = avoir.total * avoir.coupon.percent_off / 100 + avoir.total -= discount + end avoir end