-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(experimental) add running totals functionality
- Loading branch information
1 parent
6679767
commit d71730b
Showing
6 changed files
with
563 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from django.core.management.base import BaseCommand | ||
|
||
from hordak.models import Account, RunningTotal | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "Recalculate running totals for all accounts" | ||
|
||
def handle(self, *args, **options): | ||
print("Recalculating running totals for all accounts") | ||
queryset = Account.objects.all() | ||
for account in queryset[:1000]: | ||
total = account.balance() | ||
for currency in total.currencies(): | ||
RunningTotal.objects.update_or_create( | ||
account=account, | ||
currency=currency, | ||
defaults={"balance": total[currency]}, | ||
) |
Oops, something went wrong.