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|
|
2021-04-21 17:38:06 +02:00
|
|
|
json.extract! invoice[:invoice], :id, :payment_method, :created_at, :reference, :footprint
|
|
|
|
if invoice[:invoice].payment_gateway_object
|
|
|
|
json.payment_gateway_object do
|
|
|
|
json.id invoice[:invoice].payment_gateway_object.gateway_object_id
|
|
|
|
json.type invoice[:invoice].payment_gateway_object.gateway_object_type
|
|
|
|
end
|
|
|
|
end
|
2019-03-12 12:15:14 +01:00
|
|
|
json.total number_to_currency(invoice[:invoice].total / 100.0)
|
2019-01-31 12:19:50 +01:00
|
|
|
json.user do
|
2019-06-04 13:33:00 +02:00
|
|
|
json.extract! invoice[:invoice].invoicing_profile, :user_id, :email, :first_name, :last_name
|
|
|
|
json.address invoice[:invoice].invoicing_profile&.address&.address
|
|
|
|
json.invoicing_profile_id invoice[:invoice].invoicing_profile.id
|
|
|
|
if invoice[:invoice].invoicing_profile.organization
|
|
|
|
json.organization do
|
|
|
|
json.extract! invoice[:invoice].invoicing_profile.organization, :name, :id
|
|
|
|
json.address invoice[:invoice].invoicing_profile.organization&.address&.address
|
|
|
|
end
|
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|
|
2021-05-27 15:58:55 +02:00
|
|
|
json.extract! item, :id, :main, :created_at, :description, :footprint
|
2021-04-21 17:38:06 +02:00
|
|
|
if item.payment_gateway_object
|
|
|
|
json.payment_gateway_object do
|
|
|
|
json.id item.payment_gateway_object.gateway_object_id
|
|
|
|
json.type item.payment_gateway_object.gateway_object_type
|
|
|
|
end
|
|
|
|
end
|
2021-05-27 15:58:55 +02:00
|
|
|
json.object do
|
|
|
|
json.type item.object_type
|
|
|
|
json.id item.object_id
|
2021-06-10 11:36:32 +02:00
|
|
|
json.main item.main
|
2021-05-27 15:58:55 +02:00
|
|
|
end
|
2021-12-24 19:37:43 +01:00
|
|
|
json.partial! 'archive/vat', price: item.amount, vat_rate: invoice[:vat_rate][item.invoice_item_type]
|
2019-01-10 10:52:29 +01:00
|
|
|
end
|
|
|
|
end
|
2019-01-31 12:19:50 +01:00
|
|
|
end
|
|
|
|
|
2021-06-10 11:36:32 +02:00
|
|
|
json.payment_schedules do
|
|
|
|
json.array!(schedules) do |schedule|
|
|
|
|
json.extract! schedule, :id, :payment_method, :created_at, :reference, :footprint
|
|
|
|
json.payment_gateway_objects schedule.payment_gateway_objects do |object|
|
|
|
|
json.id object.gateway_object_id
|
|
|
|
json.type object.gateway_object_type
|
|
|
|
end
|
|
|
|
json.total number_to_currency(schedule.total / 100.0)
|
|
|
|
json.user do
|
|
|
|
json.extract! schedule.invoicing_profile, :user_id, :email, :first_name, :last_name
|
|
|
|
json.address schedule.invoicing_profile&.address&.address
|
|
|
|
json.invoicing_profile_id schedule.invoicing_profile.id
|
|
|
|
if schedule.invoicing_profile.organization
|
|
|
|
json.organization do
|
|
|
|
json.extract! schedule.invoicing_profile.organization, :name, :id
|
|
|
|
json.address schedule.invoicing_profile.organization&.address&.address
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
json.deadlines schedule.payment_schedule_items do |item|
|
|
|
|
json.extract! item, :id, :due_date, :state, :details, :invoice_id, :footprint, :created_at
|
|
|
|
json.amount number_to_currency(item.amount / 100.0)
|
|
|
|
end
|
|
|
|
json.objects schedule.payment_schedule_objects do |object|
|
|
|
|
json.type object.object_type
|
|
|
|
json.id object.object_id
|
|
|
|
json.main object.main
|
|
|
|
end
|
|
|
|
end
|
|
|
|
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
|
2020-02-26 10:19:43 +01:00
|
|
|
json.name 'Fab-manager'
|
2019-01-31 12:19:50 +01:00
|
|
|
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
|