fix initial balance logic and add edit for cycle data
This commit is contained in:
1 parent
7a9d600aa6
commit
697feb206c
15 files changed
+402
-93
No files matched your search
@@ -95,6 +95,25 @@ class Cycle(models.Model):
|
||||
if self.end_date and self.start_date and self.end_date < self.start_date:
|
||||
raise ValidationError({"end_date": "Must be on or after start_date"})
|
||||
|
||||
def resolved_status(self) -> str:
|
||||
"""Close the cycle once dashboard data through the end date is visible."""
|
||||
from apps.operations.services.visibility import visible_through_date
|
||||
|
||||
if visible_through_date() >= self.end_date:
|
||||
return self.STATUS_CLOSED
|
||||
return self.STATUS_ACTIVE
|
||||
|
||||
def sync_status(self) -> bool:
|
||||
resolved = self.resolved_status()
|
||||
if self.status == resolved:
|
||||
return False
|
||||
self.status = resolved
|
||||
return True
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
self.sync_status()
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
@property
|
||||
def current_day(self) -> int:
|
||||
from apps.operations.services.visibility import visible_through_date
|
||||
|
||||
Reference in new issue
Block a user