@things-factory/ops-master 10.1.314 → 10.1.316
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.
- package/dist-client/pages/master/electricity-tariff-band.d.ts +13 -0
- package/dist-client/pages/master/electricity-tariff-band.js +50 -0
- package/dist-client/pages/master/electricity-tariff.d.ts +10 -0
- package/dist-client/pages/master/electricity-tariff.js +41 -0
- package/dist-client/pages/master/master-options.d.ts +4 -0
- package/dist-client/pages/master/master-options.js +13 -0
- package/dist-client/pages/master/reference-targets.js +1 -0
- package/dist-client/pages/master-axes.d.ts +1 -1
- package/dist-client/pages/master-axes.js +3 -1
- package/dist-client/route.js +6 -0
- package/dist-server/service/energy/electricity-tariff-band.d.ts +54 -0
- package/dist-server/service/energy/electricity-tariff-band.js +141 -0
- package/dist-server/service/energy/electricity-tariff-resolver.d.ts +37 -0
- package/dist-server/service/energy/electricity-tariff-resolver.js +203 -0
- package/dist-server/service/energy/electricity-tariff.d.ts +57 -0
- package/dist-server/service/energy/electricity-tariff.js +127 -0
- package/dist-server/service/energy/index.d.ts +5 -0
- package/dist-server/service/energy/index.js +9 -0
- package/dist-server/service/energy/tariff-rules.d.ts +163 -0
- package/dist-server/service/energy/tariff-rules.js +395 -0
- package/dist-server/service/index.d.ts +5 -2
- package/dist-server/service/index.js +6 -0
- package/dist-server/service/master-axis.js +8 -0
- package/dist-server/service/recipe/index.d.ts +1 -1
- package/dist-server/service/recipe/recipe-revision.d.ts +1 -1
- package/dist-server/service/status/master-status.js +5 -1
- package/helps/ops-master/electricity-tariff-band.ko.md +16 -0
- package/helps/ops-master/electricity-tariff-band.md +16 -0
- package/helps/ops-master/electricity-tariff.ko.md +16 -0
- package/helps/ops-master/electricity-tariff.md +16 -0
- package/package.json +5 -5
- package/translations/en.json +40 -1
- package/translations/es.json +40 -1
- package/translations/ja.json +40 -1
- package/translations/ko.json +40 -1
- package/translations/ms.json +40 -1
- package/translations/zh.json +40 -1
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* ── 임시 사본 (2026-11-27) ───────────────────────────────────────────────────
|
|
4
|
+
* 이 파일은 `@operato/ops-contract` 의 `src/tariff.ts` 를 **글자 그대로** 옮긴 것이다. 규칙의 주인은 계약이다 — 트윈이 구간 단가로
|
|
5
|
+
* 요금을 셀 때 ops-master 화면과 같은 답을 내야 하므로(ADR-0239 결정 7, 계약 세션과 합의).
|
|
6
|
+
* 계약 0.9.48 이 발행되면 **이 파일을 지우고** `@operato/ops-contract` 에서 가져온다. 그때까지 여기서 고치지 않는다 — 계약을 고친다.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* **Electricity tariff rules** — the words of a time-of-use tariff and how to read it.
|
|
10
|
+
*
|
|
11
|
+
* ── Why this is in the contract (2026-11-27) ────────────────────────────────────────────────────────────────────
|
|
12
|
+
* The tariff is site master data and is stored by ops-master (`ElectricityTariff` · `ElectricityTariffBand`). What
|
|
13
|
+
* lives here is the reading: which band applies at a moment, and whether a tariff's bands cover every day. Once the
|
|
14
|
+
* twin prices usage per band (the kernel's `electricityCost({ energyChargeFromPeriods })`), ops-master's screen and the
|
|
15
|
+
* twin must give the same answer for the same moment - a rule two implementations share belongs to the contract.
|
|
16
|
+
* Storage, approval and screens stay with ops-master.
|
|
17
|
+
*
|
|
18
|
+
* Field names are the declaration's (`EMS_DECLARATION` `tariff.*`): `demandChargePerKW`, `energyChargePerKWh`,
|
|
19
|
+
* `currency`. The contract power (`contract.kW`) and billing demand (`tariff.billingDemandKW`) are not tariff rows -
|
|
20
|
+
* one is a property of the supply point, the other a per-cycle fact from the supplier.
|
|
21
|
+
*
|
|
22
|
+
* ── Which price wins ────────────────────────────────────────────────────────────────────────────────────────────
|
|
23
|
+
* A source fact's own price (`EnergyUsagePeriodData.unitPrice`) is what was charged; it wins. A band price from the
|
|
24
|
+
* master is used only for a period whose fact carries no price. The master is a declaration, the fact an observation.
|
|
25
|
+
*
|
|
26
|
+
* ── Times are the site's wall clock ─────────────────────────────────────────────────────────────────────────────
|
|
27
|
+
* Bands are set in local time ("weekdays 09:00-10:00 are on-peak"). These functions do not know time zones: the
|
|
28
|
+
* caller converts an instant to the site's month, day, weekday and minute (`LocalMoment`). Cutting in UTC would make
|
|
29
|
+
* Seoul's 09:00 into 00:00.
|
|
30
|
+
*
|
|
31
|
+
* ── A band does not cross midnight ──────────────────────────────────────────────────────────────────────────────
|
|
32
|
+
* "22:00-08:00 off-peak" is written as two rows (22:00-24:00, 00:00-08:00). A single row would have to say which day
|
|
33
|
+
* it belongs to (does Saturday night run into Sunday morning?), and tariffs answer that differently.
|
|
34
|
+
*
|
|
35
|
+
* ── A new country is rows, not code (2026-11-27) ───────────────────────────────────────────────────────────────
|
|
36
|
+
* Tariff systems differ by country and supplier: how many bands and what they are called, whether a holiday is priced
|
|
37
|
+
* like Sunday, whether demand is charged per band, which days are holidays. A new country must be written as tariff,
|
|
38
|
+
* band and calendar rows - never as a change here, in the kernel or on a screen. So:
|
|
39
|
+
* · the band **code** is the tariff's own (`base` · `intermedia` · `punta`, `super-off-peak` …); only its
|
|
40
|
+
* **load class** - for comparing across tariffs - is a closed, ordered vocabulary (`TARIFF_LOAD_CLASSES`);
|
|
41
|
+
* · `sunday` and `holiday` are separate day kinds; a tariff pricing them alike writes two rows;
|
|
42
|
+
* · the tariff's `demandChargePerKW` is the facility demand charge (any time); a band may carry its own
|
|
43
|
+
* time-of-use `demandChargePerKW`;
|
|
44
|
+
* · the tariff names its holiday calendar (`holidayCalendar`); the calendar's days are not in the contract - the
|
|
45
|
+
* caller passes `isHoliday`.
|
|
46
|
+
* Season bounds are fixed `MM-DD`. A tariff whose season moves each year ("from the first Sunday of April") is written
|
|
47
|
+
* as one tariff per year with its effective dates - not yet seen to need more (to check against CFE tariffs).
|
|
48
|
+
*
|
|
49
|
+
* ── Issues are structured ───────────────────────────────────────────────────────────────────────────────────────
|
|
50
|
+
* Checks return `{ field, code, params }`, not sentences: a screen turns the code into its own language, and
|
|
51
|
+
* `tariffIssueText` gives the one-line English `field: reason` other contract checks use.
|
|
52
|
+
*/
|
|
53
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
+
exports.TARIFF_ISSUE_CODES = exports.TARIFF_DAY_KINDS = exports.TARIFF_LOAD_CLASSES = void 0;
|
|
55
|
+
exports.tariffIssueText = tariffIssueText;
|
|
56
|
+
exports.isIso4217Code = isIso4217Code;
|
|
57
|
+
exports.minutesOf = minutesOf;
|
|
58
|
+
exports.dayOfYearOf = dayOfYearOf;
|
|
59
|
+
exports.tariffIssues = tariffIssues;
|
|
60
|
+
exports.tariffBandIssues = tariffBandIssues;
|
|
61
|
+
exports.activeBands = activeBands;
|
|
62
|
+
exports.tariffCoverageIssues = tariffCoverageIssues;
|
|
63
|
+
exports.bandAt = bandAt;
|
|
64
|
+
/**
|
|
65
|
+
* Load class of a band - **ordered from lightest to heaviest load**, for comparing bands across tariffs
|
|
66
|
+
* ("how much is shifted out of the heaviest hours"). The band's own code is the tariff's: Mexico's `base` ·
|
|
67
|
+
* `intermedia` · `punta` are classed `off-peak` · `mid-peak` · `on-peak`; a US `super-off-peak` band is that class.
|
|
68
|
+
*/
|
|
69
|
+
exports.TARIFF_LOAD_CLASSES = ['super-off-peak', 'off-peak', 'mid-peak', 'on-peak'];
|
|
70
|
+
/**
|
|
71
|
+
* Which days a band applies to. `all` ignores the day.
|
|
72
|
+
*
|
|
73
|
+
* `holiday` is a day of the tariff's holiday calendar (`holidayCalendar`) and **comes before the weekday**: a holiday
|
|
74
|
+
* falling on a Saturday is a holiday. A tariff that prices holidays like Sundays writes a `sunday` row and a `holiday`
|
|
75
|
+
* row. A tariff with no `holiday` row does not price holidays apart - its holidays are read as their weekday.
|
|
76
|
+
*/
|
|
77
|
+
exports.TARIFF_DAY_KINDS = ['all', 'weekday', 'saturday', 'sunday', 'holiday'];
|
|
78
|
+
/** The kinds a concrete day can be - every day is exactly one of these. */
|
|
79
|
+
const CONCRETE_DAY_KINDS = ['weekday', 'saturday', 'sunday', 'holiday'];
|
|
80
|
+
exports.TARIFF_ISSUE_CODES = [
|
|
81
|
+
/** A required field is empty. */
|
|
82
|
+
'required',
|
|
83
|
+
/** An amount is not a number. */
|
|
84
|
+
'not-a-number',
|
|
85
|
+
/** An amount is below zero. */
|
|
86
|
+
'negative',
|
|
87
|
+
/** A value is outside its vocabulary - `params.allowed`. */
|
|
88
|
+
'not-in-vocabulary',
|
|
89
|
+
/** A text is not in its format - `params.format`. */
|
|
90
|
+
'format',
|
|
91
|
+
/** An amount is written without a currency. */
|
|
92
|
+
'currency-required',
|
|
93
|
+
/** Season start and end must be written together or both left empty. */
|
|
94
|
+
'season-pair',
|
|
95
|
+
/** End time is not after the start - a band crossing midnight is two rows. */
|
|
96
|
+
'end-not-after-start',
|
|
97
|
+
/** The tariff has bands and a flat energy charge - which one prices an hour cannot be said. */
|
|
98
|
+
'flat-and-bands',
|
|
99
|
+
/** `params.count` bands break the row rules and were left out of the coverage check. */
|
|
100
|
+
'broken-bands',
|
|
101
|
+
/** No band covers `params.from`..`params.to` on `params.dayKind` days `params.days`. */
|
|
102
|
+
'gap',
|
|
103
|
+
/** Bands `params.bands` overlap `params.from`..`params.to` on `params.dayKind` days `params.days`. */
|
|
104
|
+
'overlap'
|
|
105
|
+
];
|
|
106
|
+
/** One English line, `field: reason` - the form other contract checks use. */
|
|
107
|
+
function tariffIssueText(issue) {
|
|
108
|
+
const p = issue.params ?? {};
|
|
109
|
+
switch (issue.code) {
|
|
110
|
+
case 'required':
|
|
111
|
+
return `${issue.field}: required${p.because ? ` (${p.because})` : ''}`;
|
|
112
|
+
case 'not-a-number':
|
|
113
|
+
return `${issue.field}: not a number (${p.value})`;
|
|
114
|
+
case 'negative':
|
|
115
|
+
return `${issue.field}: must be 0 or more (${p.value})`;
|
|
116
|
+
case 'not-in-vocabulary':
|
|
117
|
+
return `${issue.field}: must be one of ${p.allowed} ("${p.value}")`;
|
|
118
|
+
case 'format':
|
|
119
|
+
return `${issue.field}: must be ${p.format} ("${p.value}")`;
|
|
120
|
+
case 'currency-required':
|
|
121
|
+
return `${issue.field}: required when an amount is written`;
|
|
122
|
+
case 'season-pair':
|
|
123
|
+
return `${issue.field}: seasonFrom and seasonTo go together, or both empty for all year`;
|
|
124
|
+
case 'end-not-after-start':
|
|
125
|
+
return `${issue.field}: must be after fromTime (${p.from}~${p.to}); a band crossing midnight is two rows`;
|
|
126
|
+
case 'flat-and-bands':
|
|
127
|
+
return `${issue.field}: the tariff has bands - leave its flat charge empty`;
|
|
128
|
+
case 'broken-bands':
|
|
129
|
+
return `${issue.field}: ${p.count} band(s) break the row rules and were left out`;
|
|
130
|
+
case 'gap':
|
|
131
|
+
return `${issue.field}: ${p.dayKind} ${p.days} - no band ${p.from}~${p.to}`;
|
|
132
|
+
case 'overlap':
|
|
133
|
+
return `${issue.field}: ${p.dayKind} ${p.days} - ${p.bands} overlap ${p.from}~${p.to}`;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
const empty = (v) => v === undefined || v === null || (typeof v === 'string' && v.trim() === '');
|
|
137
|
+
/** An ISO 4217 code - three upper-case letters (KRW, USD). */
|
|
138
|
+
function isIso4217Code(value) {
|
|
139
|
+
return typeof value === 'string' && /^[A-Z]{3}$/.test(value);
|
|
140
|
+
}
|
|
141
|
+
/** An amount field - empty gives `undefined`; not a number or below zero is an issue. */
|
|
142
|
+
function amountOf(v, field, issues) {
|
|
143
|
+
if (empty(v))
|
|
144
|
+
return undefined;
|
|
145
|
+
const n = Number(v);
|
|
146
|
+
if (!Number.isFinite(n)) {
|
|
147
|
+
issues.push({ field, code: 'not-a-number', params: { value: String(v) } });
|
|
148
|
+
return undefined;
|
|
149
|
+
}
|
|
150
|
+
if (n < 0) {
|
|
151
|
+
issues.push({ field, code: 'negative', params: { value: n } });
|
|
152
|
+
return undefined;
|
|
153
|
+
}
|
|
154
|
+
return n;
|
|
155
|
+
}
|
|
156
|
+
/** `HH:mm` → minutes from midnight. `24:00` is 1440 and is only an end. */
|
|
157
|
+
function minutesOf(text) {
|
|
158
|
+
const m = /^(\d{2}):(\d{2})$/.exec(String(text ?? '').trim());
|
|
159
|
+
if (!m)
|
|
160
|
+
return undefined;
|
|
161
|
+
const h = Number(m[1]);
|
|
162
|
+
const min = Number(m[2]);
|
|
163
|
+
if (min > 59)
|
|
164
|
+
return undefined;
|
|
165
|
+
if (h === 24 && min === 0)
|
|
166
|
+
return 1440;
|
|
167
|
+
if (h > 23)
|
|
168
|
+
return undefined;
|
|
169
|
+
return h * 60 + min;
|
|
170
|
+
}
|
|
171
|
+
const DAYS_IN_MONTH = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
172
|
+
/** `MM-DD` → day of a leap year (0..365). Takes 02-29 - that day too must fall in some season. */
|
|
173
|
+
function dayOfYearOf(text) {
|
|
174
|
+
const m = /^(\d{2})-(\d{2})$/.exec(String(text ?? '').trim());
|
|
175
|
+
if (!m)
|
|
176
|
+
return undefined;
|
|
177
|
+
const month = Number(m[1]);
|
|
178
|
+
const day = Number(m[2]);
|
|
179
|
+
if (month < 1 || month > 12 || day < 1 || day > DAYS_IN_MONTH[month - 1])
|
|
180
|
+
return undefined;
|
|
181
|
+
let n = 0;
|
|
182
|
+
for (let i = 0; i < month - 1; i++)
|
|
183
|
+
n += DAYS_IN_MONTH[i];
|
|
184
|
+
return n + day - 1;
|
|
185
|
+
}
|
|
186
|
+
/** One tariff row, before it is saved. Empty when it is sound. */
|
|
187
|
+
function tariffIssues(row) {
|
|
188
|
+
const issues = [];
|
|
189
|
+
const d = amountOf(row.demandChargePerKW, 'demandChargePerKW', issues);
|
|
190
|
+
const e = amountOf(row.energyChargePerKWh, 'energyChargePerKWh', issues);
|
|
191
|
+
const currency = String(row.currency ?? '').trim();
|
|
192
|
+
/* An amount without a unit cannot be added to another amount - the same rule as the energy ingest. */
|
|
193
|
+
if ((d !== undefined || e !== undefined) && !currency)
|
|
194
|
+
issues.push({ field: 'currency', code: 'currency-required' });
|
|
195
|
+
if (currency && !isIso4217Code(currency))
|
|
196
|
+
issues.push({ field: 'currency', code: 'format', params: { format: 'ISO 4217 (KRW, USD)', value: currency } });
|
|
197
|
+
return issues;
|
|
198
|
+
}
|
|
199
|
+
/** One band row, before it is saved. Whether bands cover the day cannot be seen from one row - `tariffCoverageIssues`. */
|
|
200
|
+
function tariffBandIssues(row) {
|
|
201
|
+
const issues = [];
|
|
202
|
+
if (empty(row.tariffName))
|
|
203
|
+
issues.push({ field: 'tariffName', code: 'required' });
|
|
204
|
+
if (empty(row.band))
|
|
205
|
+
issues.push({ field: 'band', code: 'required' });
|
|
206
|
+
const loadClass = String(row.loadClass ?? '').trim();
|
|
207
|
+
if (!loadClass)
|
|
208
|
+
issues.push({ field: 'loadClass', code: 'required' });
|
|
209
|
+
else if (!exports.TARIFF_LOAD_CLASSES.includes(loadClass)) {
|
|
210
|
+
issues.push({ field: 'loadClass', code: 'not-in-vocabulary', params: { allowed: exports.TARIFF_LOAD_CLASSES.join('|'), value: loadClass } });
|
|
211
|
+
}
|
|
212
|
+
const dayKind = empty(row.dayKind) ? 'all' : String(row.dayKind).trim();
|
|
213
|
+
if (!exports.TARIFF_DAY_KINDS.includes(dayKind)) {
|
|
214
|
+
issues.push({ field: 'dayKind', code: 'not-in-vocabulary', params: { allowed: exports.TARIFF_DAY_KINDS.join('|'), value: dayKind } });
|
|
215
|
+
}
|
|
216
|
+
const sFromEmpty = empty(row.seasonFrom);
|
|
217
|
+
const sToEmpty = empty(row.seasonTo);
|
|
218
|
+
if (sFromEmpty !== sToEmpty)
|
|
219
|
+
issues.push({ field: sFromEmpty ? 'seasonFrom' : 'seasonTo', code: 'season-pair' });
|
|
220
|
+
if (!sFromEmpty && dayOfYearOf(row.seasonFrom) === undefined)
|
|
221
|
+
issues.push({ field: 'seasonFrom', code: 'format', params: { format: 'MM-DD', value: String(row.seasonFrom) } });
|
|
222
|
+
if (!sToEmpty && dayOfYearOf(row.seasonTo) === undefined)
|
|
223
|
+
issues.push({ field: 'seasonTo', code: 'format', params: { format: 'MM-DD', value: String(row.seasonTo) } });
|
|
224
|
+
const from = minutesOf(row.fromTime);
|
|
225
|
+
const to = minutesOf(row.toTime);
|
|
226
|
+
if (from === undefined || from === 1440)
|
|
227
|
+
issues.push({ field: 'fromTime', code: 'format', params: { format: 'HH:mm 00:00..23:59', value: String(row.fromTime ?? '') } });
|
|
228
|
+
if (to === undefined || to === 0)
|
|
229
|
+
issues.push({ field: 'toTime', code: 'format', params: { format: 'HH:mm 00:01..24:00', value: String(row.toTime ?? '') } });
|
|
230
|
+
if (from !== undefined && to !== undefined && from < 1440 && to > 0 && from >= to) {
|
|
231
|
+
issues.push({ field: 'toTime', code: 'end-not-after-start', params: { from: String(row.fromTime), to: String(row.toTime) } });
|
|
232
|
+
}
|
|
233
|
+
/* A band without a price cannot price its hours. */
|
|
234
|
+
if (empty(row.energyChargePerKWh))
|
|
235
|
+
issues.push({ field: 'energyChargePerKWh', code: 'required' });
|
|
236
|
+
else
|
|
237
|
+
amountOf(row.energyChargePerKWh, 'energyChargePerKWh', issues);
|
|
238
|
+
amountOf(row.demandChargePerKW, 'demandChargePerKW', issues);
|
|
239
|
+
return issues;
|
|
240
|
+
}
|
|
241
|
+
/** Whether a season holds that day - takes a season wrapping the year. An empty season is all year. */
|
|
242
|
+
function seasonHas(band, dayOfYear) {
|
|
243
|
+
if (empty(band.seasonFrom) && empty(band.seasonTo))
|
|
244
|
+
return true;
|
|
245
|
+
const from = dayOfYearOf(band.seasonFrom);
|
|
246
|
+
const to = dayOfYearOf(band.seasonTo);
|
|
247
|
+
if (from === undefined || to === undefined)
|
|
248
|
+
return false;
|
|
249
|
+
return from <= to ? dayOfYear >= from && dayOfYear <= to : dayOfYear >= from || dayOfYear <= to;
|
|
250
|
+
}
|
|
251
|
+
/** Whether a tariff prices holidays apart - some band names the `holiday` day kind. */
|
|
252
|
+
function pricesHolidays(bands) {
|
|
253
|
+
return bands.some(b => String(b.dayKind ?? '').trim() === 'holiday');
|
|
254
|
+
}
|
|
255
|
+
/** The kind of a concrete day. A holiday comes before the weekday, but only for a tariff that prices holidays apart. */
|
|
256
|
+
function dayKindOf(at, holidays, isHoliday) {
|
|
257
|
+
if (holidays && isHoliday?.(at.month, at.day))
|
|
258
|
+
return 'holiday';
|
|
259
|
+
return at.weekday === 0 ? 'sunday' : at.weekday === 6 ? 'saturday' : 'weekday';
|
|
260
|
+
}
|
|
261
|
+
function dayKindHas(band, kind) {
|
|
262
|
+
const k = empty(band.dayKind) ? 'all' : String(band.dayKind).trim();
|
|
263
|
+
return k === 'all' || k === kind;
|
|
264
|
+
}
|
|
265
|
+
/** Bands still in force at `at` - a band whose end has passed was retired (rows are ended, not deleted). */
|
|
266
|
+
function activeBands(bands, at) {
|
|
267
|
+
return bands.filter(b => empty(b.effectiveEnd) || new Date(b.effectiveEnd).getTime() > at.getTime());
|
|
268
|
+
}
|
|
269
|
+
const hhmm = (m) => `${String(Math.floor(m / 60)).padStart(2, '0')}:${String(m % 60).padStart(2, '0')}`;
|
|
270
|
+
function mmdd(dayOfYear) {
|
|
271
|
+
let month = 0;
|
|
272
|
+
let rest = dayOfYear;
|
|
273
|
+
while (rest >= DAYS_IN_MONTH[month])
|
|
274
|
+
rest -= DAYS_IN_MONTH[month++];
|
|
275
|
+
return `${String(month + 1).padStart(2, '0')}-${String(rest + 1).padStart(2, '0')}`;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Whether one tariff's bands cover **every minute of every day, once**.
|
|
279
|
+
*
|
|
280
|
+
* Looks at all 366 days of a leap year × the concrete day kinds (weekday, saturday, sunday, and holiday when the tariff
|
|
281
|
+
* prices holidays apart). An uncovered hour cannot be priced; an hour
|
|
282
|
+
* covered twice has two prices - either way its charge would be invented. The same problem over consecutive days is
|
|
283
|
+
* one issue (`params.days` like `06-01~08-31`).
|
|
284
|
+
*
|
|
285
|
+
* No bands is not an issue - it is a flat tariff (the tariff row's `energyChargePerKWh`). A tariff passes through
|
|
286
|
+
* wrong states while it is edited, so a screen shows this rather than refusing to save.
|
|
287
|
+
*/
|
|
288
|
+
function tariffCoverageIssues(tariff, bands) {
|
|
289
|
+
const issues = [];
|
|
290
|
+
if (!bands.length)
|
|
291
|
+
return issues;
|
|
292
|
+
const usable = bands.filter(b => tariffBandIssues(b).length === 0);
|
|
293
|
+
if (!empty(tariff.energyChargePerKWh))
|
|
294
|
+
issues.push({ field: 'energyChargePerKWh', code: 'flat-and-bands' });
|
|
295
|
+
/* Band prices are in the tariff's currency - a band amount without one cannot be added to anything. */
|
|
296
|
+
if (!String(tariff.currency ?? '').trim())
|
|
297
|
+
issues.push({ field: 'currency', code: 'currency-required' });
|
|
298
|
+
const holidays = pricesHolidays(usable);
|
|
299
|
+
if (holidays && empty(tariff.holidayCalendar)) {
|
|
300
|
+
issues.push({ field: 'holidayCalendar', code: 'required', params: { because: 'the tariff has holiday bands' } });
|
|
301
|
+
}
|
|
302
|
+
const broken = bands.length - usable.length;
|
|
303
|
+
if (broken)
|
|
304
|
+
issues.push({ field: 'bands', code: 'broken-bands', params: { count: broken } });
|
|
305
|
+
/* (day kind, problem) → the days it happened, in order */
|
|
306
|
+
const seen = new Map();
|
|
307
|
+
const note = (kind, day, code, from, to, names) => {
|
|
308
|
+
const key = [kind, code, from, to, names ?? ''].join('\u0000');
|
|
309
|
+
const entry = seen.get(key);
|
|
310
|
+
if (entry)
|
|
311
|
+
entry.days.push(day);
|
|
312
|
+
else {
|
|
313
|
+
const params = { dayKind: kind, from: hhmm(from), to: hhmm(to) };
|
|
314
|
+
if (names)
|
|
315
|
+
params.bands = names;
|
|
316
|
+
seen.set(key, { problem: { field: 'bands', code, params }, days: [day] });
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
/* A tariff that does not price holidays apart has no holiday to cover - its holidays are their weekdays. */
|
|
320
|
+
for (const kind of CONCRETE_DAY_KINDS.filter(k => k !== 'holiday' || holidays)) {
|
|
321
|
+
for (let day = 0; day < 366; day++) {
|
|
322
|
+
const today = usable
|
|
323
|
+
.filter(b => seasonHas(b, day) && dayKindHas(b, kind))
|
|
324
|
+
.map(b => ({ name: String(b.name ?? ''), from: minutesOf(b.fromTime), to: minutesOf(b.toTime) }))
|
|
325
|
+
.sort((a, b) => a.from - b.from || a.to - b.to);
|
|
326
|
+
let cursor = 0;
|
|
327
|
+
let last;
|
|
328
|
+
for (const b of today) {
|
|
329
|
+
if (b.from > cursor)
|
|
330
|
+
note(kind, day, 'gap', cursor, b.from);
|
|
331
|
+
if (last && b.from < last.to)
|
|
332
|
+
note(kind, day, 'overlap', b.from, Math.min(last.to, b.to), `${last.name}·${b.name}`);
|
|
333
|
+
if (b.to > cursor) {
|
|
334
|
+
cursor = b.to;
|
|
335
|
+
last = b;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
if (cursor < 1440)
|
|
339
|
+
note(kind, day, 'gap', cursor, 1440);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
for (const { problem, days } of seen.values()) {
|
|
343
|
+
const spans = [];
|
|
344
|
+
let start = days[0];
|
|
345
|
+
let prev = days[0];
|
|
346
|
+
for (const d of [...days.slice(1), Infinity]) {
|
|
347
|
+
if (d === prev + 1) {
|
|
348
|
+
prev = d;
|
|
349
|
+
continue;
|
|
350
|
+
}
|
|
351
|
+
spans.push(start === prev ? mmdd(start) : `${mmdd(start)}~${mmdd(prev)}`);
|
|
352
|
+
start = prev = d;
|
|
353
|
+
}
|
|
354
|
+
issues.push({ ...problem, params: { ...problem.params, days: spans.join(', ') } });
|
|
355
|
+
}
|
|
356
|
+
return issues;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* The energy charge at this moment.
|
|
360
|
+
*
|
|
361
|
+
* Without bands the tariff's flat charge applies. With bands **exactly one** must match - none is `no-band`, more than
|
|
362
|
+
* one is `ambiguous`, and no price is picked (taking the first written would be chance).
|
|
363
|
+
*/
|
|
364
|
+
function bandAt(tariff, bands, at, isHoliday) {
|
|
365
|
+
const currency = String(tariff.currency ?? '').trim() || undefined;
|
|
366
|
+
const usable = bands.filter(b => tariffBandIssues(b).length === 0);
|
|
367
|
+
if (!usable.length) {
|
|
368
|
+
const flat = empty(tariff.energyChargePerKWh) ? NaN : Number(tariff.energyChargePerKWh);
|
|
369
|
+
if (!Number.isFinite(flat))
|
|
370
|
+
return { reason: 'no-price' };
|
|
371
|
+
return { energyChargePerKWh: flat, ...(currency ? { currency } : {}), holidayKnown: true };
|
|
372
|
+
}
|
|
373
|
+
const day = dayOfYearOf(`${String(at.month).padStart(2, '0')}-${String(at.day).padStart(2, '0')}`);
|
|
374
|
+
if (day === undefined)
|
|
375
|
+
return { reason: 'no-band' };
|
|
376
|
+
const holidays = pricesHolidays(usable);
|
|
377
|
+
const kind = dayKindOf(at, holidays, isHoliday);
|
|
378
|
+
const hits = usable.filter(b => seasonHas(b, day) && dayKindHas(b, kind) && minutesOf(b.fromTime) <= at.minutes && at.minutes < minutesOf(b.toTime));
|
|
379
|
+
if (!hits.length)
|
|
380
|
+
return { reason: 'no-band' };
|
|
381
|
+
if (hits.length > 1)
|
|
382
|
+
return { reason: 'ambiguous', bands: hits.map(b => String(b.name ?? '')) };
|
|
383
|
+
const hit = hits[0];
|
|
384
|
+
const demand = empty(hit.demandChargePerKW) ? undefined : Number(hit.demandChargePerKW);
|
|
385
|
+
return {
|
|
386
|
+
bandName: String(hit.name ?? '') || undefined,
|
|
387
|
+
band: String(hit.band).trim(),
|
|
388
|
+
loadClass: String(hit.loadClass).trim(),
|
|
389
|
+
energyChargePerKWh: Number(hit.energyChargePerKWh),
|
|
390
|
+
...(demand !== undefined ? { demandChargePerKW: demand } : {}),
|
|
391
|
+
...(currency ? { currency } : {}),
|
|
392
|
+
holidayKnown: !holidays || !!isHoliday
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
//# sourceMappingURL=tariff-rules.js.map
|
|
@@ -71,14 +71,17 @@ export * from './test-spec/test-spec-query';
|
|
|
71
71
|
export * from './status/axis-stamp';
|
|
72
72
|
export * from './status/master-status';
|
|
73
73
|
export * from './quality/nonconformance-cause';
|
|
74
|
+
export * from './energy/electricity-tariff';
|
|
75
|
+
export * from './energy/electricity-tariff-band';
|
|
76
|
+
export * from './energy/tariff-rules';
|
|
74
77
|
import { MasterConformanceResolver } from './master-conformance-resolver';
|
|
75
78
|
import { MasterChangePolicy, MasterChangePolicyResolver } from './master-change-policy';
|
|
76
79
|
import { MasterValueClaim } from './assignment/master-value-claim';
|
|
77
80
|
import { SiteOfSystemSubscriber } from './location/sites-of-system';
|
|
78
81
|
export declare const subscribers: (typeof SiteOfSystemSubscriber)[];
|
|
79
|
-
export declare const entities: (typeof import("./equipment/equipment").Equipment | typeof import("./equipment/equipment-class").EquipmentClass | typeof import("./quality/nonconformance-cause").NonconformanceCause | typeof import("./material/material-definition").MaterialDefinition | typeof import("./operation/operation-definition").OperationDefinition | typeof import("./location/operational-location").OperationalLocation | typeof import("./personnel/person").Person | typeof import("./asset/physical-asset").PhysicalAsset | typeof import("./recipe").RecipeDefinition | typeof import("./recipe").RouteDefinition | typeof import("./test-spec/test-specification").TestSpecification | typeof MasterChangePolicy | typeof import("./material/material-revision").MaterialDefinitionRevision | typeof import("./material/material-revision").MaterialDefinitionPlan | typeof import("./material/material-revision").MaterialDefinitionSegment | typeof import("./material/material-revision").MaterialDefinitionBasis | typeof import("./recipe/recipe-revision").RecipeRevision | typeof import("./recipe/recipe-revision").
|
|
82
|
+
export declare const entities: (typeof import("./equipment/equipment").Equipment | typeof import("./equipment/equipment-class").EquipmentClass | typeof import("./quality/nonconformance-cause").NonconformanceCause | typeof import("./energy/electricity-tariff").ElectricityTariff | typeof import("./energy/electricity-tariff-band").ElectricityTariffBand | typeof import("./material/material-definition").MaterialDefinition | typeof import("./operation/operation-definition").OperationDefinition | typeof import("./location/operational-location").OperationalLocation | typeof import("./personnel/person").Person | typeof import("./asset/physical-asset").PhysicalAsset | typeof import("./recipe").RecipeDefinition | typeof import("./recipe").RouteDefinition | typeof import("./test-spec/test-specification").TestSpecification | typeof MasterChangePolicy | typeof import("./material/material-revision").MaterialDefinitionRevision | typeof import("./material/material-revision").MaterialDefinitionPlan | typeof import("./material/material-revision").MaterialDefinitionSegment | typeof import("./material/material-revision").MaterialDefinitionBasis | typeof import("./recipe/recipe-revision").RecipeRevision | typeof import("./recipe/recipe-revision-line").RecipeRevisionOutput | typeof import("./recipe/recipe-revision").RecipePlan | typeof import("./recipe/recipe-revision").RecipeSegment | typeof import("./recipe/recipe-revision").RecipeBasis | typeof import("./test-spec/test-spec-revision").TestSpecificationRevision | typeof import("./test-spec/test-spec-revision").TestSpecificationPlan | typeof import("./test-spec/test-spec-revision").TestSpecificationSegment | typeof import("./test-spec/test-spec-revision").TestSpecificationBasis | typeof MasterValueClaim)[];
|
|
80
83
|
export declare const schema: {
|
|
81
|
-
resolverClasses: (typeof MasterChangePolicyResolver | typeof import("./personnel/personnel-master-resolver").PersonnelClassResolver | typeof import("./personnel/personnel-master-resolver").PersonResolver | typeof import("./equipment/equipment-master-resolver").EquipmentClassResolver | typeof import("./equipment/equipment-master-resolver").EquipmentResolver | typeof import("./equipment/equipment-master-resolver").StopReasonResolver | typeof import("./asset/asset-master-resolver").PhysicalAssetClassResolver | typeof import("./asset/asset-master-resolver").PhysicalAssetResolver | typeof import("./material/material-master-resolver").MaterialClassResolver | typeof import("./material/material-master-resolver").MaterialDefinitionResolver | typeof import("./location/location-master-resolver").OperationalLocationResolver | typeof import("./operation/operation-master-resolver").OperationDefinitionResolver | typeof import("./recipe/recipe-master-resolver").RecipeDefinitionResolver | typeof import("./recipe/recipe-master-resolver").RouteDefinitionResolver | typeof import("./test-spec/test-spec-master-resolver").TestSpecificationResolver | typeof import("./master-change-approval").MasterChangeApprovalResolver | typeof MasterConformanceResolver | typeof import("./personnel/personnel-query").PersonnelQuery | typeof import("./equipment/equipment-query").EquipmentQuery | typeof import("./asset/asset-query").AssetQuery | typeof import("./location/location-query").LocationQuery | typeof import("./material/material-revision-resolver").MaterialDefinitionRevisionResolver | typeof import("./material/material-query").MaterialQuery | typeof import("./operation/operation-query").OperationQuery | typeof import("./operation/operation-readiness-resolver").OperationReadinessResolver | typeof import("./recipe/recipe-revision-resolver").RecipeRevisionResolver | typeof import("./recipe/recipe-query").RecipeQuery | typeof import("./test-spec/test-spec-revision-resolver").TestSpecificationRevisionResolver | typeof import("./test-spec/test-spec-query").TestSpecificationQuery | typeof import("./status/master-status").OpsMasterStatusQuery | typeof import("./equipment/stop-reason-query").StopReasonQuery | typeof import("./quality/nonconformance-cause-resolver").NonconformanceCauseResolver)[];
|
|
84
|
+
resolverClasses: (typeof MasterChangePolicyResolver | typeof import("./personnel/personnel-master-resolver").PersonnelClassResolver | typeof import("./personnel/personnel-master-resolver").PersonResolver | typeof import("./equipment/equipment-master-resolver").EquipmentClassResolver | typeof import("./equipment/equipment-master-resolver").EquipmentResolver | typeof import("./equipment/equipment-master-resolver").StopReasonResolver | typeof import("./asset/asset-master-resolver").PhysicalAssetClassResolver | typeof import("./asset/asset-master-resolver").PhysicalAssetResolver | typeof import("./material/material-master-resolver").MaterialClassResolver | typeof import("./material/material-master-resolver").MaterialDefinitionResolver | typeof import("./location/location-master-resolver").OperationalLocationResolver | typeof import("./operation/operation-master-resolver").OperationDefinitionResolver | typeof import("./recipe/recipe-master-resolver").RecipeDefinitionResolver | typeof import("./recipe/recipe-master-resolver").RouteDefinitionResolver | typeof import("./test-spec/test-spec-master-resolver").TestSpecificationResolver | typeof import("./master-change-approval").MasterChangeApprovalResolver | typeof MasterConformanceResolver | typeof import("./personnel/personnel-query").PersonnelQuery | typeof import("./equipment/equipment-query").EquipmentQuery | typeof import("./asset/asset-query").AssetQuery | typeof import("./location/location-query").LocationQuery | typeof import("./material/material-revision-resolver").MaterialDefinitionRevisionResolver | typeof import("./material/material-query").MaterialQuery | typeof import("./operation/operation-query").OperationQuery | typeof import("./operation/operation-readiness-resolver").OperationReadinessResolver | typeof import("./recipe/recipe-revision-resolver").RecipeRevisionResolver | typeof import("./recipe/recipe-query").RecipeQuery | typeof import("./test-spec/test-spec-revision-resolver").TestSpecificationRevisionResolver | typeof import("./test-spec/test-spec-query").TestSpecificationQuery | typeof import("./status/master-status").OpsMasterStatusQuery | typeof import("./equipment/stop-reason-query").StopReasonQuery | typeof import("./quality/nonconformance-cause-resolver").NonconformanceCauseResolver | typeof import("./energy/electricity-tariff-resolver").ElectricityTariffResolver)[];
|
|
82
85
|
};
|
|
83
86
|
export * from './assignment/master-value-claim';
|
|
84
87
|
export * from './assignment/assignment-history';
|
|
@@ -76,6 +76,9 @@ tslib_1.__exportStar(require("./test-spec/test-spec-query"), exports);
|
|
|
76
76
|
tslib_1.__exportStar(require("./status/axis-stamp"), exports);
|
|
77
77
|
tslib_1.__exportStar(require("./status/master-status"), exports);
|
|
78
78
|
tslib_1.__exportStar(require("./quality/nonconformance-cause"), exports);
|
|
79
|
+
tslib_1.__exportStar(require("./energy/electricity-tariff"), exports);
|
|
80
|
+
tslib_1.__exportStar(require("./energy/electricity-tariff-band"), exports);
|
|
81
|
+
tslib_1.__exportStar(require("./energy/tariff-rules"), exports);
|
|
79
82
|
/* IMPORT ENTITIES AND RESOLVERS */
|
|
80
83
|
const asset_1 = require("./asset");
|
|
81
84
|
const equipment_1 = require("./equipment");
|
|
@@ -84,6 +87,7 @@ const material_1 = require("./material");
|
|
|
84
87
|
const operation_1 = require("./operation");
|
|
85
88
|
const personnel_1 = require("./personnel");
|
|
86
89
|
const quality_1 = require("./quality");
|
|
90
|
+
const energy_1 = require("./energy");
|
|
87
91
|
/* 라우팅·레시피 — 품목→지시서를 이으려면 그 사이에 이 둘이 있어야 한다(§`recipe-definition.ts`). */
|
|
88
92
|
const recipe_1 = require("./recipe");
|
|
89
93
|
const status_1 = require("./status");
|
|
@@ -106,6 +110,7 @@ exports.entities = [
|
|
|
106
110
|
master_value_claim_1.MasterValueClaim,
|
|
107
111
|
...personnel_1.entities,
|
|
108
112
|
...quality_1.entities,
|
|
113
|
+
...energy_1.entities,
|
|
109
114
|
...equipment_1.entities,
|
|
110
115
|
...asset_1.entities,
|
|
111
116
|
...location_1.entities,
|
|
@@ -121,6 +126,7 @@ exports.schema = {
|
|
|
121
126
|
...master_change_approval_1.resolvers,
|
|
122
127
|
...personnel_1.resolvers,
|
|
123
128
|
...quality_1.resolvers,
|
|
129
|
+
...energy_1.resolvers,
|
|
124
130
|
...equipment_1.resolvers,
|
|
125
131
|
...asset_1.resolvers,
|
|
126
132
|
...location_1.resolvers,
|
|
@@ -6,6 +6,8 @@ const equipment_1 = require("./equipment/equipment");
|
|
|
6
6
|
const equipment_class_1 = require("./equipment/equipment-class");
|
|
7
7
|
const stop_reason_1 = require("./equipment/stop-reason");
|
|
8
8
|
const nonconformance_cause_1 = require("./quality/nonconformance-cause");
|
|
9
|
+
const electricity_tariff_1 = require("./energy/electricity-tariff");
|
|
10
|
+
const electricity_tariff_band_1 = require("./energy/electricity-tariff-band");
|
|
9
11
|
const material_class_1 = require("./material/material-class");
|
|
10
12
|
const material_definition_1 = require("./material/material-definition");
|
|
11
13
|
const operation_definition_1 = require("./operation/operation-definition");
|
|
@@ -24,6 +26,12 @@ exports.MASTER_AXES = [
|
|
|
24
26
|
{ key: 'equipment', entity: equipment_1.Equipment, searchables: ['name', 'description'], hasEffectivePeriod: true, revisable: false },
|
|
25
27
|
{ key: 'stopReason', entity: stop_reason_1.StopReason, searchables: ['name', 'description'], hasEffectivePeriod: true, revisable: false },
|
|
26
28
|
{ key: 'nonconformanceCause', entity: nonconformance_cause_1.NonconformanceCause, searchables: ['name', 'description'], hasEffectivePeriod: true, revisable: false },
|
|
29
|
+
/*
|
|
30
|
+
* 전기 요금제와 시간대 구간 (2026-11-27) — 요금표를 적을 곳이 없어 트윈 모델의 자리 속성(단일 단가)에만 있었다.
|
|
31
|
+
* 시간대 요금은 어디에도 적을 수 없었다. 규칙은 `energy/tariff-rules.ts`.
|
|
32
|
+
*/
|
|
33
|
+
{ key: 'electricityTariff', entity: electricity_tariff_1.ElectricityTariff, searchables: ['name', 'description', 'supplier'], hasEffectivePeriod: true, revisable: false },
|
|
34
|
+
{ key: 'electricityTariffBand', entity: electricity_tariff_band_1.ElectricityTariffBand, searchables: ['name', 'description', 'tariffName'], hasEffectivePeriod: true, revisable: false },
|
|
27
35
|
{ key: 'physicalAssetClass', entity: physical_asset_class_1.PhysicalAssetClass, searchables: ['name', 'description'], hasEffectivePeriod: true, revisable: false },
|
|
28
36
|
{ key: 'physicalAsset', entity: physical_asset_1.PhysicalAsset, searchables: ['name', 'description', 'identity'], hasEffectivePeriod: true, revisable: false },
|
|
29
37
|
{ key: 'materialClass', entity: material_class_1.MaterialClass, searchables: ['name', 'description'], hasEffectivePeriod: true, revisable: false },
|
|
@@ -3,7 +3,7 @@ import { RouteDefinition } from './route-definition';
|
|
|
3
3
|
import { RecipeDefinitionResolver, RouteDefinitionResolver } from './recipe-master-resolver';
|
|
4
4
|
import { RecipeQuery } from './recipe-query';
|
|
5
5
|
import { RecipeRevisionResolver } from './recipe-revision-resolver';
|
|
6
|
-
export declare const entities: (typeof RecipeDefinition | typeof RouteDefinition | typeof import("./recipe-revision").RecipeRevision | typeof import("./recipe-revision").
|
|
6
|
+
export declare const entities: (typeof RecipeDefinition | typeof RouteDefinition | typeof import("./recipe-revision").RecipeRevision | typeof import("./recipe-revision-line").RecipeRevisionOutput | typeof import("./recipe-revision").RecipePlan | typeof import("./recipe-revision").RecipeSegment | typeof import("./recipe-revision").RecipeBasis)[];
|
|
7
7
|
export declare const resolvers: (typeof RecipeDefinitionResolver | typeof RouteDefinitionResolver | typeof RecipeRevisionResolver | typeof RecipeQuery)[];
|
|
8
8
|
export * from './recipe-definition';
|
|
9
9
|
export * from './route-definition';
|
|
@@ -99,4 +99,4 @@ export declare class RecipeBasis {
|
|
|
99
99
|
businessTime: Date;
|
|
100
100
|
resolvedAt: Date;
|
|
101
101
|
}
|
|
102
|
-
export declare const RECIPE_REVISION_ENTITIES: (typeof RecipeRevision | typeof
|
|
102
|
+
export declare const RECIPE_REVISION_ENTITIES: (typeof RecipeRevision | typeof RecipeRevisionOutput | typeof RecipePlan | typeof RecipeSegment | typeof RecipeBasis)[];
|
|
@@ -18,6 +18,8 @@ const personnel_class_1 = require("../personnel/personnel-class");
|
|
|
18
18
|
const recipe_definition_1 = require("../recipe/recipe-definition");
|
|
19
19
|
const route_definition_1 = require("../recipe/route-definition");
|
|
20
20
|
const test_specification_1 = require("../test-spec/test-specification");
|
|
21
|
+
const electricity_tariff_1 = require("../energy/electricity-tariff");
|
|
22
|
+
const electricity_tariff_band_1 = require("../energy/electricity-tariff-band");
|
|
21
23
|
const axis_stamp_1 = require("./axis-stamp");
|
|
22
24
|
/**
|
|
23
25
|
* 축이 언제 바뀌었나 — **당길지 말지를 싸게 판단하는 자리.**
|
|
@@ -110,7 +112,9 @@ let OpsMasterStatusQuery = class OpsMasterStatusQuery {
|
|
|
110
112
|
axisStatus('operations', (0, shell_1.getRepository)(operation_definition_1.OperationDefinition), domain.id),
|
|
111
113
|
axisStatus('recipes', (0, shell_1.getRepository)(recipe_definition_1.RecipeDefinition), domain.id),
|
|
112
114
|
axisStatus('routes', (0, shell_1.getRepository)(route_definition_1.RouteDefinition), domain.id),
|
|
113
|
-
axisStatus('testSpecifications', (0, shell_1.getRepository)(test_specification_1.TestSpecification), domain.id)
|
|
115
|
+
axisStatus('testSpecifications', (0, shell_1.getRepository)(test_specification_1.TestSpecification), domain.id),
|
|
116
|
+
axisStatus('electricityTariffs', (0, shell_1.getRepository)(electricity_tariff_1.ElectricityTariff), domain.id),
|
|
117
|
+
axisStatus('electricityTariffBands', (0, shell_1.getRepository)(electricity_tariff_band_1.ElectricityTariffBand), domain.id)
|
|
114
118
|
]);
|
|
115
119
|
return { axes };
|
|
116
120
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# 시간대 요금 구간
|
|
2
|
+
|
|
3
|
+
시간대 요금제의 「계절 × 요일 × 시각 → 사용량 단가」 한 줄입니다.
|
|
4
|
+
|
|
5
|
+
- **구간 코드**는 요금제가 정합니다. 나라와 전력사마다 구간의 수와 이름이 다르므로 그 요금표의 이름을 그대로 씁니다(예: `punta`, `on-peak`, `super-off-peak`).
|
|
6
|
+
- **부하 등급**은 요금제끼리 견주는 기준입니다. `super-off-peak` · `off-peak` · `mid-peak` · `on-peak` 중 하나를 고릅니다(가벼운 → 무거운).
|
|
7
|
+
- **시간대별 기본요금**은 이 구간의 최대수요에 붙는 kW 당 요금입니다. 요금제의 설비 기본요금에 더해집니다. 없으면 비웁니다.
|
|
8
|
+
|
|
9
|
+
- **시각**은 현장의 벽시계로 `HH:mm` 입니다. 시작은 포함하고 끝은 포함하지 않습니다. 하루의 끝은 `24:00` 입니다.
|
|
10
|
+
- **자정을 넘는 구간**(예: 22:00~08:00)은 두 줄(22:00~24:00, 00:00~08:00)로 적습니다.
|
|
11
|
+
- **계절**은 `MM-DD` 두 개입니다. 둘 다 비우면 일 년 내내입니다. 해를 넘어도 됩니다(11-01~02-28).
|
|
12
|
+
- **요일 종류**는 `weekday`(평일) · `saturday`(토요일) · `sunday`(일요일) · `holiday`(공휴일) · `all`(모든 날)입니다. 비우면 `all` 입니다. 공휴일은 요일보다 앞섭니다. 공휴일을 일요일처럼 매기는 요금표는 `sunday` 와 `holiday` 두 줄을 적습니다. `holiday` 줄이 하나도 없으면 공휴일을 따로 매기지 않는 요금제로 봅니다.
|
|
13
|
+
|
|
14
|
+
한 요금제의 구간은 모든 날의 모든 시간을 **빈틈없이, 겹치지 않게** 덮어야 합니다. 빈 시간은 값을 매길 수 없고 겹친 시간은 단가가 둘이 됩니다. 편집하는 동안에는 늘 빈 시간이 있으므로 저장은 막지 않고, 요금제별 점검(`electricityTariffIssues`)이 빈 시간과 겹침을 알려 줍니다.
|
|
15
|
+
|
|
16
|
+
`holiday` 줄이 있으면 요금제에 **공휴일 달력 이름**을 적어야 합니다. 달력의 날짜 목록은 아직 이 기준정보에 없습니다.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Time-of-use bands
|
|
2
|
+
|
|
3
|
+
One line of a time-of-use tariff: season × days × hours → energy price.
|
|
4
|
+
|
|
5
|
+
- **Band code** is the tariff's own. Countries and utilities differ in how many bands they have and what they call them, so use the tariff sheet's name (e.g. `punta`, `on-peak`, `super-off-peak`).
|
|
6
|
+
- **Load class** is how bands are compared across tariffs: `super-off-peak`, `off-peak`, `mid-peak` or `on-peak` (lightest to heaviest).
|
|
7
|
+
- **Time-of-use demand charge** is charged per kW of the peak demand in this band, on top of the tariff's facility demand charge. Leave empty if none.
|
|
8
|
+
|
|
9
|
+
- **Times** are the site's local wall clock, `HH:mm`. The start is included, the end is not. The day ends at `24:00`.
|
|
10
|
+
- **A band across midnight** (e.g. 22:00–08:00) is entered as two lines (22:00–24:00 and 00:00–08:00).
|
|
11
|
+
- **Season** is two `MM-DD` values. Leave both empty for all year. A season may cross the new year (11-01 to 02-28).
|
|
12
|
+
- **Days** is `weekday`, `saturday`, `sunday`, `holiday` or `all`. Empty means `all`. A holiday comes before its weekday. A tariff that prices holidays like Sundays writes a `sunday` line and a `holiday` line. A tariff with no `holiday` line does not price holidays apart.
|
|
13
|
+
|
|
14
|
+
The bands of one tariff must cover every hour of every day **without gaps or overlaps**. A gap cannot be priced and an overlap has two prices. Saving is not blocked, since a tariff is incomplete while you edit it; the per-tariff check (`electricityTariffIssues`) lists gaps and overlaps.
|
|
15
|
+
|
|
16
|
+
When there are `holiday` lines, the tariff must name its **holiday calendar**. The calendar's dates are not in this master yet.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# 전기 요금제
|
|
2
|
+
|
|
3
|
+
현장이 전기 공급자와 맺은 요금 계약입니다. 트윈이 사용량(kWh)과 최대수요(kW)를 금액으로 바꿀 때 이 값을 씁니다.
|
|
4
|
+
|
|
5
|
+
- **설비 기본요금**: 요금적용전력 1kW 당, 청구 주기마다, 시간대와 상관없이 붙는 금액입니다. 시간대별 기본요금은 구간에 적습니다.
|
|
6
|
+
- **공휴일 달력**: 이 요금제의 `holiday` 구간이 따르는 달력의 이름입니다. 나라와 전력사마다 공휴일 목록이 다릅니다.
|
|
7
|
+
- **단일 사용량 단가**: 시간대 요금이 없는 요금제에서만 적습니다. 시간대 요금이면 비우고 **시간대 요금 구간** 화면에 적습니다.
|
|
8
|
+
- **통화**: 단가를 하나라도 적으면 반드시 적습니다(ISO 4217, 예: KRW).
|
|
9
|
+
- **수전 지점**: 이 요금제가 걸리는 수전 자리입니다. 수전이 하나인 현장은 비워도 됩니다.
|
|
10
|
+
|
|
11
|
+
여기 없는 것:
|
|
12
|
+
|
|
13
|
+
- **계약전력**은 수전 자리의 속성(`contract.kW`)입니다.
|
|
14
|
+
- **요금적용전력**은 청구 주기마다 공급자가 다시 정하는 값이라 기준정보가 아닙니다.
|
|
15
|
+
|
|
16
|
+
단가가 바뀌면 행을 고치지 말고 새 요금제를 등록한 뒤 옛 요금제를 끝냅니다. 지난 요금을 다시 계산할 때 그때의 단가가 남아 있어야 합니다.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Electricity tariffs
|
|
2
|
+
|
|
3
|
+
The tariff the site holds with its electricity supplier. The twin uses it to turn energy (kWh) and peak demand (kW) into money.
|
|
4
|
+
|
|
5
|
+
- **Facility demand charge per kW**: charged per kW of billing demand, each billing cycle, whatever the hour. Time-of-use demand charges go on the bands.
|
|
6
|
+
- **Holiday calendar**: the name of the calendar this tariff's `holiday` bands follow. Holiday lists differ by country and utility.
|
|
7
|
+
- **Flat energy charge per kWh**: only for a tariff without time-of-use pricing. For a time-of-use tariff leave it empty and enter the prices on **time-of-use bands**.
|
|
8
|
+
- **Currency**: required as soon as any price is entered (ISO 4217, e.g. USD).
|
|
9
|
+
- **Supply point**: the incoming supply location this tariff applies to. A site with one supply point may leave it empty.
|
|
10
|
+
|
|
11
|
+
Not here:
|
|
12
|
+
|
|
13
|
+
- **Contracted capacity** is a property of the supply point location (`contract.kW`).
|
|
14
|
+
- **Billing demand** is set again by the supplier every billing cycle, so it is not master data.
|
|
15
|
+
|
|
16
|
+
When prices change, do not edit the row: register a new tariff and end the old one, so past bills can be recalculated with the prices of their time.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/ops-master",
|
|
3
|
-
"version": "10.1.
|
|
3
|
+
"version": "10.1.316",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"things-factory": true,
|
|
6
6
|
"author": "heartyoh <heartyoh@hatiolab.com>",
|
|
@@ -42,10 +42,10 @@
|
|
|
42
42
|
"@operato/shell": "^10.29.69",
|
|
43
43
|
"@operato/styles": "^10.0.0",
|
|
44
44
|
"@operato/utils": "^10.29.39",
|
|
45
|
-
"@things-factory/auth-base": "^10.1.
|
|
45
|
+
"@things-factory/auth-base": "^10.1.316",
|
|
46
46
|
"@things-factory/env": "^10.1.298",
|
|
47
47
|
"@things-factory/shell": "^10.1.304",
|
|
48
|
-
"@things-factory/worklist": "^10.1.
|
|
48
|
+
"@things-factory/worklist": "^10.1.316"
|
|
49
49
|
},
|
|
50
50
|
"browser": "dist-client/index.js",
|
|
51
51
|
"files": [
|
|
@@ -64,9 +64,9 @@
|
|
|
64
64
|
"!**/.DS_Store"
|
|
65
65
|
],
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@things-factory/notification": "^10.1.
|
|
67
|
+
"@things-factory/notification": "^10.1.316",
|
|
68
68
|
"copyfiles": "^2.4.1",
|
|
69
69
|
"rimraf": "^6.1.3"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "8bdf4ae696ae7ec9c21312485f86f212052bb10a"
|
|
72
72
|
}
|