Fixed the _find_order_holes() utility to include the check for the minimal order in the accounting application.

This commit is contained in:
依瑪貓 2020-07-21 18:57:34 +08:00
parent e0e2815c34
commit 090f3dc3a5

View File

@ -20,7 +20,7 @@
"""
import re
from django.db.models import Sum, Case, When, F, Q, Count, Max
from django.db.models import Sum, Case, When, F, Q, Count, Max, Min
from django.db.models.functions import TruncMonth, Coalesce
from django.http import HttpResponseRedirect, Http404
from django.shortcuts import render
@ -911,8 +911,8 @@ def _find_order_holes(records):
"""
holes = [x["date"] for x in Transaction.objects
.values("date")
.annotate(count=Count("ord"), max=Max("ord"))
.filter(~Q(count=F("max")))]\
.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"))