1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-13 23:48:55 +01:00
fab-manager/app/controllers/open_api/v1/accounting_controller.rb

43 lines
1.2 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
2023-03-06 16:35:50 +01:00
require_relative 'concerns/accountings_filters_concern'
# authorized 3rd party softwares can fetch the accounting lines through the OpenAPI
class OpenAPI::V1::AccountingController < OpenAPI::V1::BaseController
2023-02-24 17:26:55 +01:00
extend OpenAPI::APIDoc
include Rails::Pagination
2023-02-24 17:26:55 +01:00
include OpenAPI::V1::Concerns::AccountingsFiltersConcern
expose_doc
def index
2022-12-09 12:28:13 +01:00
@codes = {
card: Setting.get('accounting_payment_card_code'),
wallet: Setting.get('accounting_payment_wallet_code'),
transfer: Setting.get('accounting_payment_transfer_code'),
check: Setting.get('accounting_payment_check_code'),
other: Setting.get('accounting_payment_other_code')
2022-12-09 12:28:13 +01:00
}
@lines = AccountingLine.order(date: :desc)
2022-12-09 12:28:13 +01:00
.includes(:invoicing_profile, invoice: :payment_gateway_object)
2023-03-06 16:35:50 +01:00
@lines = filter_by_after(@lines, params)
@lines = filter_by_before(@lines, params)
@lines = filter_by_invoice(@lines, params)
@lines = filter_by_line_type(@lines, params)
@lines = @lines.page(page).per(per_page)
paginate @lines, per_page: per_page
end
private
def page
params[:page] || 1
end
def per_page
params[:per_page] || 20
end
end