odant-work 1.0.90 → 1.0.92

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 (326) hide show
  1. package/#system/package-manifest.json +275 -246
  2. package/$server/$folder/$class/$data/$catalog/$folder/$class/$data/$catalog/$virtual/class.js +4 -0
  3. package/$server/$folder/$class/$data/$catalog/$folder/$class/$data/$catalog/class.js +4 -0
  4. package/$server/$folder/$class/$data/$catalog/$virtual/$folder/$class/$data/$catalog/$virtual/class.js +4 -0
  5. package/$server/$folder/$class/$data/$catalog/$virtual/class.js +8 -0
  6. package/{MODULES/Register/CATALOGS/$catalog/$folder/$class → $server/$folder/$class/$data}/$catalog/class.js +1 -0
  7. package/$server/$folder/$class/$data/$operation/$folder/$class/$data/$operation/class.js +4 -0
  8. package/{MODULES/Register/OPERATIONS/$operation/$folder/$class → $server/$folder/$class/$data}/$operation/class.js +1 -0
  9. package/$server/$folder/$class/$data/$register/$account/$folder/$class/$data/$register/$account/class.js +4 -0
  10. package/$server/$folder/$class/$data/$register/$account/class.js +8 -0
  11. package/$server/$folder/$class/$data/$register/$folder/$class/$data/$register/$account/class.js +4 -0
  12. package/$server/$folder/$class/$data/$register/$folder/$class/$data/$register/class.js +4 -0
  13. package/$server/$folder/$class/$data/$register/class.js +8 -0
  14. package/$server/$folder/$class/$data/$struct/$folder/$class/$data/$struct/class.js +4 -0
  15. package/$server/$folder/$class/$data/$struct/class.js +5 -0
  16. package/$server/$folder/$class/$data/class.js +5 -0
  17. package/$server/$folder/$class/$data/handlers/pages/form/objects/$handler/class.js +2158 -0
  18. package/$server/$folder/$class/$data/handlers/pages/form/objects/object/$handler/class.js +1377 -0
  19. package/$server/$folder/$class/$domain/$folder/$class/$domain/class.js +4 -0
  20. package/$server/$folder/$class/$domain/handlers/methods/restore/$handler/class.js +5 -5
  21. package/$server/$folder/$class/$domain/readme.md +1 -1
  22. package/$server/$folder/$class/$handler/$method/class.js +4 -0
  23. package/$server/$folder/$class/$handler/$timer/class.js +4 -0
  24. package/$server/$folder/$class/$module/$folder/$class/$data/$catalog/class.js +4 -0
  25. package/$server/$folder/$class/$module/$folder/$class/$data/$operation/class.js +4 -0
  26. package/$server/$folder/$class/$module/$folder/$class/$data/$register/class.js +4 -0
  27. package/$server/$folder/$class/$module/$folder/$class/$data/$struct/class.js +4 -0
  28. package/$server/$folder/$class/$module/$folder/$class/$domain/class.js +4 -0
  29. package/$server/$folder/$class/$module/$folder/$class/$module/class.js +4 -0
  30. package/$server/$folder/$class/$module/class.js +418 -6
  31. package/$server/$folder/$class/{handlers/pages/form/system/$handler/tabs/mcp.js → $module/handlers/pages/form/system/mcp/$handler/class.js} +261 -220
  32. package/$server/$folder/$class/$module/handlers/pages/form/system/modules/$handler/class.js +7 -0
  33. package/$server/$folder/$class/$structure/$folder/$class/$structure/class.js +4 -0
  34. package/$server/$folder/$class/$structure/$organization/$folder/$class/$data/$catalog/class.js +4 -0
  35. package/$server/$folder/$class/$structure/$organization/$folder/$class/$data/$operation/class.js +4 -0
  36. package/$server/$folder/$class/$structure/$organization/$folder/$class/$data/$register/class.js +4 -0
  37. package/$server/$folder/$class/$structure/$organization/$folder/$class/$data/$struct/class.js +4 -0
  38. package/$server/$folder/$class/$structure/$organization/$folder/$class/$domain/class.js +4 -0
  39. package/$server/$folder/$class/$structure/$organization/$folder/$class/$module/class.js +4 -0
  40. package/{ORGANIZATIONS/$domain/$folder/$class/$base → $server/$folder/$class/$structure/$organization/$folder/$class/$structure/$organization}/class.js +4 -5
  41. package/$server/$folder/$class/$structure/$organization/$folder/$class/$structure/class.js +4 -0
  42. package/{ORGANIZATIONS/$domain/$folder/$class/$base/$folder/$class/$structure/$base → $server/$folder/$class/$structure/$organization}/class.js +19 -17
  43. package/$server/$folder/$class/$structure/$organization/handlers/pages/form/system/requisites/$handler/class.js +3 -0
  44. package/$server/$folder/$class/$structure/{$base/handlers/pages/site/$handler/site.js → $organization/handlers/pages/site/$handler/class.js} +352 -365
  45. package/$server/$folder/$class/$structure/$project/$folder/$class/$data/$catalog/class.js +4 -0
  46. package/$server/$folder/$class/$structure/$project/$folder/$class/$data/$operation/class.js +4 -0
  47. package/$server/$folder/$class/$structure/$project/$folder/$class/$data/$register/class.js +4 -0
  48. package/$server/$folder/$class/$structure/$project/$folder/$class/$data/$struct/class.js +4 -0
  49. package/$server/$folder/$class/$structure/$project/$folder/$class/$domain/class.js +4 -0
  50. package/$server/$folder/$class/$structure/$project/$folder/$class/$module/class.js +4 -0
  51. package/$server/$folder/$class/$structure/$project/class.js +1 -0
  52. package/$server/$folder/$class/$structure/$project/readme.md +1 -1
  53. package/$server/$folder/$class/$structure/$server/$folder/$class/$domain/class.js +4 -0
  54. package/$server/$folder/$class/$structure/$server/handlers/pages/form/system/database/$handler/class.js +3 -0
  55. package/$server/$folder/$class/{handlers/pages/form/system/$handler/tabs/license.js → $structure/$server/handlers/pages/form/system/license/$handler/class.js} +104 -103
  56. package/$server/$folder/$class/$structure/$server/handlers/pages/site/$handler/{site.js → class.js} +45 -30
  57. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/agent/$handler/class.js +3 -0
  58. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/messengers/$handler/class.js +3 -0
  59. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/modules/$handler/class.js +3 -0
  60. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/profile/$handler/class.js +18 -0
  61. package/$server/$folder/$class/$structure/ai/system.md +1 -1
  62. package/$server/$folder/$class/$structure/class.js +1 -1
  63. package/$server/$folder/$class/$structure/handlers/methods/archive/$handler/class.js +3 -3
  64. package/$server/$folder/$class/$structure/handlers/pages/data/$handler/class.js +309 -8
  65. package/$server/$folder/$class/$structure/handlers/pages/explorer/$handler/class.js +15 -4
  66. package/$server/$folder/$class/$structure/handlers/pages/form/calendar/$handler/class.js +1281 -7
  67. package/$server/$folder/$class/$structure/handlers/pages/form/chat/$handler/class.js +2216 -6
  68. package/$server/$folder/$class/$structure/handlers/pages/form/email/$handler/class.js +1304 -6
  69. package/$server/$folder/$class/$structure/handlers/pages/form/email/$handler/methods/refresh/$method/class.js +1 -1
  70. package/$server/$folder/$class/$structure/handlers/pages/form/search/$handler/class.js +305 -9
  71. package/$server/$folder/$class/{handlers/pages/form/system/$handler/tabs/agent.js → $structure/handlers/pages/form/system/agent/$handler/class.js} +329 -320
  72. package/$server/$folder/$class/{handlers/pages/form/system/$handler/tabs/database.js → $structure/handlers/pages/form/system/database/$handler/class.js} +510 -577
  73. package/$server/$folder/$class/{handlers/pages/form/system/$handler/tabs/messengers.js → $structure/handlers/pages/form/system/messengers/$handler/class.js} +143 -144
  74. package/$server/$folder/$class/$structure/handlers/pages/form/system/modules/$handler/class.js +270 -0
  75. package/$server/$folder/$class/$structure/handlers/pages/form/system/staff/$handler/class.js +2114 -0
  76. package/$server/$folder/$class/$structure/handlers/pages/site/$handler/class.js +229 -4
  77. package/$server/$folder/$class/$structure/handlers/pages/site/$handler/readme.md +1 -1
  78. package/$server/$folder/$class/$structure/readme.md +3 -3
  79. package/$server/$folder/$class/$users/$folder/$class/$structure/$user/class.js +4 -0
  80. package/$server/$folder/$class/$users/class.js +4 -0
  81. package/$server/$folder/$class/ai/agents/integrator-1c.md +1 -1
  82. package/$server/$folder/$class/ai/agents/it-admin.md +1 -1
  83. package/$server/$folder/$class/ai/agents/org-architect.md +4 -4
  84. package/$server/$folder/$class/ai/agents/readme.md +1 -1
  85. package/$server/$folder/$class/ai/agents/schema-validator.md +2 -2
  86. package/$server/$folder/$class/ai/skills/lan-inventory.md +2 -2
  87. package/$server/$folder/$class/ai/skills/org-structure.md +1 -1
  88. package/$server/$folder/$class/ai/skills/printer-setup.md +1 -1
  89. package/$server/$folder/$class/ai/skills/telegram-notify.md +2 -2
  90. package/$server/$folder/$class/ai/skills/work-scenarios.md +3 -3
  91. package/$server/$folder/$class/ai/system.md +14 -8
  92. package/$server/$folder/$class/class.js +2 -6
  93. package/$server/$folder/$class/handlers/pages/form/folder/$handler/class.js +3 -0
  94. package/$server/$folder/$class/handlers/pages/form/system/$handler/class.js +2 -4
  95. package/$server/$folder/$class/handlers/pages/form/system/files/$handler/class.js +7 -0
  96. package/$server/$folder/$class/handlers/pages/form/system/requisites/$handler/class.js +100 -0
  97. package/$server/$folder/$class/handlers/pages/storage/$handler/class.js +25 -6
  98. package/$server/$folder/$file/$data/handlers/pages/form/editor/$handler/class.js +32 -5
  99. package/$server/$folder/$file/$devs/handlers/pages/form/file/$handler/class.js +31 -3
  100. package/$server/$folder/$file/$ics/handlers/pages/form/file/$handler/class.js +11 -3
  101. package/$server/$folder/$file/$ipynb/handlers/pages/form/file/$handler/class.js +83 -3
  102. package/$server/$folder/$file/$md/handlers/pages/form/file/$handler/class.js +61 -3
  103. package/$server/$folder/$file/$office/handlers/pages/form/file/$handler/class.js +1699 -2
  104. package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/class.js +827 -2
  105. package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/readme.md +1 -1
  106. package/$server/$folder/$file/handlers/pages/form/file/$handler/class.js +33 -3
  107. package/$server/$folder/$file/handlers/pages/form/folder/$handler/class.js +3 -0
  108. package/$server/$folder/handlers/methods/create/$handler/class.js +5 -5
  109. package/$server/$folder/handlers/pages/form/$handler/class.js +2467 -3
  110. package/$server/$folder/handlers/pages/form/folder/$handler/class.js +22 -0
  111. package/$server/$folder/handlers/readme.md +1 -1
  112. package/$server/$folder/lib/chat-item/chat-item.js +5 -10
  113. package/$server/$folder/lib/consultant/consultant.js +7 -10
  114. package/$server/$folder/lib/explorer/explorer.js +1 -1
  115. package/$server/$folder/lib/icon/icon.js +1 -1
  116. package/$server/$folder/lib/menu/menu.js +3 -2
  117. package/$server/$folder/lib/messenger-settings/messenger-settings.js +4 -4
  118. package/$server/$folder/lib/node/node.js +3 -3
  119. package/$server/$folder/lib/prompt-bar/prompt-bar.js +2 -2
  120. package/$server/$folder/lib/role/role.js +1 -2
  121. package/$server/$folder/lib/security/admin/admin.js +3 -3
  122. package/$server/$folder/lib/security/security.js +4 -4
  123. package/$server/$folder/lib/security/users/users.js +2 -5
  124. package/$server/$folder/lib/site-loc/site-loc.js +3 -3
  125. package/$server/$folder/lib/tree/tree.js +14 -22
  126. package/$server/class.js +1 -0
  127. package/AGENTS.md +21 -13
  128. package/{$server/$folder/$class/handlers/pages/form/system/$handler/tabs/ai-model.js → MODELS/$ai/$folder/$class/$ai/handlers/pages/form/system/ai/$handler/class.js} +385 -425
  129. package/{$server/$folder/$class/handlers/pages/form/system/$handler/tabs/ai-provider.js → MODELS/$ai/$folder/$class/$provider/handlers/pages/form/system/ai/$handler/class.js} +157 -161
  130. package/{$server/$folder/$class/handlers/pages/form/system/$handler/tabs/ai-root.js → MODELS/$ai/handlers/pages/form/system/ai/$handler/class.js} +34 -33
  131. package/{$server/$folder/$class/handlers/pages/form/system/$handler/tabs/ai-local.js → MODELS/Local/$provider/handlers/pages/form/system/ai/$handler/class.js} +572 -622
  132. package/MODULES/$domain/class.js +85 -4
  133. package/MODULES/$domain/handlers/pages/form/system/mcp/$handler/class.js +7 -0
  134. package/MODULES/$domain/readme.md +7 -6
  135. package/{SERVICES/1C/$service → MODULES/1C/$module}/class.js +7 -1
  136. package/MODULES/2GIS/$module/class.js +32 -0
  137. package/MODULES/2GIS/$module/readme.md +57 -0
  138. package/{SERVICES/Bitrix24/$service → MODULES/Bitrix24/$module}/class.js +7 -2
  139. package/{SERVICES/CBR/$service → MODULES/CBR/$module}/class.js +5 -0
  140. package/{SERVICES/DaData/$service → MODULES/DaData/$module}/class.js +9 -3
  141. package/MODULES/Geo//320/232/320/260/321/200/321/202/320/260/$catalog/handlers/pages/form/map/$handler/class.js +648 -21
  142. package/MODULES/KLADR/$module/handlers/pages/form/kladr/$handler/class.js +140 -6
  143. package/{SERVICES/Marketplaces/$service → MODULES/Marketplaces/$domain}/class.js +1 -1
  144. package/{SERVICES/Marketplaces/Ozon/$service → MODULES/Marketplaces/Ozon/$module}/class.js +1 -1
  145. package/{SERVICES/Marketplaces/Wildberries/$service → MODULES/Marketplaces/Wildberries/$module}/class.js +1 -1
  146. package/{SERVICES/Marketplaces/YandexMarket/$service → MODULES/Marketplaces/YandexMarket/$module}/class.js +1 -1
  147. package/MODULES/Process/$module/readme.md +1 -1
  148. package/MODULES/Process//320/227/320/260/320/264/320/260/321/207/320/270 /320/270 /321/215/321/202/320/260/320/277/321/213/$catalog/handlers/pages/form/gantt/$handler/class.js" +305 -6
  149. package/MODULES/Process//320/227/320/260/320/264/320/260/321/207/320/270 /320/270 /321/215/321/202/320/260/320/277/321/213/$catalog/handlers/pages/form/scheduler/$handler/class.js" +241 -6
  150. package/MODULES/Process//320/241/321/205/320/265/320/274/321/213 /320/277/321/200/320/276/321/206/320/265/321/201/321/201/320/276/320/262/$catalog/handlers/pages/form/bpmn/$handler/class.js" +515 -16
  151. package/MODULES/Register/CATALOGS/$catalog/$folder/$class/{$virtual → $data/$catalog/$virtual}/class.js +3 -0
  152. package/MODULES/Register/CATALOGS/$catalog/$folder/$class/$data/$catalog/$virtual/handlers/pages/form/objects/$handler/class.js +3 -0
  153. package/MODULES/Register/CATALOGS/$catalog/$folder/$class/{$virtual/handlers/pages/form/virtual/$handler/virtual.js → $data/$catalog/$virtual/handlers/pages/form/virtual/$handler/class.js} +413 -390
  154. package/MODULES/Register/CATALOGS/$catalog/$folder/$class/$data/$catalog/class.js +14 -0
  155. package/MODULES/Register/CATALOGS/$catalog/class.js +7 -14
  156. package/MODULES/Register/CATALOGS//320/241/320/276/321/202/321/200/321/203/320/264/320/275/320/270/320/272/320/270/$virtual/$folder/$class/$data/$catalog/$virtual/class.js +9 -0
  157. package/MODULES/Register/CATALOGS//320/241/320/276/321/202/321/200/321/203/320/264/320/275/320/270/320/272/320/270/$virtual/class.js +0 -7
  158. package/MODULES/Register/CATALOGS//320/241/321/203/320/261/321/212/320/265/320/272/321/202/321/213/$catalog/$folder/$class/$data/$catalog/class.js +11 -0
  159. package/MODULES/Register/CATALOGS//320/241/321/203/320/261/321/212/320/265/320/272/321/202/321/213/$catalog/class.js +0 -9
  160. package/MODULES/Register/OPERATIONS/$operation/$folder/$class/$data/$operation/class.js +16 -0
  161. package/MODULES/Register/OPERATIONS/$operation/class.js +0 -9
  162. package/MODULES/Register/OPERATIONS//320/232/320/260/320/264/321/200/321/213/$operation/$folder/$class/$data/$operation/class.js +8 -0
  163. package/MODULES/Register/OPERATIONS//320/232/320/260/320/264/321/200/321/213/$operation/class.js +4 -10
  164. package/MODULES/Register/OPERATIONS//320/232/320/260/321/201/321/201/320/260/$operation/$folder/$class/$data/$operation/class.js +8 -0
  165. package/MODULES/Register/OPERATIONS//320/232/320/260/321/201/321/201/320/260/$operation/class.js +0 -6
  166. package/MODULES/Register/OPERATIONS//320/232/320/276/320/274/320/274/321/203/320/275/320/270/320/272/320/260/321/206/320/270/320/270/$operation/$folder/$class/$data/$operation/class.js +8 -0
  167. package/MODULES/Register/OPERATIONS//320/232/320/276/320/274/320/274/321/203/320/275/320/270/320/272/320/260/321/206/320/270/320/270/$operation/class.js +4 -10
  168. package/MODULES/Register/OPERATIONS//320/237/320/273/320/260/321/202/320/265/320/266/320/270 /321/201 /321/200/320/260/321/201/321/207/321/221/321/202/320/275/320/276/320/263/320/276 /321/201/321/207/321/221/321/202/320/260/$operation/$folder/$class/$data/$operation/class.js" +10 -0
  169. package/MODULES/Register/OPERATIONS//320/237/320/273/320/260/321/202/320/265/320/266/320/270 /321/201 /321/200/320/260/321/201/321/207/321/221/321/202/320/275/320/276/320/263/320/276 /321/201/321/207/321/221/321/202/320/260/$operation/class.js" +4 -12
  170. package/MODULES/Register/OPERATIONS//320/237/320/276/321/201/321/202/321/203/320/277/320/273/320/265/320/275/320/270/321/217 /320/275/320/260 /321/200/320/260/321/201/321/207/321/221/321/202/320/275/321/213/320/271 /321/201/321/207/321/221/321/202/$operation/$folder/$class/$data/$operation/class.js" +10 -0
  171. package/MODULES/Register/OPERATIONS//320/237/320/276/321/201/321/202/321/203/320/277/320/273/320/265/320/275/320/270/321/217 /320/275/320/260 /321/200/320/260/321/201/321/207/321/221/321/202/320/275/321/213/320/271 /321/201/321/207/321/221/321/202/$operation/class.js" +4 -12
  172. package/MODULES/Register/OPERATIONS//320/240/320/265/320/260/320/273/320/270/320/267/320/260/321/206/320/270/321/217/$operation/$folder/$class/$data/$operation/class.js +24 -0
  173. package/MODULES/Register/OPERATIONS//320/240/320/265/320/260/320/273/320/270/320/267/320/260/321/206/320/270/321/217/$operation/class.js +0 -22
  174. package/MODULES/Register/REGISTER/$register/$folder/$class/{$account/handlers/pages/form/analysis/$handler/analysis.js → $data/$register/$account/handlers/pages/form/analysis/$handler/class.js} +9 -4
  175. package/MODULES/Register/REGISTER/$register/$folder/$class/{$account/handlers/pages/form/postings/$handler/postings.js → $data/$register/$account/handlers/pages/form/postings/$handler/class.js} +845 -753
  176. package/MODULES/Register/REGISTER/$register/$folder/$class/{$account/handlers/pages/form/turnovers/$handler/turnovers.js → $data/$register/$account/handlers/pages/form/turnovers/$handler/class.js} +9 -4
  177. package/MODULES/Register/REGISTER/$register/{$folder/$class/$register/handlers/pages/form/journal/$handler/journal.js → handlers/pages/form/journal/$handler/class.js} +382 -329
  178. package/MODULES/Register/REGISTER/$register/handlers/pages/form/sheet/$handler/class.js +807 -0
  179. package/MODULES/Register/REGISTER/10/$account/$folder/$class/$data/$register/$account/class.js +21 -0
  180. package/MODULES/Register/REGISTER/10/$account/class.js +0 -19
  181. package/MODULES/Register/REGISTER//320/232/320/260/320/264/321/200/321/213/$account/$folder/$class/$data/$register/$account/class.js +14 -0
  182. package/MODULES/Register/REGISTER//320/232/320/260/320/264/321/200/321/213/$account/class.js +4 -16
  183. package/{SERVICES/SearXNG/$service → MODULES/SearXNG/$module}/class.js +5 -0
  184. package/{SERVICES/Yandex/$service → MODULES/Yandex/$module}/class.js +7 -0
  185. package/{SERVICES/YandexDisk/$service → MODULES/YandexDisk/$module}/class.js +8 -2
  186. package/NODES/$node/handlers/pages/form/network/$handler/class.js +122 -5
  187. package/ORGANIZATIONS/$domain/$folder/$class/$structure/$organization/class.js +5 -0
  188. package/ORGANIZATIONS/$domain/class.js +5 -5
  189. package/oda/components/inputs/link/link.js +1 -1
  190. package/package.json +1 -1
  191. package/readme.md +6 -7
  192. package/scripts/check-architecture.mjs +541 -0
  193. package/scripts/cleanup-storage.mjs +1 -1
  194. package/scripts/demo-seed.mjs +3 -3
  195. package/scripts/import-bis.mjs +33 -15
  196. package/scripts/import-delovaya.mjs +26 -14
  197. package/sources/client/class.js +19 -10
  198. package/sources/client/folder.js +10 -22
  199. package/sources/client/handler.js +75 -33
  200. package/sources/data/api.js +9 -10
  201. package/sources/data/classes.js +85 -9
  202. package/sources/data/db.js +10 -6
  203. package/sources/data/print.js +15 -41
  204. package/sources/data/readme.md +5 -5
  205. package/sources/data/schema.js +206 -118
  206. package/sources/data/sql-inspector.js +7 -7
  207. package/sources/host/auth-methods.js +2 -5
  208. package/sources/host/auto-updater.js +1 -2
  209. package/sources/host/babel-merge.js +174 -129
  210. package/sources/host/prewarm.js +1 -1
  211. package/sources/host/watch.js +1 -1
  212. package/sources/index.html +1 -1
  213. package/sources/modules/agent/extensions.js +48 -38
  214. package/sources/modules/agent/index.js +1 -1
  215. package/sources/modules/agent/node-rules.js +69 -41
  216. package/sources/modules/agent/permissions.js +1 -1
  217. package/sources/modules/agent/plugins.js +11 -11
  218. package/sources/modules/agent/resources.js +96 -52
  219. package/sources/modules/agent/tools/net.js +1 -1
  220. package/sources/modules/agent/tools/services.js +7 -7
  221. package/sources/modules/agent/tools/work/access.js +10 -8
  222. package/sources/modules/agent/tools/work/classes.js +26 -47
  223. package/sources/modules/agent/tools/work/common.js +8 -10
  224. package/sources/modules/agent/tools/work/data.js +4 -4
  225. package/sources/modules/agent/triggers.js +1 -1
  226. package/sources/modules/agent/twin-bus.js +4 -4
  227. package/sources/modules/agent/voice.js +1 -1
  228. package/sources/modules/call/call.js +4 -4
  229. package/sources/modules/kladr/index.js +3 -3
  230. package/sources/modules/lan/register.js +7 -7
  231. package/sources/modules/mcp-marketplaces/ozon.js +1 -1
  232. package/sources/modules/mcp-marketplaces/wildberries.js +1 -1
  233. package/sources/modules/mcp-marketplaces/yandex-market.js +1 -1
  234. package/sources/modules/nodes/mount.js +2 -4
  235. package/sources/modules/notify/index.js +18 -18
  236. package/sources/modules/rag/extract.js +9 -2
  237. package/sources/modules/rag/indexer.js +1 -1
  238. package/sources/modules/rag/scope.js +7 -33
  239. package/sources/modules/trainer/dataset.js +2 -2
  240. package/sources/modules/trainer/local-engine.js +1 -1
  241. package/sources/page.html +2 -2
  242. package/sources/readme.md +1 -1
  243. package/sources/server/access/gateway.js +19 -19
  244. package/sources/server/access/invites.js +4 -5
  245. package/sources/server/access/links.js +10 -8
  246. package/sources/server/access/policy.js +65 -39
  247. package/sources/server/access/workplaces.js +20 -14
  248. package/sources/server/chat-threads.js +4 -4
  249. package/sources/server/class/archive.js +15 -15
  250. package/sources/server/class/base-template.js +13 -9
  251. package/sources/server/class/distro.js +3 -4
  252. package/sources/server/class/feed.js +3 -3
  253. package/sources/server/class/mail-calendar.js +9 -8
  254. package/sources/server/class/scaffold.js +110 -60
  255. package/sources/server/class/search.js +2 -2
  256. package/sources/server/class/security.js +76 -94
  257. package/sources/server/class.js +181 -64
  258. package/sources/server/file.js +2 -2
  259. package/sources/server/folder.js +376 -191
  260. package/sources/server/handler.js +52 -13
  261. package/sources/server/logs.js +7 -7
  262. package/sources/server/node.js +12 -43
  263. package/sources/server/server.js +16 -17
  264. package/$server/$folder/$class/$device/class.js +0 -3
  265. package/$server/$folder/$class/$handler/$task/class.js +0 -3
  266. package/$server/$folder/$class/$service/$class/$service/class.js +0 -4
  267. package/$server/$folder/$class/$structure/$base/class.js +0 -10
  268. package/$server/$folder/$class/$structure/$base/roots_1/roots.test +0 -0
  269. package/$server/$folder/$class/$structure/handlers/pages/data/$handler/data.js +0 -313
  270. package/$server/$folder/$class/$structure/handlers/pages/explorer/$handler/explorer.js +0 -16
  271. package/$server/$folder/$class/$structure/handlers/pages/form/calendar/$handler/calendar.js +0 -1226
  272. package/$server/$folder/$class/$structure/handlers/pages/form/chat/$handler/chat.js +0 -2217
  273. package/$server/$folder/$class/$structure/handlers/pages/form/email/$handler/email.js +0 -1188
  274. package/$server/$folder/$class/$structure/handlers/pages/form/search/$handler/search.js +0 -289
  275. package/$server/$folder/$class/$structure/handlers/pages/site/$handler/site.js +0 -240
  276. package/$server/$folder/$class/handlers/pages/form/object/$handler/class.js +0 -33
  277. package/$server/$folder/$class/handlers/pages/form/object/$handler/object.js +0 -1371
  278. package/$server/$folder/$class/handlers/pages/form/objects/$handler/class.js +0 -33
  279. package/$server/$folder/$class/handlers/pages/form/objects/$handler/objects.js +0 -2130
  280. package/$server/$folder/$class/handlers/pages/form/system/$handler/system.js +0 -384
  281. package/$server/$folder/$class/handlers/pages/form/system/$handler/tabs/modules.js +0 -244
  282. package/$server/$folder/$class/handlers/pages/form/system/$handler/tabs/staff.js +0 -2126
  283. package/$server/$folder/$class/handlers/pages/storage/$handler/storage.js +0 -21
  284. package/$server/$folder/$file/$data/handlers/pages/form/editor/$handler/editor.js +0 -27
  285. package/$server/$folder/$file/$devs/handlers/pages/form/file/$handler/file.js +0 -31
  286. package/$server/$folder/$file/$ics/handlers/pages/form/file/$handler/file.js +0 -10
  287. package/$server/$folder/$file/$ipynb/handlers/pages/form/file/$handler/file.js +0 -72
  288. package/$server/$folder/$file/$md/handlers/pages/form/file/$handler/file.js +0 -63
  289. package/$server/$folder/$file/$office/handlers/pages/form/file/$handler/file.js +0 -1845
  290. package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/file.js +0 -785
  291. package/$server/$folder/$file/handlers/pages/form/file/$handler/file.js +0 -29
  292. package/$server/$folder/handlers/pages/form/$handler/form.js +0 -2122
  293. package/MODULES/Geo//320/232/320/260/321/200/321/202/320/260/$catalog/handlers/pages/form/map/$handler/map.js +0 -623
  294. package/MODULES/KLADR/$module/handlers/pages/form/kladr/$handler/kladr.js +0 -134
  295. package/MODULES/Process//320/227/320/260/320/264/320/260/321/207/320/270 /320/270 /321/215/321/202/320/260/320/277/321/213/$catalog/handlers/pages/form/gantt/$handler/gantt.js" +0 -293
  296. package/MODULES/Process//320/227/320/260/320/264/320/260/321/207/320/270 /320/270 /321/215/321/202/320/260/320/277/321/213/$catalog/handlers/pages/form/scheduler/$handler/scheduler.js" +0 -234
  297. package/MODULES/Process//320/241/321/205/320/265/320/274/321/213 /320/277/321/200/320/276/321/206/320/265/321/201/321/201/320/276/320/262/$catalog/handlers/pages/form/bpmn/$handler/bpmn.js" +0 -406
  298. package/MODULES/Register/CATALOGS/$catalog/$folder/$class/$virtual/handlers/pages/form/virtual/$handler/class.js +0 -6
  299. package/MODULES/Register/REGISTER/$register/$folder/$class/$account/handlers/pages/form/analysis/$handler/class.js +0 -9
  300. package/MODULES/Register/REGISTER/$register/$folder/$class/$account/handlers/pages/form/postings/$handler/class.js +0 -9
  301. package/MODULES/Register/REGISTER/$register/$folder/$class/$account/handlers/pages/form/turnovers/$handler/class.js +0 -9
  302. package/MODULES/Register/REGISTER/$register/$folder/$class/$register/handlers/pages/form/journal/$handler/class.js +0 -6
  303. package/MODULES/Register/REGISTER/$register/$folder/$class/$register/handlers/pages/form/sheet/$handler/class.js +0 -6
  304. package/MODULES/Register/REGISTER/$register/$folder/$class/$register/handlers/pages/form/sheet/$handler/sheet.js +0 -808
  305. package/NODES/$node/handlers/pages/form/network/$handler/network.js +0 -110
  306. package/SERVICES/$service/$folder/$storage/$service/class.js +0 -8
  307. package/SERVICES/$service/class.js +0 -442
  308. package/SERVICES/readme.md +0 -36
  309. /package/$server/$folder/$class/$structure/{$base → $organization}/icon.png +0 -0
  310. /package/{SERVICES/DuckDuckGo/$service → MODULES/DuckDuckGo/$module}/class.js +0 -0
  311. /package/MODULES/KLADR/$module/$folder/$class/{$catalog → $data/$catalog}/class.js +0 -0
  312. /package/MODULES/Process/$module/$folder/$class/{$catalog → $data/$catalog}/class.js +0 -0
  313. /package/MODULES/Register/$module/$folder/$class/{$catalog → $data/$catalog}/class.js +0 -0
  314. /package/MODULES/Register/$module/$folder/$class/{$operation → $data/$operation}/class.js +0 -0
  315. /package/MODULES/Register/$module/$folder/$class/{$register → $data/$register}/class.js +0 -0
  316. /package/MODULES/Register/$module/$folder/$class/{$struct → $data/$struct}/class.js +0 -0
  317. /package/MODULES/Register/CATALOGS/$catalog/$folder/$class/{$virtual/$folder/$class → $data/$catalog/$virtual/$folder/$class/$data/$catalog}/$virtual/class.js +0 -0
  318. /package/MODULES/Register/OPERATIONS//320/237/320/273/320/260/321/202/320/265/320/266/320/270 /321/201 /321/200/320/260/321/201/321/207/321/221/321/202/320/275/320/276/320/263/320/276 /321/201/321/207/321/221/321/202/320/260/$operation/{print → $folder/$class/$data/$operation/print}//320/237/320/273/320/260/321/202/321/221/320/266/320/275/320/276/320/265 /320/277/320/276/321/200/321/203/321/207/320/265/320/275/320/270/320/265.html" +0 -0
  319. /package/MODULES/Register/REGISTER/$register/$folder/$class/{$account → $data/$register/$account}/class.js +0 -0
  320. /package/MODULES/Register/REGISTER/$register/$folder/$class/{$account → $data/$register/$account}/readme.md +0 -0
  321. /package/MODULES/Register/REGISTER/$register/$folder/$class/{$register → $data/$register}/class.js +0 -0
  322. /package/MODULES/Register/STRUCTS/$struct/$folder/$class/{$struct → $data/$struct}/class.js +0 -0
  323. /package/{SERVICES/RuCalendar/$service → MODULES/RuCalendar/$module}/class.js +0 -0
  324. /package/{SERVICES/Telegram/$service → MODULES/Telegram/$module}/class.js +0 -0
  325. /package/{SERVICES/Weather/$service → MODULES/Weather/$module}/class.js +0 -0
  326. /package/PROJECTS/$domain/$folder/$class/{$project → $structure/$project}/class.js +0 -0
