diff options
author | luxagraf <sng@luxagraf.net> | 2019-01-13 11:51:02 -0600 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2019-01-13 11:51:02 -0600 |
commit | c4da428fc9ec439389b7473ba5638d9f82085475 (patch) | |
tree | 2c135804e201b3008fe56db25d993881a49da686 /app/income/models.py | |
parent | 120021d565eefa0318c487f0ff5707c7b9893b43 (diff) |
updated income and resume apps
Diffstat (limited to 'app/income/models.py')
-rw-r--r-- | app/income/models.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/app/income/models.py b/app/income/models.py index 688d1d7..e5a351b 100644 --- a/app/income/models.py +++ b/app/income/models.py @@ -69,6 +69,9 @@ class InvoiceItem(models.Model): time_end = models.DateTimeField(null=True, blank=True) work_done = models.TextField(null=True, blank=True) + class Meta: + ordering = ('time_start',) + def __str__(self): return str(self.time_start) @@ -89,6 +92,12 @@ class InvoiceItem(models.Model): half_period_seconds = period_seconds / 2 remainder = td.total_seconds() % period_seconds if remainder >= half_period_seconds: - return timedelta(seconds=td.total_seconds() + (period_seconds - remainder)) + tdr = timedelta(seconds=td.total_seconds() + (period_seconds - remainder)) + hours, remainder = divmod(tdr.total_seconds(), 3600) + r = remainder/3600 + return float(hours)+r else: - return timedelta(seconds=td.total_seconds() - remainder) + tdr = timedelta(seconds=td.total_seconds() - remainder) + hours, remainder = divmod(tdr.total_seconds(), 3600) + r = remainder/3600 + return float(hours)+r |