1
0
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:
Sylvain 2022-12-09 11:09:39 +01:00
parent 90dc38ed10
commit e3eb8eb516
3 changed files with 15 additions and 7 deletions

View File

@ -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?

View File

@ -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

View File

@ -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]