@@ -12,152 +12,208 @@
12
12
  */
13
13
 
14
14
  const PERIOD_STORAGE_KEY = 'work.accounting.period';
15
-
16
15
  function _day(d) {
17
- return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
16
+ return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
18
17
  }
19
18
  const _today = () => _day(new Date());
20
19
  const _yearStart = () => `${new Date().getFullYear()}-01-01`;
21
20
  const _yearEnd = () => _today();
22
-
23
21
  function _readSavedPeriod() {
24
- try {
25
- const raw = typeof sessionStorage !== 'undefined' ? sessionStorage.getItem(PERIOD_STORAGE_KEY) : null;
26
- if (!raw)
27
- return null;
28
- const parsed = JSON.parse(raw);
29
- return parsed && typeof parsed === 'object' ? parsed : null;
30
- }
31
- catch {
32
- return null;
33
- }
22
+ try {
23
+ const raw = typeof sessionStorage !== 'undefined' ? sessionStorage.getItem(PERIOD_STORAGE_KEY) : null;
24
+ if (!raw) return null;
25
+ const parsed = JSON.parse(raw);
26
+ return parsed && typeof parsed === 'object' ? parsed : null;
27
+ } catch {
28
+ return null;
29
+ }
34
30
  }
35
-
36
31
  function _writeSavedPeriod(packetsKey, from, to) {
37
- try {
38
- if (typeof sessionStorage !== 'undefined')
39
- sessionStorage.setItem(PERIOD_STORAGE_KEY, JSON.stringify({ packetsKey: packetsKey || '*', from: from || '', to: to || '' }));
40
- }
41
- catch { /* ignore */ }
32
+ try {
33
+ if (typeof sessionStorage !== 'undefined') sessionStorage.setItem(PERIOD_STORAGE_KEY, JSON.stringify({
34
+ packetsKey: packetsKey || '*',
35
+ from: from || '',
36
+ to: to || ''
37
+ }));
38
+ } catch {/* ignore */}
42
39
  }
