Ignore:
Timestamp:
20 Mar 2015, 18:51:29 (10 years ago)
Author:
Henrik Bettermann
Message:

Prepare products and contracts for annual payments.

Location:
main/ikobacustom.pcn/trunk/src/ikobacustom/pcn
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • main/ikobacustom.pcn/trunk/src/ikobacustom/pcn/customers/browser.py

    r12617 r12803  
    2020from zope.component import getUtility
    2121from waeup.ikoba.interfaces import IIkobaUtils, IExtFileStore
     22from waeup.ikoba.browser.layout import action
    2223from waeup.ikoba.customers.browser import (
    23     PDFContractSlipPage, CustomerBaseEditFormPage)
     24    PDFContractSlipPage, CustomerBaseEditFormPage, ContractSelectProductPage, msave)
    2425from ikobacustom.pcn.interfaces import MessageFactory as _
    2526from ikobacustom.pcn.customers.interfaces import (
     
    8889            return error
    8990        return
     91
     92
     93class ContractSelectProductPage(ContractSelectProductPage):
     94    """ Page to select a contract product
     95
     96    This page is for both customers and officers.
     97    """
     98
     99    @action(_('Save and proceed'), style='primary')
     100    def save(self, **data):
     101        msave(self, **data)
     102        self.context.contract_year = self.context.product_object.contract_year
     103        self.context.title = self.context.product_object.contract_autotitle
     104        self.context.tc_dict = self.context.product_object.tc_dict
     105        self.context.valid_from = self.context.product_object.valid_from
     106        self.context.valid_to = self.context.product_object.valid_to
     107        isCustomer = getattr(
     108            self.request.principal, 'user_type', None) == 'customer'
     109        if isCustomer:
     110            self.redirect(self.url(self.context, 'edit'))
     111        else:
     112            self.redirect(self.url(self.context, 'manage'))
     113        return
  • main/ikobacustom.pcn/trunk/src/ikobacustom/pcn/customers/contracts.py

    r12617 r12803  
    6767
    6868
    69 class RONContract(ContractBase):
     69class PCNContract(ContractBase):
     70    """This is a sample contract.
     71    """
     72
     73    def __init__(self):
     74        super(PCNContract, self).__init__()
     75        # The site doesn't exist in unit tests
     76        self.contract_year = None
     77        return
     78
     79
     80class RONContract(PCNContract):
    7081    """This is a sample contract.
    7182    """
     
    105116
    106117
    107 class ROPContract(ContractBase):
     118class ROPContract(PCNContract):
    108119    """This is a sample contract.
    109120    """
     
    143154
    144155
    145 class RPRContract(ContractBase):
     156class RPRContract(PCNContract):
    146157    """Registration in the Provisional Register contract.
    147158    """
     
    181192
    182193
    183 class RPCContract(ContractBase):
     194class RPCContract(PCNContract):
    184195    """Registration as Pharmaceutical Chemist contract.
    185196    """
     
    219230
    220231
    221 class IPPMVLContract(ContractBase):
     232class IPPMVLContract(PCNContract):
    222233    """Issuance of Patent and Proprietary Medicines Vendors License contract.
    223234    """
     
    257268
    258269
    259 class RPPMVLContract(ContractBase):
     270class RPPMVLContract(PCNContract):
    260271    """Renewal of Patent and Proprietary Medicines Vendors License contract.
    261272    """
     
    295306
    296307
    297 class APPITContract(ContractBase):
     308class APPITContract(PCNContract):
    298309    """Accepting Pupil Pharmacist for Internship Training contract.
    299310    """
     
    333344
    334345
    335 class RPTContract(ContractBase):
     346class RPTContract(PCNContract):
    336347    """Registration as a Pharmacy Technician contract.
    337348    """
     
    371382
    372383
    373 class APPTContract(ContractBase):
     384class APPTContract(PCNContract):
    374385    """Annual Permit for Pharmacy Technician contract.
    375386    """
  • main/ikobacustom.pcn/trunk/src/ikobacustom/pcn/customers/export.py

    r12617 r12803  
    3535from ikobacustom.pcn.interfaces import MessageFactory as _
    3636
     37
    3738class PCNCustomerExporter(CustomerExporter):
    3839    """Exporter for Customers.
     
    4950    title = _(u'PCN Customer JPG Documents')
    5051    class_name = 'PCNCustomerJPGDocument'
     52
    5153
    5254class PCNCustomerPDFDocumentExporter(CustomerDocumentExporterBase):
     
    7678    class_name = 'ROPContract'
    7779
     80
    7881class RPRContractExporter(ContractExporterBase):
    7982    """Exporter for Contract instances.
     
    8386    title = _(u'Licenses: Registration in the Provisional Register')
    8487    class_name = 'RPRContract'
     88
    8589
    8690class RPCContractExporter(ContractExporterBase):
     
    9296    class_name = 'RPCContract'
    9397
     98
    9499class IPPMVLContractExporter(ContractExporterBase):
    95100    """Exporter for Contract instances.
     
    99104    title = _(u'Licenses: Issuance of Patent and Proprietary Medicines Vendors')
    100105    class_name = 'IPPMVLContract'
     106
    101107
    102108class RPPMVLContractExporter(ContractExporterBase):
     
    108114    class_name = 'RPPMVLContract'
    109115
     116
    110117class APPITContractExporter(ContractExporterBase):
    111118    """Exporter for Contract instances.
     
    115122    title = _(u'Licenses: Accepting Pupil Pharmacist for Internship Training')
    116123    class_name = 'APPITContract'
     124
    117125
    118126class RPTContractExporter(ContractExporterBase):
     
    124132    class_name = 'RPTContract'
    125133
     134
    126135class APPTContractExporter(ContractExporterBase):
    127136    """Exporter for Contract instances.
  • main/ikobacustom.pcn/trunk/src/ikobacustom/pcn/customers/interfaces.py

    r12801 r12803  
    1919from zope import schema
    2020from datetime import datetime
     21from zope.interface import Attribute, Interface
    2122from zc.sourcefactory.basic import BasicSourceFactory
    2223from waeup.ikoba.interfaces import IIkobaObject
     
    3839def year_range():
    3940    curr_year = datetime.now().year
    40     return range(curr_year - 2, curr_year + 5)
     41    return range(curr_year - 20, curr_year + 2)
    4142
    4243class PracticeSource(BasicSourceFactory):
     
    8687    """
    8788
     89class IPCNContract(IContract):
     90    """A Retention of Name contract.
     91
     92    """
     93    contract_year = Attribute('Year of License')
     94
     95
    8896# Customer contract interfaces
    8997
    90 class IRONContract(IContract):
     98class IRONContract(IPCNContract):
    9199    """A Retention of Name contract.
    92100
     
    105113        )
    106114
    107     year_qualification = schema.Choice(
     115    qualification_year = schema.Choice(
    108116        title = _(u'Year of Qualification'),
    109117        required = True,
     
    182190
    183191
    184 class IROPContract(IContract):
     192class IROPContract(IPCNContract):
    185193    """A Registration of Premises contract.
    186194
     
    291299    #    )
    292300
    293 class IRPRContract(IContract):
     301class IRPRContract(IPCNContract):
    294302    """A Registration in the Provisional Register contract.
    295303
     
    425433
    426434
    427 class IRPCContract(IContract):
     435class IRPCContract(IPCNContract):
    428436    """A Registration as Pharmaceutical Chemist contract.
    429437
     
    570578    'certificates_object'].order
    571579
    572 class IIPPMVLContract(IContract):
     580class IIPPMVLContract(IPCNContract):
    573581    """A Issuance of Patent and Proprietary Medicines Vendors License.
    574582
     
    744752    'incometax_object'].order
    745753
    746 class IRPPMVLContract(IContract):
     754class IRPPMVLContract(IPCNContract):
    747755    """A Renewal of Patent and Proprietary Medicines Vendors License.
    748756
     
    876884    """
    877885
    878 class IAPPITContract(IContract):
     886class IAPPITContract(IPCNContract):
    879887    """A Accepting Pupil Pharmacist for Internship Training contract.
    880888
     
    10201028    """
    10211029
    1022 class IRPTContract(IContract):
     1030class IRPTContract(IPCNContract):
    10231031    """A Registration as a Pharmacy Technician contract.
    10241032
     
    11301138    """
    11311139
    1132 class IAPPTContract(IContract):
     1140class IAPPTContract(IPCNContract):
    11331141    """An Annual Permit for Pharmacy Technician contract.
    11341142
  • main/ikobacustom.pcn/trunk/src/ikobacustom/pcn/customers/tests/test_browser.py

    r12798 r12803  
    224224        result = open(self.outfile, 'rb').read()
    225225        self.assertMatches(result,
    226             'categories_practice,class_name,comment,contract_category,contract_id,'
    227             'fee_based,history,last_product_id,lga,nationality,product_object,'
    228             'product_options,state,superintendent,'
    229             'tc_dict,title,user_id,valid_from,valid_to,work_address,work_email,work_phone,'
    230             'year_qualification\r\n'
    231             '[],RONContract,,ron,%s,0,'
    232             '[u\'2015-01-18 16:40:01 WAT - License created by system\'],,,,,'
    233             '[],created,,{\'en\': u\'Hello World\'},,K1000000,,,,,,\r\n'
     226            'categories_practice,class_name,comment,contract_category,'
     227            'contract_id,contract_year,fee_based,history,last_product_id,'
     228            'lga,nationality,product_object,product_options,'
     229            'qualification_year,state,superintendent,tc_dict,'
     230            'title,user_id,valid_from,valid_to,work_address,'
     231            'work_email,work_phone\r\n'
     232            '[],RONContract,,ron,%s,,0,'
     233            '[u\'2015-03-20 19:13:53 WAT - License created by system\']'
     234            ',,,,,[],,created,,{\'en\': u\'Hello World\'},,K1000000,,,,,\r\n'
    234235            % self.contract1.contract_id)
    235236        # We can reimport the file if we change the header
     
    283284        result = open(self.outfile, 'rb').read()
    284285        self.assertMatches(result,
    285             'categories_practice,class_name,contract_category,contract_id,'
    286             'date_of_qualification,fee_based,history,inspected,last_license_number,'
     286            'categories_practice,class_name,contract_category,'
     287            'contract_id,contract_year,date_of_qualification,'
     288            'fee_based,history,inspected,last_license_number,'
    287289            'last_product_id,official_in_state,other_directors,'
    288290            'pharmacists_directors,premises_address,premises_certificate,'
    289             'product_object,product_options,recommended,'
    290             'state,superintendent,tc_dict,title,user_id,valid_from,valid_to,'
    291             'work_address\r\n'
    292 
    293             '[],ROPContract,rop,%s,,0,'
    294             '[u\'2015-01-20 18:51:03 WAT - License created by system\']'
     291            'product_object,product_options,recommended,state,'
     292            'superintendent,tc_dict,title,user_id,valid_from,'
     293            'valid_to,work_address\r\n'
     294
     295            '[],ROPContract,rop,%s,,,0,'
     296            '[u\'2015-03-20 19:18:30 WAT - License created by system\']'
    295297            ',,,,,,,,,,[],,created,,{\'en\': u\'Hello World\'},,K1000000,,,\r\n'
    296298            % self.contract2.contract_id)
  • main/ikobacustom.pcn/trunk/src/ikobacustom/pcn/products/interfaces.py

    r12371 r12803  
    1616## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    1717##
     18from zope import schema
    1819from waeup.ikoba.products.interfaces import IProduct
    1920from ikobacustom.pcn.interfaces import MessageFactory as _
     
    2425
    2526    """
     27
     28    contract_year = schema.Int(
     29        title=u'Year of License',
     30        description=_(u'Enter 4-digit license year.'),
     31        required=False,
     32        min=1990,
     33        max=2050,
     34        )
     35
     36IPCNProduct['contract_year'].order = IPCNProduct['valid_from'].order
  • main/ikobacustom.pcn/trunk/src/ikobacustom/pcn/products/tests/test_browser.py

    r12686 r12803  
    5454        result = open(self.outfile, 'rb').read()
    5555        self.assertEqual(result,
    56             'contract_category,contract_title,description,options,'
     56            'contract_category,contract_title,contract_year,description,options,'
    5757            'product_id,terms_and_conditions,title,valid_from,valid_to,'
    5858            'users_with_local_roles\r\n'
    59             'ron,,,[],RON,,Unnamed,2015-12-04#,,[]\r\n')
     59            'ron,,,,[],RON,,Unnamed,2015-12-04#,,[]\r\n')
    6060        # We can import the same file.
    6161        processor = PCNProductProcessor()
     
    7474        result = processor.doImport(
    7575            self.outfile,
    76             ['contract_category','contract_title', 'description', 'options',
    77             'product_id', 'terms_and_conditions','title','valid_from','valid_to',
     76            ['contract_category','contract_title','contract_year',
     77            'description', 'options',
     78            'product_id', 'terms_and_conditions',
     79            'title','valid_from','valid_to',
    7880            'users_with_local_roles'],
    7981            mode='create')
     
    8486        result = processor.doImport(
    8587            self.outfile,
    86             ['contract_category','contract_title', 'description', 'options',
    87             'product_id', 'terms_and_conditions','title','valid_from','valid_to',
     88            ['contract_category','contract_title', 'contract_year',
     89            'description', 'options',
     90            'product_id', 'terms_and_conditions',
     91            'title','valid_from','valid_to',
    8892            'users_with_local_roles'],
    8993            mode='update')
Note: See TracChangeset for help on using the changeset viewer.