Esempio n. 1
0
    def get_time_navigation_data(self):
        # test
        if 'act_date' in self.request.POST:
            self.act_date = self.request.POST['act_date']

        if 'year' in self.request.POST:
            self.act_date = timezone.make_aware(datetime(year=self.request.POST['year'],
                                                         month=self.request.POST['month'],
                                                         day=1))

        act_date = get_monatserster(self.act_date)
        vormonat_date = shift_month(get_monatserster(self.act_date), step=-1)
        nachmonat_date = shift_month(get_monatserster(self.act_date), step=1)
        monatsliste = {}
        for i in range(1, 13):
            monatsliste[
                datetime(month=i,
                         year=1,
                         day=1).strftime('%m')] = datetime(month=i,
                                                           year=1,
                                                           day=1).strftime('%b')
        jahresliste = []
        for j in range(datetime.now().year + 2, datetime.now().year - 40, -1):
            jahresliste.append(str(j))

        return {
            'act_date': act_date,
            'vormonat_date': vormonat_date,
            'nachmonat_date': nachmonat_date,
            'monatsliste': monatsliste,
            'jahresliste': jahresliste
        }
    def get_context_data(self, **kwargs):
        self.reset()
        # Call the base implementation first to get a context
        if 'year' in self.request.GET:
            self.act_date = timezone.make_aware(
                datetime(year=int(self.request.GET['year']),
                         month=int(self.request.GET['month']),
                         day=1))
        elif 'year' in kwargs:
            self.act_date = timezone.make_aware(
                datetime(year=int(kwargs['year']),
                         month=int(kwargs['month']),
                         day=1))
        else:
            self.act_date = get_monatserster(timezone.now())

        context = super().get_context_data(**kwargs)
        context['nav_timedelta'] = self.get_time_navigation_data()
        context['schichttabelle'] = self.get_table_data()
        self.calc_add_sum_data()
        context['summen'] = self.summen
        context['first_of_month'] = self.act_date
        context['days_before_first'] = (int(self.act_date.strftime("%w")) +
                                        6) % 7

        # brutto in db speichern
        brutto_in_db(brutto=self.summen['bruttolohn'],
                     stunden=self.summen['arbeitsstunden'],
                     monat=self.act_date,
                     assistent=self.request.user.assistent)

        self.reset()
        return context
    def calc_freizeitausgleich(self):
        # anzahl aller feiertage ermitteln
        start = get_monatserster(self.act_date)
        end = get_first_of_next_month(start)

        letzter_tag = (end - timedelta(seconds=1)).day
        ausgleichsstunden = berechne_urlaub_au_saetze(
            datum=start,
            assistent=self.request.user.assistent)['stunden_pro_tag']
        ausgleichslohn = berechne_urlaub_au_saetze(
            datum=start, assistent=self.request.user.assistent)['pro_stunde']
        for tag in range(1, letzter_tag + 1):
            if check_feiertag(
                    datetime(year=start.year, month=start.month, day=tag)):
                self.summen['anzahl_feiertage'] += 1
                self.summen[
                    'freizeitausgleich'] += ausgleichslohn * ausgleichsstunden
Esempio n. 4
0
    def get_context_data(self, **kwargs):
        self.reset()
        # Call the base implementation first to get a context
        if 'year' in self.request.GET:
            self.act_date = timezone.make_aware(datetime(year=int(self.request.GET['year']),
                                                         month=int(self.request.GET['month']),
                                                         day=1))
        elif 'year' in kwargs:
            self.act_date = timezone.make_aware(datetime(year=int(kwargs['year']),
                                                         month=int(kwargs['month']),
                                                         day=1))
        else:
            self.act_date = get_monatserster(timezone.now())

        context = super().get_context_data(**kwargs)
        context['nav_timedelta'] = self.get_time_navigation_data()
        context['schichttabelle'] = self.get_table_data()
        context['first_of_month'] = self.act_date
        context['days_before_first'] = (int(self.act_date.strftime("%w")) + 6) % 7
        context['templates'], context['schichten_nach_templates'] = self.sort_schichten_in_templates()

        self.reset()
        return context