fnschool 20250109.80500.803__py3-none-any.whl → 20251011.80531.840__py3-none-any.whl

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.

Potentially problematic release.


This version of fnschool might be problematic. Click here for more details.

Files changed (276) hide show
  1. fnschoo1/__init__.py +52 -0
  2. fnschoo1/canteen/admin.py +3 -0
  3. fnschoo1/canteen/apps.py +6 -0
  4. fnschoo1/canteen/forms.py +84 -0
  5. fnschoo1/canteen/migrations/0001_initial.py +119 -0
  6. fnschoo1/canteen/migrations/0002_ingredient_is_disabled.py +20 -0
  7. fnschoo1/canteen/migrations/0003_consumption_is_disabled_alter_ingredient_is_disabled.py +23 -0
  8. fnschoo1/canteen/migrations/0004_alter_ingredient_name_category_and_more.py +66 -0
  9. fnschoo1/canteen/migrations/0005_alter_category_created_at_alter_category_name_and_more.py +41 -0
  10. fnschoo1/canteen/migrations/0006_category_is_disabled_alter_category_user_and_more.py +49 -0
  11. fnschoo1/canteen/migrations/0007_alter_consumption_amount_used_and_more.py +30 -0
  12. fnschoo1/canteen/migrations/0008_category_abbreviation_mealtype.py +67 -0
  13. fnschoo1/canteen/migrations/0009_alter_category_abbreviation_and_more.py +55 -0
  14. fnschoo1/canteen/migrations/0010_alter_consumption_options_alter_ingredient_options_and_more.py +215 -0
  15. fnschoo1/canteen/migrations/0011_category_pin_to_consumptions_top.py +23 -0
  16. fnschoo1/canteen/migrations/0012_alter_ingredient_storage_date.py +18 -0
  17. fnschoo1/canteen/models.py +179 -0
  18. fnschoo1/canteen/templates/canteen/category/create.html +17 -0
  19. fnschoo1/canteen/templates/canteen/category/delete.html +61 -0
  20. fnschoo1/canteen/templates/canteen/category/list.html +63 -0
  21. fnschoo1/canteen/templates/canteen/category/update.html +23 -0
  22. fnschoo1/canteen/templates/canteen/close.html +11 -0
  23. fnschoo1/canteen/templates/canteen/consumption/_create.html +19 -0
  24. fnschoo1/canteen/templates/canteen/consumption/create.html +456 -0
  25. fnschoo1/canteen/templates/canteen/ingredient/close.html +11 -0
  26. fnschoo1/canteen/templates/canteen/ingredient/create.html +19 -0
  27. fnschoo1/canteen/templates/canteen/ingredient/create_one.html +17 -0
  28. fnschoo1/canteen/templates/canteen/ingredient/delete.html +41 -0
  29. fnschoo1/canteen/templates/canteen/ingredient/list.html +128 -0
  30. fnschoo1/canteen/templates/canteen/ingredient/update.html +23 -0
  31. fnschoo1/canteen/templates/canteen/meal_type/create.html +17 -0
  32. fnschoo1/canteen/templates/canteen/meal_type/delete.html +56 -0
  33. fnschoo1/canteen/templates/canteen/meal_type/list.html +59 -0
  34. fnschoo1/canteen/templates/canteen/meal_type/update.html +23 -0
  35. fnschoo1/canteen/tests.py +3 -0
  36. fnschoo1/canteen/urls.py +116 -0
  37. fnschoo1/canteen/views.py +814 -0
  38. fnschoo1/canteen/workbook/generate.py +2098 -0
  39. fnschoo1/db.sqlite3 +0 -0
  40. fnschoo1/fnschool/__init__.py +13 -0
  41. fnschoo1/fnschool/asgi.py +16 -0
  42. fnschoo1/fnschool/settings.py +167 -0
  43. fnschoo1/fnschool/templatetags/fnschool_tags.py +27 -0
  44. fnschoo1/fnschool/urls.py +30 -0
  45. fnschoo1/fnschool/views.py +9 -0
  46. fnschoo1/fnschool/wsgi.py +16 -0
  47. fnschoo1/locale/en/LC_MESSAGES/django.mo +0 -0
  48. fnschoo1/locale/zh_Hans/LC_MESSAGES/django.mo +0 -0
  49. fnschoo1/manage.py +25 -0
  50. fnschoo1/profiles/admin.py +27 -0
  51. fnschoo1/profiles/apps.py +12 -0
  52. fnschoo1/profiles/forms.py +67 -0
  53. fnschoo1/profiles/migrations/0001_initial.py +192 -0
  54. fnschoo1/profiles/migrations/0002_alter_profile_bio.py +20 -0
  55. fnschoo1/profiles/migrations/0003_alter_profile_options_alter_profile_address_and_more.py +67 -0
  56. fnschoo1/profiles/migrations/0004_profile_gender.py +26 -0
  57. fnschoo1/profiles/migrations/0005_alter_profile_gender.py +23 -0
  58. fnschoo1/profiles/models.py +60 -0
  59. fnschoo1/profiles/signals.py +20 -0
  60. fnschoo1/profiles/templates/profiles/create.html +16 -0
  61. fnschoo1/profiles/templates/profiles/detail.html +14 -0
  62. fnschoo1/profiles/templates/profiles/edit.html +12 -0
  63. fnschoo1/profiles/templates/profiles/log_in.html +20 -0
  64. fnschoo1/profiles/templates/profiles/log_out.html +12 -0
  65. fnschoo1/profiles/tests.py +3 -0
  66. fnschoo1/profiles/urls.py +15 -0
  67. fnschoo1/profiles/views.py +63 -0
  68. fnschoo1/static/css/bootstrap.min.css +11776 -0
  69. fnschoo1/static/css/fnschool.css +26 -0
  70. fnschoo1/static/js/bootstrap.bundle.min.js +4223 -0
  71. fnschoo1/static/js/bootstrap.min.js +2919 -0
  72. fnschoo1/static/js/fnschool.js +84 -0
  73. fnschoo1/static/js/jquery.min.js +5413 -0
  74. fnschoo1/static/js/jquery.slim.min.js +4331 -0
  75. fnschoo1/static/js/popper.min.js +1306 -0
  76. fnschoo1/static_collected/admin/css/autocomplete.css +377 -0
  77. fnschoo1/static_collected/admin/css/base.css +1224 -0
  78. fnschoo1/static_collected/admin/css/changelists.css +334 -0
  79. fnschoo1/static_collected/admin/css/dark_mode.css +136 -0
  80. fnschoo1/static_collected/admin/css/dashboard.css +30 -0
  81. fnschoo1/static_collected/admin/css/forms.css +546 -0
  82. fnschoo1/static_collected/admin/css/login.css +62 -0
  83. fnschoo1/static_collected/admin/css/nav_sidebar.css +145 -0
  84. fnschoo1/static_collected/admin/css/responsive.css +1043 -0
  85. fnschoo1/static_collected/admin/css/responsive_rtl.css +84 -0
  86. fnschoo1/static_collected/admin/css/rtl.css +311 -0
  87. fnschoo1/static_collected/admin/css/vendor/select2/select2.css +708 -0
  88. fnschoo1/static_collected/admin/css/vendor/select2/select2.min.css +1 -0
  89. fnschoo1/static_collected/admin/css/widgets.css +639 -0
  90. fnschoo1/static_collected/admin/js/SelectBox.js +128 -0
  91. fnschoo1/static_collected/admin/js/SelectFilter2.js +503 -0
  92. fnschoo1/static_collected/admin/js/actions.js +232 -0
  93. fnschoo1/static_collected/admin/js/admin/DateTimeShortcuts.js +496 -0
  94. fnschoo1/static_collected/admin/js/admin/RelatedObjectLookups.js +276 -0
  95. fnschoo1/static_collected/admin/js/autocomplete.js +33 -0
  96. fnschoo1/static_collected/admin/js/calendar.js +251 -0
  97. fnschoo1/static_collected/admin/js/cancel.js +29 -0
  98. fnschoo1/static_collected/admin/js/change_form.js +21 -0
  99. fnschoo1/static_collected/admin/js/collapse.js +43 -0
  100. fnschoo1/static_collected/admin/js/core.js +174 -0
  101. fnschoo1/static_collected/admin/js/filters.js +37 -0
  102. fnschoo1/static_collected/admin/js/inlines.js +439 -0
  103. fnschoo1/static_collected/admin/js/jquery.init.js +8 -0
  104. fnschoo1/static_collected/admin/js/nav_sidebar.js +81 -0
  105. fnschoo1/static_collected/admin/js/popup_response.js +24 -0
  106. fnschoo1/static_collected/admin/js/prepopulate.js +43 -0
  107. fnschoo1/static_collected/admin/js/prepopulate_init.js +20 -0
  108. fnschoo1/static_collected/admin/js/theme.js +57 -0
  109. fnschoo1/static_collected/admin/js/urlify.js +529 -0
  110. fnschoo1/static_collected/admin/js/vendor/jquery/jquery.js +10913 -0
  111. fnschoo1/static_collected/admin/js/vendor/jquery/jquery.min.js +2 -0
  112. fnschoo1/static_collected/admin/js/vendor/select2/i18n/af.js +43 -0
  113. fnschoo1/static_collected/admin/js/vendor/select2/i18n/ar.js +36 -0
  114. fnschoo1/static_collected/admin/js/vendor/select2/i18n/az.js +33 -0
  115. fnschoo1/static_collected/admin/js/vendor/select2/i18n/bg.js +38 -0
  116. fnschoo1/static_collected/admin/js/vendor/select2/i18n/bn.js +39 -0
  117. fnschoo1/static_collected/admin/js/vendor/select2/i18n/bs.js +48 -0
  118. fnschoo1/static_collected/admin/js/vendor/select2/i18n/ca.js +41 -0
  119. fnschoo1/static_collected/admin/js/vendor/select2/i18n/cs.js +62 -0
  120. fnschoo1/static_collected/admin/js/vendor/select2/i18n/da.js +37 -0
  121. fnschoo1/static_collected/admin/js/vendor/select2/i18n/de.js +41 -0
  122. fnschoo1/static_collected/admin/js/vendor/select2/i18n/dsb.js +51 -0
  123. fnschoo1/static_collected/admin/js/vendor/select2/i18n/el.js +43 -0
  124. fnschoo1/static_collected/admin/js/vendor/select2/i18n/en.js +41 -0
  125. fnschoo1/static_collected/admin/js/vendor/select2/i18n/es.js +41 -0
  126. fnschoo1/static_collected/admin/js/vendor/select2/i18n/et.js +38 -0
  127. fnschoo1/static_collected/admin/js/vendor/select2/i18n/eu.js +45 -0
  128. fnschoo1/static_collected/admin/js/vendor/select2/i18n/fa.js +42 -0
  129. fnschoo1/static_collected/admin/js/vendor/select2/i18n/fi.js +42 -0
  130. fnschoo1/static_collected/admin/js/vendor/select2/i18n/fr.js +43 -0
  131. fnschoo1/static_collected/admin/js/vendor/select2/i18n/gl.js +40 -0
  132. fnschoo1/static_collected/admin/js/vendor/select2/i18n/he.js +44 -0
  133. fnschoo1/static_collected/admin/js/vendor/select2/i18n/hi.js +40 -0
  134. fnschoo1/static_collected/admin/js/vendor/select2/i18n/hr.js +45 -0
  135. fnschoo1/static_collected/admin/js/vendor/select2/i18n/hsb.js +51 -0
  136. fnschoo1/static_collected/admin/js/vendor/select2/i18n/hu.js +44 -0
  137. fnschoo1/static_collected/admin/js/vendor/select2/i18n/hy.js +40 -0
  138. fnschoo1/static_collected/admin/js/vendor/select2/i18n/id.js +36 -0
  139. fnschoo1/static_collected/admin/js/vendor/select2/i18n/is.js +37 -0
  140. fnschoo1/static_collected/admin/js/vendor/select2/i18n/it.js +43 -0
  141. fnschoo1/static_collected/admin/js/vendor/select2/i18n/ja.js +40 -0
  142. fnschoo1/static_collected/admin/js/vendor/select2/i18n/ka.js +42 -0
  143. fnschoo1/static_collected/admin/js/vendor/select2/i18n/km.js +38 -0
  144. fnschoo1/static_collected/admin/js/vendor/select2/i18n/ko.js +42 -0
  145. fnschoo1/static_collected/admin/js/vendor/select2/i18n/lt.js +45 -0
  146. fnschoo1/static_collected/admin/js/vendor/select2/i18n/lv.js +41 -0
  147. fnschoo1/static_collected/admin/js/vendor/select2/i18n/mk.js +42 -0
  148. fnschoo1/static_collected/admin/js/vendor/select2/i18n/ms.js +38 -0
  149. fnschoo1/static_collected/admin/js/vendor/select2/i18n/nb.js +38 -0
  150. fnschoo1/static_collected/admin/js/vendor/select2/i18n/ne.js +44 -0
  151. fnschoo1/static_collected/admin/js/vendor/select2/i18n/nl.js +46 -0
  152. fnschoo1/static_collected/admin/js/vendor/select2/i18n/pl.js +43 -0
  153. fnschoo1/static_collected/admin/js/vendor/select2/i18n/ps.js +41 -0
  154. fnschoo1/static_collected/admin/js/vendor/select2/i18n/pt-BR.js +39 -0
  155. fnschoo1/static_collected/admin/js/vendor/select2/i18n/pt.js +41 -0
  156. fnschoo1/static_collected/admin/js/vendor/select2/i18n/ro.js +43 -0
  157. fnschoo1/static_collected/admin/js/vendor/select2/i18n/ru.js +48 -0
  158. fnschoo1/static_collected/admin/js/vendor/select2/i18n/sk.js +61 -0
  159. fnschoo1/static_collected/admin/js/vendor/select2/i18n/sl.js +41 -0
  160. fnschoo1/static_collected/admin/js/vendor/select2/i18n/sq.js +43 -0
  161. fnschoo1/static_collected/admin/js/vendor/select2/i18n/sr-Cyrl.js +48 -0
  162. fnschoo1/static_collected/admin/js/vendor/select2/i18n/sr.js +48 -0
  163. fnschoo1/static_collected/admin/js/vendor/select2/i18n/sv.js +40 -0
  164. fnschoo1/static_collected/admin/js/vendor/select2/i18n/th.js +36 -0
  165. fnschoo1/static_collected/admin/js/vendor/select2/i18n/tk.js +36 -0
  166. fnschoo1/static_collected/admin/js/vendor/select2/i18n/tr.js +40 -0
  167. fnschoo1/static_collected/admin/js/vendor/select2/i18n/uk.js +59 -0
  168. fnschoo1/static_collected/admin/js/vendor/select2/i18n/vi.js +37 -0
  169. fnschoo1/static_collected/admin/js/vendor/select2/i18n/zh-CN.js +36 -0
  170. fnschoo1/static_collected/admin/js/vendor/select2/i18n/zh-TW.js +33 -0
  171. fnschoo1/static_collected/admin/js/vendor/select2/select2.full.js +7115 -0
  172. fnschoo1/static_collected/admin/js/vendor/select2/select2.full.min.js +2 -0
  173. fnschoo1/static_collected/admin/js/vendor/xregexp/xregexp.js +4993 -0
  174. fnschoo1/static_collected/admin/js/vendor/xregexp/xregexp.min.js +160 -0
  175. fnschoo1/static_collected/css/bootstrap.min.css +11776 -0
  176. fnschoo1/static_collected/css/fnschool.css +26 -0
  177. fnschoo1/static_collected/js/bootstrap.bundle.min.js +4223 -0
  178. fnschoo1/static_collected/js/bootstrap.min.js +2919 -0
  179. fnschoo1/static_collected/js/fnschool.js +84 -0
  180. fnschoo1/static_collected/js/jquery.min.js +5413 -0
  181. fnschoo1/static_collected/js/jquery.slim.min.js +4331 -0
  182. fnschoo1/static_collected/js/popper.min.js +1306 -0
  183. fnschoo1/templates/base/_css.html +1 -0
  184. fnschoo1/templates/base/_js.html +15 -0
  185. fnschoo1/templates/base/content.html +30 -0
  186. fnschoo1/templates/base/header_content_footer.html +35 -0
  187. fnschoo1/templates/close.html +11 -0
  188. fnschoo1/templates/home.html +51 -0
  189. fnschoo1/templates/includes/_footer.html +39 -0
  190. fnschoo1/templates/includes/_header.html +77 -0
  191. fnschoo1/templates/includes/_navigation.html +0 -0
  192. fnschoo1/templates/includes/_paginator.html +27 -0
  193. fnschoo1/templates/registration/logged_out.html +0 -0
  194. fnschoo1/templates/registration/login.html +0 -0
  195. fnschool-20251011.80531.840.dist-info/METADATA +179 -0
  196. fnschool-20251011.80531.840.dist-info/RECORD +207 -0
  197. {fnschool-20250109.80500.803.dist-info → fnschool-20251011.80531.840.dist-info}/WHEEL +1 -1
  198. fnschool-20251011.80531.840.dist-info/entry_points.txt +2 -0
  199. fnschool-20251011.80531.840.dist-info/top_level.txt +1 -0
  200. fnschool/__init__.py +0 -35
  201. fnschool/__main__.py +0 -16
  202. fnschool/app.py +0 -103
  203. fnschool/canteen/__init__.py +0 -3
  204. fnschool/canteen/__main__.py +0 -3
  205. fnschool/canteen/bill.py +0 -253
  206. fnschool/canteen/canteen.py +0 -1
  207. fnschool/canteen/canteen.toml +0 -61
  208. fnschool/canteen/config.py +0 -10
  209. fnschool/canteen/consuming.py +0 -53
  210. fnschool/canteen/currency.py +0 -17
  211. fnschool/canteen/data/bill.i18n.xlsx +0 -0
  212. fnschool/canteen/data/bill.xlsx +0 -0
  213. fnschool/canteen/data/consuming.xlsx +0 -0
  214. fnschool/canteen/data/purchase_list.xlsx +0 -0
  215. fnschool/canteen/entry.py +0 -40
  216. fnschool/canteen/food.py +0 -206
  217. fnschool/canteen/food_classes.py +0 -33
  218. fnschool/canteen/food_classes.toml +0 -64
  219. fnschool/canteen/operator.py +0 -91
  220. fnschool/canteen/path.py +0 -28
  221. fnschool/canteen/spreadsheet/base.py +0 -212
  222. fnschool/canteen/spreadsheet/consuming.py +0 -310
  223. fnschool/canteen/spreadsheet/consumingsum.py +0 -76
  224. fnschool/canteen/spreadsheet/cover.py +0 -64
  225. fnschool/canteen/spreadsheet/ctspreadsheet.py +0 -351
  226. fnschool/canteen/spreadsheet/food.py +0 -680
  227. fnschool/canteen/spreadsheet/inventory.py +0 -375
  228. fnschool/canteen/spreadsheet/merging.py +0 -340
  229. fnschool/canteen/spreadsheet/preconsuming.py +0 -329
  230. fnschool/canteen/spreadsheet/purchasing.py +0 -885
  231. fnschool/canteen/spreadsheet/purchasingsum.py +0 -110
  232. fnschool/canteen/spreadsheet/spreadsheet.py +0 -363
  233. fnschool/canteen/spreadsheet/translating.py +0 -12
  234. fnschool/canteen/spreadsheet/unwarehousing.py +0 -178
  235. fnschool/canteen/spreadsheet/unwarehousingsum.py +0 -11
  236. fnschool/canteen/spreadsheet/warehousing.py +0 -360
  237. fnschool/canteen/spreadsheet/workbook.py +0 -17
  238. fnschool/canteen/test.py +0 -97
  239. fnschool/config.py +0 -48
  240. fnschool/entry.py +0 -67
  241. fnschool/exam/__init__.py +0 -8
  242. fnschool/exam/data/parental_emails.xlsx +0 -0
  243. fnschool/exam/data/score.xlsx +0 -0
  244. fnschool/exam/email.py +0 -349
  245. fnschool/exam/entry.py +0 -36
  246. fnschool/exam/language.py +0 -19
  247. fnschool/exam/path.py +0 -24
  248. fnschool/exam/score.py +0 -1191
  249. fnschool/exam/subject.py +0 -20
  250. fnschool/exam/teacher.py +0 -54
  251. fnschool/external.py +0 -89
  252. fnschool/games/__init__.py +0 -1
  253. fnschool/games/__main__.py +0 -1
  254. fnschool/games/games.py +0 -1
  255. fnschool/inoutput.py +0 -97
  256. fnschool/language.py +0 -40
  257. fnschool/locales/en_US/LC_MESSAGES/fnschool.mo +0 -0
  258. fnschool/locales/zh_CN/LC_MESSAGES/fnschool.mo +0 -0
  259. fnschool/locales/zh_HK/LC_MESSAGES/fnschool.mo +0 -0
  260. fnschool/locales/zh_SG/LC_MESSAGES/fnschool.mo +0 -0
  261. fnschool/locales/zh_TW/LC_MESSAGES/fnschool.mo +0 -0
  262. fnschool/path.py +0 -45
  263. fnschool/test.py +0 -24
  264. fnschool/user.py +0 -262
  265. fnschool-20250109.80500.803.dist-info/METADATA +0 -342
  266. fnschool-20250109.80500.803.dist-info/RECORD +0 -78
  267. fnschool-20250109.80500.803.dist-info/entry_points.txt +0 -5
  268. fnschool-20250109.80500.803.dist-info/top_level.txt +0 -1
  269. /fnschool/canteen/consume.py → /fnschoo1/canteen/__init__.py +0 -0
  270. /fnschool/canteen/food_recount.toml → /fnschoo1/canteen/migrations/__init__.py +0 -0
  271. {fnschool/canteen/spreadsheet → fnschoo1/canteen/workbook}/__init__.py +0 -0
  272. /fnschool/exam/__main__.py → /fnschoo1/fnschool/templatetags/__init__.py +0 -0
  273. /fnschool/canteen/food_recounts.toml → /fnschoo1/profiles/__init__.py +0 -0
  274. /fnschool/canteen/warehouse.py → /fnschoo1/profiles/migrations/__init__.py +0 -0
  275. /fnschool/canteen/workbook.toml → /fnschoo1/templates/base/_content.html +0 -0
  276. {fnschool-20250109.80500.803.dist-info → fnschool-20251011.80531.840.dist-info/licenses}/LICENSE +0 -0