43
-
44
40
  function _derivePacketsKey(from, to, fallback = '*') {
45
- if (!from && !to)
46
- return '*';
47
- if (fallback && fallback !== '*')
48
- return fallback;
49
- if (from && to) {
50
- const ym1 = /^(\d{4})-01-01$/.exec(from);
51
- const ym2 = /^(\d{4})-12-31$/.exec(to);
52
- if (ym1 && ym2 && ym1[1] === ym2[1])
53
- return `${ym1[1]}*`;
54
- return `period:${from}:${to}`;
55
- }
56
- return fallback || '*';
41
+ if (!from && !to) return '*';
42
+ if (fallback && fallback !== '*') return fallback;
43
+ if (from && to) {
44
+ const ym1 = /^(\d{4})-01-01$/.exec(from);
45
+ const ym2 = /^(\d{4})-12-31$/.exec(to);
46
+ if (ym1 && ym2 && ym1[1] === ym2[1]) return `${ym1[1]}*`;
47
+ return `period:${from}:${to}`;
48
+ }
49
+ return fallback || '*';
57
50
  }
58
-
59
51
  function _daysInMonth(y, m) {
60
- return new Date(y, m, 0).getDate();
52
+ return new Date(y, m, 0).getDate();
61
53
  }
62
-
63
54
  function _weekBounds(dt) {
64
- const dow = dt.getDay();
65
- const diffToMon = dow === 0 ? -6 : 1 - dow;
66
- const mon = new Date(dt.getFullYear(), dt.getMonth(), dt.getDate() + diffToMon);
67
- const sun = new Date(mon.getFullYear(), mon.getMonth(), mon.getDate() + 6);
68
- return { from: _day(mon), to: _day(sun) };
55
+ const dow = dt.getDay();
56
+ const diffToMon = dow === 0 ? -6 : 1 - dow;
57
+ const mon = new Date(dt.getFullYear(), dt.getMonth(), dt.getDate() + diffToMon);
58
+ const sun = new Date(mon.getFullYear(), mon.getMonth(), mon.getDate() + 6);
59
+ return {
60
+ from: _day(mon),
61
+ to: _day(sun)
62
+ };
69
63
  }
