mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-18 07:52:23 +01:00
(api) accounting: report external id for user
This commit is contained in:
parent
90dc38ed10
commit
e3eb8eb516
@ -8,7 +8,7 @@ class OpenAPI::V1::AccountingController < OpenAPI::V1::BaseController
|
||||
|
||||
def index
|
||||
@lines = AccountingLine.order(date: :desc)
|
||||
.includes(:invoice)
|
||||
.includes(:invoice, :invoicing_profile)
|
||||
|
||||
@lines = @lines.where('date >= ?', DateTime.parse(params[:after])) if params[:after].present?
|
||||
@lines = @lines.where('date <= ?', DateTime.parse(params[:before])) if params[:before].present?
|
||||
|
@ -2,11 +2,18 @@
|
||||
|
||||
json.lines @lines do |line|
|
||||
json.extract! line, :id, :line_type, :journal_code, :date, :account_code, :account_label, :analytical_code, :debit, :credit, :currency, :summary
|
||||
json.invoice do
|
||||
json.extract! line.invoice, :reference, :id
|
||||
json.label Invoices::LabelService.build(line.invoice)
|
||||
json.url download_open_api_v1_invoice_path(line.invoice)
|
||||
if line.association(:invoice).loaded?
|
||||
json.invoice do
|
||||
json.extract! line.invoice, :reference, :id
|
||||
json.label Invoices::LabelService.build(line.invoice)
|
||||
json.url download_open_api_v1_invoice_path(line.invoice)
|
||||
end
|
||||
end
|
||||
if line.association(:invoicing_profile).loaded?
|
||||
json.user do
|
||||
json.invoicing_profile_id line.invoicing_profile_id
|
||||
json.external_id line.invoicing_profile.external_id
|
||||
end
|
||||
end
|
||||
json.user_invoicing_profile_id line.invoicing_profile_id
|
||||
end
|
||||
json.status Accounting::AccountingService.status
|
||||
|
@ -28,7 +28,8 @@ class OpenApi::AccountingTest < ActionDispatch::IntegrationTest
|
||||
assert_not_nil lines[:lines][0][:invoice][:id]
|
||||
assert_not_empty lines[:lines][0][:invoice][:label]
|
||||
assert_not_empty lines[:lines][0][:invoice][:url]
|
||||
assert_not_nil lines[:lines][0][:user_invoicing_profile_id]
|
||||
assert_not_nil lines[:lines][0][:user][:invoicing_profile_id]
|
||||
assert_not_nil lines[:lines][0][:user][:external_id]
|
||||
assert_not_nil lines[:lines][0][:debit]
|
||||
assert_not_nil lines[:lines][0][:credit]
|
||||
assert_not_empty lines[:lines][0][:currency]
|
||||
|
Loading…
x
Reference in New Issue
Block a user