@@ -1,329 +0,0 @@
1
- import os
2
- import sys
3
- import random
4
- import calendar
5
- from datetime import datetime, timedelta
6
- import math
7
- from openpyxl.styles import PatternFill
8
-
9
- from fnschool import *
10
- from fnschool.canteen.food import *
11
- from fnschool.canteen.path import *
12
- from fnschool.canteen.spreadsheet.base import *
13
-
14
-
15
- class PreConsuming(Base):
16
- def __init__(self, bill):
17
- super().__init__(bill)
18
- self.path0 = pre_consuming0_fpath
19
- self.row_index_offset = 3
20
- self.col_index_offset = 5
21
-
22
- self.sheet_name0 = self.s.preconsuming_name0
23
-
24
- def get_colored_cols(self, days_diff):
25
- days_diff += 4
26
- colored_cols = list(range(1, days_diff + 1))
27
- colored_cols.remove(3)
28
- return colored_cols
29
-
30
- def pre_consume_foods(self):
31
- foods = self.bill.foods
32
- cfoods = [f for f in foods if not f.is_abandoned]
33
- if len(cfoods) < 1:
34
- print_error(_("No food found, exit."))
35
- exit()
36
- year = self.bill.consuming.year
37
- month = self.bill.consuming.month
38
- __, last_day = calendar.monthrange(year, month)
39
- mday_m1 = datetime(year, month, last_day)
40
- time_nodes = sorted(
41
- list(
42
- set(
43
- [f.xdate for f in cfoods]
44
- + [
45
- datetime(
46
- year,
47
- month,
48
- calendar.monthrange(year, month)[1],
49
- )
50
- ]
51
- )
52
- )
53
- )
54
- if len(time_nodes) > 1:
55
- t1 = time_nodes[1]
56
- if t1.day == 1:
57
- del time_nodes[1]
58
-
59
- wb_fpathes = []
60
- for i in range(1, len(time_nodes)):
61
- tn0, tn1 = time_nodes[i - 1], time_nodes[i]
62
- tn0_cp = tn0
63
- if tn0.month != tn1.month:
64
- tn0 = datetime(tn1.year, tn1.month, 1)
65
-
66
- file_t0 = (
67
- tn0
68
- if not tn0_cp.month == tn1.month
69
- else (tn0 + timedelta(days=1))
70
- )
71
- file_t1 = tn1
72
-
73
- file_t0 = _("{year}.{month}.{day}").format(
74
- year=file_t0.year, month=file_t0.month, day=file_t0.day
75
- )
76
- file_t1 = _("{year}.{month}.{day}").format(
77
- year=file_t1.year, month=file_t1.month, day=file_t1.day
78
- )
79
-
80
- wb_fpath = (
81
- self.bill.operator.preconsuming_dpath
82
- / (
83
- _("food_consuming--{t0}--{t1}.xlsx").format(
84
- t0=file_t0, t1=file_t1
85
- )
86
- )
87
- ).as_posix()
88
-
89
- wb_fpathes.append(wb_fpath)
90
-
91
- for i, wb_fpath in enumerate(wb_fpathes):
92
- if not Path(wb_fpath).exists():
93
- shutil.copy(self.path0, wb_fpath)
94
- print_info(
95
- _('Spreadsheet "{0}" was copied to "{1}".').format(
96
- self.path0, wb_fpath
97
- )
98
- )
99
- wb = load_workbook(wb_fpath)
100
- sheet = wb[self.sheet_name0]
101
- tn1 = time_nodes[i + 1]
102
- tn0 = time_nodes[i]
103
- tn0_cp = tn0
104
-
105
- new_meal_type_rows = []
106
-
107
- if not tn0.month == tn1.month:
108
- tn0 = datetime(tn1.year, tn1.month, 1)
109
-
110
- wbfoods = [
111
- f
112
- for f in cfoods
113
- if f.get_remainder(mday_m1) > 0 and f.xdate <= tn0
114
- ]
115
-
116
- wbfoods = sorted(
117
- wbfoods,
118
- key=lambda f: (f.meal_type, f.xdate, f.name, f.unit_price),
119
- )
120
-
121
- col_index = 0
122
- tn1_r = calendar.monthrange(tn1.year, tn1.month)
123
- tn1_r = datetime(tn1.year, tn1.month, tn1_r[-1])
124
- days_diff = (tn1_r - tn0).days
125
-
126
- for d_index in range(0, days_diff + 1):
127
- d_date = tn0 + timedelta(
128
- days=d_index + (1 if tn0_cp.month == tn1_r.month else 0)
129
- )
130
- col_index = self.col_index_offset + d_index
131
- sheet.cell(
132
- 1,
133
- col_index,
134
- d_date.strftime("%Y.%m.%d"),
135
- )
136
- if d_date == tn1_r:
137
- break
138
-
139
- for col_index in range(col_index + 1, sheet.max_column):
140
- sheet.cell(1, col_index, "")
141
-
142
- row_index = 0
143
- last_meal_type = None
144
- for f_index in range(0, len(wbfoods)):
145
- wbfood = wbfoods[f_index]
146
- row_index = self.row_index_offset + f_index
147
- sheet.cell(
148
- row_index, 1, wbfood.get_display_name(time_node0=tn0)
149
- )
150
- sheet.cell(row_index, 2, wbfood.get_remainder(mday_m1))
151
- sheet.cell(row_index, 4, wbfood.unit_price)
152
- if wbfood.meal_type and not last_meal_type == wbfood.meal_type:
153
- new_meal_type_rows.append([wbfood.meal_type, row_index])
154
- last_meal_type = wbfood.meal_type
155
-
156
- for row_index in range(row_index + 1, sheet.max_row + 1):
157
- sheet.cell(row_index, 1, "")
158
- sheet.cell(row_index, 2, "")
159
- sheet.cell(row_index, 4, "")
160
- pass
161
-
162
- new_meal_type_rows = [
163
- [new_meal_type_rows[i][1], new_meal_type_rows[i + 1][1]]
164
- for i in range(0, len(new_meal_type_rows), 2)
165
- if i + 1 < len(new_meal_type_rows)
166
- ]
167
-
168
- for [row_index0, row_index1] in new_meal_type_rows:
169
- colored_cols = self.get_colored_cols(days_diff)
170
-
171
- for row_index in range(row_index0, row_index1):
172
- for col_index in colored_cols:
173
- cell = sheet.cell(row_index, col_index)
174
- cell.fill = self.cell_fill0
175
- cell.border = self.cell_border1
176
-
177
- wb.save(wb_fpath)
178
- print_warning(
179
- _(
180
- "Sheet '{0}' of \"{1}\" was updated.\n"
181
- + "Press any key to continue when you have "
182
- + "completed the foods allocation."
183
- ).format(sheet.title, wb_fpath)
184
- )
185
- new_wbfoods = [
186
- f for f in cfoods if f.get_remainder(tn1) > 0 and f.xdate == tn1
187
- ]
188
- if len(new_wbfoods) > 0:
189
- print_info(
190
- (
191
- _("New purchased food for date {0} is:")
192
- if len(new_wbfoods) > 1
193
- else _("New purchased foods for date {0} are:")
194
- ).format(tn1.strftime("%Y.%m.%d"))
195
- )
196
-
197
- new_wbfoods_count_len = len(str(len(new_wbfoods)))
198
-
199
- number_mark = random.choice([" ", ".", ">", "-", ")", ":", "|"])
200
- new_wbfood_tips = [
201
- (
202
- f"{i+1:>{new_wbfoods_count_len}}"
203
- + number_mark
204
- + f"{f.name}"
205
- + _("({0})").format(f.meal_type)
206
- + f" {f.count} {f.unit_name}"
207
- )
208
- for i, f in enumerate(new_wbfoods)
209
- ]
210
-
211
- new_wbfood_tips_value = sqr_slist(new_wbfood_tips)
212
-
213
- print_warning(new_wbfood_tips_value)
214
-
215
- print_warning(_("Negligible foods are not listed."))
216
- else:
217
- print_info(
218
- _("There is no purchased food for {0}.").format(
219
- tn1.strftime("%Y.%m.%d")
220
- )
221
- )
222
-
223
- print_error(
224
- _(
225
- "There is no need to design for "
226
- + "dates without food consumption. "
227
- + "(Ok, I know [press any key to continue])"
228
- )
229
- )
230
- get_input()
231
- wb.close()
232
- open_path(wb_fpath)
233
- print_info(
234
- _(
235
- "Ok! I have updated spreadsheet '{0}'. (Press any key)"
236
- ).format(wb_fpath)
237
- )
238
- get_input()
239
-
240
- wb = load_workbook(wb_fpath)
241
- sheet = wb[self.sheet_name0]
242
-
243
- f_index = 0
244
- for row in sheet.iter_rows(
245
- min_row=self.row_index_offset,
246
- min_col=self.col_index_offset,
247
- max_row=sheet.max_row,
248
- max_col=sheet.max_column,
249
- ):
250
- if f_index == len(wbfoods):
251
- break
252
- food = wbfoods[f_index]
253
- col_index = self.col_index_offset
254
- for cell in row:
255
- if cell.value:
256
- cdate = sheet.cell(1, col_index).value
257
- food.consumptions.append(
258
- [
259
- datetime.strptime(cdate, "%Y.%m.%d"),
260
- float(cell.value),
261
- ]
262
- )
263
- col_index += 1
264
- f_index += 1
265
- wb.close()
266
- sheet = None
267
- self.print_consuming_days(cfoods)
268
- pass
269
-
270
- def print_consuming_days(self, foods):
271
- consumption_days = []
272
- year = self.bill.consuming.year
273
- month = self.bill.consuming.month
274
- year_month = _("{year}.{month}").format(year=year, month=month)
275
-
276
- meal_types = list(set([f.meal_type for f in foods]))
277
-
278
- for meal_type in meal_types:
279
-
280
- for f in foods:
281
- for d, c in f.consumptions:
282
- if not d.day in consumption_days:
283
- consumption_days.append(d.day)
284
-
285
- consumption_days_value = ""
286
- space_len = 5
287
- for week in calendar.monthcalendar(year, month):
288
- for d in week:
289
- if d == 0:
290
- consumption_days_value += " " * space_len
291
- elif d in consumption_days:
292
- consumption_day = f"({d:>2})"
293
- consumption_days_value += (
294
- f"{consumption_day:>{space_len}}"
295
- )
296
- else:
297
- d = f" {d:>2} "
298
- consumption_days_value += f"{d:>{space_len}}"
299
- consumption_days_value += "\n"
300
-
301
- print()
302
- print_error(
303
- _("Consuming days of {0} ({1}):").format(year_month, meal_type)
304
- if meal_type
305
- else _("Consuming days of {0}:").format(year_month)
306
- )
307
- print_warning(f"{year_month:^{space_len*7}}")
308
- if consumption_days_value.endswith("\n"):
309
- consumption_days_value = consumption_days_value[:-1]
310
- print_info(consumption_days_value[:-1])
311
- consumption_days_len = len(consumption_days)
312
- total_days = (
313
- _("{0} days in total.")
314
- if consumption_days_len > 1
315
- else _("{0} day in total.")
316
- ).format(consumption_days_len)
317
- print_warning(f"{total_days:^{space_len*7}}")
318
- print_info(
319
- _("Yes, they are all right. (Press any key to continue)")
320
- )
321
-
322
- get_input()
323
-
324
- pass
325
-
326
- return
327
-
328
-
329
- # The end.