1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-30 19:52:20 +01:00

fix pdf invoice generation with cash coupon

This commit is contained in:
Sylvain 2016-11-28 09:57:09 +01:00
parent 3ce41f0c5c
commit f0e11cf718
4 changed files with 12 additions and 5 deletions

View File

@ -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

View File

@ -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"

View File

@ -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"

View File

@ -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}"