1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-26 20:54:21 +01:00

refactoring generate invoice settlement info

This commit is contained in:
Peng DU 2016-07-19 13:16:49 +02:00
parent 85153c201e
commit 9befe091b8

View File

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