diff --git a/app/pdfs/pdf/invoice.rb b/app/pdfs/pdf/invoice.rb index dfc1c699d..b7720dcd1 100644 --- a/app/pdfs/pdf/invoice.rb +++ b/app/pdfs/pdf/invoice.rb @@ -3,6 +3,7 @@ module PDF class Invoice < Prawn::Document require 'stringio' include ActionView::Helpers::NumberHelper + include ApplicationHelper def initialize(invoice) super(:margin => 70) @@ -147,15 +148,21 @@ module PDF if cp.type == 'percent_off' discount = total_calc * cp.percent_off / 100.0 elsif cp.type == 'amount_off' - discount = cp.amount_off + discount = cp.amount_off / 100.00 else raise InvalidCouponError end total_calc = total_calc - discount + # discount textual description + literal_discount = cp.percent_off + if cp.type == 'amount_off' + literal_discount = number_to_currency(discount) + end + # add a row for the coupon - data += [ [I18n.t('invoices.coupon_CODE_discount_of_PERCENT', CODE: cp.code, PERCENT: cp.percent_off), number_to_currency(-discount)] ] + data += [ [_t('invoices.coupon_CODE_discount_of_DISCOUNT', {CODE: cp.code, DISCOUNT: literal_discount, TYPE: cp.type}), number_to_currency(-discount)] ] end # total verification diff --git a/config/locales/en.yml b/config/locales/en.yml index cb4689a00..f30febc5e 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -87,7 +87,7 @@ en: one: "One %{NAME} ticket" other: "%{count} %{NAME} tickets" reservation_other: "Reservation (other)" - coupon_CODE_discount_of_PERCENT: "Coupon %{CODE}: discount of %{PERCENT}%" + coupon_CODE_discount_of_DISCOUNT: "Coupon {CODE}: discount of {DISCOUNT}{TYPE, select, percent_off{%} other{}}" # messageFormat interpolation total_including_all_taxes: "Total incl. all taxes" including_VAT_RATE: "Including VAT %{RATE}%" including_total_excluding_taxes: "Including Total excl. taxes" diff --git a/config/locales/fr.yml b/config/locales/fr.yml index bef046965..68bb7179c 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -87,7 +87,7 @@ fr: one: "Une place %{NAME}" other: "%{count} places %{NAME}" reservation_other: "Réservation (autre)" - coupon_CODE_discount_of_PERCENT: "Code %{CODE} : remise de %{PERCENT} %" + coupon_CODE_discount_of_DISCOUNT: "Code {CODE} : remise de {DISCOUNT} {TYPE, select, percent_off{%} other{}}" # messageFormat interpolation total_including_all_taxes: "Total TTC" including_VAT_RATE: "Dont TVA %{RATE}%" including_total_excluding_taxes: "Dont total HT" diff --git a/config/locales/mails.fr.yml b/config/locales/mails.fr.yml index 14d1ee941..a34aff9c6 100644 --- a/config/locales/mails.fr.yml +++ b/config/locales/mails.fr.yml @@ -279,7 +279,7 @@ fr: body: enjoy_a_discount_of_PERCENT_with_code_CODE: "Bénéficiez d'une remise de %{PERCENT} % sur tout le site en utilisant le code promo %{CODE}." enjoy_a_discount_of_AMOUNT_with_code_CODE: "Bénéficiez d'une remise de %{AMOUNT} sur tout le site en utilisant le code promo %{CODE}." - this_coupon_is_valid_USAGE_times_until_DATE_for_all_your_purchases: "Ce code promo est valable {USAGE, plural, =1{une seule fois} other{plusieurs fois}} : pour tous vos achats {TYPE, select, amount_off{dont le montant est au moins de celui du code promo} other{}}, dès maintenant {DATE, select, NO-DATE{et sans limitation de durée} other{et jusqu'au {DATE}}}." + this_coupon_is_valid_USAGE_times_until_DATE_for_all_your_purchases: "Ce code promo est valable {USAGE, plural, =1{une seule fois} other{plusieurs fois}} : pour tous vos achats {TYPE, select, amount_off{dont le montant est au moins égal à celui du code promo} other{}}, dès maintenant {DATE, select, NO-DATE{et sans limitation de durée} other{et jusqu'au {DATE}}}." shared: hello: "Bonjour %{user_name}"