示例#1
0
    def _getHousePrice(self, houseName, weekList):
        '''
        '''
        totalPrice = 0
        cleaning = None

        for start, end in weekList:
            duration = (end - start).days
            assert ((duration <= 7) and (duration > 0))

            season = self._getSeason(start, end)
            house = Houses[houseName]

            priceWeek = PRICE_WEEK[house.name][season]

            priceNight = 30000
            if season in PRICE_NIGHT[house.name]:
                priceNight = PRICE_NIGHT[house.name][season]
            else:
                self.logger.log('Pas de tarif à la nuit cette saison')
            # end if

            pricePerNight = self._duration * priceNight
            if (duration == 7) or (pricePerNight > priceWeek):
                # Duration = a week or price for a week is smaller
                housePrice = priceWeek
                cleaning = PRICE_WEEK[house.name][CLEANING]
            else:
                # Price
                housePrice = pricePerNight
                cleaning = PRICE_NIGHT[house.name][CLEANING]
            # end if

            self.logger.log('Prix pour %s (%s au %s): %d Euros' %
                            (houseName, DateTools.shortDate(start),
                             DateTools.shortDate(end), housePrice))
            totalPrice += housePrice
        # end for

        self.logger.log('Ménage pour %s : %d Euros' % (houseName, cleaning))

        addText = ''
        if self._cleaningInc:
            totalPrice += cleaning
            addText = ' (ménage inclus)'
        # end if
        self.logger.log('Total pour %s : %d Euros %s' %
                        (houseName, totalPrice, addText))
        return (totalPrice, cleaning)
示例#2
0
    def _saveConfig(self):
        '''
        '''
        config = {}

        config['locataire'] = self._locataire
        config['start'] = DateTools.shortDate(self._start)
        config['end'] = DateTools.shortDate(self._end)
        config['automatic'] = self._automatic
        config['price'] = self._price
        config['cleaning'] = self._cleaning
        config['avelmor'] = self._avelMor
        config['tyagathe'] = self._tyAgathe
        config['tytania'] = self._tyTania
        config['typapy'] = self._tyPapy
        config['cleaninginc'] = self._cleaningInc

        filename = 'contrats.ini'
        with open(filename, 'w') as f:
            for key, value in config.items():
                f.write('%s = %s\n' % (key, value))
示例#3
0
 def _setend(self, end):
     self._setText('end', DateTools.shortDate(end))
示例#4
0
 def _setstart(self, start):
     self._setText('start', DateTools.shortDate(start))