1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-29 18:52:22 +01:00

show pay by wallet in invoice

This commit is contained in:
Peng DU 2016-07-18 19:29:21 +02:00
parent 773c1adf4a
commit f2010e752d
7 changed files with 28 additions and 2 deletions

View File

@ -365,6 +365,7 @@ class Reservation < ActiveRecord::Base
if @wallet_amount_debit.present? and @wallet_amount_debit != 0
amount = @wallet_amount_debit / 100.0
WalletService.new(user: user, wallet: user.wallet).debit(amount, self)
self.invoice.update_columns(wallet_amount: @wallet_amount_debit)
end
end
end

View File

@ -235,6 +235,7 @@ class Subscription < ActiveRecord::Base
if @wallet_amount_debit.present? and @wallet_amount_debit != 0
amount = @wallet_amount_debit / 100.0
WalletService.new(user: user, wallet: user.wallet).debit(amount, self)
invoices.order(created_at: :ASC).last.update_columns(wallet_amount: @wallet_amount_debit)
end
end
end

View File

@ -185,6 +185,10 @@ 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
@ -209,12 +213,22 @@ module PDF
else
payment_verbose = I18n.t('invoices.settlement_done_at_the_reception')
end
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'
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))
end
end
text payment_verbose

View File

@ -100,12 +100,14 @@ en:
by_wallet: "by wallet"
settlement_by_debit_card: "Settlement by debit card"
settlement_done_at_the_reception: "Settlement done at the reception"
settlement_by_wallet: "Settlement by wallet"
on_DATE_at_TIME: "on %{DATE} at %{TIME},"
for_an_amount_of_AMOUNT: "for an amount of %{AMOUNT}"
on_DATE_from_START_to_END: "On %{DATE} from %{START} to %{END}" # eg: on feb. 7 from 7AM to 9AM
from_STARTDATE_to_ENDDATE_from_STARTTIME_to_ENDTIME: "From %{STARTDATE} to %{ENDDATE}, from %{STARTTIME} to %{ENDTIME}" # eg: from feb. 7 to feb. 10, from 6PM to 10PM
subscription_of_NAME_for_DURATION_starting_from_DATE: "Subscription of %{NAME} for %{DURATION} starting from %{DATE}"
subscription_of_NAME_extended_starting_from_STARTDATE_until_ENDDATE: "Subscription of %{NAME} extended (Free days) starting from %{STARTDATE} until %{ENDDATE}"
and: 'and'
trainings:
# training availabilities

View File

@ -100,12 +100,14 @@ fr:
no_refund: "Pas de remboursement"
settlement_by_debit_card: "Règlement effectué par carte bancaire"
settlement_done_at_the_reception: "Règlement effectué à l'accueil"
settlement_by_wallet: "Règlement effectué par porte-monnaie"
on_DATE_at_TIME: "le %{DATE} à %{TIME},"
for_an_amount_of_AMOUNT: "pour un montant de %{AMOUNT}"
on_DATE_from_START_to_END: "Le %{DATE} de %{START} à %{END}" # eg: on feb. 7 from 7AM to 9AM
from_STARTDATE_to_ENDDATE_from_STARTTIME_to_ENDTIME: "Du %{STARTDATE} au %{ENDDATE}, de %{STARTTIME} à %{ENDTIME}" # eg: from feb. 7 to feb. 10, from 6PM to 10PM
subscription_of_NAME_for_DURATION_starting_from_DATE: "Abonnement de %{NAME} pour %{DURATION} à compter du %{DATE}"
subscription_of_NAME_extended_starting_from_STARTDATE_until_ENDDATE: "Prolongement Abonnement (Jours gratuits) de %{NAME} à compter du %{STARTDATE} jusqu'au %{ENDDATE}"
and: 'et'
trainings:
# disponibilités formations

View File

@ -0,0 +1,5 @@
class AddWalletAmountToInvoice < ActiveRecord::Migration
def change
add_column :invoices, :wallet_amount, :integer
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20160714095018) do
ActiveRecord::Schema.define(version: 20160718165434) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -220,6 +220,7 @@ ActiveRecord::Schema.define(version: 20160714095018) do
t.string "type", limit: 255
t.boolean "subscription_to_expire"
t.text "description"
t.integer "wallet_amount"
end
add_index "invoices", ["invoice_id"], name: "index_invoices_on_invoice_id", using: :btree