Example #1
0
def month(self, mesec, leto, mesec_html):
    current_user = users.get_current_user()

    if current_user:
        salary = Salary.query(Salary.user == current_user.nickname(), Salary.m == mesec,
                              Salary.y == leto).order(Salary.date).fetch()

        daily = []

        for item in salary:
            daily.append(item.daily)

        daily = [w.replace(',', '.') for w in daily]
        daily = map(float, daily)
        month_total_daily = sum(daily)

        dailywtax = []

        for item in salary:
            dailywtax.append(item.dailywtax)

        dailywtax = [w.replace(',', '.') for w in dailywtax]
        dailywtax = map(float, dailywtax)
        month_total_dailywtax = sum(dailywtax)

        total_hrs = []

        for item in salary:
            (h, m) = item.total_hrs.split(":")
            result = int(h) * 3600 + int(m) * 60
            total_hrs.append(result)

        result = sum(total_hrs)

        result = float(result) / 3600.0
        result = str(result)
        (h, m) = result.split(".")
        h = str(h)
        m = str(m)

        m = ("0.%s") % m
        m = float(m)
        m = m * 60.0
        m = round(m)
        m = int(m)
        m = str(m)

        if len(m) < 2:
            m = ("0%s") % (m)

        month_total_hrs = ("%s:%s") % (h, m)

        params = {"salary": salary, "month_total_daily": month_total_daily,
                  "month_total_dailywtax": month_total_dailywtax, "month_total_hrs": month_total_hrs}

        self.render_template(mesec_html, params)

    else:
        return self.render_template(mesec_html)
Example #2
0
    def post(self):
        date = self.request.get("date")
        start = self.request.get("start")
        end = self.request.get("end")
        job_name = self.request.get("job_name")
        eur_hour = self.request.get("eur_hour")
        note = self.request.get("note")
        user = str(users.get_current_user())

        if note == "":
            note = "brez"

        if eur_hour.find(",") != -1:
            eur_hour = eur_hour.replace(",", ".")

        eur_hour = float(eur_hour)

        ts = start
        te = end

        (h, m) = ts.split(":")

        result1 = int(h) * 3600 + int(m) * 60

        (h, m) = te.split(":")

        result2 = int(h) * 3600 + int(m) * 60

        result = result2 - result1

        result = float(result) / 3600.0
        result = str(result)
        (h, m) = result.split(".")
        h = str(h)
        m = str(m)

        m = ("0.%s") % m
        m = float(m)
        m = m * 60.0
        m = round(m)
        m = int(m)
        m = str(m)

        if len(m) < 2:
            m = ("0%s") % (m)

        total_hrs = ("%s:%s") % (h, m)

        dm = float(m) / 60.0
        dm = str(dm)

        (dh, dm2) = dm.split(".")
        daily = ("%s.%s") % (h, dm2)

        daily = float(daily) * eur_hour
        daily = round(daily, 2)

        dailywtax = daily * (1.0 - 0.155)
        dailywtax = round(dailywtax, 2)

        daily = str(daily)
        dailywtax = str(dailywtax)

        if daily.find(".") != -1:
            daily = daily.replace(".", ",")

        if dailywtax.find(".") != -1:
            dailywtax = dailywtax.replace(".", ",")

        eur_hour = str(eur_hour)

        if eur_hour.find(".") != -1:
            eur_hour = eur_hour.replace(".", ",")

        (m, d, y) = date.split("/")

        date = ("%s.%s.%s") % (d, m, y)

        salary = Salary(date=date, start=start, end=end, job_name=job_name, eur_hour=eur_hour, note=note, user=user,
                        total_hrs=total_hrs, daily=daily, dailywtax=dailywtax, d=d, m=m, y=y)
        salary.put()

        self.render_template("dodano.html")
Example #3
0
 def post(self, table_id):
     table = Salary.get_by_id(int(table_id))
     table.key.delete()
     return self.redirect_to("pregled")
Example #4
0
    def get(self, table_id):
        table = Salary.get_by_id(int(table_id))

        params = {"table": table}

        self.render_template("table_delete.html", params)
