@things-factory/compliance 10.1.255 → 10.1.257

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 (86) hide show
  1. package/dist-client/components/compliance-case-form.d.ts +11 -6
  2. package/dist-client/components/compliance-case-form.js +67 -88
  3. package/dist-client/components/compliance-case-form.js.map +1 -1
  4. package/dist-client/components/compliance-case-sheet.d.ts +14 -12
  5. package/dist-client/components/compliance-case-sheet.js +92 -133
  6. package/dist-client/components/compliance-case-sheet.js.map +1 -1
  7. package/dist-client/components/compliance-my-inventions.d.ts +3 -4
  8. package/dist-client/components/compliance-my-inventions.js +10 -30
  9. package/dist-client/components/compliance-my-inventions.js.map +1 -1
  10. package/dist-client/components/compliance-my-privacy-requests.d.ts +6 -6
  11. package/dist-client/components/compliance-my-privacy-requests.js +30 -66
  12. package/dist-client/components/compliance-my-privacy-requests.js.map +1 -1
  13. package/dist-client/components/compliance-my-reports.d.ts +3 -4
  14. package/dist-client/components/compliance-my-reports.js +19 -40
  15. package/dist-client/components/compliance-my-reports.js.map +1 -1
  16. package/dist-client/components/invention-report-form.d.ts +5 -4
  17. package/dist-client/components/invention-report-form.js +24 -45
  18. package/dist-client/components/invention-report-form.js.map +1 -1
  19. package/dist-client/components/my-trainings.d.ts +3 -5
  20. package/dist-client/components/my-trainings.js +20 -49
  21. package/dist-client/components/my-trainings.js.map +1 -1
  22. package/dist-client/components/seal-use-form.d.ts +9 -6
  23. package/dist-client/components/seal-use-form.js +60 -81
  24. package/dist-client/components/seal-use-form.js.map +1 -1
  25. package/dist-client/components/training-attendance-form.d.ts +6 -4
  26. package/dist-client/components/training-attendance-form.js +30 -50
  27. package/dist-client/components/training-attendance-form.js.map +1 -1
  28. package/dist-client/pages/regulation-detail.d.ts +17 -5
  29. package/dist-client/pages/regulation-detail.js +202 -133
  30. package/dist-client/pages/regulation-detail.js.map +1 -1
  31. package/dist-client/pages/regulations.d.ts +7 -5
  32. package/dist-client/pages/regulations.js +79 -68
  33. package/dist-client/pages/regulations.js.map +1 -1
  34. package/dist-client/regulation/regulation-fragments.js +5 -0
  35. package/dist-client/regulation/regulation-fragments.js.map +1 -1
  36. package/dist-client/regulation/regulation-guide.js +2 -1
  37. package/dist-client/regulation/regulation-guide.js.map +1 -1
  38. package/dist-client/tsconfig.tsbuildinfo +1 -1
  39. package/dist-client/words.js +2 -2
  40. package/dist-client/words.js.map +1 -1
  41. package/dist-server/index.d.ts +1 -0
  42. package/dist-server/index.js +1 -0
  43. package/dist-server/index.js.map +1 -1
  44. package/dist-server/service/compliance-case/compliance-case-query.js +1 -1
  45. package/dist-server/service/compliance-case/compliance-case-query.js.map +1 -1
  46. package/dist-server/service/compliance-case/compliance-case-rules.d.ts +1 -3
  47. package/dist-server/service/compliance-case/compliance-case-rules.js +2 -4
  48. package/dist-server/service/compliance-case/compliance-case-rules.js.map +1 -1
  49. package/dist-server/service/compliance-case/compliance-case-service.d.ts +3 -3
  50. package/dist-server/service/compliance-case/compliance-case-service.js +4 -6
  51. package/dist-server/service/compliance-case/compliance-case-service.js.map +1 -1
  52. package/dist-server/service/compliance-case/compliance-case-type.js +1 -1
  53. package/dist-server/service/compliance-case/compliance-case-type.js.map +1 -1
  54. package/dist-server/service/compliance-case/compliance-case.js +1 -1
  55. package/dist-server/service/compliance-case/compliance-case.js.map +1 -1
  56. package/dist-server/service/index.d.ts +1 -1
  57. package/dist-server/service/index.js +2 -1
  58. package/dist-server/service/index.js.map +1 -1
  59. package/dist-server/service/regulation/regulation-mutation.d.ts +1 -0
  60. package/dist-server/service/regulation/regulation-mutation.js +14 -0
  61. package/dist-server/service/regulation/regulation-mutation.js.map +1 -1
  62. package/dist-server/service/regulation/regulation-read.js +11 -2
  63. package/dist-server/service/regulation/regulation-read.js.map +1 -1
  64. package/dist-server/service/regulation/regulation-rules.d.ts +25 -6
  65. package/dist-server/service/regulation/regulation-rules.js +85 -29
  66. package/dist-server/service/regulation/regulation-rules.js.map +1 -1
  67. package/dist-server/service/regulation/regulation-service.d.ts +12 -0
  68. package/dist-server/service/regulation/regulation-service.js +48 -7
  69. package/dist-server/service/regulation/regulation-service.js.map +1 -1
  70. package/dist-server/service/regulation/regulation-type.d.ts +4 -0
  71. package/dist-server/service/regulation/regulation-type.js +16 -0
  72. package/dist-server/service/regulation/regulation-type.js.map +1 -1
  73. package/dist-server/service/regulation/regulation.d.ts +3 -1
  74. package/dist-server/service/regulation/regulation.js +12 -2
  75. package/dist-server/service/regulation/regulation.js.map +1 -1
  76. package/dist-server/tsconfig.tsbuildinfo +1 -1
  77. package/dist-server/work-doors.d.ts +1 -0
  78. package/dist-server/work-doors.js +15 -0
  79. package/dist-server/work-doors.js.map +1 -0
  80. package/package.json +17 -17
  81. package/translations/en.json +46 -14
  82. package/translations/es.json +46 -14
  83. package/translations/ja.json +46 -14
  84. package/translations/ko.json +46 -14
  85. package/translations/ms.json +46 -14
  86. package/translations/zh.json +46 -14
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PROCEDURE_METHODS = exports.REGULATION_KINDS = void 0;
4
- exports.clausesOf = clausesOf;
3
+ exports.clausesOf = exports.PROCEDURE_METHODS = exports.REGULATION_KINDS = void 0;
4
+ exports.partsOf = partsOf;
5
5
  exports.clauseChanges = clauseChanges;
6
6
  exports.regulationRefusal = regulationRefusal;
7
7
  exports.adoptionRefusal = adoptionRefusal;
8
+ exports.inForceRefusal = inForceRefusal;
8
9
  exports.procedureRefusal = procedureRefusal;
9
10
  exports.standingOf = standingOf;
10
11
  exports.periodOfVersion = periodOfVersion;
@@ -24,46 +25,81 @@ exports.REGULATION_KINDS = {
24
25
  };
25
26
  /** How an opinion, a consent or a filing was taken. */
