mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-30 19:52:20 +01:00
(api) accounting: report build status
This commit is contained in:
parent
b7838db648
commit
3a05398c8c
@ -14,7 +14,8 @@ class OpenAPI::V1::AccountingDoc < OpenAPI::V1::BaseDoc
|
|||||||
doc_for :index do
|
doc_for :index do
|
||||||
api :GET, "/#{API_VERSION}/accounting", 'Accounting lines'
|
api :GET, "/#{API_VERSION}/accounting", 'Accounting lines'
|
||||||
description 'All accounting lines, paginated (necessarily becauce there is a lot of data) with optional dates filtering. ' \
|
description 'All accounting lines, paginated (necessarily becauce there is a lot of data) with optional dates filtering. ' \
|
||||||
'Ordered by *date* descendant.'
|
'Ordered by *date* descendant.<br><br>The field *status* indicates if the accounting data is being built ' \
|
||||||
|
'or if the build is over. Possible status are: <i>building</i> or <i>built</i>.'
|
||||||
param_group :pagination
|
param_group :pagination
|
||||||
param :after, DateTime, optional: true, desc: 'Filter accounting lines to lines after the given date.'
|
param :after, DateTime, optional: true, desc: 'Filter accounting lines to lines after the given date.'
|
||||||
param :before, DateTime, optional: true, desc: 'Filter accounting lines to lines before the given date.'
|
param :before, DateTime, optional: true, desc: 'Filter accounting lines to lines before the given date.'
|
||||||
@ -84,7 +85,8 @@ class OpenAPI::V1::AccountingDoc < OpenAPI::V1::BaseDoc
|
|||||||
"currency": "EUR",
|
"currency": "EUR",
|
||||||
"summary": "Dupont Marcel, 22010009/VL, subscr."
|
"summary": "Dupont Marcel, 22010009/VL, subscr."
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"status": "built"
|
||||||
}
|
}
|
||||||
LINES
|
LINES
|
||||||
end
|
end
|
||||||
|
@ -28,6 +28,14 @@ class Accounting::AccountingService
|
|||||||
AccountingLine.create!(lines)
|
AccountingLine.create!(lines)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.status
|
||||||
|
workers = Sidekiq::Workers.new
|
||||||
|
workers.each do |_process_id, _thread_id, work|
|
||||||
|
return 'building' if work['payload']['class'] == 'AccountingWorker'
|
||||||
|
end
|
||||||
|
'built'
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def generate_lines(invoice)
|
def generate_lines(invoice)
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
|
||||||
json.lines @lines do |line|
|
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.extract! line, :id, :line_type, :journal_code, :date, :account_code, :account_label, :analytical_code, :debit, :credit, :currency, :summary
|
||||||
json.invoice do
|
json.invoice do
|
||||||
@ -10,3 +9,4 @@ json.lines @lines do |line|
|
|||||||
end
|
end
|
||||||
json.user_invoicing_profile_id line.invoicing_profile_id
|
json.user_invoicing_profile_id line.invoicing_profile_id
|
||||||
end
|
end
|
||||||
|
json.status Accounting::AccountingService.status
|
||||||
|
@ -33,6 +33,7 @@ class OpenApi::AccountingTest < ActionDispatch::IntegrationTest
|
|||||||
assert_not_nil lines[:lines][0][:credit]
|
assert_not_nil lines[:lines][0][:credit]
|
||||||
assert_not_empty lines[:lines][0][:currency]
|
assert_not_empty lines[:lines][0][:currency]
|
||||||
assert_not_empty lines[:lines][0][:summary]
|
assert_not_empty lines[:lines][0][:summary]
|
||||||
|
assert_equal 'built', lines[:status]
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'list all accounting lines with pagination' do
|
test 'list all accounting lines with pagination' do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user