70
-
71
64
  function _boundsFromPacketsKey(key, defaultMode = 'month') {
72
- const k = String(key || '').trim();
73
- if (!k || k === '*')
74
- return { from: '', to: '' };
75
- if (k.startsWith('period:')) {
76
- const [, s = '', e = ''] = k.split(':');
77
- return { from: s, to: e };
78
- }
79
- if (k === 'now' || k.startsWith('now:')) {
80
- const gran = k.startsWith('now:') ? k.slice(4) : defaultMode;
81
- const now = new Date();
82
- const y = now.getFullYear(), m = now.getMonth() + 1;
83
- if (gran === 'day') {
84
- const d = _day(now);
85
- return { from: d, to: d };
86
- }
87
- if (gran === 'week')
88
- return _weekBounds(now);
89
- if (gran === 'quarter') {
90
- const q = Math.floor((m - 1) / 3) + 1;
91
- const m1 = String((q - 1) * 3 + 1).padStart(2, '0');
92
- const m2 = (q - 1) * 3 + 3;
93
- return { from: `${y}-${m1}-01`, to: `${y}-${String(m2).padStart(2, '0')}-${String(_daysInMonth(y, m2)).padStart(2, '0')}` };
94
- }
95
- if (gran === 'year')
96
- return { from: `${y}-01-01`, to: `${y}-12-31` };
97
- const ms = String(m).padStart(2, '0');
98
- return { from: `${y}-${ms}-01`, to: `${y}-${ms}-${String(_daysInMonth(y, m)).padStart(2, '0')}` };
99
- }
100
- const clean = k.replace(/\*+$/, '');
101
- if (/^\d{4}$/.test(clean))
102
- return { from: `${clean}-01-01`, to: `${clean}-12-31` };
103
- const qm = /^(\d{4})-q([1-4])$/i.exec(clean);
104
- if (qm) {
105
- const y = +qm[1], q = +qm[2];
106
- const m1 = String((q - 1) * 3 + 1).padStart(2, '0');
107
- const m2 = (q - 1) * 3 + 3;
108
- return { from: `${y}-${m1}-01`, to: `${y}-${String(m2).padStart(2, '0')}-${String(_daysInMonth(y, m2)).padStart(2, '0')}` };
65
+ const k = String(key || '').trim();
66
+ if (!k || k === '*') return {
67
+ from: '',
68
+ to: ''
69
+ };
70
+ if (k.startsWith('period:')) {
71
+ const [, s = '', e = ''] = k.split(':');
72
+ return {
73
+ from: s,
74
+ to: e
75
+ };
76
+ }
77
+ if (k === 'now' || k.startsWith('now:')) {
78
+ const gran = k.startsWith('now:') ? k.slice(4) : defaultMode;
79
+ const now = new Date();
80
+ const y = now.getFullYear(),
81
+ m = now.getMonth() + 1;
82
+ if (gran === 'day') {
83
+ const d = _day(now);
84
+ return {
85
+ from: d,
86
+ to: d
87
+ };
109
88
  }
110
- const mm = /^(\d{4})-(0[1-9]|1[0-2])$/.exec(clean);
111
- if (mm) {
112
- const y = +mm[1], m = +mm[2];
113
- return { from: `${clean}-01`, to: `${clean}-${String(_daysInMonth(y, m)).padStart(2, '0')}` };
89
+ if (gran === 'week') return _weekBounds(now);
90
+ if (gran === 'quarter') {
91
+ const q = Math.floor((m - 1) / 3) + 1;
92
+ const m1 = String((q - 1) * 3 + 1).padStart(2, '0');
93
+ const m2 = (q - 1) * 3 + 3;
94
+ return {
95
+ from: `${y}-${m1}-01`,
96
+ to: `${y}-${String(m2).padStart(2, '0')}-${String(_daysInMonth(y, m2)).padStart(2, '0')}`
97
+ };
114
98
  }
115
- if (clean.startsWith('week:')) {
116
- const monIso = clean.slice(5);
117
- if (/^\d{4}-\d{2}-\d{2}$/.test(monIso)) {
118
- const [y, m, d] = monIso.split('-').map(Number);
119
- return _weekBounds(new Date(y, m - 1, d));
120
- }
99
+ if (gran === 'year') return {
100
+ from: `${y}-01-01`,
101
+ to: `${y}-12-31`
102
+ };
103
+ const ms = String(m).padStart(2, '0');
104
+ return {
105
+ from: `${y}-${ms}-01`,
106
+ to: `${y}-${ms}-${String(_daysInMonth(y, m)).padStart(2, '0')}`
107
+ };
108
+ }
109
+ const clean = k.replace(/\*+$/, '');
110
+ if (/^\d{4}$/.test(clean)) return {
111
+ from: `${clean}-01-01`,
112
+ to: `${clean}-12-31`
113
+ };
114
+ const qm = /^(\d{4})-q([1-4])$/i.exec(clean);
115
+ if (qm) {
116
+ const y = +qm[1],
117
+ q = +qm[2];
118
+ const m1 = String((q - 1) * 3 + 1).padStart(2, '0');
119
+ const m2 = (q - 1) * 3 + 3;
120
+ return {
121
+ from: `${y}-${m1}-01`,
122
+ to: `${y}-${String(m2).padStart(2, '0')}-${String(_daysInMonth(y, m2)).padStart(2, '0')}`
123
+ };
124
+ }
125
+ const mm = /^(\d{4})-(0[1-9]|1[0-2])$/.exec(clean);
126
+ if (mm) {
127
+ const y = +mm[1],
128
+ m = +mm[2];
129
+ return {
130
+ from: `${clean}-01`,
131
+ to: `${clean}-${String(_daysInMonth(y, m)).padStart(2, '0')}`
132
+ };
133
+ }
134
+ if (clean.startsWith('week:')) {
135
+ const monIso = clean.slice(5);
136
+ if (/^\d{4}-\d{2}-\d{2}$/.test(monIso)) {
137
+ const [y, m, d] = monIso.split('-').map(Number);
138
+ return _weekBounds(new Date(y, m - 1, d));
121
139
  }
122
- if (/^\d{4}-\d{2}-\d{2}$/.test(clean))
123
- return { from: clean, to: clean };
124
- return { from: '', to: '' };
140
+ }
141
+ if (/^\d{4}-\d{2}-\d{2}$/.test(clean)) return {
142
+ from: clean,
143
+ to: clean
144
+ };
145
+ return {
146
+ from: '',
147
+ to: ''
148
+ };
125
149
  }
126
-
127
- const money = v => (Number(v) ? Number(v).toLocaleString('ru-RU', { minimumFractionDigits: 2, maximumFractionDigits: 2 }) : '');
128
- const qtyFmt = v => (Number(v) ? Number(v).toLocaleString('ru-RU', { maximumFractionDigits: 4 }) : '');
150
+ const money = v => Number(v) ? Number(v).toLocaleString('ru-RU', {
151
+ minimumFractionDigits: 2,
152
+ maximumFractionDigits: 2
153
+ }) : '';
154
+ const qtyFmt = v => Number(v) ? Number(v).toLocaleString('ru-RU', {
155
+ maximumFractionDigits: 4
156
+ }) : '';
129
157
  /** Сальдо со знаком (Дт − Кт) текстом: «1 200,00 Дт», «300,00 Кт». */
130
- const saldo = v => (Number(v) > 0 ? money(v) + ' Дт' : Number(v) < 0 ? money(-v) + ' Кт' : '0');
131
-
132
- export const TURNOVER_GROUPS = [
133
- { id: 'none', label: 'Нет' },
134
- { id: 'day', label: 'Дни' },
135
- { id: 'week', label: 'Недели' },
136
- { id: 'month', label: 'Месяцы' },
137
- { id: 'quarter', label: 'Кварталы' },
138
- { id: 'year', label: 'Годы' },
139
- { id: 'operation', label: 'Операции' },
140
- { id: 'account', label: 'Счета' },
141
- { id: 'all', label: 'Все' },
142
- ];
158
+ const saldo = v => Number(v) > 0 ? money(v) + ' Дт' : Number(v) < 0 ? money(-v) + ' Кт' : '0';
159
+ export const TURNOVER_GROUPS = [{
160
+ id: 'none',
161
+ label: 'Нет'
162
+ }, {
163
+ id: 'day',
164
+ label: 'Дни'
165
+ }, {
166
+ id: 'week',
167
+ label: 'Недели'
168
+ }, {
169
+ id: 'month',
170
+ label: 'Месяцы'
171
+ }, {
172
+ id: 'quarter',
173
+ label: 'Кварталы'
174
+ }, {
175
+ id: 'year',
176
+ label: 'Годы'
177
+ }, {
178
+ id: 'operation',
179
+ label: 'Операции'
180
+ }, {
181
+ id: 'account',
182
+ label: 'Счета'
183
+ }, {
184
+ id: 'all',
185
+ label: 'Все'
186
+ }];
143
187
 
144
188
  /** Парсинг строки фильтра субаналитики: «поле:значение» или просто текст поиска по name. */
145
189
  function parseSubFilterInput(raw) {
146
- const s = String(raw || '').trim();
147
- if (!s)
148
- return null;
149
- const colon = s.indexOf(':');
150
- const eq = s.indexOf('=');
151
- const sep = colon > 0 && (eq < 0 || colon < eq) ? colon : eq;
152
- if (sep > 0) {
153
- const field = s.slice(0, sep).trim();
154
- const val = s.slice(sep + 1).trim();
155
- return field && val ? { [field]: { contains: val } } : null;
190
+ const s = String(raw || '').trim();
191
+ if (!s) return null;
192
+ const colon = s.indexOf(':');
193
+ const eq = s.indexOf('=');
194
+ const sep = colon > 0 && (eq < 0 || colon < eq) ? colon : eq;
195
+ if (sep > 0) {
196
+ const field = s.slice(0, sep).trim();
197
+ const val = s.slice(sep + 1).trim();
198
+ return field && val ? {
199
+ [field]: {
200
+ contains: val
201
+ }
202
+ } : null;
203
+ }
204
+ return {
205
+ name: {
206
+ contains: s
156
207
  }
157
- return { name: { contains: s } };
208
+ };
158
209
  }
159
-
160
210
  export default {
211
+ icon: 'icons:list',
212
+ label: 'Проводки',
213
+ service: true,
214
+ order: 3,
215
+ default: true,
216
+ component: {
161
217
  imports: 'oda//button, oda//packets, ~/lib//editor-form',
162
218
  template: /*html*/`
163
219
  <style>
@@ -884,7 +940,11 @@ export default {
884
940
  </div>
885
941
  </div>
886
942
  `,
887
- packetsKey: { $def: '*', $type: String, $save: true },
943
+ packetsKey: {
944
+ $def: '*',
945
+ $type: String,
946
+ $save: true
947
+ },
888
948
  packetsStart: '',
889
949
  packetsEnd: '',
890
950
  packetDays: null,
@@ -929,772 +989,804 @@ export default {
929
989
  unit: '',
930
990
  items: [],
931
991
  count: 0,
932
- opening: { debit: 0, credit: 0 },
933
- turnover: { debit: 0, credit: 0 },
934
- closing: { debit: 0, credit: 0 },
935
- names: { objects: {}, classes: {}, paths: {} },
992
+ opening: {
993
+ debit: 0,
994
+ credit: 0
995
+ },
996
+ turnover: {
997
+ debit: 0,
998
+ credit: 0
999
+ },
1000
+ closing: {
1001
+ debit: 0,
1002
+ credit: 0
1003
+ },
1004
+ names: {
1005
+ objects: {},
1006
+ classes: {},
1007
+ paths: {}
1008
+ },
936
1009
  error: '',
937
1010
  money,
938
1011
  get analysisSlots() {
939
- return this.slots?.length ? this.slots : [{ id: '_default', label: 'Объект / Субсчёт' }];
1012
+ return this.slots?.length ? this.slots : [{
1013
+ id: '_default',
1014
+ label: 'Объект / Субсчёт'
1015
+ }];
940
1016
  },
941
1017
  get analysisGridCols() {
942
- const n = this.analysisSlots.length;
943
- const firstCols = Array(n).fill(n === 1 ? 'minmax(210px, 2.5fr)' : 'minmax(150px, 1.45fr)').join(' ');
944
- return `${firstCols} repeat(6, minmax(90px, 1fr))`;
1018
+ const n = this.analysisSlots.length;
1019
+ const firstCols = Array(n).fill(n === 1 ? 'minmax(210px, 2.5fr)' : 'minmax(150px, 1.45fr)').join(' ');
1020
+ return `${firstCols} repeat(6, minmax(90px, 1fr))`;
945
1021
  },
946
1022
  slotQueryOf(slotId) {
947
- if (this.slotQueries && slotId in this.slotQueries)
948
- return this.slotQueries[slotId] || '';
949
- if (this.analysisSlots.length === 1)
950
- return this.analysisQuery || '';
951
- return '';
1023
+ if (this.slotQueries && slotId in this.slotQueries) return this.slotQueries[slotId] || '';
1024
+ if (this.analysisSlots.length === 1) return this.analysisQuery || '';
1025
+ return '';
952
1026
  },
953
1027
  setSlotQuery(slotId, val) {
954
- const v = String(val || '');
955
- this.slotQueries = { ...(this.slotQueries || {}), [slotId]: v };
956
- if (this.analysisSlots.length === 1)
957
- this.analysisQuery = v;
1028
+ const v = String(val || '');
1029
+ this.slotQueries = {
1030
+ ...(this.slotQueries || {}),
1031
+ [slotId]: v
1032
+ };
1033
+ if (this.analysisSlots.length === 1) this.analysisQuery = v;
958
1034
  },
959
1035
  get cardGridCols() {
960
- const slotCols = (this.slots || []).map(() => 'minmax(105px, 1.15fr)').join(' ');
961
- return `84px minmax(125px, 1.4fr) minmax(94px, 1fr) minmax(94px, 1fr) minmax(64px, 0.65fr) ${slotCols ? slotCols + ' ' : ''}minmax(125px, 1.3fr) minmax(105px, 1.1fr)`;
1036
+ const slotCols = (this.slots || []).map(() => 'minmax(105px, 1.15fr)').join(' ');
1037
+ return `84px minmax(125px, 1.4fr) minmax(94px, 1fr) minmax(94px, 1fr) minmax(64px, 0.65fr) ${slotCols ? slotCols + ' ' : ''}minmax(125px, 1.3fr) minmax(105px, 1.1fr)`;
962
1038
  },
963
1039
  get openingText() {
964
- return saldo((Number(this.opening?.debit) || 0) - (Number(this.opening?.credit) || 0));
1040
+ return saldo((Number(this.opening?.debit) || 0) - (Number(this.opening?.credit) || 0));
965
1041
  },
966
1042
  get closingText() {
967
- return saldo((Number(this.closing?.debit) || 0) - (Number(this.closing?.credit) || 0));
1043
+ return saldo((Number(this.closing?.debit) || 0) - (Number(this.closing?.credit) || 0));
968
1044
  },
969
1045
  get netTurnoverText() {
970
- return saldo((Number(this.turnover?.debit) || 0) - (Number(this.turnover?.credit) || 0));
1046
+ return saldo((Number(this.turnover?.debit) || 0) - (Number(this.turnover?.credit) || 0));
971
1047
  },
972
1048
  get countText() {
973
- const n = (this.items || []).length;
974
- return n < this.count ? `${n} из ${this.count}` : '';
1049
+ const n = (this.items || []).length;
1050
+ return n < this.count ? `${n} из ${this.count}` : '';
975
1051
  },
976
1052
  get entryCardDate() {
977
- return this.entryCard?.time ? new Date(this.entryCard.time).toLocaleDateString('ru-RU') : '';
1053
+ return this.entryCard?.time ? new Date(this.entryCard.time).toLocaleDateString('ru-RU') : '';
978
1054
  },
979
1055
  get entryCardOpTitle() {
980
- return this.entryCard?.operation?.title || this.entryCard?.operation?.classLabel || '';
1056
+ return this.entryCard?.operation?.title || this.entryCard?.operation?.classLabel || '';
981
1057
  },
982
1058
  get entryCardDebitLabel() {
983
- return this.entryCard?.debit?.label || this.entryCard?.debit?.account || '';
1059
+ return this.entryCard?.debit?.label || this.entryCard?.debit?.account || '';
984
1060
  },
985
1061
  get entryCardCreditLabel() {
986
- return this.entryCard?.credit?.label || this.entryCard?.credit?.account || '';
1062
+ return this.entryCard?.credit?.label || this.entryCard?.credit?.account || '';
987
1063
  },
988
1064
  accountText(cid) {
989
- const code = String(cid || '').split('/').pop().replace(/^acc\./, '');
990
- const label = String(this.names?.classes?.[cid] || '').trim();
991
- if (!label || label === code)
992
- return code;
993
- if (label.startsWith(code + ' ') || label.startsWith(code + '.') || /^\d+(?:\.\d+)?\s/.test(label))
994
- return label;
995
- return `${code} ${label}`;
1065
+ const code = String(cid || '').split('/').pop().replace(/^acc\./, '');
1066
+ const label = String(this.names?.classes?.[cid] || '').trim();
1067
+ if (!label || label === code) return code;
1068
+ if (label.startsWith(code + ' ') || label.startsWith(code + '.') || /^\d+(?:\.\d+)?\s/.test(label)) return label;
1069
+ return `${code} ${label}`;
996
1070
  },
997
1071
  /** Операция: её название, без названия (ядро отдаёт id) — класс операции. */
998
1072
  opText(i) {
999
- const title = this.names?.objects?.[i.op_id];
1000
- return (title && title !== i.op_id ? title : '') || this.names?.classes?.[i.op_cid] || i.op_id || '';
1073
+ const title = this.names?.objects?.[i.op_id];
1074
+ return (title && title !== i.op_id ? title : '') || this.names?.classes?.[i.op_cid] || i.op_id || '';
1001
1075
  },
1002
1076
  get displayRows() {
1003
- return (this.items || []).map(i => ({
1004
- entry: i.entry || i.id || null,
1005
- date: i.time ? new Date(i.time).toLocaleDateString() : '',
1006
- op: this.opText(i),
1007
- op_id: i.op_id || '',
1008
- op_cid: i.op_cid || '',
1009
- debit: money(i.debit),
1010
- credit: money(i.credit),
1011
- qty: i.qty ? String(i.qty) : '',
1012
- slots: (this.slots || []).map(s => {
1013
- const id = i.analytics?.[s.id];
1014
- return id ? this.names?.objects?.[id] || id : '';
1015
- }),
1016
- corr: this.accountText(i.corr),
1017
- corr_cid: i.corr || '',
1018
- bal: saldo(i.balance),
1019
- storno: !!i.storno,
1020
- }));
1077
+ return (this.items || []).map(i => ({
1078
+ entry: i.entry || i.id || null,
1079
+ date: i.time ? new Date(i.time).toLocaleDateString() : '',
1080
+ op: this.opText(i),
1081
+ op_id: i.op_id || '',
1082
+ op_cid: i.op_cid || '',
1083
+ debit: money(i.debit),
1084
+ credit: money(i.credit),
1085
+ qty: i.qty ? String(i.qty) : '',
1086
+ slots: (this.slots || []).map(s => {
1087
+ const id = i.analytics?.[s.id];
1088
+ return id ? this.names?.objects?.[id] || id : '';
1089
+ }),
1090
+ corr: this.accountText(i.corr),
1091
+ corr_cid: i.corr || '',
1092
+ bal: saldo(i.balance),
1093
+ storno: !!i.storno
1094
+ }));
1021
1095
  },
1022
1096
  /** Сводные строки групп для левой таблицы Экрана 3 (Обороты счёта). */
1023
1097
  get turnoverGroups() {
1024
- return (this.groups || []).map(g => ({
1025
- key: g.key,
1026
- label: g.label,
1027
- debit: money(g.debit),
1028
- credit: money(g.credit),
1029
- balance: saldo(g.balance),
1030
- turnover: saldo(g.turnover),
1031
- count: g.count || 0,
1032
- }));
1098
+ return (this.groups || []).map(g => ({
1099
+ key: g.key,
1100
+ label: g.label,
1101
+ debit: money(g.debit),
1102
+ credit: money(g.credit),
1103
+ balance: saldo(g.balance),
1104
+ turnover: saldo(g.turnover),
1105
+ count: g.count || 0
1106
+ }));
1033
1107
  },
1034
1108
  /** Первичные документы выбранного периода для правой таблицы Экрана 3 (Обороты счёта). */
1035
1109
  get turnoverDocs() {
1036
- const sel = this.selectedGroupKey;
1037
- const list = (this.items || []).filter(i => !sel || !i.groupKey || i.groupKey === sel);
1038
- return list.map(i => {
1039
- const corrName = this.accountText(i.corr);
1040
- const prefix = Number(i.debit) > 0 ? 'со сч. ' : 'на сч. ';
1041
- return {
1042
- entry: i.entry || i.id || null,
1043
- date: i.time ? new Date(i.time).toLocaleDateString() : '',
1044
- op: this.opText(i),
1045
- op_id: i.op_id || '',
1046
- op_cid: i.op_cid || '',
1047
- corr: corrName,
1048
- corrDir: corrName ? prefix + corrName : '',
1049
- corr_cid: i.corr || '',
1050
- debit: money(i.debit),
1051
- credit: money(i.credit),
1052
- rawDebit: Number(i.debit) || 0,
1053
- rawCredit: Number(i.credit) || 0,
1054
- storno: !!i.storno,
1055
- };
1056
- });
1110
+ const sel = this.selectedGroupKey;
1111
+ const list = (this.items || []).filter(i => !sel || !i.groupKey || i.groupKey === sel);
1112
+ return list.map(i => {
1113
+ const corrName = this.accountText(i.corr);
1114
+ const prefix = Number(i.debit) > 0 ? 'со сч. ' : 'на сч. ';
1115
+ return {
1116
+ entry: i.entry || i.id || null,
1117
+ date: i.time ? new Date(i.time).toLocaleDateString() : '',
1118
+ op: this.opText(i),
1119
+ op_id: i.op_id || '',
1120
+ op_cid: i.op_cid || '',
1121
+ corr: corrName,
1122
+ corrDir: corrName ? prefix + corrName : '',
1123
+ corr_cid: i.corr || '',
1124
+ debit: money(i.debit),
1125
+ credit: money(i.credit),
1126
+ rawDebit: Number(i.debit) || 0,
1127
+ rawCredit: Number(i.credit) || 0,
1128
+ storno: !!i.storno
1129
+ };
1130
+ });
1057
1131
  },
1058
1132
  get turnoverDocsTotals() {
1059
- let d = 0, c = 0;
1060
- for (const doc of this.turnoverDocs || []) {
1061
- d += doc.rawDebit || 0;
1062
- c += doc.rawCredit || 0;
1063
- }
1064
- return { debit: money(d), credit: money(c) };
1133
+ let d = 0,
1134
+ c = 0;
1135
+ for (const doc of this.turnoverDocs || []) {
1136
+ d += doc.rawDebit || 0;
1137
+ c += doc.rawCredit || 0;
1138
+ }
1139
+ return {
1140
+ debit: money(d),
1141
+ credit: money(c)
1142
+ };
1065
1143
  },
1066
1144
  /** Форматирование ячеек Анализа счёта (Сумма или Количество). */
1067
1145
  analysisCells(r) {
1068
- if (this.valueMode === 'qty') {
1069
- const q = r?.qty || {};
1070
- const openNet = Number(q.opening) || 0;
1071
- const closeNet = Number(q.closing) || 0;
1072
- return {
1073
- open_debit: openNet > 0 ? qtyFmt(openNet) : '',
1074
- open_credit: openNet < 0 ? qtyFmt(-openNet) : '',
1075
- debit: qtyFmt(q.debit),
1076
- credit: qtyFmt(q.credit),
1077
- close_debit: closeNet > 0 ? qtyFmt(closeNet) : '',
1078
- close_credit: closeNet < 0 ? qtyFmt(-closeNet) : '',
1079
- };
1080
- }
1146
+ if (this.valueMode === 'qty') {
1147
+ const q = r?.qty || {};
1148
+ const openNet = Number(q.opening) || 0;
1149
+ const closeNet = Number(q.closing) || 0;
1081
1150
  return {
1082
- open_debit: money(r?.opening?.debit), open_credit: money(r?.opening?.credit),
1083
- debit: money(r?.turnover?.debit), credit: money(r?.turnover?.credit),
1084
- close_debit: money(r?.closing?.debit), close_credit: money(r?.closing?.credit),
1151
+ open_debit: openNet > 0 ? qtyFmt(openNet) : '',
1152
+ open_credit: openNet < 0 ? qtyFmt(-openNet) : '',
1153
+ debit: qtyFmt(q.debit),
1154
+ credit: qtyFmt(q.credit),
1155
+ close_debit: closeNet > 0 ? qtyFmt(closeNet) : '',
1156
+ close_credit: closeNet < 0 ? qtyFmt(-closeNet) : ''
1085
1157
  };
1158
+ }
1159
+ return {
1160
+ open_debit: money(r?.opening?.debit),
1161
+ open_credit: money(r?.opening?.credit),
1162
+ debit: money(r?.turnover?.debit),
1163
+ credit: money(r?.turnover?.credit),
1164
+ close_debit: money(r?.closing?.debit),
1165
+ close_credit: money(r?.closing?.credit)
1166
+ };
1086
1167
  },
1087
1168
  /** Строки таблицы Экрана 2 (Анализ счёта) с колонками по каждому аналитическому справочнику. */
1088
1169
  get analysisRows() {
1089
- const q = String(this.analysisQuery || '').trim().toLowerCase();
1090
- const sq = this.slotQueries || {};
1091
- const aSlots = this.analysisSlots;
1092
- const rawList = this.sheetRows || [];
1093
- const hasDetailRows = rawList.some(r => r?.key);
1094
- const filteredRaw = hasDetailRows ? rawList.filter(r => r?.key) : rawList;
1095
- const rows = filteredRaw.map(r => {
1096
- const slotCells = aSlots.map(s => {
1097
- if (r.key && typeof r.key === 'object') {
1098
- const id = s.id in r.key ? r.key[s.id] : Object.values(r.key)[0];
1099
- return id === null || id === undefined ? '—' : (this.names?.objects?.[id] || String(id));
1100
- }
1101
- return this.accountText(r.account);
1102
- });
1103
- const label = r.key
1104
- ? slotCells.join(' / ')
1105
- : this.accountText(r.account);
1106
- return {
1107
- account: r.account,
1108
- key: r.key || null,
1109
- detail: !!r.key,
1110
- slotCells,
1111
- label,
1112
- indent: (Number(r.level) || 0) * 16,
1113
- ...this.analysisCells(r),
1114
- };
1115
- });
1116
- return rows.filter(r => {
1117
- if (q && !r.label.toLowerCase().includes(q))
1118
- return false;
1119
- for (let i = 0; i < aSlots.length; i++) {
1120
- const slotQ = String(sq[aSlots[i].id] || '').trim().toLowerCase();
1121
- if (slotQ && !String(r.slotCells[i] || '').toLowerCase().includes(slotQ))
1122
- return false;
1123
- }
1124
- return true;
1170
+ const q = String(this.analysisQuery || '').trim().toLowerCase();
1171
+ const sq = this.slotQueries || {};
1172
+ const aSlots = this.analysisSlots;
1173
+ const rawList = this.sheetRows || [];
1174
+ const hasDetailRows = rawList.some(r => r?.key);
1175
+ const filteredRaw = hasDetailRows ? rawList.filter(r => r?.key) : rawList;
1176
+ const rows = filteredRaw.map(r => {
1177
+ const slotCells = aSlots.map(s => {
1178
+ if (r.key && typeof r.key === 'object') {
1179
+ const id = s.id in r.key ? r.key[s.id] : Object.values(r.key)[0];
1180
+ return id === null || id === undefined ? '—' : this.names?.objects?.[id] || String(id);
1181
+ }
1182
+ return this.accountText(r.account);
1125
1183
  });
1184
+ const label = r.key ? slotCells.join(' / ') : this.accountText(r.account);
1185
+ return {
1186
+ account: r.account,
1187
+ key: r.key || null,
1188
+ detail: !!r.key,
1189
+ slotCells,
1190
+ label,
1191
+ indent: (Number(r.level) || 0) * 16,
1192
+ ...this.analysisCells(r)
1193
+ };
1194
+ });
1195
+ return rows.filter(r => {
1196
+ if (q && !r.label.toLowerCase().includes(q)) return false;
1197
+ for (let i = 0; i < aSlots.length; i++) {
1198
+ const slotQ = String(sq[aSlots[i].id] || '').trim().toLowerCase();
1199
+ if (slotQ && !String(r.slotCells[i] || '').toLowerCase().includes(slotQ)) return false;
1200
+ }
1201
+ return true;
1202
+ });
1126
1203
  },
1127
1204
  get analysisTotals() {
1128
- return this.analysisCells(this.sheetTotal);
1205
+ return this.analysisCells(this.sheetTotal);
1129
1206
  },
1130
1207
  featureLabel(feat) {
1131
- if (!feat)
1132
- return '';
1133
- if ((this.slots || []).length > 1 && feat.slotLabel)
1134
- return `${feat.slotLabel}: ${feat.label || feat.id}`;
1135
- return feat.label || feat.id;
1208
+ if (!feat) return '';
1209
+ if ((this.slots || []).length > 1 && feat.slotLabel) return `${feat.slotLabel}: ${feat.label || feat.id}`;
1210
+ return feat.label || feat.id;
1136
1211
  },
1137
1212
  featureValueOf(feat) {
1138
- if (!feat)
1139
- return '';
1140
- if (feat.isObject)
1141
- return String(this.filters?.[feat.slotId] || '');
1142
- return String(this.featureValues?.[feat.id] || '');
1213
+ if (!feat) return '';
1214
+ if (feat.isObject) return String(this.filters?.[feat.slotId] || '');
1215
+ return String(this.featureValues?.[feat.id] || '');
1143
1216
  },
1144
1217
  featureValueLabel(feat) {
1145
- const val = this.featureValueOf(feat);
1146
- if (!val)
1147
- return 'Все';
1148
- const opt = (feat?.options || []).find(o => o.value === val);
1149
- return opt?.label || val;
1218
+ const val = this.featureValueOf(feat);
1219
+ if (!val) return 'Все';
1220
+ const opt = (feat?.options || []).find(o => o.value === val);
1221
+ return opt?.label || val;
1150
1222
  },
1151
1223
  async setFeatureValue(feat, value) {
1152
- if (!feat)
1153
- return;
1154
- const val = String(value || '');
1155
- if (feat.isObject) {
1156
- this.filters = { ...(this.filters || {}), [feat.slotId]: val };
1157
- await this.onFilterChanged();
1158
- return;
1159
- }
1160
- this.featureValues = { ...(this.featureValues || {}), [feat.id]: val };
1161
- if (val && !(this.activeSlots || []).includes(feat.spec) && !(this.activeSlots || []).includes(feat.slotId)) {
1162
- this.activeSlots = [...(this.activeSlots || []), feat.spec];
1163
- }
1164
- await this.reload();
1224
+ if (!feat) return;
1225
+ const val = String(value || '');
1226
+ if (feat.isObject) {
1227
+ this.filters = {
1228
+ ...(this.filters || {}),
1229
+ [feat.slotId]: val
1230
+ };
1231
+ await this.onFilterChanged();
1232
+ return;
1233
+ }
1234
+ this.featureValues = {
1235
+ ...(this.featureValues || {}),
1236
+ [feat.id]: val
1237
+ };
1238
+ if (val && !(this.activeSlots || []).includes(feat.spec) && !(this.activeSlots || []).includes(feat.slotId)) {
1239
+ this.activeSlots = [...(this.activeSlots || []), feat.spec];
1240
+ }
1241
+ await this.reload();
1165
1242
  },
1166
1243
  async moveFeature(delta) {
1167
- const list = [...(this.analyticFeatures || [])];
1168
- const idx = list.findIndex(f => f.id === this.selectedFeatureId);
1169
- if (idx < 0)
1170
- return;
1171
- const target = idx + delta;
1172
- if (target < 0 || target >= list.length)
1173
- return;
1174
- const [moved] = list.splice(idx, 1);
1175
- list.splice(target, 0, moved);
1176
- this.analyticFeatures = list;
1177
- const order = list.map(f => f.spec);
1178
- this.activeSlots = (this.activeSlots || []).slice().sort((a, b) => {
1179
- const ia = order.indexOf(a), ib = order.indexOf(b);
1180
- return (ia < 0 ? 999 : ia) - (ib < 0 ? 999 : ib);
1181
- });
1182
- if (this.mode === 'analysis')
1183
- await this.reload();
1244
+ const list = [...(this.analyticFeatures || [])];
1245
+ const idx = list.findIndex(f => f.id === this.selectedFeatureId);
1246
+ if (idx < 0) return;
1247
+ const target = idx + delta;
1248
+ if (target < 0 || target >= list.length) return;
1249
+ const [moved] = list.splice(idx, 1);
1250
+ list.splice(target, 0, moved);
1251
+ this.analyticFeatures = list;
1252
+ const order = list.map(f => f.spec);
1253
+ this.activeSlots = (this.activeSlots || []).slice().sort((a, b) => {
1254
+ const ia = order.indexOf(a),
1255
+ ib = order.indexOf(b);
1256
+ return (ia < 0 ? 999 : ia) - (ib < 0 ? 999 : ib);
1257
+ });
1258
+ if (this.mode === 'analysis') await this.reload();
1184
1259
  },
1185
1260
  isSlotActive(slotId) {
1186
- return (this.activeSlots || []).includes(slotId);
1261
+ return (this.activeSlots || []).includes(slotId);
1187
1262
  },
1188
1263
  async toggleSlot(slotId, checked) {
1189
- const cur = new Set(this.activeSlots || []);
1190
- if (checked)
1191
- cur.add(slotId);
1192
- else
1193
- cur.delete(slotId);
1194
- const order = (this.analyticFeatures || []).map(f => f.spec);
1195
- this.activeSlots = [...cur].sort((a, b) => {
1196
- const ia = order.indexOf(a), ib = order.indexOf(b);
1197
- if (ia < 0 && ib < 0)
1198
- return 0;
1199
- return (ia < 0 ? 999 : ia) - (ib < 0 ? 999 : ib);
1200
- });
1201
- if (this.mode === 'analysis')
1202
- await this.reload();
1264
+ const cur = new Set(this.activeSlots || []);
1265
+ if (checked) cur.add(slotId);else cur.delete(slotId);
1266
+ const order = (this.analyticFeatures || []).map(f => f.spec);
1267
+ this.activeSlots = [...cur].sort((a, b) => {
1268
+ const ia = order.indexOf(a),
1269
+ ib = order.indexOf(b);
1270
+ if (ia < 0 && ib < 0) return 0;
1271
+ return (ia < 0 ? 999 : ia) - (ib < 0 ? 999 : ib);
1272
+ });
1273
+ if (this.mode === 'analysis') await this.reload();
1203
1274
  },
1204
1275
  async moveSlot(index, delta) {
1205
- const list = [...(this.slots || [])];
1206
- const target = index + delta;
1207
- if (index < 0 || index >= list.length || target < 0 || target >= list.length)
1208
- return;
1209
- const [moved] = list.splice(index, 1);
1210
- list.splice(target, 0, moved);
1211
- this.slots = list;
1212
- const order = list.map(s => s.id);
1213
- this.activeSlots = (this.activeSlots || []).slice().sort((a, b) => order.indexOf(a) - order.indexOf(b));
1214
- if (this.analyticFeatures?.length) {
1215
- this.analyticFeatures = [...this.analyticFeatures].sort((a, b) => order.indexOf(a.slotId) - order.indexOf(b.slotId));
1216
- }
1217
- if (this.mode === 'analysis')
1218
- await this.reload();
1276
+ const list = [...(this.slots || [])];
1277
+ const target = index + delta;
1278
+ if (index < 0 || index >= list.length || target < 0 || target >= list.length) return;
1279
+ const [moved] = list.splice(index, 1);
1280
+ list.splice(target, 0, moved);
1281
+ this.slots = list;
1282
+ const order = list.map(s => s.id);
1283
+ this.activeSlots = (this.activeSlots || []).slice().sort((a, b) => order.indexOf(a) - order.indexOf(b));
1284
+ if (this.analyticFeatures?.length) {
1285
+ this.analyticFeatures = [...this.analyticFeatures].sort((a, b) => order.indexOf(a.slotId) - order.indexOf(b.slotId));
1286
+ }
1287
+ if (this.mode === 'analysis') await this.reload();
1219
1288
  },
1220
1289
  async setUnit(val) {
1221
- this.unit = String(val || '');
1222
- await this.reload();
1290
+ this.unit = String(val || '');
1291
+ await this.reload();
1223
1292
  },
1224
1293
  async onFilterChanged() {
1225
- const sig = JSON.stringify(this.analytics());
1226
- if (this._lastFilterSig === sig)
1227
- return;
1228
- this._lastFilterSig = sig;
1229
- await this.reload();
1294
+ const sig = JSON.stringify(this.analytics());
1295
+ if (this._lastFilterSig === sig) return;
1296
+ this._lastFilterSig = sig;
1297
+ await this.reload();
1230
1298
  },
1231
1299
  async setSubFilter(slotId, value) {
1232
- this.subFilters = { ...(this.subFilters || {}), [slotId]: String(value || '') };
1233
- await this.reload();
1300
+ this.subFilters = {
1301
+ ...(this.subFilters || {}),
1302
+ [slotId]: String(value || '')
1303
+ };
1304
+ await this.reload();
1234
1305
  },
1235
1306
  setValueMode(vm) {
1236
- this.valueMode = vm === 'qty' ? 'qty' : 'amount';
1307
+ this.valueMode = vm === 'qty' ? 'qty' : 'amount';
1237
1308
  },
1238
1309
  async setMode(m) {
1239
- const next = ['card', 'analysis', 'turnovers'].includes(m) ? m : 'card';
1240
- if (this.mode === next)
1241
- return;
1242
- this.mode = next;
1243
- await this.reload();
1244
- this.async?.(() => this.render?.());
1310
+ const next = ['card', 'analysis', 'turnovers'].includes(m) ? m : 'card';
1311
+ if (this.mode === next) return;
1312
+ this.mode = next;
1313
+ await this.reload();
1314
+ this.async?.(() => this.render?.());
1245
1315
  },
1246
1316
  async setGroupBy(g) {
1247
- this.groupBy = g || 'quarter';
1248
- this.selectedGroupKey = '';
1249
- await this.reload();
1317
+ this.groupBy = g || 'quarter';
1318
+ this.selectedGroupKey = '';
1319
+ await this.reload();
1250
1320
  },
1251
1321
  _notifyConsultantContext() {
1252
- try {
1253
- const wf = this._findFormHost?.() || this.domHost;
1254
- if (!wf || typeof wf.buildConsultantContext !== 'function')
1255
- return;
1256
- const exp = window.top?.explorer || window.parent?.explorer;
1257
- const cons = exp?.$?.('#consultant') || exp?.$?.('item-consultant');
1258
- if (cons) {
1259
- const ctx = wf.buildConsultantContext();
1260
- cons.activeFormContext = ctx;
1261
- cons.activeFormSummary = ctx;
1262
- }
1263
- }
1264
- catch { /* ignore */ }
1322
+ try {
1323
+ const wf = this._findFormHost?.() || this.domHost;
1324
+ if (!wf || typeof wf.buildConsultantContext !== 'function') return;
1325
+ const exp = window.top?.explorer || window.parent?.explorer;
1326
+ const cons = exp?.$?.('#consultant') || exp?.$?.('item-consultant');
1327
+ if (cons) {
1328
+ const ctx = wf.buildConsultantContext();
1329
+ cons.activeFormContext = ctx;
1330
+ cons.activeFormSummary = ctx;
1331
+ }
1332
+ } catch {/* ignore */}
1265
1333
  },
1266
1334
  selectGroup(key) {
1267
- this.selectedGroupKey = this.selectedGroupKey === key ? '' : key;
1268
- this._notifyConsultantContext();
1335
+ this.selectedGroupKey = this.selectedGroupKey === key ? '' : key;
1336
+ this._notifyConsultantContext();
1269
1337
  },
1270
1338
  async openTurnoversFromAnalysis(row) {
1271
- const r = row || this.selectedAnalysisRow;
1272
- if (r?.key && typeof r.key === 'object') {
1273
- const next = { ...(this.filters || {}) };
1274
- for (const [k, v] of Object.entries(r.key)) {
1275
- if (v)
1276
- next[k] = v;
1277
- }
1278
- this.filters = next;
1279
- }
1280
- const host = this.domHost || this.parentElement;
1281
- if (host && typeof host.applyNav === 'function' && host.view?.id && host.view.id !== 'turnovers') {
1282
- await host.applyNav({
1283
- view: 'turnovers',
1284
- mode: 'turnovers',
1285
- from: this.from,
1286
- to: this.to,
1287
- packetsKey: this.packetsKey,
1288
- unit: this.unit,
1289
- filters: this.filters,
1290
- });
1291
- return;
1292
- }
1293
- this.mode = 'turnovers';
1294
- await this.reload();
1339
+ const r = row || this.selectedAnalysisRow;
1340
+ if (r?.key && typeof r.key === 'object') {
1341
+ const next = {
1342
+ ...(this.filters || {})
1343
+ };
1344
+ for (const [k, v] of Object.entries(r.key)) {
1345
+ if (v) next[k] = v;
1346
+ }
1347
+ this.filters = next;
1348
+ }
1349
+ const host = this.domHost || this.parentElement;
1350
+ if (host && typeof host.applyNav === 'function' && host.view?.id && host.view.id !== 'turnovers') {
1351
+ await host.applyNav({
1352
+ view: 'turnovers',
1353
+ mode: 'turnovers',
1354
+ from: this.from,
1355
+ to: this.to,
1356
+ packetsKey: this.packetsKey,
1357
+ unit: this.unit,
1358
+ filters: this.filters
1359
+ });
1360
+ return;
1361
+ }
1362
+ this.mode = 'turnovers';
1363
+ await this.reload();
1295
1364
  },
1296
1365
  /** Открыть сборную карточку проводки (Экран 4 ODANT) по номеру entry. */
1297
1366
  async openEntry(entryId) {
1298
- if (!entryId || !this.$item)
1299
- return null;
1300
- this.error = '';
1301
- try {
1302
- const card = await this.$item.fetch('db_entry', { entry: entryId });
1303
- if (card && typeof card === 'object') {
1304
- const t = card.operation?.title;
1305
- card.opTitle = (t && t !== card.operation?.id ? t : '') || card.operation?.label || card.operation?.classLabel || t || '';
1306
- card.debitLabel = card.debit?.label || card.debit?.account || '';
1307
- card.debitAmount = card.debit?.amount ?? card.amount ?? 0;
1308
- card.debitQty = card.debit?.qty ?? card.qty ?? 0;
1309
- card.debitAnalytics = card.debit?.analytics || [];
1310
- card.creditLabel = card.credit?.label || card.credit?.account || '';
1311
- card.creditAmount = card.credit?.amount ?? card.amount ?? 0;
1312
- card.creditQty = card.credit?.qty ?? card.qty ?? 0;
1313
- card.creditAnalytics = card.credit?.analytics || [];
1314
- }
1315
- this.entryCard = card;
1316
- return this.entryCard;
1317
- }
1318
- catch (e) {
1319
- this.error = String(e?.message || e);
1320
- return null;
1321
- }
1367
+ if (!entryId || !this.$item) return null;
1368
+ this.error = '';
1369
+ try {
1370
+ const card = await this.$item.fetch('db_entry', {
1371
+ entry: entryId
1372
+ });
1373
+ if (card && typeof card === 'object') {
1374
+ const t = card.operation?.title;
1375
+ card.opTitle = (t && t !== card.operation?.id ? t : '') || card.operation?.label || card.operation?.classLabel || t || '';
1376
+ card.debitLabel = card.debit?.label || card.debit?.account || '';
1377
+ card.debitAmount = card.debit?.amount ?? card.amount ?? 0;
1378
+ card.debitQty = card.debit?.qty ?? card.qty ?? 0;
1379
+ card.debitAnalytics = card.debit?.analytics || [];
1380
+ card.creditLabel = card.credit?.label || card.credit?.account || '';
1381
+ card.creditAmount = card.credit?.amount ?? card.amount ?? 0;
1382
+ card.creditQty = card.credit?.qty ?? card.qty ?? 0;
1383
+ card.creditAnalytics = card.credit?.analytics || [];
1384
+ }
1385
+ this.entryCard = card;
1386
+ return this.entryCard;
1387
+ } catch (e) {
1388
+ this.error = String(e?.message || e);
1389
+ return null;
1390
+ }
1322
1391
  },
1323
1392
  closeEntry() {
1324
- this.entryCard = null;
1393
+ this.entryCard = null;
1325
1394
  },
1326
1395
  openEntryOperation() {
1327
- if (!this.entryCard?.operation)
1328
- return;
1329
- return this.openOperation({
1330
- op_cid: this.entryCard.operation.path || this.entryCard.operation.cid,
1331
- op_id: this.entryCard.operation.id,
1332
- });
1396
+ if (!this.entryCard?.operation) return;
1397
+ return this.openOperation({
1398
+ op_cid: this.entryCard.operation.path || this.entryCard.operation.cid,
1399
+ op_id: this.entryCard.operation.id
1400
+ });
1333
1401
  },
1334
1402
  openEntrySideAccount(side) {
1335
- const s = side === 'credit' ? this.entryCard?.credit : this.entryCard?.debit;
1336
- if (!s?.path && !s?.account)
1337
- return;
1338
- return this.openCorr({ corr_cid: s.path || s.account });
1403
+ const s = side === 'credit' ? this.entryCard?.credit : this.entryCard?.debit;
1404
+ if (!s?.path && !s?.account) return;
1405
+ return this.openCorr({
1406
+ corr_cid: s.path || s.account
1407
+ });
1339
1408
  },
1340
1409
  _findFormHost() {
1341
- if (this.$form && ('focusedItem' in this.$form || typeof this.$form.syncFromView === 'function' || typeof this.$form.setFormPeriod === 'function'))
1342
- return this.$form;
1343
- for (let p = this.parentElement || this.domHost; p; p = p.parentElement || p.domHost) {
1344
- if (p.localName === 'work-form' || typeof p.syncFromView === 'function' || typeof p.setFormPeriod === 'function' || 'focusedItem' in p)
1345
- return p;
1346
- }
1347
- return null;
1410
+ if (this.$form && ('focusedItem' in this.$form || typeof this.$form.syncFromView === 'function' || typeof this.$form.setFormPeriod === 'function')) return this.$form;
1411
+ for (let p = this.parentElement || this.domHost; p; p = p.parentElement || p.domHost) {
1412
+ if (p.localName === 'work-form' || typeof p.syncFromView === 'function' || typeof p.setFormPeriod === 'function' || 'focusedItem' in p) return p;
1413
+ }
1414
+ return null;
1348
1415
  },
1349
1416
  async onPackets(e) {
1350
- const d = e?.detail?.value ?? e?.detail ?? {};
1351
- if (Array.isArray(d))
1352
- return;
1353
- if (this._initializingPackets)
1354
- return;
1355
- const nextKey = d.value || (d.selected?.name === '*' ? '*' : (d.selected?.mask || this.packetsKey || '*'));
1356
- if (d.selected?.name === '*') {
1357
- this.packetsKey = '*';
1358
- _writeSavedPeriod('*', '', '');
1359
- this._findFormHost()?.setFormPeriod?.({ packetsKey: '*', from: '', to: '' });
1360
- if (this._packetFiltered || this.from || this.to) {
1361
- this._packetFiltered = false;
1362
- this.from = '';
1363
- this.to = '';
1364
- await this.reload();
1365
- }
1366
- return;
1367
- }
1368
- if (d.period?.start && d.period?.end) {
1369
- const changed = this.from !== d.period.start || this.to !== d.period.end || !this._packetFiltered;
1370
- this._packetFiltered = true;
1371
- this.from = d.period.start;
1372
- this.to = d.period.end;
1373
- this.packetsKey = _derivePacketsKey(this.from, this.to, nextKey);
1374
- _writeSavedPeriod(this.packetsKey, this.from, this.to);
1375
- this._findFormHost()?.setFormPeriod?.({ packetsKey: this.packetsKey, from: this.from, to: this.to });
1376
- if (changed)
1377
- await this.reload();
1378
- }
1417
+ const d = e?.detail?.value ?? e?.detail ?? {};
1418
+ if (Array.isArray(d)) return;
1419
+ if (this._initializingPackets) return;
1420
+ const nextKey = d.value || (d.selected?.name === '*' ? '*' : d.selected?.mask || this.packetsKey || '*');
1421
+ if (d.selected?.name === '*') {
1422
+ this.packetsKey = '*';
1423
+ _writeSavedPeriod('*', '', '');
1424
+ this._findFormHost()?.setFormPeriod?.({
1425
+ packetsKey: '*',
1426
+ from: '',
1427
+ to: ''
1428
+ });
1429
+ if (this._packetFiltered || this.from || this.to) {
1430
+ this._packetFiltered = false;
1431
+ this.from = '';
1432
+ this.to = '';
1433
+ await this.reload();
1434
+ }
1435
+ return;
1436
+ }
1437
+ if (d.period?.start && d.period?.end) {
1438
+ const changed = this.from !== d.period.start || this.to !== d.period.end || !this._packetFiltered;
1439
+ this._packetFiltered = true;
1440
+ this.from = d.period.start;
1441
+ this.to = d.period.end;
1442
+ this.packetsKey = _derivePacketsKey(this.from, this.to, nextKey);
1443
+ _writeSavedPeriod(this.packetsKey, this.from, this.to);
1444
+ this._findFormHost()?.setFormPeriod?.({
1445
+ packetsKey: this.packetsKey,
1446
+ from: this.from,
1447
+ to: this.to
1448
+ });
1449
+ if (changed) await this.reload();
1450
+ }
1379
1451
  },
1380
1452
  _restorePeriodState(nav = null) {
1381
- const hasNavPeriod = nav && (nav.from !== undefined || nav.to !== undefined || nav.packetsKey);
1382
- if (!hasNavPeriod && (this.from || this.to))
1383
- return;
1384
- const formPeriod = this._findFormHost()?.formPeriod || null;
1385
- const saved = _readSavedPeriod();
1386
- const localSavedKey = typeof this.loadFromLocalStorage === 'function' ? this.loadFromLocalStorage('packetsKey') : undefined;
1387
- if (!hasNavPeriod && !formPeriod && !saved && typeof localSavedKey === 'string' && localSavedKey && (typeof this.packetsKey !== 'string' || this.packetsKey === '*'))
1388
- this.packetsKey = localSavedKey;
1389
- const pk = typeof this.packetsKey === 'string' ? this.packetsKey : '';
1390
- const src = hasNavPeriod ? nav : (formPeriod || saved || (pk && pk !== '*' ? { packetsKey: pk } : null));
1391
- if (!src)
1392
- return;
1393
- this._initializingPackets = true;
1394
- try {
1395
- const rawKey = typeof src.packetsKey === 'string' && src.packetsKey ? src.packetsKey : (pk || '*');
1396
- let from = String(src.from || '');
1397
- let to = String(src.to || '');
1398
- if (!from && !to && rawKey !== '*') {
1399
- const derived = _boundsFromPacketsKey(rawKey, 'month');
1400
- if (derived.from && derived.to) {
1401
- from = derived.from;
1402
- to = derived.to;
1403
- }
1404
- }
1405
- const key = _derivePacketsKey(from, to, rawKey);
1406
- this.from = from;
1407
- this.to = to;
1408
- this._packetFiltered = !!(from || to);
1409
- this.packetsKey = key;
1410
- this._findFormHost()?.setFormPeriod?.({ packetsKey: this.packetsKey, from: this.from, to: this.to });
1411
- }
1412
- finally {
1413
- this._initializingPackets = false;
1414
- }
1453
+ const hasNavPeriod = nav && (nav.from !== undefined || nav.to !== undefined || nav.packetsKey);
1454
+ if (!hasNavPeriod && (this.from || this.to)) return;
1455
+ const formPeriod = this._findFormHost()?.formPeriod || null;
1456
+ const saved = _readSavedPeriod();
1457
+ const localSavedKey = typeof this.loadFromLocalStorage === 'function' ? this.loadFromLocalStorage('packetsKey') : undefined;
1458
+ if (!hasNavPeriod && !formPeriod && !saved && typeof localSavedKey === 'string' && localSavedKey && (typeof this.packetsKey !== 'string' || this.packetsKey === '*')) this.packetsKey = localSavedKey;
1459
+ const pk = typeof this.packetsKey === 'string' ? this.packetsKey : '';
1460
+ const src = hasNavPeriod ? nav : formPeriod || saved || (pk && pk !== '*' ? {
1461
+ packetsKey: pk
1462
+ } : null);
1463
+ if (!src) return;
1464
+ this._initializingPackets = true;
1465
+ try {
1466
+ const rawKey = typeof src.packetsKey === 'string' && src.packetsKey ? src.packetsKey : pk || '*';
1467
+ let from = String(src.from || '');
1468
+ let to = String(src.to || '');
1469
+ if (!from && !to && rawKey !== '*') {
1470
+ const derived = _boundsFromPacketsKey(rawKey, 'month');
1471
+ if (derived.from && derived.to) {
1472
+ from = derived.from;
1473
+ to = derived.to;
1474
+ }
1475
+ }
1476
+ const key = _derivePacketsKey(from, to, rawKey);
1477
+ this.from = from;
1478
+ this.to = to;
1479
+ this._packetFiltered = !!(from || to);
1480
+ this.packetsKey = key;
1481
+ this._findFormHost()?.setFormPeriod?.({
1482
+ packetsKey: this.packetsKey,
1483
+ from: this.from,
1484
+ to: this.to
1485
+ });
1486
+ } finally {
1487
+ this._initializingPackets = false;
1488
+ }
1415
1489
  },
1416
1490
  async syncFormPeriod(fp) {
1417
- if (!fp || typeof fp !== 'object')
1418
- return;
1419
- const nextFrom = String(fp.from || '');
1420
- const nextTo = String(fp.to || '');
1421
- const nextKey = String(fp.packetsKey || '*');
1422
- if (this.from === nextFrom && this.to === nextTo && this.packetsKey === nextKey)
1423
- return;
1424
- this._restorePeriodState(fp);
1425
- await this.reload();
1491
+ if (!fp || typeof fp !== 'object') return;
1492
+ const nextFrom = String(fp.from || '');
1493
+ const nextTo = String(fp.to || '');
1494
+ const nextKey = String(fp.packetsKey || '*');
1495
+ if (this.from === nextFrom && this.to === nextTo && this.packetsKey === nextKey) return;
1496
+ this._restorePeriodState(fp);
1497
+ await this.reload();
1426
1498
  },
1427
1499
  _applyNavFields(nav) {
1428
- if (!nav || typeof nav !== 'object')
1429
- return;
1430
- if (nav.mode && ['card', 'analysis', 'turnovers'].includes(nav.mode))
1431
- this.mode = nav.mode;
1432
- else if (nav.view === 'turnovers' || nav.view === 'analysis')
1433
- this.mode = nav.view;
1434
- else if (nav.view === 'postings')
1435
- this.mode = 'card';
1436
- if (nav.groupBy)
1437
- this.groupBy = String(nav.groupBy);
1438
- this._restorePeriodState(nav);
1439
- if (nav.unit !== undefined)
1440
- this.unit = String(nav.unit || '');
1441
- if (nav.filters && typeof nav.filters === 'object')
1442
- this.filters = { ...nav.filters };
1443
- _writeSavedPeriod(this.packetsKey, this.from, this.to);
1444
- this._findFormHost()?.setFormPeriod?.({ packetsKey: this.packetsKey, from: this.from, to: this.to });
1500
+ if (!nav || typeof nav !== 'object') return;
1501
+ if (nav.mode && ['card', 'analysis', 'turnovers'].includes(nav.mode)) this.mode = nav.mode;else if (nav.view === 'turnovers' || nav.view === 'analysis') this.mode = nav.view;else if (nav.view === 'postings') this.mode = 'card';
1502
+ if (nav.groupBy) this.groupBy = String(nav.groupBy);
1503
+ this._restorePeriodState(nav);
1504
+ if (nav.unit !== undefined) this.unit = String(nav.unit || '');
1505
+ if (nav.filters && typeof nav.filters === 'object') this.filters = {
1506
+ ...nav.filters
1507
+ };
1508
+ _writeSavedPeriod(this.packetsKey, this.from, this.to);
1509
+ this._findFormHost()?.setFormPeriod?.({
1510
+ packetsKey: this.packetsKey,
1511
+ from: this.from,
1512
+ to: this.to
1513
+ });
1445
1514
  },
1446
1515
  async attached() {
1447
- if (this._attachedDone && !this._initialNav)
1448
- return;
1449
- const initNav = this._initialNav;
1450
- this._initialNav = null;
1451
- if (initNav)
1452
- this._applyNavFields(initNav);
1453
- else
1454
- this._restorePeriodState();
1455
- await Promise.all([this.loadSlots(), this.loadScope()]);
1456
- await this.reload();
1457
- if (initNav?.entry)
1458
- await this.openEntry(initNav.entry);
1459
- this._attachedDone = true;
1516
+ if (this._attachedDone && !this._initialNav) return;
1517
+ const initNav = this._initialNav;
1518
+ this._initialNav = null;
1519
+ if (initNav) this._applyNavFields(initNav);else this._restorePeriodState();
1520
+ await Promise.all([this.loadSlots(), this.loadScope()]);
1521
+ await this.reload();
1522
+ if (initNav?.entry) await this.openEntry(initNav.entry);
1523
+ this._attachedDone = true;
1460
1524
  },
1461
1525
  async applyNav(nav) {
1462
- if (!nav || typeof nav !== 'object')
1463
- return;
1464
- this._applyNavFields(nav);
1465
- await this.reload();
1466
- if (nav.entry)
1467
- await this.openEntry(nav.entry);
1526
+ if (!nav || typeof nav !== 'object') return;
1527
+ this._applyNavFields(nav);
1528
+ await this.reload();
1529
+ if (nav.entry) await this.openEntry(nav.entry);
1468
1530
  },
1469
1531
  async openOperation(row) {
1470
- const path = this.names?.paths?.[row?.op_cid] || row?.op_cid;
1471
- if (!path)
1472
- return;
1473
- try {
1474
- const t = await WORK.get_item(path);
1475
- if (t && window.execute)
1476
- window.execute(t, { view: 'objects', id: row.op_id });
1477
- }
1478
- catch (e) {
1479
- this.error = String(e?.message || e);
1480
- }
1532
+ const path = this.names?.paths?.[row?.op_cid] || row?.op_cid;
1533
+ if (!path) return;
1534
+ try {
1535
+ const t = await WORK.get_item(path);
1536
+ if (t && window.execute) window.execute(t, {
1537
+ view: 'objects',
1538
+ id: row.op_id
1539
+ });
1540
+ } catch (e) {
1541
+ this.error = String(e?.message || e);
1542
+ }
1481
1543
  },
1482
1544
  async openCorr(row) {
1483
- const path = this.names?.paths?.[row?.corr_cid] || row?.corr_cid;
1484
- if (!path)
1485
- return;
1486
- try {
1487
- const t = await WORK.get_item(path);
1488
- if (t && window.execute)
1489
- window.execute(t, { view: 'postings', from: this.from, to: this.to, unit: this.unit });
1490
- }
1491
- catch (e) {
1492
- this.error = String(e?.message || e);
1493
- }
1545
+ const path = this.names?.paths?.[row?.corr_cid] || row?.corr_cid;
1546
+ if (!path) return;
1547
+ try {
1548
+ const t = await WORK.get_item(path);
1549
+ if (t && window.execute) window.execute(t, {
1550
+ view: 'postings',
1551
+ from: this.from,
1552
+ to: this.to,
1553
+ unit: this.unit
1554
+ });
1555
+ } catch (e) {
1556
+ this.error = String(e?.message || e);
1557
+ }
1494
1558
  },
1495
1559
  /** Видимые подразделения для фильтра; без ответа — без фильтра. */
1496
1560
  async loadScope() {
1497
- try {
1498
- const s = await this.$item?.fetch('db_scope');
1499
- this.units = Array.isArray(s?.units) && !s.all ? s.units : [];
1500
- }
1501
- catch {
1502
- this.units = [];
1503
- }
1561
+ try {
1562
+ const s = await this.$item?.fetch('db_scope');
1563
+ this.units = Array.isArray(s?.units) && !s.all ? s.units : [];
1564
+ } catch {
1565
+ this.units = [];
1566
+ }
1504
1567
  },
1505
1568
  /** Слоты аналитик счёта из схемы ядра (с учётом наследования) и поля прилинкованных справочников. */
1506
1569
  loadSlots() {
1507
- const p = (async () => {
1508
- try {
1509
- const res = await this.$item?.fetch('db_schema');
1510
- const s = res?.schema;
1511
- const fields = Array.isArray(s?.fields) ? s.fields : [];
1512
- this.slots = fields.filter(f => f?.analytic && f.type === 'link')
1513
- .map(f => ({ id: f.id, label: f.label || f.id, type: 'Link', catalog: f.targetPath || f.target, placeholder: f.label || f.id }));
1514
- this.activeSlots = this.slots.map(f => f.id);
1515
- const serverSlots = Array.isArray(res?.slots) ? res.slots : [];
1516
- const features = [];
1517
- for (const slot of this.slots) {
1518
- const srv = serverSlots.find(x => x.id === slot.id);
1519
- if (Array.isArray(srv?.fields) && srv.fields.length) {
1520
- features.push(...srv.fields);
1521
- }
1522
- else {
1523
- features.push({
1524
- id: slot.id,
1525
- spec: slot.id,
1526
- slotId: slot.id,
1527
- fieldId: 'name',
1528
- label: 'Наименование',
1529
- slotLabel: slot.label,
1530
- isObject: true,
1531
- type: 'link',
1532
- catalog: slot.catalog,
1533
- options: [],
1534
- });
1535
- }
1536
- }
1537
- this.analyticFeatures = features;
1538
- this.selectedFeatureId = features[0]?.id || '';
1539
- }
1540
- catch (e) {
1541
- this.slots = [];
1542
- this.activeSlots = [];
1543
- this.analyticFeatures = [];
1544
- this.selectedFeatureId = '';
1545
- this.error = String(e?.message || e);
1546
- }
1547
- finally {
1548
- if (this._slotsPromise === p)
1549
- this._slotsPromise = null;
1570
+ const p = (async () => {
1571
+ try {
1572
+ const res = await this.$item?.fetch('db_schema');
1573
+ const s = res?.schema;
1574
+ const fields = Array.isArray(s?.fields) ? s.fields : [];
1575
+ this.slots = fields.filter(f => f?.analytic && f.type === 'link').map(f => ({
1576
+ id: f.id,
1577
+ label: f.label || f.id,
1578
+ type: 'Link',
1579
+ catalog: f.targetPath || f.target,
1580
+ placeholder: f.label || f.id
1581
+ }));
1582
+ this.activeSlots = this.slots.map(f => f.id);
1583
+ const serverSlots = Array.isArray(res?.slots) ? res.slots : [];
1584
+ const features = [];
1585
+ for (const slot of this.slots) {
1586
+ const srv = serverSlots.find(x => x.id === slot.id);
1587
+ if (Array.isArray(srv?.fields) && srv.fields.length) {
1588
+ features.push(...srv.fields);
1589
+ } else {
1590
+ features.push({
1591
+ id: slot.id,
1592
+ spec: slot.id,
1593
+ slotId: slot.id,
1594
+ fieldId: 'name',
1595
+ label: 'Наименование',
1596
+ slotLabel: slot.label,
1597
+ isObject: true,
1598
+ type: 'link',
1599
+ catalog: slot.catalog,
1600
+ options: []
1601
+ });
1550
1602
  }
1551
- })();
1552
- this._slotsPromise = p;
1553
- return p;
1603
+ }
1604
+ this.analyticFeatures = features;
1605
+ this.selectedFeatureId = features[0]?.id || '';
1606
+ } catch (e) {
1607
+ this.slots = [];
1608
+ this.activeSlots = [];
1609
+ this.analyticFeatures = [];
1610
+ this.selectedFeatureId = '';
1611
+ this.error = String(e?.message || e);
1612
+ } finally {
1613
+ if (this._slotsPromise === p) this._slotsPromise = null;
1614
+ }
1615
+ })();
1616
+ this._slotsPromise = p;
1617
+ return p;
1554
1618
  },
1555
1619
  /** Заданные фильтры аналитик. */
1556
1620
  analytics() {
1557
- const out = {};
1558
- for (const [k, v] of Object.entries(this.filters || {})) {
1559
- if (v)
1560
- out[k] = v;
1561
- }
1562
- return out;
1621
+ const out = {};
1622
+ for (const [k, v] of Object.entries(this.filters || {})) {
1623
+ if (v) out[k] = v;
1624
+ }
1625
+ return out;
1563
1626
  },
1564
1627
  /** Заданные фильтры субаналитик. */
1565
1628
  subanalytics() {
1566
- const out = {};
1567
- for (const [slotId, raw] of Object.entries(this.subFilters || {})) {
1568
- const parsed = parseSubFilterInput(raw);
1569
- if (parsed)
1570
- out[slotId] = { ...(out[slotId] || {}), ...parsed };
1571
- }
1572
- for (const feat of this.analyticFeatures || []) {
1573
- if (feat.isObject)
1574
- continue;
1575
- const val = this.featureValues?.[feat.id];
1576
- if (val !== undefined && val !== null && val !== '') {
1577
- if (!out[feat.slotId])
1578
- out[feat.slotId] = {};
1579
- out[feat.slotId][feat.fieldId] = feat.type === 'boolean' ? (val === '1' || val === 'true' ? 1 : 0) : val;
1580
- }
1581
- }
1582
- return out;
1629
+ const out = {};
1630
+ for (const [slotId, raw] of Object.entries(this.subFilters || {})) {
1631
+ const parsed = parseSubFilterInput(raw);
1632
+ if (parsed) out[slotId] = {
1633
+ ...(out[slotId] || {}),
1634
+ ...parsed
1635
+ };
1636
+ }
1637
+ for (const feat of this.analyticFeatures || []) {
1638
+ if (feat.isObject) continue;
1639
+ const val = this.featureValues?.[feat.id];
1640
+ if (val !== undefined && val !== null && val !== '') {
1641
+ if (!out[feat.slotId]) out[feat.slotId] = {};
1642
+ out[feat.slotId][feat.fieldId] = feat.type === 'boolean' ? val === '1' || val === 'true' ? 1 : 0 : val;
1643
+ }
1644
+ }
1645
+ return out;
1583
1646
  },
1584
1647
  params() {
1585
- const p = { limit: 500 };
1586
- for (const key of ['from', 'to', 'unit']) {
1587
- const s = String(this[key] ?? '').trim();
1588
- if (s)
1589
- p[key] = s;
1590
- }
1591
- const a = this.analytics();
1592
- if (Object.keys(a).length)
1593
- p.analytics = JSON.stringify(a);
1594
- const sub = this.subanalytics();
1595
- if (Object.keys(sub).length)
1596
- p.subanalytics = JSON.stringify(sub);
1597
- return p;
1648
+ const p = {
1649
+ limit: 500
1650
+ };
1651
+ for (const key of ['from', 'to', 'unit']) {
1652
+ const s = String(this[key] ?? '').trim();
1653
+ if (s) p[key] = s;
1654
+ }
1655
+ const a = this.analytics();
1656
+ if (Object.keys(a).length) p.analytics = JSON.stringify(a);
1657
+ const sub = this.subanalytics();
1658
+ if (Object.keys(sub).length) p.subanalytics = JSON.stringify(sub);
1659
+ return p;
1598
1660
  },
1599
1661
  _syncPacketRange(res) {
1600
- if (!res)
1601
- return false;
1602
- if (!('range' in res)) {
1603
- if (!this.packetsStart) {
1604
- this.packetsStart = _yearStart();
1605
- this.packetsEnd = _yearEnd();
1606
- }
1607
- return false;
1608
- }
1609
- const r = res.range;
1610
- if (!r || !r.start || !r.end) {
1611
- this.packetsStart = '';
1612
- this.packetsEnd = '';
1613
- this.packetDays = null;
1614
- return false;
1615
- }
1616
- this.packetsStart = r.start;
1617
- this.packetsEnd = r.end;
1618
- this.packetDays = Array.isArray(r.days) && r.days.length ? r.days : null;
1619
- const keyStr = typeof this.packetsKey === 'string' ? this.packetsKey : '';
1620
- const isNowKey = keyStr === 'now' || keyStr.startsWith('now:');
1621
- if (this._packetFiltered && !isNowKey && this.to && this.to < r.start) {
1622
- this._initializingPackets = true;
1623
- try {
1624
- this._packetFiltered = false;
1625
- this.from = '';
1626
- this.to = '';
1627
- this.packetsKey = '*';
1628
- _writeSavedPeriod('*', '', '');
1629
- }
1630
- finally {
1631
- this._initializingPackets = false;
1632
- }
1633
- return true;
1662
+ if (!res) return false;
1663
+ if (!('range' in res)) {
1664
+ if (!this.packetsStart) {
1665
+ this.packetsStart = _yearStart();
1666
+ this.packetsEnd = _yearEnd();
1634
1667
  }
1635
1668
  return false;
1636
- },
1637
- async reload() {
1638
- this.error = '';
1639
- if (!this.$item) {
1640
- this.items = [];
1641
- this.groups = [];
1642
- this.sheetRows = [];
1643
- this.sheetTotal = null;
1644
- this.count = 0;
1645
- this.opening = this.turnover = this.closing = { debit: 0, credit: 0 };
1646
- return;
1647
- }
1648
- this._lastFilterSig = JSON.stringify(this.analytics());
1669
+ }
1670
+ const r = res.range;
1671
+ if (!r || !r.start || !r.end) {
1672
+ this.packetsStart = '';
1673
+ this.packetsEnd = '';
1674
+ this.packetDays = null;
1675
+ return false;
1676
+ }
1677
+ this.packetsStart = r.start;
1678
+ this.packetsEnd = r.end;
1679
+ this.packetDays = Array.isArray(r.days) && r.days.length ? r.days : null;
1680
+ const keyStr = typeof this.packetsKey === 'string' ? this.packetsKey : '';
1681
+ const isNowKey = keyStr === 'now' || keyStr.startsWith('now:');
1682
+ if (this._packetFiltered && !isNowKey && this.to && this.to < r.start) {
1683
+ this._initializingPackets = true;
1649
1684
  try {
1650
- if (this._slotsPromise)
1651
- await this._slotsPromise;
1652
- if (this.mode === 'analysis') {
1653
- const p = this.params();
1654
- delete p.limit;
1655
- const by = (this.activeSlots?.length ? this.activeSlots : (this.slots || []).map(s => s.id)).filter(Boolean);
1656
- if (by.length)
1657
- p.by = JSON.stringify(by);
1658
- const res = await this.$item.fetch('db_sheet', p);
1659
- if (this._syncPacketRange(res))
1660
- return await this.reload();
1661
- this.names = { objects: {}, classes: {}, paths: {}, ...(res?.names || {}) };
1662
- this.sheetRows = Array.isArray(res?.rows) ? res.rows : [];
1663
- this.sheetTotal = res?.total || null;
1664
- this.selectedAnalysisRow = this.analysisRows.find(r => r.detail) || this.analysisRows[0] || null;
1665
- return;
1666
- }
1667
- if (this.mode === 'turnovers') {
1668
- const p = { ...this.params(), groupBy: this.groupBy || 'quarter' };
1669
- const res = await this.$item.fetch('db_turnovers', p);
1670
- if (this._syncPacketRange(res))
1671
- return await this.reload();
1672
- this.names = { objects: {}, classes: {}, paths: {}, ...(res?.names || {}) };
1673
- this.groups = Array.isArray(res?.groups) ? res.groups : [];
1674
- this.items = Array.isArray(res?.items) ? res.items : [];
1675
- this.count = Number(res?.total) || this.items.length;
1676
- this.opening = res?.opening || { debit: 0, credit: 0 };
1677
- this.closing = res?.closing || { debit: 0, credit: 0 };
1678
- this.turnover = { debit: res?.closing?.debit ?? 0, credit: res?.closing?.credit ?? 0 };
1679
- if (!this.selectedGroupKey && this.groups.length)
1680
- this.selectedGroupKey = this.groups[0].key;
1681
- return;
1682
- }
1683
- const res = await this.$item.fetch('db_card', this.params());
1684
- if (this._syncPacketRange(res))
1685
- return await this.reload();
1686
- this.names = { objects: {}, classes: {}, paths: {}, ...(res?.names || {}) };
1687
- this.items = Array.isArray(res?.items) ? res.items : [];
1688
- this.count = Number(res?.total) || this.items.length;
1689
- this.opening = res?.opening || { debit: 0, credit: 0 };
1690
- this.turnover = res?.turnover || { debit: 0, credit: 0 };
1691
- this.closing = res?.closing || { debit: 0, credit: 0 };
1692
- }
1693
- catch (e) {
1694
- this.error = String(e?.message || e);
1695
- }
1696
- finally {
1697
- this._notifyConsultantContext();
1698
- }
1685
+ this._packetFiltered = false;
1686
+ this.from = '';
1687
+ this.to = '';
1688
+ this.packetsKey = '*';
1689
+ _writeSavedPeriod('*', '', '');
1690
+ } finally {
1691
+ this._initializingPackets = false;
1692
+ }
1693
+ return true;
1694
+ }
1695
+ return false;
1699
1696
  },
1697
+ async reload() {
1698
+ this.error = '';
1699
+ if (!this.$item) {
1700
+ this.items = [];
1701
+ this.groups = [];
1702
+ this.sheetRows = [];
1703
+ this.sheetTotal = null;
1704
+ this.count = 0;
1705
+ this.opening = this.turnover = this.closing = {
1706
+ debit: 0,
1707
+ credit: 0
1708
+ };
1709
+ return;
1710
+ }
1711
+ this._lastFilterSig = JSON.stringify(this.analytics());
1712
+ try {
1713
+ if (this._slotsPromise) await this._slotsPromise;
1714
+ if (this.mode === 'analysis') {
1715
+ const p = this.params();
1716
+ delete p.limit;
1717
+ const by = (this.activeSlots?.length ? this.activeSlots : (this.slots || []).map(s => s.id)).filter(Boolean);
1718
+ if (by.length) p.by = JSON.stringify(by);
1719
+ const res = await this.$item.fetch('db_sheet', p);
1720
+ if (this._syncPacketRange(res)) return await this.reload();
1721
+ this.names = {
1722
+ objects: {},
1723
+ classes: {},
1724
+ paths: {},
1725
+ ...(res?.names || {})
1726
+ };
1727
+ this.sheetRows = Array.isArray(res?.rows) ? res.rows : [];
1728
+ this.sheetTotal = res?.total || null;
1729
+ this.selectedAnalysisRow = this.analysisRows.find(r => r.detail) || this.analysisRows[0] || null;
1730
+ return;
1731
+ }
1732
+ if (this.mode === 'turnovers') {
1733
+ const p = {
1734
+ ...this.params(),
1735
+ groupBy: this.groupBy || 'quarter'
1736
+ };
1737
+ const res = await this.$item.fetch('db_turnovers', p);
1738
+ if (this._syncPacketRange(res)) return await this.reload();
1739
+ this.names = {
1740
+ objects: {},
1741
+ classes: {},
1742
+ paths: {},
1743
+ ...(res?.names || {})
1744
+ };
1745
+ this.groups = Array.isArray(res?.groups) ? res.groups : [];
1746
+ this.items = Array.isArray(res?.items) ? res.items : [];
1747
+ this.count = Number(res?.total) || this.items.length;
1748
+ this.opening = res?.opening || {
1749
+ debit: 0,
1750
+ credit: 0
1751
+ };
1752
+ this.closing = res?.closing || {
1753
+ debit: 0,
1754
+ credit: 0
1755
+ };
1756
+ this.turnover = {
1757
+ debit: res?.closing?.debit ?? 0,
1758
+ credit: res?.closing?.credit ?? 0
1759
+ };
1760
+ if (!this.selectedGroupKey && this.groups.length) this.selectedGroupKey = this.groups[0].key;
1761
+ return;
1762
+ }
1763
+ const res = await this.$item.fetch('db_card', this.params());
1764
+ if (this._syncPacketRange(res)) return await this.reload();
1765
+ this.names = {
1766
+ objects: {},
1767
+ classes: {},
1768
+ paths: {},
1769
+ ...(res?.names || {})
1770
+ };
1771
+ this.items = Array.isArray(res?.items) ? res.items : [];
1772
+ this.count = Number(res?.total) || this.items.length;
1773
+ this.opening = res?.opening || {
1774
+ debit: 0,
1775
+ credit: 0
1776
+ };
1777
+ this.turnover = res?.turnover || {
1778
+ debit: 0,
1779
+ credit: 0
1780
+ };
1781
+ this.closing = res?.closing || {
1782
+ debit: 0,
1783
+ credit: 0
1784
+ };
1785
+ } catch (e) {
1786
+ this.error = String(e?.message || e);
1787
+ } finally {
1788
+ this._notifyConsultantContext();
1789
+ }
1790
+ }
1791
+ }
1700
1792
  };