fnschool 20251012.81520.855__tar.gz → 20251013.81200.824__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/PKG-INFO +1 -1
  2. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/__init__.py +2 -2
  3. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/canteen/templates/canteen/consumption/create.html +3 -0
  4. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/canteen/workbook/generate.py +88 -56
  5. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschool.egg-info/PKG-INFO +1 -1
  6. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/LICENSE +0 -0
  7. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/README.md +0 -0
  8. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/pyproject.toml +0 -0
  9. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/setup.cfg +0 -0
  10. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/canteen/__init__.py +0 -0
  11. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/canteen/admin.py +0 -0
  12. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/canteen/apps.py +0 -0
  13. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/canteen/forms.py +0 -0
  14. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/canteen/migrations/0001_initial.py +0 -0
  15. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/canteen/migrations/0002_ingredient_is_disabled.py +0 -0
  16. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/canteen/migrations/0003_consumption_is_disabled_alter_ingredient_is_disabled.py +0 -0
  17. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/canteen/migrations/0004_alter_ingredient_name_category_and_more.py +0 -0
  18. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/canteen/migrations/0005_alter_category_created_at_alter_category_name_and_more.py +0 -0
  19. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/canteen/migrations/0006_category_is_disabled_alter_category_user_and_more.py +0 -0
  20. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/canteen/migrations/0007_alter_consumption_amount_used_and_more.py +0 -0
  21. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/canteen/migrations/0008_category_abbreviation_mealtype.py +0 -0
  22. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/canteen/migrations/0009_alter_category_abbreviation_and_more.py +0 -0
  23. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/canteen/migrations/0010_alter_consumption_options_alter_ingredient_options_and_more.py +0 -0
  24. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/canteen/migrations/0011_category_pin_to_consumptions_top.py +0 -0
  25. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/canteen/migrations/0012_alter_ingredient_storage_date.py +0 -0
  26. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/canteen/migrations/0013_alter_consumption_options_alter_ingredient_options_and_more.py +0 -0
  27. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/canteen/migrations/__init__.py +0 -0
  28. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/canteen/models.py +0 -0
  29. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/canteen/templates/canteen/category/create.html +0 -0
  30. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/canteen/templates/canteen/category/delete.html +0 -0
  31. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/canteen/templates/canteen/category/list.html +0 -0
  32. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/canteen/templates/canteen/category/update.html +0 -0
  33. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/canteen/templates/canteen/close.html +0 -0
  34. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/canteen/templates/canteen/consumption/_create.html +0 -0
  35. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/canteen/templates/canteen/ingredient/close.html +0 -0
  36. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/canteen/templates/canteen/ingredient/create.html +0 -0
  37. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/canteen/templates/canteen/ingredient/create_one.html +0 -0
  38. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/canteen/templates/canteen/ingredient/delete.html +0 -0
  39. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/canteen/templates/canteen/ingredient/list.html +0 -0
  40. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/canteen/templates/canteen/ingredient/update.html +0 -0
  41. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/canteen/templates/canteen/meal_type/create.html +0 -0
  42. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/canteen/templates/canteen/meal_type/delete.html +0 -0
  43. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/canteen/templates/canteen/meal_type/list.html +0 -0
  44. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/canteen/templates/canteen/meal_type/update.html +0 -0
  45. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/canteen/tests.py +0 -0
  46. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/canteen/urls.py +0 -0
  47. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/canteen/views.py +0 -0
  48. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/canteen/workbook/__init__.py +0 -0
  49. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/fnschool/__init__.py +0 -0
  50. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/fnschool/asgi.py +0 -0
  51. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/fnschool/settings.py +0 -0
  52. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/fnschool/templatetags/__init__.py +0 -0
  53. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/fnschool/templatetags/fnschool_tags.py +0 -0
  54. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/fnschool/urls.py +0 -0
  55. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/fnschool/views.py +0 -0
  56. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/fnschool/wsgi.py +0 -0
  57. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/locale/en/LC_MESSAGES/django.mo +0 -0
  58. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/locale/zh_Hans/LC_MESSAGES/django.mo +0 -0
  59. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/manage.py +0 -0
  60. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/profiles/__init__.py +0 -0
  61. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/profiles/admin.py +0 -0
  62. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/profiles/apps.py +0 -0
  63. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/profiles/forms.py +0 -0
  64. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/profiles/migrations/0001_initial.py +0 -0
  65. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/profiles/migrations/0002_alter_profile_bio.py +0 -0
  66. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/profiles/migrations/0003_alter_profile_options_alter_profile_address_and_more.py +0 -0
  67. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/profiles/migrations/0004_profile_gender.py +0 -0
  68. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/profiles/migrations/0005_alter_profile_gender.py +0 -0
  69. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/profiles/migrations/__init__.py +0 -0
  70. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/profiles/models.py +0 -0
  71. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/profiles/signals.py +0 -0
  72. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/profiles/templates/profiles/create.html +0 -0
  73. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/profiles/templates/profiles/detail.html +0 -0
  74. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/profiles/templates/profiles/edit.html +0 -0
  75. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/profiles/templates/profiles/log_in.html +0 -0
  76. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/profiles/templates/profiles/log_out.html +0 -0
  77. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/profiles/tests.py +0 -0
  78. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/profiles/urls.py +0 -0
  79. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/profiles/views.py +0 -0
  80. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/static/css/bootstrap.min.css +0 -0
  81. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/static/css/fnschool.css +0 -0
  82. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/static/images/favicon.ico +0 -0
  83. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/static/js/bootstrap.bundle.min.js +0 -0
  84. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/static/js/bootstrap.min.js +0 -0
  85. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/static/js/fnschool.js +0 -0
  86. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/static/js/jquery.min.js +0 -0
  87. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/static/js/jquery.slim.min.js +0 -0
  88. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/static/js/popper.min.js +0 -0
  89. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/templates/base/_content.html +0 -0
  90. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/templates/base/_css.html +0 -0
  91. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/templates/base/_js.html +0 -0
  92. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/templates/base/content.html +0 -0
  93. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/templates/base/header_content_footer.html +0 -0
  94. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/templates/close.html +0 -0
  95. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/templates/home.html +0 -0
  96. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/templates/includes/_footer.html +0 -0
  97. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/templates/includes/_header.html +0 -0
  98. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/templates/includes/_navigation.html +0 -0
  99. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/templates/includes/_paginator.html +0 -0
  100. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/templates/registration/logged_out.html +0 -0
  101. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschoo1/templates/registration/login.html +0 -0
  102. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschool.egg-info/SOURCES.txt +0 -0
  103. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschool.egg-info/dependency_links.txt +0 -0
  104. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschool.egg-info/entry_points.txt +0 -0
  105. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschool.egg-info/requires.txt +0 -0
  106. {fnschool-20251012.81520.855 → fnschool-20251013.81200.824}/src/fnschool.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fnschool
