diff --git a/app/pdfs/pdf/invoice.rb b/app/pdfs/pdf/invoice.rb index 4a2ec3d4f..f35a9c07e 100644 --- a/app/pdfs/pdf/invoice.rb +++ b/app/pdfs/pdf/invoice.rb @@ -185,10 +185,6 @@ module PDF # payment details move_down 20 - if invoice.wallet_amount - wallet_amount = invoice.wallet_amount / 100.0 - total = total - wallet_amount - end if invoice.is_a?(Avoir) payment_verbose = I18n.t('invoices.refund_on_DATE', DATE:I18n.l(invoice.avoir_date.to_date))+' ' case invoice.avoir_mode @@ -207,7 +203,14 @@ module PDF else puts "ERROR : specified refunding method (#{payment_verbose}) is unknown" end + payment_verbose += ' '+I18n.t('invoices.for_an_amount_of_AMOUNT', AMOUNT: number_to_currency(total)) + else + if invoice.wallet_amount + wallet_amount = invoice.wallet_amount / 100.0 + total = total - wallet_amount + end + if invoice.stp_invoice_id payment_verbose = I18n.t('invoices.settlement_by_debit_card') else @@ -216,18 +219,17 @@ module PDF if total == 0 and wallet_amount payment_verbose = I18n.t('invoices.settlement_by_wallet') end - end - unless invoice.is_a?(Avoir) + payment_verbose += ' '+I18n.t('invoices.on_DATE_at_TIME', DATE: I18n.l(invoice.created_at.to_date), TIME:I18n.l(invoice.created_at, format: :hour_minute)) - end - unless invoice.is_a?(Avoir) and invoice.avoir_mode == 'none' - payment_verbose += ' '+I18n.t('invoices.for_an_amount_of_AMOUNT', AMOUNT: number_to_currency(total)) if invoice.avoir_mode != 'none' if total > 0 - end - if invoice.wallet_amount - if total > 0 - payment_verbose += ' '+I18n.t('invoices.and') + ' ' + I18n.t('invoices.by_wallet') + ' ' + I18n.t('invoices.for_an_amount_of_AMOUNT', AMOUNT: number_to_currency(wallet_amount)) - else - payment_verbose += ' '+I18n.t('invoices.for_an_amount_of_AMOUNT', AMOUNT: number_to_currency(wallet_amount)) + if total > 0 or !invoice.wallet_amount + payment_verbose += ' '+I18n.t('invoices.for_an_amount_of_AMOUNT', AMOUNT: number_to_currency(total)) + end + if invoice.wallet_amount + if total > 0 + payment_verbose += ' '+I18n.t('invoices.and') + ' ' + I18n.t('invoices.by_wallet') + ' ' + I18n.t('invoices.for_an_amount_of_AMOUNT', AMOUNT: number_to_currency(wallet_amount)) + else + payment_verbose += ' '+I18n.t('invoices.for_an_amount_of_AMOUNT', AMOUNT: number_to_currency(wallet_amount)) + end end end text payment_verbose