Example #5
0
def month(self, mesec, leto, mesec_html):
    current_user = users.get_current_user()

    if current_user:
        salary = Salary.query(Salary.user == current_user.nickname(),
                              Salary.m == mesec,
                              Salary.y == leto).order(Salary.date).fetch()

        daily = []

        for item in salary:
            daily.append(item.daily)

        daily = [w.replace(',', '.') for w in daily]
        daily = map(float, daily)
        month_total_daily = sum(daily)

        dailywtax = []

        for item in salary:
            dailywtax.append(item.dailywtax)

        dailywtax = [w.replace(',', '.') for w in dailywtax]
        dailywtax = map(float, dailywtax)
        month_total_dailywtax = sum(dailywtax)

        total_hrs = []

        for item in salary:
            (h, m) = item.total_hrs.split(":")
            result = int(h) * 3600 + int(m) * 60
            total_hrs.append(result)

        result = sum(total_hrs)

        result = float(result) / 3600.0
        result = str(result)
        (h, m) = result.split(".")
        h = str(h)
        m = str(m)

        m = ("0.%s") % m
        m = float(m)
        m = m * 60.0
        m = round(m)
        m = int(m)
        m = str(m)

        if len(m) < 2:
            m = ("0%s") % (m)

        month_total_hrs = ("%s:%s") % (h, m)

        params = {
            "salary": salary,
            "month_total_daily": month_total_daily,
            "month_total_dailywtax": month_total_dailywtax,
            "month_total_hrs": month_total_hrs
        }

        self.render_template(mesec_html, params)

    else:
        return self.render_template(mesec_html)
Example #6
0
    def post(self):
        date = self.request.get("date")
        start = self.request.get("start")
        end = self.request.get("end")
        job_name = self.request.get("job_name")
        eur_hour = self.request.get("eur_hour")
        note = self.request.get("note")
        user = str(users.get_current_user())

        if note == "":
            note = "brez"

        if eur_hour.find(",") != -1:
            eur_hour = eur_hour.replace(",", ".")

        eur_hour = float(eur_hour)

        ts = start
        te = end

        (h, m) = ts.split(":")

        result1 = int(h) * 3600 + int(m) * 60

        (h, m) = te.split(":")

        result2 = int(h) * 3600 + int(m) * 60

        result = result2 - result1

        result = float(result) / 3600.0
        result = str(result)
        (h, m) = result.split(".")
        h = str(h)
        m = str(m)

        m = ("0.%s") % m
        m = float(m)
        m = m * 60.0
        m = round(m)
        m = int(m)
        m = str(m)

        if len(m) < 2:
            m = ("0%s") % (m)

        total_hrs = ("%s:%s") % (h, m)

        dm = float(m) / 60.0
        dm = str(dm)

        (dh, dm2) = dm.split(".")
        daily = ("%s.%s") % (h, dm2)

        daily = float(daily) * eur_hour
        daily = round(daily, 2)

        dailywtax = daily * (1.0 - 0.155)
        dailywtax = round(dailywtax, 2)

        daily = str(daily)
        dailywtax = str(dailywtax)

        if daily.find(".") != -1:
            daily = daily.replace(".", ",")

        if dailywtax.find(".") != -1:
            dailywtax = dailywtax.replace(".", ",")

        eur_hour = str(eur_hour)

        if eur_hour.find(".") != -1:
            eur_hour = eur_hour.replace(".", ",")

        (m, d, y) = date.split("/")

        date = ("%s.%s.%s") % (d, m, y)

        salary = Salary(date=date,
                        start=start,
                        end=end,
                        job_name=job_name,
                        eur_hour=eur_hour,
                        note=note,
                        user=user,
                        total_hrs=total_hrs,
                        daily=daily,
                        dailywtax=dailywtax,
                        d=d,
                        m=m,
                        y=y)
        salary.put()

        self.render_template("dodano.html")
Example #7
0
 def post(self, table_id):
     table = Salary.get_by_id(int(table_id))
     table.key.delete()
     return self.redirect_to("pregled")
Example #8
0
    def get(self, table_id):
        table = Salary.get_by_id(int(table_id))

        params = {"table": table}

        self.render_template("table_delete.html", params)