## $Id: interfaces.py 7627 2012-02-10 20:35:28Z henrik $
##
## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program 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 General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##
from zope.interface import Attribute
from zope import schema
from waeup.sirp.interfaces import ISIRPObject, SimpleSIRPVocabulary

payment_states = SimpleSIRPVocabulary(
    ('Not yet paid','unpaid'),
    ('Paid','paid'),
    ('Failed','failed'),
    )

payment_categories = SimpleSIRPVocabulary(
    ('School Fee','schoolfee'),
    ('Clearance','clearance'),
    ('Bed Allocation','bed_allocation'),
    ('Hostel Maintenance','hostel_maintenance'),
    ('Transfer','transfer'),
    ('Gown','gown'),
    ('Acceptance Fee', 'acceptance'),
    )

class IPaymentsContainer(ISIRPObject):
    """A container for all kind of payment objects.

    """

class IPayment(ISIRPObject):
    """A base representation of payments.

    """
    p_id = Attribute('Payment identifier.')

    p_category = schema.Choice(
        title = u'Payment Category',
        default = u'schoolfee',
        vocabulary = payment_categories,
        required = True,
        )

    p_item = schema.TextLine(
        title = u'Payment Item',
        default = None,
        required = False,
        )

    p_state = schema.Choice(
        title = u'Payment State',
        default = u'unpaid',
        vocabulary = payment_states,
        required = True,
        )

    creation_date = schema.Datetime(
        title = u'Ticket Creation Date',
        readonly = False,
        )

    payment_date = schema.Datetime(
        title = u'Payment Date',
        required = False,
        readonly = False,
        )

    amount_auth = schema.Int(
        title = u'Amount Authorized',
        default = 0,
        required = True,
        readonly = True,
        )

class ISCPayment(IPayment):
    """A scratch card payment.

    """

    p_code = schema.TextLine(
        title = u'Payment Access Code',
        default = u'Certificate XYZ',
        required = False,
        readonly = True,
        )

class IOnlinePayment(IPayment):
    """A payment via payment gateways.

    """

    surcharge_1 = schema.Int(
        title = u'Surcharge 1',
        default = 0,
        required = False,
        readonly = True,
        )

    surcharge_2 = schema.Int(
        title = u'Surcharge 2',
        default = 0,
        required = False,
        readonly = True,
        )

    surcharge_3 = schema.Int(
        title = u'Surcharge 3',
        default = 0,
        required = False,
        readonly = True,
        )

    #order_id = schema.TextLine(
    #    title = u'Order Id',
    #    default = None,
    #    required = True,
    #    )

    ac = schema.TextLine(
        title = u'Activation Code',
        default = None,
        required = False,
        readonly = False,
        )

    r_amount_approved = schema.Int(
        title = u'Response Amount Approved',
        default = 0,
        required = False,
        readonly = False,
        )

    r_desc = schema.TextLine(
        title = u'Response Description',
        default = None,
        required = False,
        readonly = False,
        )

    r_pay_reference = schema.TextLine(
        title = u'Response Payment Reference',
        default = None,
        required = False,
        readonly = False,
        )

    r_code = schema.TextLine(
        title = u'Response Code',
        default = None,
        required = False,
        readonly = False,
        )

    r_card_num = schema.TextLine(
        title = u'Response Card Number',
        default = None,
        required = False,
        readonly = False,
        )