mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-04-10 00:53:51 +02:00
set organization name in invoice object, if any (#64)
This commit is contained in:
parent
54154b1713
commit
7960964aed
@ -3,6 +3,7 @@
|
|||||||
## next release
|
## next release
|
||||||
|
|
||||||
- Ability for admins to create users as organizations
|
- Ability for admins to create users as organizations
|
||||||
|
- Invoices object will contain the organization name if any (#64)
|
||||||
|
|
||||||
## v2.5.5 2017 May 15
|
## v2.5.5 2017 May 15
|
||||||
|
|
||||||
|
@ -53,8 +53,10 @@ module PDF
|
|||||||
# user/organization's information
|
# user/organization's information
|
||||||
if invoice&.user&.profile&.organization
|
if invoice&.user&.profile&.organization
|
||||||
name = invoice.user.profile.organization.name
|
name = invoice.user.profile.organization.name
|
||||||
|
full_name = "#{name} (#{invoice.user.profile.full_name})"
|
||||||
else
|
else
|
||||||
name = invoice.user.profile.full_name
|
name = invoice.user.profile.full_name
|
||||||
|
full_name = name
|
||||||
end
|
end
|
||||||
|
|
||||||
if invoice&.user&.profile&.organization&.address
|
if invoice&.user&.profile&.organization&.address
|
||||||
@ -66,6 +68,7 @@ module PDF
|
|||||||
end
|
end
|
||||||
|
|
||||||
text_box "<b>#{name}</b>\n#{invoice.user.email}\n#{address}", :at => [bounds.width - 130, bounds.top - 49], :width => 130, :align => :right, :inline_format => true
|
text_box "<b>#{name}</b>\n#{invoice.user.email}\n#{address}", :at => [bounds.width - 130, bounds.top - 49], :width => 130, :align => :right, :inline_format => true
|
||||||
|
name = full_name
|
||||||
|
|
||||||
# object
|
# object
|
||||||
move_down 25
|
move_down 25
|
||||||
@ -78,18 +81,18 @@ module PDF
|
|||||||
else
|
else
|
||||||
case invoice.invoiced_type
|
case invoice.invoiced_type
|
||||||
when 'Reservation'
|
when 'Reservation'
|
||||||
object = I18n.t('invoices.reservation_of_USER_on_DATE_at_TIME', USER:invoice.user.profile.full_name, DATE:I18n.l(invoice.invoiced.slots[0].start_at.to_date), TIME:I18n.l(invoice.invoiced.slots[0].start_at, format: :hour_minute))
|
object = I18n.t('invoices.reservation_of_USER_on_DATE_at_TIME', USER:name, DATE:I18n.l(invoice.invoiced.slots[0].start_at.to_date), TIME:I18n.l(invoice.invoiced.slots[0].start_at, format: :hour_minute))
|
||||||
invoice.invoice_items.each do |item|
|
invoice.invoice_items.each do |item|
|
||||||
if item.subscription_id
|
if item.subscription_id
|
||||||
subscription = Subscription.find item.subscription_id
|
subscription = Subscription.find item.subscription_id
|
||||||
object = "\n- #{object}\n- #{(invoice.is_a?(Avoir) ? I18n.t('invoices.cancellation')+' - ' : '') + subscription_verbose(subscription, invoice.user)}"
|
object = "\n- #{object}\n- #{(invoice.is_a?(Avoir) ? I18n.t('invoices.cancellation')+' - ' : '') + subscription_verbose(subscription, name)}"
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
when 'Subscription'
|
when 'Subscription'
|
||||||
object = subscription_verbose(invoice.invoiced, invoice.user)
|
object = subscription_verbose(invoice.invoiced, name)
|
||||||
when 'OfferDay'
|
when 'OfferDay'
|
||||||
object = offer_day_verbose(invoice.invoiced, invoice.user)
|
object = offer_day_verbose(invoice.invoiced, name)
|
||||||
else
|
else
|
||||||
puts "ERROR : specified invoiced type (#{invoice.invoiced_type}) is unknown"
|
puts "ERROR : specified invoiced type (#{invoice.invoiced_type}) is unknown"
|
||||||
end
|
end
|
||||||
@ -324,7 +327,7 @@ module PDF
|
|||||||
def subscription_verbose(subscription, user)
|
def subscription_verbose(subscription, user)
|
||||||
subscription_start_at = subscription.expired_at - subscription.plan.duration
|
subscription_start_at = subscription.expired_at - subscription.plan.duration
|
||||||
duration_verbose = I18n.t("duration.#{subscription.plan.interval}", count: subscription.plan.interval_count)
|
duration_verbose = I18n.t("duration.#{subscription.plan.interval}", count: subscription.plan.interval_count)
|
||||||
I18n.t('invoices.subscription_of_NAME_for_DURATION_starting_from_DATE', NAME: user.profile.full_name, DURATION: duration_verbose, DATE: I18n.l(subscription_start_at.to_date))
|
I18n.t('invoices.subscription_of_NAME_for_DURATION_starting_from_DATE', NAME: user, DURATION: duration_verbose, DATE: I18n.l(subscription_start_at.to_date))
|
||||||
end
|
end
|
||||||
|
|
||||||
def offer_day_verbose(offer_day, user)
|
def offer_day_verbose(offer_day, user)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user