26
27
  exports.PROCEDURE_METHODS = {
27
- OPINION: ['MAJORITY_UNION', 'WORKERS_MEETING', 'SIGNATURES'],
28
- CONSENT: ['MAJORITY_UNION', 'WORKERS_MEETING', 'SIGNATURES'],
28
+ OPINION: ['WORKERS_MEETING', 'SIGNATURES'],
29
+ CONSENT: ['WORKERS_MEETING', 'SIGNATURES'],
29
30
  FILING: ['ONLINE', 'VISIT', 'MAIL']
30
31
  };
31
32
  const DAY = /^\d{4}-\d{2}-\d{2}$/;
32
33
  const CODE = /^[A-Za-z0-9_-]{1,40}$/;
33
34
  const ARTICLE = /^\s*(?:#{1,6}\s*)?(?:\*\*)?제\s*(\d+(?:의\s*\d+)?)\s*조\s*(?:[((]([^))]*)[))])?(?:\*\*)?\s*(.*)$/;
34
35
  const CHAPTER = /^\s*(?:#{1,6}\s*)?(?:\*\*)?(제\s*\d+\s*장.*?)(?:\*\*)?\s*$/;
36
+ const SECTION = /^\s*(?:#{1,6}\s*)?(?:\*\*)?<?\s*(제\s*\d+\s*절[^>]*?)\s*>?(?:\*\*)?\s*$/;
37
+ const ADDENDA = /^\s*(?:#{1,6}\s*)?(?:\*\*)?부\s*칙(?:\*\*)?\s*(?:<[^>]*>)?\s*$/;
38
+ const APPENDIX = /^\s*(?:#{1,6}\s*)?\[[^\]]+\]/;
39
+ /** How an article is named on the page - 「제3조(휴게)」, in the addenda 「부칙 제1조(시행일)」. */
40
+ const headingOf = (number, title) => {
41
+ const addenda = number.startsWith('부칙');
42
+ return `${addenda ? '부칙 ' : ''}제${addenda ? number.slice(2) : number}조${title ? `(${title})` : ''}`;
43
+ };
35
44
  /**
36
- * The articles of a text, each from its `제n조(제목)` head up to the next article or chapter. The words before the first
37
- * article are no article. A chapter head (`제2장 근로시간`) is kept as the chapter of the articles after it.
45
+ * The parts of a text (ADR-0187 decision 2): its articles, each from its `제n조(제목)` head up to the next article or
46
+ * head, and the appendix - from the first line headed in brackets (`[별표 1]`) to the end. The words before the first
47
+ * article are no article. A chapter (`제2장 근로시간`) and a section (`제1절 근로시간`) are kept as the chapter of the
48
+ * articles after them. The articles after 「부칙」 are numbered `부칙1`, `부칙2` - apart from the body's.
38
49
  */
39
- function clausesOf(body) {
50
+ function partsOf(body) {
40
51
  const clauses = [];
41
52
  let chapter = null;
53
+ let section = null;
54
+ let addenda = false;
42
55
  let current = null;
43
56
  const close = () => {
44
57
  if (!current)
45
58
  return;
46
- clauses.push({ number: current.number, title: current.title, chapter: current.chapter, text: current.lines.join('\n').trim() });
59
+ clauses.push({ number: current.number, title: current.title, chapter: current.chapter, heading: headingOf(current.number, current.title), text: current.lines.join('\n').trim() });
47
60
  current = null;
48
61
  };
49
- for (const line of (body ?? '').split(/\r?\n/)) {
62
+ const lines = (body ?? '').split(/\r?\n/);
63
+ for (const [index, line] of lines.entries()) {
64
+ if (APPENDIX.test(line)) {
65
+ close();
66
+ return { clauses, appendix: lines.slice(index).join('\n').trim() || null };
67
+ }
50
68
  const article = ARTICLE.exec(line);
51
69
  if (article) {
52
70
  close();
53
- current = { number: article[1].replace(/\s+/g, ''), title: article[2]?.trim() || null, chapter, text: '', lines: article[3] ? [article[3]] : [] };
71
+ const number = article[1].replace(/\s+/g, '');
72
+ current = { number: addenda ? `부칙${number}` : number, title: article[2]?.trim() || null, chapter: [chapter, section].filter(Boolean).join(' · ') || null, lines: article[3] ? [article[3]] : [] };
54
73
  continue;
55
74
  }
56
75
  const head = CHAPTER.exec(line);
57
76
  if (head) {
58
77
  close();
59
78
  chapter = head[1].replace(/\s+/g, ' ').trim();
79
+ section = null;
80
+ continue;
81
+ }
82
+ const part = SECTION.exec(line);
83
+ if (part) {
84
+ close();
85
+ section = part[1].replace(/\s+/g, ' ').trim();
86
+ continue;
87
+ }
88
+ if (ADDENDA.test(line)) {
89
+ close();
90
+ addenda = true;
91
+ chapter = '부칙';
92
+ section = null;
60
93
  continue;
61
94
  }
62
95
  current?.lines.push(line);
63
96
  }
64
97
  close();
65
- return clauses;
98
+ return { clauses, appendix: null };
66
99
  }
100
+ /** The articles of a text. */
101
+ const clausesOf = (body) => partsOf(body).clauses;
102
+ exports.clausesOf = clausesOf;
67
103
  /** What a version changed of the one before, article by article - by number; a heading or words that differ is a change. */
68
104
  function clauseChanges(before, after) {
69
105
  const old = new Map(before.map(one => [one.number, one]));
@@ -72,13 +108,13 @@ function clauseChanges(before, after) {
72
108
  for (const one of after) {
73
109
  const was = old.get(one.number);
74
110
  if (!was)
75
- changes.push({ number: one.number, title: one.title, change: 'ADDED' });
111
+ changes.push({ number: one.number, title: one.title, heading: one.heading, change: 'ADDED' });
76
112
  else if (was.text !== one.text || (was.title ?? '') !== (one.title ?? ''))
77
- changes.push({ number: one.number, title: one.title, change: 'CHANGED' });
113
+ changes.push({ number: one.number, title: one.title, heading: one.heading, change: 'CHANGED' });
78
114
  }
79
115
  for (const one of before)
80
116
  if (!fresh.has(one.number))
81
- changes.push({ number: one.number, title: one.title, change: 'REMOVED' });
117
+ changes.push({ number: one.number, title: one.title, heading: one.heading, change: 'REMOVED' });
82
118
  return changes;
83
119
  }
84
120
  /** What a regulation asks before it is written. */
@@ -92,35 +128,55 @@ function regulationRefusal(input) {
92
128
  return null;
93
129
  }
94
130
  /**
95
- * What a version asks before it is put up for adoption (decision 4). The writer must say whether the change is against
96
- * the workers - there is no default. A rule of working conditions needs the majority's opinion with its papers; against
97
- * them, the consent of more than half with its papers.
131
+ * Only working-condition rules require the statutory procedure evidence. Other rules follow company approval.
132
+ * The original evidence is reviewed by the approver; this function does not certify its legal validity.
98
133
  */
99
134
  function adoptionRefusal(version, procedures, today) {
100
- if (!clausesOf(version.body).length)
135
+ const asks = exports.REGULATION_KINDS[version.kind];
136
+ if (!asks)
137
+ return new shell_1.Refusal('regulation-kind-required', {}, 'pick what the rule is');
138
+ /* Rules of employment are written in articles; a work guideline or an operating rule may be plain sentences. */
139
+ if (!version.body?.trim())
140
+ return new shell_1.Refusal('regulation-body-empty', {}, 'write the text of the rule');
141
+ if (asks.opinion && !(0, exports.clausesOf)(version.body).length)
101
142
  return new shell_1.Refusal('regulation-body-required', {}, 'the text has no article - begin each with 제n조(제목)');
102
143
  if (!version.effectiveOn || !DAY.test(version.effectiveOn))
103
144
  return new shell_1.Refusal('regulation-effective-required', {}, 'give the day it takes effect, YYYY-MM-DD');
104
145
  if (version.effectiveOn < today)
105
146
  return new shell_1.Refusal('regulation-effective-past', { effectiveOn: version.effectiveOn, today }, `the effective day ${version.effectiveOn} is before today ${today}`);
106
- if (version.unfavourable == null)
107
- return new shell_1.Refusal('regulation-unfavourable-required', {}, 'say whether the change is against the workers');
108
- const asks = exports.REGULATION_KINDS[version.kind];
109
- if (!asks)
110
- return new shell_1.Refusal('regulation-kind-required', {}, 'pick what the rule is');
111
- if (asks.opinion && !procedures.some(one => one.kind === 'OPINION' && one.files > 0))
147
+ if (asks.consentWhenUnfavourable && version.unfavourable == null)
148
+ return new shell_1.Refusal('regulation-unfavourable-required', {}, 'identify whether these working conditions change unfavourably');
149
+ const evidenced = procedures.filter(one => one.files > 0);
150
+ if (asks.opinion && !evidenced.some(one => one.kind === 'OPINION' || (version.unfavourable && one.kind === 'CONSENT')))
112
151
  return new shell_1.Refusal('regulation-opinion-required', {}, "record the workers' majority opinion with its paper attached");
113
152
  if (asks.consentWhenUnfavourable && version.unfavourable) {
114
153
  const consent = procedures.find(one => one.kind === 'CONSENT' && one.files > 0);
115
154
  if (!consent)
116
155
  return new shell_1.Refusal('regulation-consent-required', {}, "a change against the workers needs the majority's consent recorded with its paper attached");
117
- const workers = Number(consent.workersCount ?? 0);
118
- const consented = Number(consent.consentCount ?? 0);
119
- if (!(workers > 0) || !(consented * 2 > workers))
120
- return new shell_1.Refusal('regulation-consent-short', { consented, workers }, `a change against the workers - the consent (${consented}) is not more than half of the workers (${workers})`);
156
+ // The approval reviews the original evidence. A separate headcount is not a statutory filing field here.
121
157
  }
122
158
  return null;
123
159
  }
160
+ /**
161
+ * What a version asks before it is registered as in force already (ADR-0187 decision 3, amendment 2): the first version
162
+ * of its rule to be adopted, still being written, with a text, a day come by today and the original attached. No article
163
+ * is asked - a table of amounts has none; no procedure is asked - it was taken before the system.
164
+ */
165
+ function inForceRefusal(version, adoptedBefore, originals, today) {
166
+ if (version.status !== 'DRAFT')
167
+ return new shell_1.Refusal('regulation-register-not-draft', {}, 'only a version being written is registered');
168
+ if (adoptedBefore)
169
+ return new shell_1.Refusal('regulation-in-force-first-only', {}, 'the rule has a version adopted or in approval - a change of it goes through approval');
170
+ if (!version.body?.trim())
171
+ return new shell_1.Refusal('regulation-body-empty', {}, 'write the text of the rule');
172
+ if (!version.effectiveOn || !DAY.test(version.effectiveOn))
173
+ return new shell_1.Refusal('regulation-effective-required', {}, 'give the day it takes effect, YYYY-MM-DD');
174
+ if (version.effectiveOn > today)
175
+ return new shell_1.Refusal('regulation-in-force-future', { effectiveOn: version.effectiveOn, today }, `the effective day ${version.effectiveOn} is after today ${today} - a rule to take effect later is adopted through approval`);
176
+ if (!originals)
177
+ return new shell_1.Refusal('regulation-original-required', {}, 'attach the original of the rule');
178
+ return null;
179
+ }
124
180
  /** What a procedure record asks before it is written. */
125
181
  function procedureRefusal(input) {
126
182
  if (!exports.PROCEDURE_METHODS[input.kind ?? ''])
@@ -129,7 +185,7 @@ function procedureRefusal(input) {
129
185
  return new shell_1.Refusal('regulation-procedure-day-required', {}, 'give the day, YYYY-MM-DD');
130
186
  if (input.method && !exports.PROCEDURE_METHODS[input.kind].includes(input.method))
131
187
  return new shell_1.Refusal('regulation-procedure-method-unknown', {}, 'pick how it was taken');
132
- if (input.kind === 'CONSENT') {
188
+ if (input.kind === 'CONSENT' && (input.workersCount != null || input.consentCount != null)) {
133
189
  if (!(Number.isInteger(input.workersCount) && input.workersCount > 0))
134
190
  return new shell_1.Refusal('regulation-procedure-workers-required', {}, 'give how many workers it was of');
135
191
  if (!(Number.isInteger(input.consentCount) && input.consentCount >= 0 && input.consentCount <= input.workersCount))
@@ -1 +1 @@
1
- {"version":3,"file":"regulation-rules.js","sourceRoot":"","sources":["../../../server/service/regulation/regulation-rules.ts"],"names":[],"mappings":";;;AAuCA,8BA0BC;AASD,sCAWC;AAkBD,8CAKC;AAOD,0CAkBC;AAGD,4CAUC;AAGD,gCAIC;AAGD,0CAIC;AAGD,sCAIC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AAS;QAAE,OAAO,IAAI,eAAO,CAAC,0BAA0B,EAAE,EAAE,EAAE,wEAAwE,CAAC,CAAA;IACtJ,IAAI,MAAM,KAAK,aAAa;QAAE,OAAO,IAAI,eAAO,CAAC,wBAAwB,EAAE,EAAE,EAAE,uDAAuD,CAAC,CAAA;IACvI,OAAO,IAAI,CAAA;AACb,CAAC;AAED,6FAA6F;AAC7F,SAAgB,qBAAqB,CAAC,MAAc,EAAE,IAAY;IAChE,IAAI,MAAM,KAAK,OAAO;QAAE,OAAO,IAAI,CAAA;IACnC,IAAI,MAAM,KAAK,SAAS,IAAI,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAA;IAC1D,OAAO,IAAI,eAAO,CAAC,4BAA4B,EAAE,EAAE,EAAE,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,kDAAkD,CAAC,CAAC,CAAC,mEAAmE,CAAC,CAAA;AACpM,CAAC","sourcesContent":["import { Refusal } from '@things-factory/shell'\n\n/*\n * What a company rule holds to (ADR-0187 decisions 2-4). Pure - the service reads the rows, these say yes or no.\n */\n\n/** Each kind, and the procedure the law asks before a version of it is adopted. */\nexport const REGULATION_KINDS: Record<string, { opinion: boolean; consentWhenUnfavourable: boolean; filing: boolean }> = {\n WORK_RULES: { opinion: true, consentWhenUnfavourable: true, filing: true },\n WORK_RULES_ANNEX: { opinion: true, consentWhenUnfavourable: true, filing: true },\n PRIVACY_POLICY: { opinion: false, consentWhenUnfavourable: false, filing: false },\n PRIVACY_PLAN: { opinion: false, consentWhenUnfavourable: false, filing: false },\n OTHER: { opinion: false, consentWhenUnfavourable: false, filing: false }\n}\n\n/** How an opinion, a consent or a filing was taken. */\nexport const PROCEDURE_METHODS: Record<string, string[]> = {\n OPINION: ['MAJORITY_UNION', 'WORKERS_MEETING', 'SIGNATURES'],\n CONSENT: ['MAJORITY_UNION', 'WORKERS_MEETING', 'SIGNATURES'],\n FILING: ['ONLINE', 'VISIT', 'MAIL']\n}\n\nconst DAY = /^\\d{4}-\\d{2}-\\d{2}$/\nconst CODE = /^[A-Za-z0-9_-]{1,40}$/\n\nexport interface Clause {\n number: string\n title: string | null\n chapter: string | null\n text: string\n}\n\nconst ARTICLE = /^\\s*(?:#{1,6}\\s*)?(?:\\*\\*)?제\\s*(\\d+(?:의\\s*\\d+)?)\\s*조\\s*(?:[((]([^))]*)[))])?(?:\\*\\*)?\\s*(.*)$/\nconst CHAPTER = /^\\s*(?:#{1,6}\\s*)?(?:\\*\\*)?(제\\s*\\d+\\s*장.*?)(?:\\*\\*)?\\s*$/\n\n/**\n * The articles of a text, each from its `제n조(제목)` head up to the next article or chapter. The words before the first\n * article are no article. A chapter head (`제2장 근로시간`) is kept as the chapter of the articles after it.\n */\nexport function clausesOf(body: string | null | undefined): Clause[] {\n const clauses: Clause[] = []\n let chapter: string | null = null\n let current: (Clause & { lines: string[] }) | null = null\n const close = () => {\n if (!current) return\n clauses.push({ number: current.number, title: current.title, chapter: current.chapter, text: current.lines.join('\\n').trim() })\n current = null\n }\n for (const line of (body ?? '').split(/\\r?\\n/)) {\n const article = ARTICLE.exec(line)\n if (article) {\n close()\n current = { number: article[1].replace(/\\s+/g, ''), title: article[2]?.trim() || null, chapter, text: '', lines: article[3] ? [article[3]] : [] }\n continue\n }\n const head = CHAPTER.exec(line)\n if (head) {\n close()\n chapter = head[1].replace(/\\s+/g, ' ').trim()\n continue\n }\n current?.lines.push(line)\n }\n close()\n return clauses\n}\n\nexport interface ClauseChange {\n number: string\n title: string | null\n change: 'ADDED' | 'CHANGED' | 'REMOVED'\n}\n\n/** What a version changed of the one before, article by article - by number; a heading or words that differ is a change. */\nexport function clauseChanges(before: Clause[], after: Clause[]): ClauseChange[] {\n const old = new Map(before.map(one => [one.number, one]))\n const fresh = new Map(after.map(one => [one.number, one]))\n const changes: ClauseChange[] = []\n for (const one of after) {\n const was = old.get(one.number)\n if (!was) changes.push({ number: one.number, title: one.title, change: 'ADDED' })\n else if (was.text !== one.text || (was.title ?? '') !== (one.title ?? '')) changes.push({ number: one.number, title: one.title, change: 'CHANGED' })\n }\n for (const one of before) if (!fresh.has(one.number)) changes.push({ number: one.number, title: one.title, change: 'REMOVED' })\n return changes\n}\n\nexport interface ProcedureFacts {\n kind: string\n day?: string | null\n workersCount?: number | null\n consentCount?: number | null\n files: number\n}\n\nexport interface VersionFacts {\n kind: string\n body?: string | null\n effectiveOn?: string | null\n unfavourable?: boolean | null\n}\n\n/** What a regulation asks before it is written. */\nexport function regulationRefusal(input: { code?: string | null; name?: string | null; kind?: string | null }): Refusal | null {\n if (!input.code || !CODE.test(input.code)) return new Refusal('regulation-code-required', {}, 'give the code - letters, digits, - and _, up to 40')\n if (!input.name?.trim()) return new Refusal('regulation-name-required', {}, 'give the name')\n if (!REGULATION_KINDS[input.kind ?? '']) return new Refusal('regulation-kind-required', {}, 'pick what the rule is')\n return null\n}\n\n/**\n * What a version asks before it is put up for adoption (decision 4). The writer must say whether the change is against\n * the workers - there is no default. A rule of working conditions needs the majority's opinion with its papers; against\n * them, the consent of more than half with its papers.\n */\nexport function adoptionRefusal(version: VersionFacts, procedures: ProcedureFacts[], today: string): Refusal | null {\n if (!clausesOf(version.body).length) return new Refusal('regulation-body-required', {}, 'the text has no article - begin each with 제n조(제목)')\n if (!version.effectiveOn || !DAY.test(version.effectiveOn)) return new Refusal('regulation-effective-required', {}, 'give the day it takes effect, YYYY-MM-DD')\n if (version.effectiveOn < today) return new Refusal('regulation-effective-past', { effectiveOn: version.effectiveOn, today }, `the effective day ${version.effectiveOn} is before today ${today}`)\n if (version.unfavourable == null) return new Refusal('regulation-unfavourable-required', {}, 'say whether the change is against the workers')\n const asks = REGULATION_KINDS[version.kind]\n if (!asks) return new Refusal('regulation-kind-required', {}, 'pick what the rule is')\n if (asks.opinion && !procedures.some(one => one.kind === 'OPINION' && one.files > 0))\n return new Refusal('regulation-opinion-required', {}, \"record the workers' majority opinion with its paper attached\")\n if (asks.consentWhenUnfavourable && version.unfavourable) {\n const consent = procedures.find(one => one.kind === 'CONSENT' && one.files > 0)\n if (!consent) return new Refusal('regulation-consent-required', {}, \"a change against the workers needs the majority's consent recorded with its paper attached\")\n const workers = Number(consent.workersCount ?? 0)\n const consented = Number(consent.consentCount ?? 0)\n if (!(workers > 0) || !(consented * 2 > workers))\n return new Refusal('regulation-consent-short', { consented, workers }, `a change against the workers - the consent (${consented}) is not more than half of the workers (${workers})`)\n }\n return null\n}\n\n/** What a procedure record asks before it is written. */\nexport function procedureRefusal(input: { kind?: string | null; day?: string | null; method?: string | null; workersCount?: number | null; consentCount?: number | null }): Refusal | null {\n if (!PROCEDURE_METHODS[input.kind ?? '']) return new Refusal('regulation-procedure-kind-required', {}, 'pick opinion, consent or filing')\n if (!input.day || !DAY.test(input.day)) return new Refusal('regulation-procedure-day-required', {}, 'give the day, YYYY-MM-DD')\n if (input.method && !PROCEDURE_METHODS[input.kind!].includes(input.method)) return new Refusal('regulation-procedure-method-unknown', {}, 'pick how it was taken')\n if (input.kind === 'CONSENT') {\n if (!(Number.isInteger(input.workersCount) && (input.workersCount as number) > 0)) return new Refusal('regulation-procedure-workers-required', {}, 'give how many workers it was of')\n if (!(Number.isInteger(input.consentCount) && (input.consentCount as number) >= 0 && (input.consentCount as number) <= (input.workersCount as number)))\n return new Refusal('regulation-procedure-consent-invalid', { workers: input.workersCount }, `the consent count is from 0 to the workers (${input.workersCount})`)\n }\n return null\n}\n\n/** Adopted versions as they stand on `today`: the one in force is the latest whose day has come. */\nexport function standingOf<V extends { status: string; effectiveOn?: string | null; version: number }>(versions: V[], today: string): { inForce: V | null; due: V | null } {\n const adopted = versions.filter(one => one.status === 'ADOPTED' && one.effectiveOn).sort((a, b) => (a.effectiveOn! < b.effectiveOn! ? -1 : a.effectiveOn! > b.effectiveOn! ? 1 : a.version - b.version))\n const come = adopted.filter(one => one.effectiveOn! <= today)\n return { inForce: come[come.length - 1] ?? null, due: adopted.find(one => one.effectiveOn! > today) ?? null }\n}\n\n/** Where an adopted version stands on `today`. */\nexport function periodOfVersion(version: { status: string; effectiveOn?: string | null; id: string }, standing: { inForce: { id: string } | null }, today: string): 'DRAFT' | 'IN_APPROVAL' | 'DUE' | 'IN_FORCE' | 'PAST' {\n if (version.status !== 'ADOPTED') return version.status as 'DRAFT' | 'IN_APPROVAL'\n if (standing.inForce?.id === version.id) return 'IN_FORCE'\n return version.effectiveOn! > today ? 'DUE' : 'PAST'\n}\n\n/** What may change on an adopted version - nothing but the workers count the filing reads. A draft changes freely. */\nexport function changeRefusal(status: string): Refusal | null {\n if (status === 'ADOPTED') return new Refusal('regulation-adopted-fixed', {}, 'an adopted version stays as it was - put up a new version to change it')\n if (status === 'IN_APPROVAL') return new Refusal('regulation-in-approval', {}, 'a version in approval is taken back before it changes')\n return null\n}\n\n/** A procedure is recorded on a draft; a filing also after adoption, since it follows it. */\nexport function procedureWriteRefusal(status: string, kind: string): Refusal | null {\n if (status === 'DRAFT') return null\n if (status === 'ADOPTED' && kind === 'FILING') return null\n return new Refusal('regulation-procedure-fixed', {}, kind === 'FILING' ? 'a filing is recorded once the version is adopted' : 'the procedure of a version in approval or adopted stays as it was')\n}\n"]}
1
+ {"version":3,"file":"regulation-rules.js","sourceRoot":"","sources":["../../../server/service/regulation/regulation-rules.ts"],"names":[],"mappings":";;;AAmDA,0BAgDC;AAaD,sCAWC;AAmBD,8CAKC;AAMD,0CAkBC;AAOD,wCAQC;AAGD,4CAUC;AAGD,gCAIC;AAGD,0CAIC;AAGD,sCAIC;AAGD,sDAIC;AAnOD,iDAA+C;AAE/C;;GAEG;AAEH,mFAAmF;AACtE,QAAA,gBAAgB,GAA4F;IACvH,UAAU,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,uBAAuB,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;IAC1E,gBAAgB,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,uBAAuB,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;IAChF,cAAc,EAAE,EAAE,OAAO,EAAE,KAAK,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,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAA;AACtD,CAAC;AAED,sHAAsH;AACtH,SAAgB,aAAa,CAAC,MAAc;IAC1C,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,IAAI,eAAO,CAAC,0BAA0B,EAAE,EAAE,EAAE,wEAAwE,CAAC,CAAA;IACtJ,IAAI,MAAM,KAAK,aAAa;QAAE,OAAO,IAAI,eAAO,CAAC,wBAAwB,EAAE,EAAE,EAAE,uDAAuD,CAAC,CAAA;IACvI,OAAO,IAAI,CAAA;AACb,CAAC;AAED,6FAA6F;AAC7F,SAAgB,qBAAqB,CAAC,MAAc,EAAE,IAAY;IAChE,IAAI,MAAM,KAAK,OAAO;QAAE,OAAO,IAAI,CAAA;IACnC,IAAI,MAAM,KAAK,SAAS,IAAI,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAA;IAC1D,OAAO,IAAI,eAAO,CAAC,4BAA4B,EAAE,EAAE,EAAE,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,kDAAkD,CAAC,CAAC,CAAC,mEAAmE,CAAC,CAAA;AACpM,CAAC","sourcesContent":["import { Refusal } from '@things-factory/shell'\n\n/*\n * What a company rule holds to (ADR-0187 decisions 2-4). Pure - the service reads the rows, these say yes or no.\n */\n\n/** Each kind, and the procedure the law asks before a version of it is adopted. */\nexport const REGULATION_KINDS: Record<string, { opinion: boolean; consentWhenUnfavourable: boolean; filing: boolean }> = {\n WORK_RULES: { opinion: true, consentWhenUnfavourable: true, filing: true },\n WORK_RULES_ANNEX: { opinion: true, consentWhenUnfavourable: true, filing: true },\n PRIVACY_POLICY: { opinion: false, consentWhenUnfavourable: false, filing: false },\n PRIVACY_PLAN: { opinion: false, consentWhenUnfavourable: false, filing: false },\n OTHER: { opinion: false, consentWhenUnfavourable: false, filing: false }\n}\n\n/** How an opinion, a consent or a filing was taken. */\nexport const PROCEDURE_METHODS: Record<string, string[]> = {\n OPINION: ['WORKERS_MEETING', 'SIGNATURES'],\n CONSENT: ['WORKERS_MEETING', 'SIGNATURES'],\n FILING: ['ONLINE', 'VISIT', 'MAIL']\n}\n\nconst DAY = /^\\d{4}-\\d{2}-\\d{2}$/\nconst CODE = /^[A-Za-z0-9_-]{1,40}$/\n\nexport interface Clause {\n number: string\n title: string | null\n chapter: string | null\n heading: string\n text: string\n}\n\nconst ARTICLE = /^\\s*(?:#{1,6}\\s*)?(?:\\*\\*)?제\\s*(\\d+(?:의\\s*\\d+)?)\\s*조\\s*(?:[((]([^))]*)[))])?(?:\\*\\*)?\\s*(.*)$/\nconst CHAPTER = /^\\s*(?:#{1,6}\\s*)?(?:\\*\\*)?(제\\s*\\d+\\s*장.*?)(?:\\*\\*)?\\s*$/\nconst SECTION = /^\\s*(?:#{1,6}\\s*)?(?:\\*\\*)?<?\\s*(제\\s*\\d+\\s*절[^>]*?)\\s*>?(?:\\*\\*)?\\s*$/\nconst ADDENDA = /^\\s*(?:#{1,6}\\s*)?(?:\\*\\*)?부\\s*칙(?:\\*\\*)?\\s*(?:<[^>]*>)?\\s*$/\nconst APPENDIX = /^\\s*(?:#{1,6}\\s*)?\\[[^\\]]+\\]/\n\n/** How an article is named on the page - 「제3조(휴게)」, in the addenda 「부칙 제1조(시행일)」. */\nconst headingOf = (number: string, title: string | null) => {\n const addenda = number.startsWith('부칙')\n return `${addenda ? '부칙 ' : ''}제${addenda ? number.slice(2) : number}조${title ? `(${title})` : ''}`\n}\n\n/**\n * The parts of a text (ADR-0187 decision 2): its articles, each from its `제n조(제목)` head up to the next article or\n * head, and the appendix - from the first line headed in brackets (`[별표 1]`) to the end. The words before the first\n * article are no article. A chapter (`제2장 근로시간`) and a section (`제1절 근로시간`) are kept as the chapter of the\n * articles after them. The articles after 「부칙」 are numbered `부칙1`, `부칙2` - apart from the body's.\n */\nexport function partsOf(body: string | null | undefined): { clauses: Clause[]; appendix: string | null } {\n const clauses: Clause[] = []\n let chapter: string | null = null\n let section: string | null = null\n let addenda = false\n let current: (Omit<Clause, 'text' | 'heading'> & { lines: string[] }) | null = null\n const close = () => {\n if (!current) return\n clauses.push({ number: current.number, title: current.title, chapter: current.chapter, heading: headingOf(current.number, current.title), text: current.lines.join('\\n').trim() })\n current = null\n }\n const lines = (body ?? '').split(/\\r?\\n/)\n for (const [index, line] of lines.entries()) {\n if (APPENDIX.test(line)) {\n close()\n return { clauses, appendix: lines.slice(index).join('\\n').trim() || null }\n }\n const article = ARTICLE.exec(line)\n if (article) {\n close()\n const number = article[1].replace(/\\s+/g, '')\n current = { number: addenda ? `부칙${number}` : number, title: article[2]?.trim() || null, chapter: [chapter, section].filter(Boolean).join(' · ') || null, lines: article[3] ? [article[3]] : [] }\n continue\n }\n const head = CHAPTER.exec(line)\n if (head) {\n close()\n chapter = head[1].replace(/\\s+/g, ' ').trim()\n section = null\n continue\n }\n const part = SECTION.exec(line)\n if (part) {\n close()\n section = part[1].replace(/\\s+/g, ' ').trim()\n continue\n }\n if (ADDENDA.test(line)) {\n close()\n addenda = true\n chapter = '부칙'\n section = null\n continue\n }\n current?.lines.push(line)\n }\n close()\n return { clauses, appendix: null }\n}\n\n/** The articles of a text. */\nexport const clausesOf = (body: string | null | undefined): Clause[] => partsOf(body).clauses\n\nexport interface ClauseChange {\n number: string\n title: string | null\n heading: string\n change: 'ADDED' | 'CHANGED' | 'REMOVED'\n}\n\n/** What a version changed of the one before, article by article - by number; a heading or words that differ is a change. */\nexport function clauseChanges(before: Clause[], after: Clause[]): ClauseChange[] {\n const old = new Map(before.map(one => [one.number, one]))\n const fresh = new Map(after.map(one => [one.number, one]))\n const changes: ClauseChange[] = []\n for (const one of after) {\n const was = old.get(one.number)\n if (!was) changes.push({ number: one.number, title: one.title, heading: one.heading, change: 'ADDED' })\n else if (was.text !== one.text || (was.title ?? '') !== (one.title ?? '')) changes.push({ number: one.number, title: one.title, heading: one.heading, change: 'CHANGED' })\n }\n for (const one of before) if (!fresh.has(one.number)) changes.push({ number: one.number, title: one.title, heading: one.heading, change: 'REMOVED' })\n return changes\n}\n\nexport interface ProcedureFacts {\n kind: string\n day?: string | null\n method?: string | null\n workersCount?: number | null\n consentCount?: number | null\n files: number\n}\n\nexport interface VersionFacts {\n kind: string\n body?: string | null\n effectiveOn?: string | null\n unfavourable?: boolean | null\n}\n\n/** What a regulation asks before it is written. */\nexport function regulationRefusal(input: { code?: string | null; name?: string | null; kind?: string | null }): Refusal | null {\n if (!input.code || !CODE.test(input.code)) return new Refusal('regulation-code-required', {}, 'give the code - letters, digits, - and _, up to 40')\n if (!input.name?.trim()) return new Refusal('regulation-name-required', {}, 'give the name')\n if (!REGULATION_KINDS[input.kind ?? '']) return new Refusal('regulation-kind-required', {}, 'pick what the rule is')\n return null\n}\n\n/**\n * Only working-condition rules require the statutory procedure evidence. Other rules follow company approval.\n * The original evidence is reviewed by the approver; this function does not certify its legal validity.\n */\nexport function adoptionRefusal(version: VersionFacts, procedures: ProcedureFacts[], today: string): Refusal | null {\n const asks = REGULATION_KINDS[version.kind]\n if (!asks) return new Refusal('regulation-kind-required', {}, 'pick what the rule is')\n /* Rules of employment are written in articles; a work guideline or an operating rule may be plain sentences. */\n if (!version.body?.trim()) return new Refusal('regulation-body-empty', {}, 'write the text of the rule')\n if (asks.opinion && !clausesOf(version.body).length) return new Refusal('regulation-body-required', {}, 'the text has no article - begin each with 제n조(제목)')\n if (!version.effectiveOn || !DAY.test(version.effectiveOn)) return new Refusal('regulation-effective-required', {}, 'give the day it takes effect, YYYY-MM-DD')\n if (version.effectiveOn < today) return new Refusal('regulation-effective-past', { effectiveOn: version.effectiveOn, today }, `the effective day ${version.effectiveOn} is before today ${today}`)\n if (asks.consentWhenUnfavourable && version.unfavourable == null) return new Refusal('regulation-unfavourable-required', {}, 'identify whether these working conditions change unfavourably')\n const evidenced = procedures.filter(one => one.files > 0)\n if (asks.opinion && !evidenced.some(one => one.kind === 'OPINION' || (version.unfavourable && one.kind === 'CONSENT')))\n return new Refusal('regulation-opinion-required', {}, \"record the workers' majority opinion with its paper attached\")\n if (asks.consentWhenUnfavourable && version.unfavourable) {\n const consent = procedures.find(one => one.kind === 'CONSENT' && one.files > 0)\n if (!consent) return new Refusal('regulation-consent-required', {}, \"a change against the workers needs the majority's consent recorded with its paper attached\")\n // The approval reviews the original evidence. A separate headcount is not a statutory filing field here.\n }\n return null\n}\n\n/**\n * What a version asks before it is registered as in force already (ADR-0187 decision 3, amendment 2): the first version\n * of its rule to be adopted, still being written, with a text, a day come by today and the original attached. No article\n * is asked - a table of amounts has none; no procedure is asked - it was taken before the system.\n */\nexport function inForceRefusal(version: { status: string; body?: string | null; effectiveOn?: string | null }, adoptedBefore: number, originals: number, today: string): Refusal | null {\n if (version.status !== 'DRAFT') return new Refusal('regulation-register-not-draft', {}, 'only a version being written is registered')\n if (adoptedBefore) return new Refusal('regulation-in-force-first-only', {}, 'the rule has a version adopted or in approval - a change of it goes through approval')\n if (!version.body?.trim()) return new Refusal('regulation-body-empty', {}, 'write the text of the rule')\n if (!version.effectiveOn || !DAY.test(version.effectiveOn)) return new Refusal('regulation-effective-required', {}, 'give the day it takes effect, YYYY-MM-DD')\n if (version.effectiveOn > today) return new Refusal('regulation-in-force-future', { effectiveOn: version.effectiveOn, today }, `the effective day ${version.effectiveOn} is after today ${today} - a rule to take effect later is adopted through approval`)\n if (!originals) return new Refusal('regulation-original-required', {}, 'attach the original of the rule')\n return null\n}\n\n/** What a procedure record asks before it is written. */\nexport function procedureRefusal(input: { kind?: string | null; day?: string | null; method?: string | null; workersCount?: number | null; consentCount?: number | null }): Refusal | null {\n if (!PROCEDURE_METHODS[input.kind ?? '']) return new Refusal('regulation-procedure-kind-required', {}, 'pick opinion, consent or filing')\n if (!input.day || !DAY.test(input.day)) return new Refusal('regulation-procedure-day-required', {}, 'give the day, YYYY-MM-DD')\n if (input.method && !PROCEDURE_METHODS[input.kind!].includes(input.method)) return new Refusal('regulation-procedure-method-unknown', {}, 'pick how it was taken')\n if (input.kind === 'CONSENT' && (input.workersCount != null || input.consentCount != null)) {\n if (!(Number.isInteger(input.workersCount) && (input.workersCount as number) > 0)) return new Refusal('regulation-procedure-workers-required', {}, 'give how many workers it was of')\n if (!(Number.isInteger(input.consentCount) && (input.consentCount as number) >= 0 && (input.consentCount as number) <= (input.workersCount as number)))\n return new Refusal('regulation-procedure-consent-invalid', { workers: input.workersCount }, `the consent count is from 0 to the workers (${input.workersCount})`)\n }\n return null\n}\n\n/** Adopted versions as they stand on `today`: the one in force is the latest whose day has come. */\nexport function standingOf<V extends { status: string; effectiveOn?: string | null; version: number }>(versions: V[], today: string): { inForce: V | null; due: V | null } {\n const adopted = versions.filter(one => one.status === 'ADOPTED' && one.effectiveOn).sort((a, b) => (a.effectiveOn! < b.effectiveOn! ? -1 : a.effectiveOn! > b.effectiveOn! ? 1 : a.version - b.version))\n const come = adopted.filter(one => one.effectiveOn! <= today)\n return { inForce: come[come.length - 1] ?? null, due: adopted.find(one => one.effectiveOn! > today) ?? null }\n}\n\n/** Where an adopted version stands on `today`. */\nexport function periodOfVersion(version: { status: string; effectiveOn?: string | null; id: string }, standing: { inForce: { id: string } | null }, today: string): 'DRAFT' | 'IN_APPROVAL' | 'DUE' | 'IN_FORCE' | 'PAST' {\n if (version.status !== 'ADOPTED') return version.status as 'DRAFT' | 'IN_APPROVAL'\n if (standing.inForce?.id === version.id) return 'IN_FORCE'\n return version.effectiveOn! > today ? 'DUE' : 'PAST'\n}\n\n/** What may change on an adopted version - nothing but the workers count the filing reads. A draft changes freely. */\nexport function changeRefusal(status: string): Refusal | null {\n if (status === 'ADOPTED') return new Refusal('regulation-adopted-fixed', {}, 'an adopted version stays as it was - put up a new version to change it')\n if (status === 'IN_APPROVAL') return new Refusal('regulation-in-approval', {}, 'a version in approval is taken back before it changes')\n return null\n}\n\n/** A procedure is recorded on a draft; a filing also after adoption, since it follows it. */\nexport function procedureWriteRefusal(status: string, kind: string): Refusal | null {\n if (status === 'DRAFT') return null\n if (status === 'ADOPTED' && kind === 'FILING') return null\n return new Refusal('regulation-procedure-fixed', {}, kind === 'FILING' ? 'a filing is recorded once the version is adopted' : 'the procedure of a version in approval or adopted stays as it was')\n}\n"]}
@@ -4,6 +4,8 @@ import { Regulation, RegulationProcedure, RegulationVersion } from './regulation
4
4
  import { NewRegulation, NewRegulationProcedure, RegulationPatch, RegulationVersionPatch } from './regulation-type';
5
5
  /** The papers of a procedure hang on it under this `refType` (attachment-base). */
6
6
  export declare const REGULATION_PROCEDURE_REF_TYPE = "RegulationProcedure";
7
+ /** The original of a version registered as in force hangs on the version under this `refType`. */
8
+ export declare const REGULATION_ORIGINAL_REF_TYPE = "RegulationVersion";
7
9
  /** The help source of the articles (ADR-0187 decision 12). */
8
10
  export declare const REGULATION_HELP_SOURCE = "regulation";
9
11
  /** The announcement trigger of an adoption (ADR-0187 decision 6). */
@@ -37,6 +39,16 @@ export declare function proceduresOf(tx: EntityManager, domain: {
37
39
  export declare function previousAdopted(tx: EntityManager, version: RegulationVersion): Promise<RegulationVersion | null>;
38
40
  /** Puts a version up for adoption - or adopts it at once where the domain names no approver (decision 5). */
39
41
  export declare function submitRegulationVersion(id: string, context: ResolverContext): Promise<RegulationVersion>;
42
+ /**
43
+ * Registers the first version of a rule as in force already (decision 3, amendment 2): adopted as it stands from its own
44
+ * day, its original attached, its articles cut and indexed - with no approval, since nothing is decided, and no
45
+ * announcement, since the employees live under it already.
46
+ */
47
+ export declare function registerRegulationInForce(id: string, files: FileUpload[] | undefined, context: ResolverContext): Promise<RegulationVersion>;
48
+ /** How many originals each version carries. */
49
+ export declare function originalsOf(tx: EntityManager, domain: {
50
+ id: string;
51
+ }, versionIds: string[]): Promise<Map<string, number>>;
40
52
  /** Takes back a version in approval - it is being written again. */
41
53
  export declare function withdrawRegulationVersion(id: string, context: ResolverContext): Promise<RegulationVersion>;
42
54
  /**
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.REGULATION_ADOPTED_TRIGGER = exports.REGULATION_HELP_SOURCE = exports.REGULATION_PROCEDURE_REF_TYPE = void 0;
3
+ exports.REGULATION_ADOPTED_TRIGGER = exports.REGULATION_HELP_SOURCE = exports.REGULATION_ORIGINAL_REF_TYPE = exports.REGULATION_PROCEDURE_REF_TYPE = void 0;
4
4
  exports.versionOf = versionOf;
5
5
  exports.createRegulation = createRegulation;
6
6
  exports.updateRegulation = updateRegulation;
@@ -13,6 +13,8 @@ exports.deleteRegulationProcedure = deleteRegulationProcedure;
13
13
  exports.proceduresOf = proceduresOf;
14
14
  exports.previousAdopted = previousAdopted;
15
15
  exports.submitRegulationVersion = submitRegulationVersion;
16
+ exports.registerRegulationInForce = registerRegulationInForce;
17
+ exports.originalsOf = originalsOf;
16
18
  exports.withdrawRegulationVersion = withdrawRegulationVersion;
17
19
  exports.decideRegulationVersion = decideRegulationVersion;
18
20
  exports.announcementsOfVersions = announcementsOfVersions;
@@ -32,10 +34,13 @@ const regulation_rules_1 = require("./regulation-rules");
32
34
  * Writing a company rule and adopting its versions (ADR-0187 decisions 2-6). The one way a version is adopted: through
33
35
  * the work door `Compliance Regulation Adopt` - raised for approval where the domain names approvers, adopted at once
34
36
  * and written down where it names none. Adopting cuts its articles, tells the employees through the announcement of
35
- * the trigger `compliance.regulation-adopted`, and has the help index the articles again.
37
+ * the trigger `compliance.regulation-adopted`, and has the help index the articles again. A rule in force before the
38
+ * system is registered as it stands instead - its first version, with its original attached (amendment 2).
36
39
  */
37
40
  /** The papers of a procedure hang on it under this `refType` (attachment-base). */
38
41
  exports.REGULATION_PROCEDURE_REF_TYPE = 'RegulationProcedure';
42
+ /** The original of a version registered as in force hangs on the version under this `refType`. */
43
+ exports.REGULATION_ORIGINAL_REF_TYPE = 'RegulationVersion';
39
44
  /** The help source of the articles (ADR-0187 decision 12). */
40
45
  exports.REGULATION_HELP_SOURCE = 'regulation';
41
46
  /** The announcement trigger of an adoption (ADR-0187 decision 6). */
@@ -255,7 +260,7 @@ async function submitRegulationVersion(id, context) {
255
260
  headline,
256
261
  reason: [
257
262
  ...(version.changeSummary ? [`바뀐 곳: ${version.changeSummary}`] : []),
258
- ...(changes.length ? [`조문: ${changes.map(one => `제${one.number}조 ${words[one.change]}`).join(', ')}`] : []),
263
+ ...(changes.length ? [`조문: ${changes.map(one => `${one.heading} ${words[one.change]}`).join(', ')}`] : []),
259
264
  `불리한 변경: ${version.unfavourable ? '예' : '아니오'}`,
260
265
  ...procedures.map(one => `${{ OPINION: '의견 청취', CONSENT: '동의', FILING: '신고' }[one.kind]} ${one.day}${one.kind === 'CONSENT' ? ` · ${one.consentCount}/${one.workersCount}` : ''} · 첨부 ${one.files}`)
261
266
  ],
@@ -268,6 +273,45 @@ async function submitRegulationVersion(id, context) {
268
273
  saved.activityInstanceId = instance.id;
269
274
  return await tx.getRepository(regulation_1.RegulationVersion).save(saved);
270
275
  }
276
+ /**
277
+ * Registers the first version of a rule as in force already (decision 3, amendment 2): adopted as it stands from its own
278
+ * day, its original attached, its articles cut and indexed - with no approval, since nothing is decided, and no
279
+ * announcement, since the employees live under it already.
280
+ */
281
+ async function registerRegulationInForce(id, files, context) {
282
+ const { domain, user, tx } = context.state;
283
+ const version = await versionOf(tx, domain, id);
284
+ const adoptedBefore = await tx.getRepository(regulation_1.RegulationVersion).count({
285
+ where: { regulation: { id: version.regulationId }, status: (0, typeorm_1.In)([regulation_1.RegulationVersionStatus.ADOPTED, regulation_1.RegulationVersionStatus.IN_APPROVAL]) }
286
+ });
287
+ const refusal = (0, regulation_rules_1.inForceRefusal)(version, adoptedBefore, files?.length ?? 0, (0, employee_reader_1.todayIn)(domain));
288
+ if (refusal)
289
+ throw refusal;
290
+ version.status = regulation_1.RegulationVersionStatus.ADOPTED;
291
+ version.registeredInForce = true;
292
+ version.adoptedAt = new Date();
293
+ version.adoptedBy = user;
294
+ version.adoptionNote = null;
295
+ version.updater = user;
296
+ const saved = await tx.getRepository(regulation_1.RegulationVersion).save(version);
297
+ await keepClauses(saved, context);
298
+ for (const file of files ?? [])
299
+ await (0, attachment_base_1.createAttachment)(null, { attachment: { file, refType: exports.REGULATION_ORIGINAL_REF_TYPE, refBy: saved.id } }, context);
300
+ (0, help_1.invalidateHelpSource)(exports.REGULATION_HELP_SOURCE, domain.id);
301
+ return saved;
302
+ }
303
+ /** How many originals each version carries. */
304
+ async function originalsOf(tx, domain, versionIds) {
305
+ const rows = versionIds.length ? await tx.getRepository(attachment_base_1.Attachment).find({ where: { domain: { id: domain.id }, refType: exports.REGULATION_ORIGINAL_REF_TYPE, refBy: (0, typeorm_1.In)(versionIds) } }) : [];
306
+ return rows.reduce((counts, one) => counts.set(one.refBy, (counts.get(one.refBy) ?? 0) + 1), new Map());
307
+ }
308
+ /** The articles of an adopted version, cut from its text and kept. */
309
+ async function keepClauses(version, context) {
310
+ const { domain, tx } = context.state;
311
+ await tx.getRepository(regulation_1.RegulationClause).delete({ version: { id: version.id } });
312
+ for (const [rank, one] of (0, regulation_rules_1.clausesOf)(version.body).entries())
313
+ await tx.getRepository(regulation_1.RegulationClause).save({ domain, version, rank, ...one });
314
+ }
271
315
  /** Takes back a version in approval - it is being written again. */
272
316
  async function withdrawRegulationVersion(id, context) {
273
317
  const { domain, user, tx } = context.state;
@@ -320,10 +364,7 @@ async function adopt(version, context) {
320
364
  version.adoptedBy = user;
321
365
  version.adoptionNote = null;
322
366
  const saved = await tx.getRepository(regulation_1.RegulationVersion).save(version);
323
- const clauses = (0, regulation_rules_1.clausesOf)(saved.body);
324
- await tx.getRepository(regulation_1.RegulationClause).delete({ version: { id: saved.id } });
325
- for (const [rank, one] of clauses.entries())
326
- await tx.getRepository(regulation_1.RegulationClause).save({ domain, version: saved, rank, ...one });
367
+ await keepClauses(saved, context);
327
368
  const regulation = version.regulation;
328
369
  const announcement = await (0, announcement_1.announce)(context, {
329
370
  trigger: exports.REGULATION_ADOPTED_TRIGGER,