2016-06-16 23:03:45 +02:00

231 lines
6.7 KiB
Python

"""
This file is part of Accountant.
Accountant is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Accountant is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Accountant. If not, see <http://www.gnu.org/licenses/>.
"""
from flask.ext.restplus import fields
from .. import api
# Account model.
account_model = api.model('Account', {
'id': fields.Integer(
default=None,
readonly=True,
description='Id of the account'),
'name': fields.String(
required=True,
description='Name of the account'),
'authorized_overdraft': fields.Float(
required=True,
description='Authorized overdraft')
})
# Account status model.
solds_model = api.model('Solds', {
'current': fields.Float(
readonly=True,
description='Current sold of the account'),
'pointed': fields.Float(
readonly=True,
description='Pointed sold of the account'),
'future': fields.Float(
readonly=True,
description='Future sold of the account')
})
# Account balance model.
balance_model = api.model('Balance', {
'expenses': fields.Float(
readonly=True,
description='Total amount of expenses'),
'revenues': fields.Float(
readonly=True,
description='Total amount of revenues'),
'balance': fields.Float(
readonly=True,
description='Balance'),
})
# Category with expenses and revenues.
category_model = api.model('Category', {
'category': fields.String(
readonly=True,
description='Category name'),
'expenses': fields.Float(
readonly=True,
description='Total amount of expenses for the category'),
'revenues': fields.Float(
readonly=True,
description='Total amount of revenues for the category')
})
# OHLC model.
ohlc_model = api.model('OHLC', {
'operation_date': fields.DateTime(
dt_format='iso8601',
readonly=True,
required=True,
description='Date of the OHLC object'
),
'open': fields.Float(
readonly=True,
required=True,
description='Open value'
),
'high': fields.Float(
readonly=True,
required=True,
description='High value'
),
'low': fields.Float(
readonly=True,
required=True,
description='Low value'
),
'close': fields.Float(
readonly=True,
required=True,
description='Close value'
)
})
# Operation with sold model.
operation_model = api.model('Operation', {
'id': fields.Integer(
default=None,
readonly=True,
description='Id of the operation'),
'operation_date': fields.DateTime(
dt_format='iso8601',
required=True,
description='Date of the operation'),
'label': fields.String(
required=True,
description='Label of the operation'),
'value': fields.Float(
required=True,
description='Value of the operation'),
'pointed': fields.Boolean(
required=True,
description='Pointed status of the operation'),
'category': fields.String(
required=False,
default=None,
description='Category of the operation'),
'account_id': fields.Integer(
required=True,
readonly=True,
description='Account id of the operation'),
'scheduled_operation_id': fields.Integer(
default=None,
readonly=True,
description='Scheduled operation ID of the operation'),
'confirmed': fields.Boolean(
description='Confirmed status of the operation'),
'canceled': fields.Boolean(
description='Canceled status of the operation (for a scheduled one)')
})
operation_with_sold_model = api.clone(
'OperationWithSold', operation_model, {
'sold': fields.Float(
readonly=True,
description='Cumulated sold'
),
}
)
# Scheduled operation model.
scheduled_operation_model = api.model('ScheduledOperation', {
'id': fields.Integer(
description='Id of the scheduled operation',
readonly=True,
default=None),
'start_date': fields.DateTime(
dt_format='iso8601',
required=True,
description='Start date of the scheduled operation'),
'stop_date': fields.DateTime(
dt_format='iso8601',
required=True,
description='End date of the scheduled operation'),
'day': fields.Integer(
required=True,
description='Day of month for the scheduled operation'),
'frequency': fields.Integer(
required=True,
description='Frequency of the scheduling in months'),
'label': fields.String(
required=True,
description='Label of the generated operations'),
'value': fields.Float(
required=True,
description='Value of the generated operations'),
'category': fields.String(
required=False,
description='Category of the generated operations'),
'account_id': fields.Integer(
default=None,
readonly=True,
required=True,
description='Account id of the scheduled operation'),
})
# Token with expiration time and type.
token_model = api.model('Token', {
'token': fields.String(
required=True,
readonly=True,
description='Token value'),
'expiration': fields.DateTime(
dt_format='iso8601',
required=True,
readonly=True,
description='Expiration time of the token'),
'token_type': fields.String(
required=True,
readonly=True,
description='Token type')
})
# User model.
user_model = api.model('User', {
'id': fields.Integer(
default=None,
required=True,
readonly=True,
description='Id of the user'),
'email': fields.String(
required=True,
readonly=True,
decription='Email address of the user'),
'active': fields.Boolean(
required=True,
readonly=True,
description='Active state of the user')
})
# Login model.
login_model = api.model('Login', {
'email': fields.String(
required=True,
description='Email to use for login'
),
'password': fields.String(
required=True,
description='Plain text password to use for login'
)
})