@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,57 @@
|
|
|
1
|
+
import { Domain } from '@things-factory/shell';
|
|
2
|
+
import { User } from '@things-factory/auth-base';
|
|
3
|
+
/**
|
|
4
|
+
* **전기 요금제** — 이 현장이 공급자와 맺은 요금 계약 하나.
|
|
5
|
+
*
|
|
6
|
+
* ── 무엇을 담나 ─────────────────────────────────────────────────────────────
|
|
7
|
+
* 설비 기본요금 단가(최대수요 1kW 당) · 통화 · 공휴일 달력 이름. 시간대 요금이면 사용량 단가는 구간(`ElectricityTariffBand`)이 갖고,
|
|
8
|
+
* 단일 단가 요금제면 이 행의 `energyChargePerKWh` 가 갖는다 — **둘 다 적지 않는다**(`tariffCoverageIssues`).
|
|
9
|
+
*
|
|
10
|
+
* ── 담지 않는 것 ────────────────────────────────────────────────────────────
|
|
11
|
+
* · **계약전력**은 수전 자리의 속성(`contract.kW`)이다. 넘었을 때의 뜻(약정 위반)이 요금과 다르다.
|
|
12
|
+
* · **요금적용전력**(`billingDemandKW`)은 청구 주기마다 공급자가 다시 정하는 값이라 기준정보가 아니다 — 원 시스템이
|
|
13
|
+
* 요금 기준(`energy.tariff.basis`)으로 보낸다.
|
|
14
|
+
* · 래칫 · 최소 청구액 · 역률 요금 · 계절별 기본요금은 아직 칸이 없다. 있는 척하지 않는다.
|
|
15
|
+
*
|
|
16
|
+
* 요금제가 바뀌면(해마다 단가 조정) 새 이름으로 새 행을 세우고 옛 행의 `effectiveEnd` 를 채운다 — 지난 달 요금을
|
|
17
|
+
* 다시 계산할 때 그때의 단가가 남아 있어야 한다.
|
|
18
|
+
*/
|
|
19
|
+
export declare class ElectricityTariff {
|
|
20
|
+
readonly id: string;
|
|
21
|
+
domain?: Domain;
|
|
22
|
+
domainId?: string;
|
|
23
|
+
/** 요금제 코드 — 구간이 이 값을 가리킨다. */
|
|
24
|
+
name: string;
|
|
25
|
+
description?: string;
|
|
26
|
+
/** 공급자 — 이름 그대로. 거래 상대 정체성(biz-base)으로 묶는 것은 정산이 들어올 때의 일이다. */
|
|
27
|
+
supplier?: string;
|
|
28
|
+
/**
|
|
29
|
+
* 이 요금제가 걸리는 **수전 지점** — `OperationalLocation` 의 이름(설비의 `homeLocation` 과 같은 방식).
|
|
30
|
+
*
|
|
31
|
+
* 수전이 둘인 현장은 요금 계약도 둘이다. 비우면 「이 현장 전체」로 읽힌다.
|
|
32
|
+
*/
|
|
33
|
+
incomingLocation?: string;
|
|
34
|
+
/** ISO 4217 — 단가를 하나라도 적으면 반드시 적는다. */
|
|
35
|
+
currency?: string;
|
|
36
|
+
/**
|
|
37
|
+
* **설비 기본요금** — 요금적용전력 1kW 당, 청구 주기마다, 시간대와 무관하게. 시간대별 기본요금은 구간이 갖는다
|
|
38
|
+
* (`ElectricityTariffBand.demandChargePerKW`) — 미국 산업용 요금이 흔히 둘을 함께 매긴다.
|
|
39
|
+
*/
|
|
40
|
+
demandChargePerKW?: number;
|
|
41
|
+
/** 단일 사용량 단가 — **구간이 없는 요금제에서만** 적는다. */
|
|
42
|
+
energyChargePerKWh?: number;
|
|
43
|
+
/**
|
|
44
|
+
* 이 요금제의 `holiday` 구간이 따르는 **공휴일 달력의 이름** — 나라 · 전력사마다 목록이 다르다(미국 전력사 목록 · 멕시코 법정 휴일 …).
|
|
45
|
+
* 날짜 목록은 여기 없다(자리는 ADR-0239 Q4). `holiday` 구간이 있는데 비면 점검이 짚는다.
|
|
46
|
+
*/
|
|
47
|
+
holidayCalendar?: string;
|
|
48
|
+
effectiveStart?: Date;
|
|
49
|
+
/** 쓰지 않는 요금제는 지우지 않고 이 칸을 채운다 — 지난 요금을 다시 셀 때 그때의 단가가 있어야 한다. */
|
|
50
|
+
effectiveEnd?: Date;
|
|
51
|
+
createdAt?: Date;
|
|
52
|
+
updatedAt?: Date;
|
|
53
|
+
creator?: User;
|
|
54
|
+
creatorId?: string;
|
|
55
|
+
updater?: User;
|
|
56
|
+
updaterId?: string;
|
|
57
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ElectricityTariff = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const typeorm_1 = require("typeorm");
|
|
6
|
+
const type_graphql_1 = require("type-graphql");
|
|
7
|
+
const shell_1 = require("@things-factory/shell");
|
|
8
|
+
const auth_base_1 = require("@things-factory/auth-base");
|
|
9
|
+
/**
|
|
10
|
+
* **전기 요금제** — 이 현장이 공급자와 맺은 요금 계약 하나.
|
|
11
|
+
*
|
|
12
|
+
* ── 무엇을 담나 ─────────────────────────────────────────────────────────────
|
|
13
|
+
* 설비 기본요금 단가(최대수요 1kW 당) · 통화 · 공휴일 달력 이름. 시간대 요금이면 사용량 단가는 구간(`ElectricityTariffBand`)이 갖고,
|
|
14
|
+
* 단일 단가 요금제면 이 행의 `energyChargePerKWh` 가 갖는다 — **둘 다 적지 않는다**(`tariffCoverageIssues`).
|
|
15
|
+
*
|
|
16
|
+
* ── 담지 않는 것 ────────────────────────────────────────────────────────────
|
|
17
|
+
* · **계약전력**은 수전 자리의 속성(`contract.kW`)이다. 넘었을 때의 뜻(약정 위반)이 요금과 다르다.
|
|
18
|
+
* · **요금적용전력**(`billingDemandKW`)은 청구 주기마다 공급자가 다시 정하는 값이라 기준정보가 아니다 — 원 시스템이
|
|
19
|
+
* 요금 기준(`energy.tariff.basis`)으로 보낸다.
|
|
20
|
+
* · 래칫 · 최소 청구액 · 역률 요금 · 계절별 기본요금은 아직 칸이 없다. 있는 척하지 않는다.
|
|
21
|
+
*
|
|
22
|
+
* 요금제가 바뀌면(해마다 단가 조정) 새 이름으로 새 행을 세우고 옛 행의 `effectiveEnd` 를 채운다 — 지난 달 요금을
|
|
23
|
+
* 다시 계산할 때 그때의 단가가 남아 있어야 한다.
|
|
24
|
+
*/
|
|
25
|
+
let ElectricityTariff = class ElectricityTariff {
|
|
26
|
+
};
|
|
27
|
+
exports.ElectricityTariff = ElectricityTariff;
|
|
28
|
+
tslib_1.__decorate([
|
|
29
|
+
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
30
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.ID),
|
|
31
|
+
tslib_1.__metadata("design:type", String)
|
|
32
|
+
], ElectricityTariff.prototype, "id", void 0);
|
|
33
|
+
tslib_1.__decorate([
|
|
34
|
+
(0, typeorm_1.ManyToOne)(type => shell_1.Domain),
|
|
35
|
+
(0, type_graphql_1.Field)(type => shell_1.Domain),
|
|
36
|
+
tslib_1.__metadata("design:type", shell_1.Domain)
|
|
37
|
+
], ElectricityTariff.prototype, "domain", void 0);
|
|
38
|
+
tslib_1.__decorate([
|
|
39
|
+
(0, typeorm_1.RelationId)((tariff) => tariff.domain),
|
|
40
|
+
tslib_1.__metadata("design:type", String)
|
|
41
|
+
], ElectricityTariff.prototype, "domainId", void 0);
|
|
42
|
+
tslib_1.__decorate([
|
|
43
|
+
(0, typeorm_1.Column)(),
|
|
44
|
+
(0, type_graphql_1.Field)({ description: 'the tariff code its bands refer to' }),
|
|
45
|
+
tslib_1.__metadata("design:type", String)
|
|
46
|
+
], ElectricityTariff.prototype, "name", void 0);
|
|
47
|
+
tslib_1.__decorate([
|
|
48
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
49
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
50
|
+
tslib_1.__metadata("design:type", String)
|
|
51
|
+
], ElectricityTariff.prototype, "description", void 0);
|
|
52
|
+
tslib_1.__decorate([
|
|
53
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
54
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'who supplies the electricity, as the contract names it' }),
|
|
55
|
+
tslib_1.__metadata("design:type", String)
|
|
56
|
+
], ElectricityTariff.prototype, "supplier", void 0);
|
|
57
|
+
tslib_1.__decorate([
|
|
58
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
59
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'the incoming supply point (operational location) this tariff applies to' }),
|
|
60
|
+
tslib_1.__metadata("design:type", String)
|
|
61
|
+
], ElectricityTariff.prototype, "incomingLocation", void 0);
|
|
62
|
+
tslib_1.__decorate([
|
|
63
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
64
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'ISO 4217 currency code' }),
|
|
65
|
+
tslib_1.__metadata("design:type", String)
|
|
66
|
+
], ElectricityTariff.prototype, "currency", void 0);
|
|
67
|
+
tslib_1.__decorate([
|
|
68
|
+
(0, typeorm_1.Column)({ type: 'float', nullable: true }),
|
|
69
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true, description: 'facility demand charge per kW of billing demand, per billing cycle, whatever the hour' }),
|
|
70
|
+
tslib_1.__metadata("design:type", Number)
|
|
71
|
+
], ElectricityTariff.prototype, "demandChargePerKW", void 0);
|
|
72
|
+
tslib_1.__decorate([
|
|
73
|
+
(0, typeorm_1.Column)({ type: 'float', nullable: true }),
|
|
74
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true, description: 'flat energy charge per kWh — only for a tariff without time-of-use bands' }),
|
|
75
|
+
tslib_1.__metadata("design:type", Number)
|
|
76
|
+
], ElectricityTariff.prototype, "energyChargePerKWh", void 0);
|
|
77
|
+
tslib_1.__decorate([
|
|
78
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
79
|
+
(0, type_graphql_1.Field)({ nullable: true, description: "the holiday calendar this tariff's holiday bands follow (a name)" }),
|
|
80
|
+
tslib_1.__metadata("design:type", String)
|
|
81
|
+
], ElectricityTariff.prototype, "holidayCalendar", void 0);
|
|
82
|
+
tslib_1.__decorate([
|
|
83
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
84
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
85
|
+
tslib_1.__metadata("design:type", Date
|
|
86
|
+
/** 쓰지 않는 요금제는 지우지 않고 이 칸을 채운다 — 지난 요금을 다시 셀 때 그때의 단가가 있어야 한다. */
|
|
87
|
+
)
|
|
88
|
+
], ElectricityTariff.prototype, "effectiveStart", void 0);
|
|
89
|
+
tslib_1.__decorate([
|
|
90
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
91
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
92
|
+
tslib_1.__metadata("design:type", Date)
|
|
93
|
+
], ElectricityTariff.prototype, "effectiveEnd", void 0);
|
|
94
|
+
tslib_1.__decorate([
|
|
95
|
+
(0, typeorm_1.CreateDateColumn)(),
|
|
96
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
97
|
+
tslib_1.__metadata("design:type", Date)
|
|
98
|
+
], ElectricityTariff.prototype, "createdAt", void 0);
|
|
99
|
+
tslib_1.__decorate([
|
|
100
|
+
(0, typeorm_1.UpdateDateColumn)(),
|
|
101
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
102
|
+
tslib_1.__metadata("design:type", Date)
|
|
103
|
+
], ElectricityTariff.prototype, "updatedAt", void 0);
|
|
104
|
+
tslib_1.__decorate([
|
|
105
|
+
(0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
|
|
106
|
+
(0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true }),
|
|
107
|
+
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
108
|
+
], ElectricityTariff.prototype, "creator", void 0);
|
|
109
|
+
tslib_1.__decorate([
|
|
110
|
+
(0, typeorm_1.RelationId)((tariff) => tariff.creator),
|
|
111
|
+
tslib_1.__metadata("design:type", String)
|
|
112
|
+
], ElectricityTariff.prototype, "creatorId", void 0);
|
|
113
|
+
tslib_1.__decorate([
|
|
114
|
+
(0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
|
|
115
|
+
(0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true }),
|
|
116
|
+
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
117
|
+
], ElectricityTariff.prototype, "updater", void 0);
|
|
118
|
+
tslib_1.__decorate([
|
|
119
|
+
(0, typeorm_1.RelationId)((tariff) => tariff.updater),
|
|
120
|
+
tslib_1.__metadata("design:type", String)
|
|
121
|
+
], ElectricityTariff.prototype, "updaterId", void 0);
|
|
122
|
+
exports.ElectricityTariff = ElectricityTariff = tslib_1.__decorate([
|
|
123
|
+
(0, typeorm_1.Entity)({ name: 'ops_electricity_tariff' }),
|
|
124
|
+
(0, typeorm_1.Index)('ix_ops_electricity_tariff_0', (tariff) => [tariff.domain, tariff.name], { unique: true }),
|
|
125
|
+
(0, type_graphql_1.ObjectType)({ description: 'An electricity tariff the site holds with its supplier' })
|
|
126
|
+
], ElectricityTariff);
|
|
127
|
+
//# sourceMappingURL=electricity-tariff.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ElectricityTariff } from './electricity-tariff';
|
|
2
|
+
import { ElectricityTariffBand } from './electricity-tariff-band';
|
|
3
|
+
import { ElectricityTariffResolver } from './electricity-tariff-resolver';
|
|
4
|
+
export declare const entities: (typeof ElectricityTariff | typeof ElectricityTariffBand)[];
|
|
5
|
+
export declare const resolvers: (typeof ElectricityTariffResolver)[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolvers = exports.entities = void 0;
|
|
4
|
+
const electricity_tariff_1 = require("./electricity-tariff");
|
|
5
|
+
const electricity_tariff_band_1 = require("./electricity-tariff-band");
|
|
6
|
+
const electricity_tariff_resolver_1 = require("./electricity-tariff-resolver");
|
|
7
|
+
exports.entities = [electricity_tariff_1.ElectricityTariff, electricity_tariff_band_1.ElectricityTariffBand];
|
|
8
|
+
exports.resolvers = [electricity_tariff_resolver_1.ElectricityTariffResolver];
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* **Electricity tariff rules** — the words of a time-of-use tariff and how to read it.
|
|
3
|
+
*
|
|
4
|
+
* ── Why this is in the contract (2026-11-27) ────────────────────────────────────────────────────────────────────
|
|
5
|
+
* The tariff is site master data and is stored by ops-master (`ElectricityTariff` · `ElectricityTariffBand`). What
|
|
6
|
+
* lives here is the reading: which band applies at a moment, and whether a tariff's bands cover every day. Once the
|
|
7
|
+
* twin prices usage per band (the kernel's `electricityCost({ energyChargeFromPeriods })`), ops-master's screen and the
|
|
8
|
+
* twin must give the same answer for the same moment - a rule two implementations share belongs to the contract.
|
|
9
|
+
* Storage, approval and screens stay with ops-master.
|
|
10
|
+
*
|
|
11
|
+
* Field names are the declaration's (`EMS_DECLARATION` `tariff.*`): `demandChargePerKW`, `energyChargePerKWh`,
|
|
12
|
+
* `currency`. The contract power (`contract.kW`) and billing demand (`tariff.billingDemandKW`) are not tariff rows -
|
|
13
|
+
* one is a property of the supply point, the other a per-cycle fact from the supplier.
|
|
14
|
+
*
|
|
15
|
+
* ── Which price wins ────────────────────────────────────────────────────────────────────────────────────────────
|
|
16
|
+
* A source fact's own price (`EnergyUsagePeriodData.unitPrice`) is what was charged; it wins. A band price from the
|
|
17
|
+
* master is used only for a period whose fact carries no price. The master is a declaration, the fact an observation.
|
|
18
|
+
*
|
|
19
|
+
* ── Times are the site's wall clock ─────────────────────────────────────────────────────────────────────────────
|
|
20
|
+
* Bands are set in local time ("weekdays 09:00-10:00 are on-peak"). These functions do not know time zones: the
|
|
21
|
+
* caller converts an instant to the site's month, day, weekday and minute (`LocalMoment`). Cutting in UTC would make
|
|
22
|
+
* Seoul's 09:00 into 00:00.
|
|
23
|
+
*
|
|
24
|
+
* ── A band does not cross midnight ──────────────────────────────────────────────────────────────────────────────
|
|
25
|
+
* "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
|
|
26
|
+
* it belongs to (does Saturday night run into Sunday morning?), and tariffs answer that differently.
|
|
27
|
+
*
|
|
28
|
+
* ── A new country is rows, not code (2026-11-27) ───────────────────────────────────────────────────────────────
|
|
29
|
+
* Tariff systems differ by country and supplier: how many bands and what they are called, whether a holiday is priced
|
|
30
|
+
* like Sunday, whether demand is charged per band, which days are holidays. A new country must be written as tariff,
|
|
31
|
+
* band and calendar rows - never as a change here, in the kernel or on a screen. So:
|
|
32
|
+
* · the band **code** is the tariff's own (`base` · `intermedia` · `punta`, `super-off-peak` …); only its
|
|
33
|
+
* **load class** - for comparing across tariffs - is a closed, ordered vocabulary (`TARIFF_LOAD_CLASSES`);
|
|
34
|
+
* · `sunday` and `holiday` are separate day kinds; a tariff pricing them alike writes two rows;
|
|
35
|
+
* · the tariff's `demandChargePerKW` is the facility demand charge (any time); a band may carry its own
|
|
36
|
+
* time-of-use `demandChargePerKW`;
|
|
37
|
+
* · the tariff names its holiday calendar (`holidayCalendar`); the calendar's days are not in the contract - the
|
|
38
|
+
* caller passes `isHoliday`.
|
|
39
|
+
* Season bounds are fixed `MM-DD`. A tariff whose season moves each year ("from the first Sunday of April") is written
|
|
40
|
+
* as one tariff per year with its effective dates - not yet seen to need more (to check against CFE tariffs).
|
|
41
|
+
*
|
|
42
|
+
* ── Issues are structured ───────────────────────────────────────────────────────────────────────────────────────
|
|
43
|
+
* Checks return `{ field, code, params }`, not sentences: a screen turns the code into its own language, and
|
|
44
|
+
* `tariffIssueText` gives the one-line English `field: reason` other contract checks use.
|
|
45
|
+
*/
|
|
46
|
+
/**
|
|
47
|
+
* Load class of a band - **ordered from lightest to heaviest load**, for comparing bands across tariffs
|
|
48
|
+
* ("how much is shifted out of the heaviest hours"). The band's own code is the tariff's: Mexico's `base` ·
|
|
49
|
+
* `intermedia` · `punta` are classed `off-peak` · `mid-peak` · `on-peak`; a US `super-off-peak` band is that class.
|
|
50
|
+
*/
|
|
51
|
+
export declare const TARIFF_LOAD_CLASSES: readonly ["super-off-peak", "off-peak", "mid-peak", "on-peak"];
|
|
52
|
+
export type TariffLoadClass = (typeof TARIFF_LOAD_CLASSES)[number];
|
|
53
|
+
/**
|
|
54
|
+
* Which days a band applies to. `all` ignores the day.
|
|
55
|
+
*
|
|
56
|
+
* `holiday` is a day of the tariff's holiday calendar (`holidayCalendar`) and **comes before the weekday**: a holiday
|
|
57
|
+
* falling on a Saturday is a holiday. A tariff that prices holidays like Sundays writes a `sunday` row and a `holiday`
|
|
58
|
+
* row. A tariff with no `holiday` row does not price holidays apart - its holidays are read as their weekday.
|
|
59
|
+
*/
|
|
60
|
+
export declare const TARIFF_DAY_KINDS: readonly ["all", "weekday", "saturday", "sunday", "holiday"];
|
|
61
|
+
export type TariffDayKind = (typeof TARIFF_DAY_KINDS)[number];
|
|
62
|
+
export interface TariffLike {
|
|
63
|
+
name?: string;
|
|
64
|
+
currency?: string | null;
|
|
65
|
+
/** Facility demand charge per kW of billing demand - whatever the hour. */
|
|
66
|
+
demandChargePerKW?: number | string | null;
|
|
67
|
+
/** Flat energy charge - only for a tariff without bands. */
|
|
68
|
+
energyChargePerKWh?: number | string | null;
|
|
69
|
+
/** The holiday calendar this tariff's `holiday` bands follow - a name; the days are the caller's. */
|
|
70
|
+
holidayCalendar?: string | null;
|
|
71
|
+
}
|
|
72
|
+
export interface TariffBandLike {
|
|
73
|
+
name?: string;
|
|
74
|
+
tariffName?: string;
|
|
75
|
+
/** The tariff's own band code (`punta`, `on-peak`, `super-off-peak` …). */
|
|
76
|
+
band?: string | null;
|
|
77
|
+
/** `TARIFF_LOAD_CLASSES` - for comparing across tariffs. */
|
|
78
|
+
loadClass?: string | null;
|
|
79
|
+
/** Season start `MM-DD`; empty together with `seasonTo` means all year. May wrap the year (11-01..02-28). */
|
|
80
|
+
seasonFrom?: string | null;
|
|
81
|
+
/** Season end `MM-DD`, inclusive. */
|
|
82
|
+
seasonTo?: string | null;
|
|
83
|
+
dayKind?: string | null;
|
|
84
|
+
/** `HH:mm`, inclusive. */
|
|
85
|
+
fromTime?: string | null;
|
|
86
|
+
/** `HH:mm`, exclusive; `24:00` ends the day. */
|
|
87
|
+
toTime?: string | null;
|
|
88
|
+
energyChargePerKWh?: number | string | null;
|
|
89
|
+
/** Time-of-use demand charge per kW in this band, on top of the tariff's facility charge. Optional. */
|
|
90
|
+
demandChargePerKW?: number | string | null;
|
|
91
|
+
effectiveEnd?: Date | string | null;
|
|
92
|
+
}
|
|
93
|
+
export declare const TARIFF_ISSUE_CODES: readonly ["required", "not-a-number", "negative", "not-in-vocabulary", "format", "currency-required", "season-pair", "end-not-after-start", "flat-and-bands", "broken-bands", "gap", "overlap"];
|
|
94
|
+
export type TariffIssueCode = (typeof TARIFF_ISSUE_CODES)[number];
|
|
95
|
+
export interface TariffIssue {
|
|
96
|
+
/** The field the issue is about (`currency`, `fromTime`, `bands` …). */
|
|
97
|
+
field: string;
|
|
98
|
+
code: TariffIssueCode;
|
|
99
|
+
params?: Record<string, string | number>;
|
|
100
|
+
}
|
|
101
|
+
/** One English line, `field: reason` - the form other contract checks use. */
|
|
102
|
+
export declare function tariffIssueText(issue: TariffIssue): string;
|
|
103
|
+
/** An ISO 4217 code - three upper-case letters (KRW, USD). */
|
|
104
|
+
export declare function isIso4217Code(value: unknown): value is string;
|
|
105
|
+
/** `HH:mm` → minutes from midnight. `24:00` is 1440 and is only an end. */
|
|
106
|
+
export declare function minutesOf(text: unknown): number | undefined;
|
|
107
|
+
/** `MM-DD` → day of a leap year (0..365). Takes 02-29 - that day too must fall in some season. */
|
|
108
|
+
export declare function dayOfYearOf(text: unknown): number | undefined;
|
|
109
|
+
/** One tariff row, before it is saved. Empty when it is sound. */
|
|
110
|
+
export declare function tariffIssues(row: TariffLike): TariffIssue[];
|
|
111
|
+
/** One band row, before it is saved. Whether bands cover the day cannot be seen from one row - `tariffCoverageIssues`. */
|
|
112
|
+
export declare function tariffBandIssues(row: TariffBandLike): TariffIssue[];
|
|
113
|
+
/** Bands still in force at `at` - a band whose end has passed was retired (rows are ended, not deleted). */
|
|
114
|
+
export declare function activeBands<T extends TariffBandLike>(bands: readonly T[], at: Date): T[];
|
|
115
|
+
/**
|
|
116
|
+
* Whether one tariff's bands cover **every minute of every day, once**.
|
|
117
|
+
*
|
|
118
|
+
* Looks at all 366 days of a leap year × the concrete day kinds (weekday, saturday, sunday, and holiday when the tariff
|
|
119
|
+
* prices holidays apart). An uncovered hour cannot be priced; an hour
|
|
120
|
+
* covered twice has two prices - either way its charge would be invented. The same problem over consecutive days is
|
|
121
|
+
* one issue (`params.days` like `06-01~08-31`).
|
|
122
|
+
*
|
|
123
|
+
* No bands is not an issue - it is a flat tariff (the tariff row's `energyChargePerKWh`). A tariff passes through
|
|
124
|
+
* wrong states while it is edited, so a screen shows this rather than refusing to save.
|
|
125
|
+
*/
|
|
126
|
+
export declare function tariffCoverageIssues(tariff: TariffLike, bands: readonly TariffBandLike[]): TariffIssue[];
|
|
127
|
+
/** A moment on the site's wall clock - the caller converts to the site's time zone. */
|
|
128
|
+
export interface LocalMoment {
|
|
129
|
+
/** 1..12 */
|
|
130
|
+
month: number;
|
|
131
|
+
/** 1..31 */
|
|
132
|
+
day: number;
|
|
133
|
+
/** 0 = Sunday … 6 = Saturday (as `Date.getDay`) */
|
|
134
|
+
weekday: number;
|
|
135
|
+
/** Minutes from midnight (0..1439) */
|
|
136
|
+
minutes: number;
|
|
137
|
+
}
|
|
138
|
+
export type BandAt = {
|
|
139
|
+
/** Band row name - absent for a flat tariff. */
|
|
140
|
+
bandName?: string;
|
|
141
|
+
/** The tariff's band code. */
|
|
142
|
+
band?: string;
|
|
143
|
+
loadClass?: TariffLoadClass;
|
|
144
|
+
energyChargePerKWh: number;
|
|
145
|
+
/** Time-of-use demand charge of the band, when it has one. The tariff's facility charge is not repeated here. */
|
|
146
|
+
demandChargePerKW?: number;
|
|
147
|
+
currency?: string;
|
|
148
|
+
/**
|
|
149
|
+
* False only when the tariff prices holidays apart and no `isHoliday` was given - a holiday may then have been
|
|
150
|
+
* priced as its weekday.
|
|
151
|
+
*/
|
|
152
|
+
holidayKnown: boolean;
|
|
153
|
+
} | {
|
|
154
|
+
reason: 'no-price' | 'no-band' | 'ambiguous';
|
|
155
|
+
bands?: string[];
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* The energy charge at this moment.
|
|
159
|
+
*
|
|
160
|
+
* Without bands the tariff's flat charge applies. With bands **exactly one** must match - none is `no-band`, more than
|
|
161
|
+
* one is `ambiguous`, and no price is picked (taking the first written would be chance).
|
|
162
|
+
*/
|
|
163
|
+
export declare function bandAt(tariff: TariffLike, bands: readonly TariffBandLike[], at: LocalMoment, isHoliday?: (month: number, day: number) => boolean): BandAt;
|