2019-03-12 12:15:14 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-01-31 12:19:50 +01:00
|
|
|
json.invoices do
|
|
|
|
json.array!(invoices) do |invoice|
|
2019-03-12 12:15:14 +01:00
|
|
|
json.extract! invoice[:invoice], :id, :stp_invoice_id, :created_at, :reference, :footprint
|
|
|
|
json.total number_to_currency(invoice[:invoice].total / 100.0)
|
2019-01-31 12:19:50 +01:00
|
|
|
json.invoiced do
|
2019-03-12 12:15:14 +01:00
|
|
|
json.type invoice[:invoice].invoiced_type
|
|
|
|
json.id invoice[:invoice].invoiced_id
|
|
|
|
if invoice[:invoice].invoiced_type == Subscription.name
|
|
|
|
json.partial! 'archive/subscription', invoiced: invoice[:invoice].invoiced
|
|
|
|
elsif invoice[:invoice].invoiced_type == Reservation.name
|
|
|
|
json.partial! 'archive/reservation', invoiced: invoice[:invoice].invoiced, vat_rate: invoice[:vat_rate]
|
2019-01-10 10:52:29 +01:00
|
|
|
end
|
|
|
|
end
|
2019-01-31 12:19:50 +01:00
|
|
|
json.user do
|
2019-03-12 12:15:14 +01:00
|
|
|
json.extract! invoice[:invoice].user, :id, :email, :created_at
|
2019-01-31 12:19:50 +01:00
|
|
|
json.profile do
|
2019-03-12 12:15:14 +01:00
|
|
|
json.extract! invoice[:invoice].user.profile, :id, :first_name, :last_name, :birthday, :phone
|
|
|
|
json.gender invoice[:invoice].user.profile.gender ? 'male' : 'female'
|
2019-01-31 12:19:50 +01:00
|
|
|
end
|
|
|
|
end
|
2019-03-12 12:15:14 +01:00
|
|
|
json.invoice_items invoice[:invoice].invoice_items do |item|
|
2019-02-12 14:45:21 +01:00
|
|
|
json.extract! item, :id, :stp_invoice_item_id, :created_at, :description, :footprint
|
2019-03-12 12:15:14 +01:00
|
|
|
json.partial! 'archive/vat', price: item.amount, vat_rate: invoice[:vat_rate]
|
2019-01-10 10:52:29 +01:00
|
|
|
end
|
|
|
|
end
|
2019-01-31 12:19:50 +01:00
|
|
|
end
|
|
|
|
|
2019-02-25 14:51:19 +01:00
|
|
|
json.totals do
|
2019-03-12 12:15:14 +01:00
|
|
|
json.period_total number_to_currency(period_total / 100.0)
|
|
|
|
json.perpetual_total number_to_currency(perpetual_total / 100.0)
|
2019-02-25 14:51:19 +01:00
|
|
|
end
|
|
|
|
|
2019-01-31 12:19:50 +01:00
|
|
|
json.software do
|
|
|
|
json.name 'Fab-Manager'
|
|
|
|
json.version software_version
|
|
|
|
json.code_checksum code_checksum
|
|
|
|
end
|
|
|
|
|
|
|
|
json.previous_archive do
|
|
|
|
json.filename previous_file
|
|
|
|
json.checksum last_archive_checksum
|
2019-01-10 10:52:29 +01:00
|
|
|
end
|
2019-02-25 14:51:19 +01:00
|
|
|
|
|
|
|
json.period_footprint period_footprint
|
2019-03-11 16:25:51 +01:00
|
|
|
json.archive_date date
|