3
- Version: 20251012.81520.855
3
+ Version: 20251013.81200.824
4
4
  Summary: Just some school related scripts, without any ambition.
5
5
  Author-email: larryw3i <larryw3i@163.com>, Larry Wei <larryw3i@126.com>, Larry W3i <larryw3i@yeah.net>
6
6
  Maintainer-email: larryw3i <larryw3i@163.com>, Larry Wei <larryw3i@126.com>
@@ -6,7 +6,7 @@ import random
6
6
  import sys
7
7
  from pathlib import Path
8
8
 
9
- __version__ = "20251012.81520.855"
9
+ __version__ = "20251013.81200.824"
10
10
 
11
11
  FNSCHOOL_PATH = Path(__file__).parent
12
12
  if FNSCHOOL_PATH.as_posix() not in sys.path:
@@ -46,7 +46,7 @@ def main():
46
46
  if is_windows:
47
47
  os.startfile(local_url)
48
48
  else:
49
- os.system("open " + local_url)
49
+ os.system("sleep 5 && open " + local_url)
50
50
  except Exception as e:
51
51
  print(e)
52
52
 
@@ -8,6 +8,9 @@
8
8
  <hr>
9
9
  <div class="container">
10
10
  <div class="row justify-content-end">
11
+ <button class="btn btn-success col-md-1 col-lg-1 col-2"
12
+ onclick="list_consumptions();">{% trans "Refresh" %}</button>
13
+
11
14
  <div class="col col-3 col-md-2 col-lg-2">
