Package Camelot :: Package camelot :: Package view :: Package wizard :: Module new_company |
[frames] | no frames]

# Source Code for Module Camelot.camelot.view.wizard.new_company

      1  #import urllib

      2  #from PyQt4 import QtGui, QtCore

      3  #

      4  #class NewCompanyWizard( QtGui.QWizard ):

      5  #    def __init__( wizard, organization_getter, parent = None ):

      6  #        super( NewCompanyWizard, wizard ).__init__( parent )

      7  #        wizard.value = ''

      8  #        wizard.success = False

      9  #        wizard.name = ''

     10  #        wizard.town = ''

     11  #        wizard.street = ''

     12  #        wizard.taxid = ''

     13  #        wizard.setWindowTitle( 'New Company Wizard' )

     14  #        combobox = QtGui.QComboBox()

     15  #        combobox.insertItem( 0, unicode( 'Loading list ...' ), QtCore.QVariant( all ) )

     16  #

     17  #        class WelcomePage( QtGui.QWizardPage ):

     18  #            def __init__( self ):

     19  #                super( WelcomePage, self ).__init__()

     20  #                self.setTitle( 'New Company Wizard' )

     21  #                self.setSubTitle( 'Welcome, This wizard will help you to add a new company' )

     22  #

     23  #        class inputPage( QtGui.QWizardPage ):

     24  #            def __init__( self ):

     25  #                super( inputPage, self ).__init__()

     26  #                self.comboBox = QtGui.QComboBox()

     27  #                self.vat = QtGui.QLineEdit()

     28  #                self.setTitle( 'New Company Wizard' )

     29  #                self.setSubTitle( 'Select the company\'s country, and fill in its VAT Number' )

     30  #                layout = QtGui.QHBoxLayout()

     31  #                layout.addSpacing( 30 )

     32  #                layout.addWidget( self.comboBox )

     33  #                layout.addWidget( self.vat )

     34  #                #layout.maximumSize()

     35  #                self.connect( self.vat, QtCore.SIGNAL( 'textChanged(const QString&)' ), self.textChanged )

     36  #                layout.addStretch( 0 )

     37  #                self.setLayout( layout )

     38  #

     39  #            def textChanged( self, text ):

     40  #                self.emit( QtCore.SIGNAL( 'completeChanged()' ) )

     41  #

     42  #            def isComplete( self ):

     43  #                wizard.value = str( self.comboBox.currentText() )[0:2] + str( self.vat.text() )

     44  #                if wizard.value[10:] is '':

     45  #                    return False

     46  #                else:

     47  #                    return True

     48  #

     49  #            def initializePage( self ):

     50  #                landen = QtCore.QStringList()

     51  #                landen.append( 'AT - Austria' )

     52  #                landen.append( 'BE - Belgium' )

     53  #                landen.append( 'BG - Bulgaria' )

     54  #                landen.append( 'CY - Cyprus' )

     55  #                landen.append( 'CZ - Czech Republic' )

     56  #                landen.append( 'DE - Germany' )

     57  #                landen.append( 'DK - Denmark' )

     58  #                landen.append( 'EE - Estonia' )

     59  #                landen.append( 'EL - Greece ' )

     60  #                landen.append( 'ES - Spain ' )

     61  #                landen.append( 'FI - Finland' )

     62  #                landen.append( 'FR - France' )

     63  #                landen.append( 'GB - United Kingdom' )

     64  #                landen.append( 'HU - Hungary' )

     65  #                landen.append( 'IE - Ireland' )

     66  #                landen.append( 'IT - Italy' )

     67  #                landen.append( 'LT - Lithuania' )

     68  #                landen.append( 'LU - Luxembourg' )

     69  #                landen.append( 'LV - Latvia' )

     70  #                landen.append( 'MT - Malta' )

     71  #                landen.append( 'NL - The Netherlands' )

     72  #                landen.append( 'PL - Poland' )

     73  #                landen.append( 'PT - Portugal' )

     74  #                landen.append( 'RO - Romania' )

     75  #                landen.append( 'SE - Sweden' )

     76  #                landen.append( 'SI - Slovenia' )

     77  #                landen.append( 'sK - Slovakia' )

     78  #                self.comboBox.addItems( landen )

     79  #

     80  #        class checkPage( QtGui.QWizardPage ):

     81  #            def __init__( self ):

     82  #                super( checkPage, self ).__init__()

     83  #                self.success = False

     84  #                self.ondernemingsVorm = QtGui.QLabel()

     85  #                self.name = QtGui.QLabel()

     86  #                self.street = QtGui.QLabel()

     87  #                self.town = QtGui.QLabel()

     88  #                self.setTitle( 'Add New Company' )

     89  #                if self.success == False:

     90  #                    self.setSubTitle( '' )

     91  #                else:

     92  #                    self.setSubTitle( 'Here is the adress we found in the database, make sure this is correct.' )

     93  #                layout = QtGui.QVBoxLayout()

     94  #                naamlayout = QtGui.QHBoxLayout()

     95  #                naamlayout.addWidget( self.ondernemingsVorm )

     96  #                naamlayout.addWidget( self.name )

     97  #                layout.addLayout( naamlayout )

     98  #                layout.addWidget( self.street )

     99  #                layout.addWidget( self.town )

    100  #                layout.addStretch( 1 )

    101  #                self.setLayout( layout )

    102  #

    103  #            def isComplete( self ):

    104  #                if not wizard.success:

    105  #                    return False

    106  #                else:

    107  #                    return True

    108  #

    109  #            def initializePage( self ):

    110  #                url = 'http://ec.europa.eu/taxation_customs/vies/viesquer.do?ms=' + wizard.value[0:2] + '&iso=' + wizard.value[0:2] + '&vat=' + wizard.value[2:]

    111  #                file = urllib.urlopen( url )

    112  #                test = file.readlines()

    113  #                succes = str( test[323] )

    114  #                name = str( test[365] )

    115  #                adress = str( test[378] )

    116  #                succes = succes.strip()

    117  #                print succes

    118  #                if succes[0] == 'S':

    119  #                    self.setSubTitle( 'System Overloaded, please try again later.' )

    120  #                else:

    121  #                    if succes[0] == 'Y':

    122  #                        wizard.success = True

    123  #                    else:

    124  #                        wizard.success = False

    125  #                    if wizard.success == False:

    126  #                        self.setSubTitle( '' )

    127  #                    else:

    128  #                        self.setSubTitle( 'Here is the address we found in the database, make sure this is correct.' )

    129  #                        name = name.strip()

    130  #                        if name.find( ' ' ) == -1:

    131  #                            self.setSubTitle( 'VAT Number Correct, but no information was found in the Database.' )

    132  #                            self.name.setText( '' )

    133  #                            self.ondernemingsVorm.setText( '' )

    134  #                            self.street.setText( '' )

    135  #                            self.town.setText( '' )

    136  #                        else:

    137  #                            self.name.setText( name )

    138  #                            firstSpace = name.index( ' ' )

    139  #                            self.ondernemingsVorm.setText( name[0:firstSpace] )

    140  #                            name = name[firstSpace:]

    141  #                            wizard.name = name.strip()

    142  #                            self.name.setText( name )

    143  #                            adress = adress.strip()

    144  #                            firstTag = adress.index( '<' )

    145  #                            wizard.street = adress[0:firstTag]

    146  #                            adress = adress[firstTag + 4:]

    147  #                            wizard.town = adress

    148  #                            self.street.setText( wizard.street )

    149  #                            self.town.setText( wizard.town )

    150  #                            wizard.taxid = str( wizard.value )

    151  #                    if not wizard.success:

    152  #                        self.ondernemingsVorm.setText( 'Nothing Found.' )

    153  #                        self.name.setText( ' ' )

    154  #                        self.street.setText( 'Please retyp the VAT number' )

    155  #                        self.town.setText( ' ' )

    156  #

    157  #        wizard.addPage( WelcomePage() )

    158  #        wizard.addPage( inputPage() )

    159  #        wizard.addPage( checkPage() )

    160  #

    161  #    def finished( self, result ):

    162  #        pass
    163