Revised the code of the views of the account application with PEP8.
This commit is contained in:
parent
b353a3fba8
commit
7a6879951a
@ -114,10 +114,8 @@ def cash(request, account_code, period_spec):
|
||||
Q(transaction__in=Transaction.objects.filter(
|
||||
Q(date__gte=period.start),
|
||||
Q(date__lte=period.end),
|
||||
Q(record__account__code__startswith=
|
||||
current_account.code))),
|
||||
~Q(account__code__startswith=
|
||||
current_account.code))
|
||||
Q(record__account__code__startswith=account_code))),
|
||||
~Q(account__code__startswith=account_code))
|
||||
.order_by("transaction__date", "is_credit", "ord"))
|
||||
balance_before = Record.objects\
|
||||
.filter(
|
||||
@ -215,10 +213,10 @@ def cash_summary(request, account_code):
|
||||
~Q(account__code__startswith="11"),
|
||||
~Q(account__code__startswith="12"),
|
||||
~Q(account__code__startswith="21"),
|
||||
~Q(account__code__startswith="22")) \
|
||||
.annotate(month=TruncMonth("transaction__date")) \
|
||||
.values("month") \
|
||||
.order_by("month") \
|
||||
~Q(account__code__startswith="22"))
|
||||
.annotate(month=TruncMonth("transaction__date"))
|
||||
.values("month")
|
||||
.order_by("month")
|
||||
.annotate(
|
||||
debit=Coalesce(
|
||||
Sum(Case(When(is_credit=False, then=F("amount")))),
|
||||
@ -233,12 +231,11 @@ def cash_summary(request, account_code):
|
||||
months = [RecordSummary(**x) for x in Record.objects
|
||||
.filter(
|
||||
Q(transaction__in=Transaction.objects.filter(
|
||||
record__account__code__startswith=
|
||||
current_account.code)),
|
||||
~Q(account__code__startswith=current_account.code)) \
|
||||
.annotate(month=TruncMonth("transaction__date")) \
|
||||
.values("month") \
|
||||
.order_by("month") \
|
||||
record__account__code__startswith=account_code)),
|
||||
~Q(account__code__startswith=account_code))
|
||||
.annotate(month=TruncMonth("transaction__date"))
|
||||
.values("month")
|
||||
.order_by("month")
|
||||
.annotate(
|
||||
debit=Coalesce(
|
||||
Sum(Case(When(is_credit=False, then=F("amount")))),
|
||||
@ -289,7 +286,8 @@ def ledger_default(request):
|
||||
account_code = settings.ACCOUNTING["DEFAULT_LEDGER_ACCOUNT"]
|
||||
period_spec = dateformat.format(timezone.localdate(), "Y-m")
|
||||
return HttpResponseRedirect(
|
||||
reverse("accounting:ledger", args=(account_code, period_spec)))
|
||||
reverse("accounting:ledger",
|
||||
args=(account_code, period_spec)))
|
||||
|
||||
|
||||
@require_GET
|
||||
@ -400,11 +398,11 @@ def ledger_summary(request, account_code):
|
||||
if current_account is None:
|
||||
raise Http404()
|
||||
# The month summaries
|
||||
months = [RecordSummary(**x) for x in Record.objects\
|
||||
.filter(account__code__startswith=current_account.code)\
|
||||
.annotate(month=TruncMonth("transaction__date"))\
|
||||
.values("month")\
|
||||
.order_by("month")\
|
||||
months = [RecordSummary(**x) for x in Record.objects
|
||||
.filter(account__code__startswith=current_account.code)
|
||||
.annotate(month=TruncMonth("transaction__date"))
|
||||
.values("month")
|
||||
.order_by("month")
|
||||
.annotate(
|
||||
debit=Coalesce(
|
||||
Sum(Case(When(is_credit=False, then=F("amount")))),
|
||||
@ -942,9 +940,11 @@ def _find_order_holes(records):
|
||||
"""
|
||||
holes = [x["date"] for x in Transaction.objects
|
||||
.values("date")
|
||||
.annotate(count=Count("ord"), max=Max("ord"), min=Min("ord"))
|
||||
.filter(~(Q(max=F("count")) & Q(min=1)))]\
|
||||
+ [x["date"] for x in Transaction.objects
|
||||
.annotate(count=Count("ord"),
|
||||
max=Max("ord"),
|
||||
min=Min("ord"))
|
||||
.filter(~(Q(max=F("count")) & Q(min=1)))] +\
|
||||
[x["date"] for x in Transaction.objects
|
||||
.values("date", "ord")
|
||||
.annotate(count=Count("sn"))
|
||||
.filter(~Q(count=1))]
|
||||
|
Loading…
Reference in New Issue
Block a user