12
15
  <input class=" form-control"
13
16
  onkeydown="if(event.keyCode==13){list_consumptions();}"
@@ -15,7 +15,15 @@ from dateutil.relativedelta import relativedelta
15
15
  from django.contrib.auth.decorators import login_required
16
16
  from django.contrib.auth.mixins import LoginRequiredMixin
17
17
  from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator
18
- from django.db.models import DecimalField, ExpressionWrapper, F, Q, Sum, Value
18
+ from django.db.models import (
19
+ Count,
20
+ DecimalField,
21
+ ExpressionWrapper,
22
+ F,
23
+ Q,
24
+ Sum,
25
+ Value,
26
+ )
19
27
  from django.db.models.functions import Coalesce
20
28
  from django.http import HttpResponse
21
29
  from django.shortcuts import get_object_or_404, redirect, render
@@ -1597,54 +1605,69 @@ class CanteenWorkBook:
1597
1605
  & Q(is_disabled=False)
1598
1606
  & Q(is_ignorable=False)
1599
1607
  ).all()
1600
- month_days = [
1601
- self.date_start + timedelta(days=i)
1602
- for i in range((self.date_end - self.date_start).days)
1603
- ]
1604
- month_days.append(self.date_end)
1605
-
1606
- min_storage_date = min(
1607
- [
1608
- i.storage_date
1609
- for i in ingredients
1610
- if i.storage_date >= self.date_start
1608
+
1609
+ consumptions = []
1610
+ for ingredient in ingredients:
1611
+ consumptions += [
1612
+ c
1613
+ for c in ingredient.consumptions.filter(
1614
+ Q(date_of_using__lte=self.date_end) & Q(is_disabled=False)
1615
+ ).all()
1611
1616
  ]
1617
+
1618
+ inventory_days = []
1619
+ dates_of_using = sorted(
1620
+ list(set([c.date_of_using for c in consumptions]))
1612
1621
  )
1613
- print("min_storage_date", min_storage_date)
1614
- sundays = [
1615
- d for d in month_days if d.weekday() == 6 and d >= min_storage_date
1616
- ]
1622
+ for i, date_of_using in enumerate(dates_of_using):
1623
+ if i + 1 < len(dates_of_using):
1624
+ if (date_of_using + timedelta(days=1)) < dates_of_using[i + 1]:
1625
+ inventory_days.append(date_of_using)
1626
+ else:
1627
+ inventory_days.append(date_of_using)
1617
1628
 
1629
+ if len(inventory_days) < 1:
1630
+ inventory_days.insert(-1, self.date_end)
1631
+
1632
+ inventory_days.insert(
1633
+ 0, (self.date_start.replace(day=1) - timedelta(days=1))
1634
+ )
1618
1635
  formed_ingredients = []
1619
- for sunday in sundays:
1620
- sunday_ingredients = []
1636
+ for inventory_day in inventory_days:
1637
+ inventory_day_ingredients = []
1621
1638
  for ingredient in ingredients:
1639
+ if (
1640
+ ingredient.storage_date > inventory_day
1641
+ and inventory_day != inventory_days[-1]
1642
+ ):
1643
+ continue
1622
1644
  remaining_quantity = ingredient.quantity - sum(
1623
1645
  [
1624
1646
  c.amount_used
1625
1647
  for c in ingredient.consumptions.filter(
1626
1648
  Q(is_disabled=False)
1649
+ & Q(date_of_using__lte=inventory_day)
1627
1650
  ).all()
1628
- if c.date_of_using <= sunday
1629
1651
  ]
1630
1652
  )
1631
1653
  if remaining_quantity > Decimal("0.0"):
1632
- sunday_ingredients.append(ingredient)
1633
- print(ingredient.name, remaining_quantity)
1634
- form_count = len(sunday_ingredients) / ingredient_rows_count
1654
+ inventory_day_ingredients.append(ingredient)
1655
+ form_count = len(inventory_day_ingredients) / ingredient_rows_count
1635
1656
  surplus_ingredients_len = (
1636
- len(sunday_ingredients) % ingredient_rows_count
1657
+ len(inventory_day_ingredients) % ingredient_rows_count
1637
1658
  )
1638
1659
  fake_ingredients_len = (
1639
1660
  ingredient_rows_count - surplus_ingredients_len
1640
1661
  )
1641
1662
 
1642
- sunday_ingredients = sorted(
1643
- sunday_ingredients, key=lambda i: i.category.name
1663
+ inventory_day_ingredients = sorted(
1664
+ inventory_day_ingredients, key=lambda i: i.category.name
1644
1665
  )
1645
1666
 
1646
- s_ingredient0 = sunday_ingredients[0]
1647
- sunday_ingredients += [
1667
+ if len(inventory_day_ingredients) < 1:
1668
+ continue
1669
+ s_ingredient0 = inventory_day_ingredients[0]
1670
+ inventory_day_ingredients += [
1648
1671
  Ingredient(
1649
1672
  user=user,
1650
1673
  storage_date=self.date_start,
@@ -1660,17 +1683,21 @@ class CanteenWorkBook:
1660
1683
  for i in range(fake_ingredients_len)
1661
1684
  ]
1662
1685
  for index in range(
1663
- 0, len(sunday_ingredients), ingredient_rows_count
1686
+ 0, len(inventory_day_ingredients), ingredient_rows_count
1664
1687
  ):
1665
- split_ingredients = sunday_ingredients[
1688
+ split_ingredients = inventory_day_ingredients[
1666
1689
  index : index + ingredient_rows_count
1667
1690
  ]
1668
1691
 
1669
- formed_ingredients.append([sunday, index, split_ingredients])
1692
+ formed_ingredients.append(
1693
+ [inventory_day, index, split_ingredients]
1694
+ )
1670
1695
 
1671
- for index, (sunday, sunday_index, ingredients) in enumerate(
1672
- formed_ingredients
1673
- ):
1696
+ for index, (
1697
+ inventory_day,
1698
+ inventory_day_index,
1699
+ ingredients,
1700
+ ) in enumerate(formed_ingredients):
1674
1701
 
1675
1702
  title_row_num = (ingredient_rows_count + 8) * index + 1
1676
1703
  title_cell = sheet.cell(title_row_num, 1)
@@ -1693,9 +1720,9 @@ class CanteenWorkBook:
1693
1720
  )
1694
1721
  ).format(
1695
1722
  affiliation=user.affiliation,
1696
- year=sunday.year,
1697
- month=sunday.month,
1698
- day=sunday.day,
1723
+ year=inventory_day.year,
1724
+ month=inventory_day.month,
1725
+ day=inventory_day.day,
1699
1726
  )
1700
1727
 
1701
1728
  sub_title_affiliation_date_cell.font = self.font_12
@@ -1766,6 +1793,7 @@ class CanteenWorkBook:
1766
1793
  )
1767
1794
 
1768
1795
  summary_total_price = Decimal("0.0")
1796
+ formed_ingredients_index = index
1769
1797
  for index, ingredient in enumerate(ingredients):
1770
1798
  ingredient_row_num = header1_row_num + index + 1
1771
1799
  ingredient_quantity = (
@@ -1774,9 +1802,9 @@ class CanteenWorkBook:
1774
1802
  [
1775
1803
  c.amount_used
1776
1804
  for c in ingredient.consumptions.filter(
1777
- is_disabled=False
1805
+ Q(date_of_using__lte=inventory_day)
1806
+ & Q(is_disabled=False)
1778
1807
  ).all()
1779
- if c.date_of_using <= sunday
1780
1808
  ]
1781
1809
  )
1782
1810
  if ingredient.id
@@ -1808,25 +1836,29 @@ class CanteenWorkBook:
1808
1836
 
1809
1837
  summary_row_num = header1_row_num + ingredient_rows_count + 1
1810
1838
 
1811
- prev_sunday = (
1812
- formed_ingredients[index - 1][0]
1813
- if 0 <= index - 1 < len(formed_ingredients)
1839
+ prev_inventory_day = (
1840
+ formed_ingredients[formed_ingredients_index - 1][0]
1841
+ if 0 <= formed_ingredients_index - 1 < len(formed_ingredients)
1814
1842
  else None
1815
1843
  )
1816
- next_sunday = (
1817
- storaged_ingredients[index + 1][0]
1818
- if 0 < index + 1 < (len(formed_ingredients) - 1)
1844
+ next_inventory_day = (
1845
+ formed_ingredients[formed_ingredients_index + 1][0]
1846
+ if 0 < formed_ingredients_index + 1 < len(formed_ingredients)
1819
1847
  else None
1820
1848
  )
1821
- summary_1_value = ""
1849
+ summary_col1_value = ""
1822
1850
 
1823
- if not next_sunday or not next_sunday == sunday:
1824
- summary_1_value = _("Summary Total Price (Surplus Sheet)")
1851
+ if next_inventory_day and next_inventory_day == inventory_day:
1852
+ summary_col1_value = _(
1853
+ "Sub0-summary Total Price (Surplus Sheet)"
1854
+ )
1855
+ else:
1856
+ summary_col1_value = _("Summary Total Price (Surplus Sheet)")
1825
1857
  summary_total_price = Decimal("0.0")
1826
1858
  ingredients_list = [
1827
1859
  __ingredients
1828
- for __sunday, __sunday_index, __ingredients in formed_ingredients
1829
- if __sunday == sunday
1860
+ for __inventory_day, __inventory_day_index, __ingredients in formed_ingredients
1861
+ if __inventory_day == inventory_day
1830
1862
  ]
1831
1863
  for ingredients in ingredients_list:
1832
1864
  for ingredient in ingredients:
@@ -1835,7 +1867,8 @@ class CanteenWorkBook:
1835
1867
  [
1836
1868
  c.amount_used
1837
1869
  for c in ingredient.consumptions.filter(
1838
- is_disabled=False
1870
+ Q(is_disabled=False)
1871
+ & Q(date_of_using__lte=inventory_day)
1839
1872
  ).all()
1840
1873
  ]
1841
1874
  )
@@ -1846,10 +1879,7 @@ class CanteenWorkBook:
1846
1879
  ingredient_quantity * ingredient.unit_price
1847
1880
  )
1848
1881
 
1849
- else:
1850
- summary_1_value = _("Sub0-summary Total Price (Surplus Sheet)")
1851
-
1852
- sheet.cell(summary_row_num, 1, summary_1_value)
1882
+ sheet.cell(summary_row_num, 1, summary_col1_value)
1853
1883
 
1854
1884
  sheet.cell(summary_row_num, 4, summary_total_price)
1855
1885
  sheet.cell(summary_row_num, 6, summary_total_price)
@@ -2088,8 +2118,10 @@ class CanteenWorkBook:
2088
2118
 
2089
2119
 
2090
2120
  def get_workbook_zip(request, month):
2091
- meal_types = MealType.objects.filter(
2092
- Q(user=request.user) & Q(is_disabled=False)
2121
+ meal_types = MealType.objects.annotate(
2122
+ ingredients_count=Count("ingredients")
2123
+ ).filter(
2124
+ Q(user=request.user) & Q(is_disabled=False) & Q(ingredients_count__gt=0)
2093
2125
  )
2094
2126
 
2095
2127
  zip_buffer = io.BytesIO()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fnschool
3
- Version: 20251012.81520.855
3
+ Version: 20251013.81200.824
4
4
  Summary: Just some school related scripts, without any ambition.
5
5
  Author-email: larryw3i <larryw3i@163.com>, Larry Wei <larryw3i@126.com>, Larry W3i <larryw3i@yeah.net>
6
6
  Maintainer-email: larryw3i <larryw3i@163.com>, Larry Wei <larryw3i@126.com>