2022-11-16 15:41:08 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
# openAPI documentation for accounting endpoints
|
|
|
|
class OpenAPI::V1::AccountingDoc < OpenAPI::V1::BaseDoc
|
|
|
|
resource_description do
|
|
|
|
short 'Accounting lines'
|
|
|
|
desc 'Accounting lines according to the French General Accounting Plan (PCG)'
|
|
|
|
formats FORMATS
|
|
|
|
api_version API_VERSION
|
|
|
|
end
|
|
|
|
|
|
|
|
include OpenAPI::V1::Concerns::ParamGroups
|
|
|
|
|
|
|
|
doc_for :index do
|
|
|
|
api :GET, "/#{API_VERSION}/accounting", 'Accounting lines'
|
2022-11-23 17:35:39 +01:00
|
|
|
description 'All accounting lines, paginated (necessarily becauce there is a lot of data) with optional dates filtering. ' \
|
2022-12-09 16:50:01 +01:00
|
|
|
'Ordered by *date* descendant.<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>.<br>' \
|
2022-12-12 11:10:06 +01:00
|
|
|
'The field *invoice.payment_details* is available if line_type=payment. It will contain the following data:<br>' \
|
2022-12-09 16:50:01 +01:00
|
|
|
'· *payment_mean*, possible status are: <i>card</i>, <i>wallet</i> or <i>other</i>. *WARNING*: If an invoice was settled ' \
|
|
|
|
'using multiple payment means, this will only report the payment mean applicable to current line.<br>' \
|
|
|
|
'· *gateway_object_id*, if payment_mean=card, report the ID of the payment gateway related object<br>' \
|
|
|
|
'· *gateway_object_type*, if payment_mean=card, report the type of the payment gateway related object<br>' \
|
|
|
|
'· *wallet_transaction_id*, if payment_mean=wallet, report the ID of the wallet transaction<br>'
|
2022-11-16 15:41:08 +01:00
|
|
|
param_group :pagination
|
|
|
|
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.'
|
2022-11-23 17:35:39 +01:00
|
|
|
param :invoice_id, [Integer, Array], optional: true, desc: 'Scope the request to one or various invoices.'
|
2022-12-08 16:24:40 +01:00
|
|
|
param :type, %w[client vat item], optional: true, desc: 'Filter accounting lines by line type.'
|
2022-11-23 17:35:39 +01:00
|
|
|
|
2022-11-16 15:41:08 +01:00
|
|
|
example <<-LINES
|
|
|
|
# /open_api/v1/accounting?after=2022-01-01T00:00:00+02:00&page=1&per_page=3
|
|
|
|
{
|
|
|
|
"lines": [
|
|
|
|
{
|
2022-11-23 17:35:39 +01:00
|
|
|
"id": 1,
|
2022-12-12 11:10:06 +01:00
|
|
|
"line_type": "payment",
|
2022-11-16 15:41:08 +01:00
|
|
|
"journal_code": "VT01",
|
|
|
|
"date": "2022-01-02T18:14:21+01:00",
|
|
|
|
"account_code": "5802",
|
2022-11-23 17:35:39 +01:00
|
|
|
"account_label": "Card customers",
|
|
|
|
"analytical_code": "",
|
2022-11-16 15:41:08 +01:00
|
|
|
"invoice": {
|
|
|
|
"reference": "22010009/VL",
|
|
|
|
"id": 274,
|
2022-11-23 17:35:39 +01:00
|
|
|
"label": "Subscription of Dupont Marcel for 1 month starting from 2022, january 2nd",
|
2022-12-09 16:50:01 +01:00
|
|
|
"url": "/open_api/v1/invoices/247/download",
|
|
|
|
"payment_details": {
|
|
|
|
"payment_mean": "card",
|
|
|
|
"gateway_object_id": "pi_3MA2PPW4kx8QemzC02ABBEbo",
|
|
|
|
"gateway_object_type": "Stripe::PaymentIntent"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"user": {
|
|
|
|
"invoicing_profile_id": 6512,
|
|
|
|
"external_id": "U52-ALC4"
|
2022-11-16 15:41:08 +01:00
|
|
|
},
|
2022-12-13 12:38:19 +01:00
|
|
|
"debit": 14.0,
|
2022-11-23 17:35:39 +01:00
|
|
|
"credit": 0
|
2022-11-16 15:41:08 +01:00
|
|
|
"currency": "EUR",
|
2022-11-23 17:35:39 +01:00
|
|
|
"summary": "Dupont Marcel, 22010009/VL, subscr."
|
2022-11-16 15:41:08 +01:00
|
|
|
},
|
|
|
|
{
|
2022-11-23 17:35:39 +01:00
|
|
|
"id": 2,
|
|
|
|
"line_type": "item",
|
2022-11-16 15:41:08 +01:00
|
|
|
"journal_code": "VT01",
|
|
|
|
"date": "2022-01-02T18:14:21+01:00",
|
2022-11-23 17:35:39 +01:00
|
|
|
"account_code": "7071",
|
|
|
|
"account_label": "Subscriptions",
|
2022-11-16 15:41:08 +01:00
|
|
|
"analytical_code": "P3D71",
|
|
|
|
"invoice": {
|
|
|
|
"reference": "22010009/VL",
|
|
|
|
"id": 274,
|
2022-11-23 17:35:39 +01:00
|
|
|
"label": "Subscription of Dupont Marcel for 1 month starting from 2022, january 2nd",
|
|
|
|
"url": "/open_api/v1/invoices/247/download"
|
2022-11-16 15:41:08 +01:00
|
|
|
},
|
2022-11-23 17:35:39 +01:00
|
|
|
"user_invoicing_profile_id": 6512,
|
|
|
|
"debit": 0,
|
2022-12-13 12:38:19 +01:00
|
|
|
"credit": 11.67
|
2022-11-16 15:41:08 +01:00
|
|
|
"currency": "EUR",
|
2022-11-23 17:35:39 +01:00
|
|
|
"summary": "Dupont Marcel, 22010009/VL, subscr."
|
2022-11-16 15:41:08 +01:00
|
|
|
},
|
|
|
|
{
|
2022-11-23 17:35:39 +01:00
|
|
|
"id": 3,
|
|
|
|
"line_type": "vat",
|
2022-11-16 15:41:08 +01:00
|
|
|
"journal_code": "VT01",
|
|
|
|
"date": "2022-01-02T18:14:21+01:00",
|
2022-11-23 17:35:39 +01:00
|
|
|
"account_code": "4457",
|
|
|
|
"account_label": "Collected VAT",
|
2022-11-16 15:41:08 +01:00
|
|
|
"analytical_code": "P3D71",
|
|
|
|
"invoice": {
|
|
|
|
"reference": "22010009/VL",
|
|
|
|
"id": 274,
|
2022-11-23 17:35:39 +01:00
|
|
|
"label": "Subscription of Dupont Marcel for 1 month starting from 2022, january 2nd",
|
|
|
|
"url": "/open_api/v1/invoices/247/download"
|
2022-11-16 15:41:08 +01:00
|
|
|
},
|
2022-11-23 17:35:39 +01:00
|
|
|
"user_invoicing_profile_id": 6512,
|
|
|
|
"debit": 0,
|
2022-12-13 12:38:19 +01:00
|
|
|
"credit": 2.33
|
2022-11-16 15:41:08 +01:00
|
|
|
"currency": "EUR",
|
2022-11-23 17:35:39 +01:00
|
|
|
"summary": "Dupont Marcel, 22010009/VL, subscr."
|
2022-11-16 15:41:08 +01:00
|
|
|
}
|
2022-12-08 16:14:59 +01:00
|
|
|
],
|
|
|
|
"status": "built"
|
2022-11-16 15:41:08 +01:00
|
|
|
}
|
|
|
|
LINES
|
|
|
|
end
|
|
|
|
end
|