from flask_restplus import fields

from open_budget_data_api.api.restplus import api

budget_item = api.model('Budget Item', {
    'code': fields.String(description='The budget item code'),
    'year': fields.Integer(description='The budget item year'),
    'title': fields.String(description='Title'),
    'net_allocated': fields.Integer,
    'net_revised': fields.Integer,
    'net_used': fields.Integer,
    'gross_allocated': fields.Integer,
    'gross_revised': fields.Integer,
    'personnel_allocated': fields.Float,
    'personnel_revised': fields.Float,
    'commitment_allocated': fields.Integer,
    'commitment_revised': fields.Integer,
    'amounts_allocated': fields.Integer,
    'amounts_revised': fields.Integer,
    'contractors_allocated': fields.Integer,
    'contractors_revised': fields.Integer,
    'dedicated_allocated': fields.Integer,
    'dedicated_revised': fields.Integer,
    'equiv_code': fields.List(fields.String),
    'group_full': fields.List(fields.String),
    'group_top': fields.List(fields.String),
    'class_full': fields.List(fields.String),
    'class_top': fields.List(fields.String),
    'kind': fields.List(fields.String),
    'subkind': fields.List(fields.String),
})

equiv_budget_item = api.model('Budget Item', {
    'code': fields.String(description='The budget item code'),
    'year': fields.Integer(description='The budget item year'),
    'title': fields.String(description='Title'),
    'net_allocated': fields.Integer,
    'net_revised': fields.Integer,
    'net_used': fields.Integer,
    'gross_allocated': fields.Integer,
    'gross_revised': fields.Integer,
    'personnel_allocated': fields.Float,
    'personnel_revised': fields.Float,
    'commitment_allocated': fields.Integer,
    'commitment_revised': fields.Integer,
    'amounts_allocated': fields.Integer,
    'amounts_revised': fields.Integer,
    'contractors_allocated': fields.Integer,
    'contractors_revised': fields.Integer,
    'dedicated_allocated': fields.Integer,
    'dedicated_revised': fields.Integer,
    'orig_codes': fields.List(fields.String),
})

entity_item = api.model('Entity', {
    'id': fields.String,
    'kind': fields.String,
    'name': fields.String,
    'manpower_contractor': fields.String,
    'service_contractor': fields.String,
    'gov_company': fields.Boolean,
    'company_name': fields.String,
    'company_status': fields.String,
    'company_type': fields.String,
    'company_government': fields.String,
    'company_limit': fields.String,
    'company_postal_code': fields.String,
    'company_mafera': fields.String,
    'company_address': fields.String,
    'company_city': fields.String,
    'lat': fields.Float,
    'lng': fields.Float,
})

exemption_item = api.model('Exemption', {
    'publication_id': fields.Integer,
    'budget_code': fields.String,
    'publisher': fields.String,
    'regulation': fields.String,
    'supplier': fields.String,
    'supplier_id': fields.String,
    'start_date': fields.Date,
    'end_date': fields.Date,
    'claim_date': fields.Date,
    'last_update_date': fields.Date,
    'contact': fields.String,
    'contact_email': fields.String,
    'description': fields.String,
    'volume': fields.Integer,
    'reason': fields.String,
    'decision': fields.String,
    'url': fields.String,
    'subjects': fields.List(fields.String),
    'source_currency': fields.String,
    'page_title': fields.String,
    'entity_id': fields.String,
    'entity_kind': fields.String,
    'documents': fields.String,
})

procurement_item = api.model('Procurement', {
    'publisher': fields.String,
    'purchasing_unit': fields.String,
    'buyer_description': fields.String,
    'budget_code': fields.String,
    'budget_title': fields.String,
    'supplier_code': fields.String,
    'supplier_name': fields.String,
    'volume': fields.Float,
    'executed': fields.Float,
    'currency': fields.String,
    'purchase_method': fields.String,
    'manof_ref': fields.String,
    'exemption_reason': fields.String,
    'purpose': fields.String,
    'order_id': fields.String,
    'sensitive_order': fields.Boolean,
    'report_date': fields.String,
    'report_title': fields.String,
    'report_publisher': fields.String,
    'report_year': fields.Integer,
    'report_period': fields.Integer,
    'report_error': fields.String,
    'order_date': fields.Date,
    'entity_id': fields.String,
    'entity_kind': fields.String,
})

support_item = api.model('Support', {
    'year': fields.Integer(readOnly=True, description='The support item year'),
    'subject': fields.String(description='Subject'),
    'code': fields.String(required=True, description='The support item code'),
    'title': fields.String(description='Title'),
    'kind': fields.String,
    'amount_supported': fields.Integer,
    'amount_allocated': fields.Integer,
    'num_used': fields.Integer,
    'recipient': fields.String,
    'entity_id': fields.String,
    'entity_kind': fields.String()
})

changes_item = api.model('Entity', {
    'year': fields.Integer,
    'leading_item': fields.Integer,
    'req_code': fields.Integer,
    'req_title': fields.String,
    'change_code': fields.Integer,
    'change_title': fields.String,
    'change_type_id': fields.Integer,
    'change_type_name': fields.String,
    'committee_id': fields.Integer,
    'budget_code': fields.String,
    'budget_title': fields.String,
    'net_expense_diff': fields.Integer,
    'gross_expense_diff': fields.Integer,
    'allocated_income_diff': fields.Integer,
    'commitment_limit_diff': fields.Integer,
    'personnel_max_diff': fields.Float,
    'date': fields.String,
    'pending': fields.Boolean,
    'equiv_code': fields.List(fields.String)
})
