Skip to content

Commit fd9f1c5

Browse files
author
Even Fjeldstad
committed
Fixed issues after bump
1 parent bf7a7d8 commit fd9f1c5

File tree

5 files changed

+27
-28
lines changed

5 files changed

+27
-28
lines changed

itkufs/accounting/management/commands/createuser.py

+11-24
Original file line numberDiff line numberDiff line change
@@ -26,31 +26,18 @@
2626

2727
CONSOLE_LOG_FORMAT = "%(levelname)-8s %(message)s"
2828

29-
29+
3030
class Command(BaseCommand):
31-
option_list = BaseCommand.option_list + (
32-
make_option(
33-
"-g",
34-
"--group",
35-
dest="group_slug",
36-
help="Group to create new account in",
37-
),
38-
make_option(
39-
"-u",
40-
"--user",
41-
dest="username",
42-
help="User to create uFS user and account for",
43-
),
44-
make_option(
45-
"-y",
46-
"--yes",
47-
action="store_const",
48-
const=1,
49-
dest="yes",
50-
default=0,
51-
help="Do not ask for confirmation",
52-
),
53-
)
31+
def add_arguments(self, parser):
32+
parser.add_argument('-g', '--group',
33+
help="Group to create new account in", dest="group_slug")
34+
35+
parser.add_argument('-u', '--user',
36+
help="User to create uFS user and account for", dest="username")
37+
38+
parser.add_argument('-y', '--yes', action='store_const', const=1,
39+
dest="yes", default=0,
40+
help="Do not ask for confirmation")
5441

5542
def __init__(self):
5643
self.logger = self._setup_logging()

itkufs/accounting/models.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
Value,
1212
F,
1313
ExpressionWrapper,
14+
IntegerField,
1415
)
1516
from django.contrib.auth.models import User
1617
from django.urls import reverse
@@ -913,7 +914,14 @@ class Meta:
913914
unique_together = (("transaction", "account"),)
914915
verbose_name = _("transaction entry")
915916
verbose_name_plural = _("transaction entries")
916-
ordering = ("credit", "debit")
917+
ordering = (
918+
Case(
919+
When(credit__gt=0, then=Value(1)),
920+
When(debit__gt=0, then=Value(0)),
921+
output_field=IntegerField(),
922+
),
923+
"account__name",
924+
)
917925

918926
def __str__(self):
919927
return _("%(account)s: debit %(debit)s, credit %(credit)s") % {

itkufs/common/static/common/ufs.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ Element.observe(window, 'load', Transaction.init);
9999

100100
var Multiselect = {
101101
init: function() {
102-
$$('select[multiple=multiple]').each( // Use css selector to get right nodes.
102+
$$('select[multiple]').each( // Use css selector to get right nodes.
103103
function(selected) {
104104
// Create sibling select
105105
var available = new Element('select', {

itkufs/reports/forms.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def save(self, group: Optional[Group] = None, **kwargs):
134134

135135
if original_commit:
136136
list.save()
137-
list.extra_accounts = self.cleaned_data["extra_accounts"]
137+
list.extra_accounts.set(self.cleaned_data["extra_accounts"])
138138

139139
return list
140140

itkufs/reports/views.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from django.contrib import messages
66
from django.contrib.auth.decorators import login_required
77
from django.db import transaction as db_transaction
8-
from django.db.models import Q, Sum, Case, When
8+
from django.db.models import Q, Sum, Case, When, DecimalField
99
from django.db.models.functions import Coalesce
1010
from django.forms.models import inlineformset_factory, model_to_dict
1111
from django.http import Http404, HttpResponseRedirect, HttpResponse, HttpRequest
@@ -339,17 +339,21 @@ def balance(request: HttpRequest, group: Group, is_admin=False):
339339
Sum(
340340
Case(
341341
When(normal_balance__gt=0, then="normal_balance"),
342+
output_field=DecimalField()
342343
)
343344
),
344345
0,
346+
output_field=DecimalField()
345347
),
346348
negative_sum=Coalesce(
347349
Sum(
348350
Case(
349351
When(normal_balance__lt=0, then="normal_balance"),
352+
output_field=DecimalField()
350353
)
351354
),
352355
0,
356+
output_field=DecimalField()
353357
),
354358
)
355359
)

0 commit comments

Comments
 (0)