@things-factory/ops-master 10.1.306 → 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.
Files changed (39) hide show
  1. package/dist-client/pages/master/electricity-tariff-band.d.ts +13 -0
  2. package/dist-client/pages/master/electricity-tariff-band.js +50 -0
  3. package/dist-client/pages/master/electricity-tariff.d.ts +10 -0
  4. package/dist-client/pages/master/electricity-tariff.js +41 -0
  5. package/dist-client/pages/master/master-options.d.ts +4 -0
  6. package/dist-client/pages/master/master-options.js +13 -0
  7. package/dist-client/pages/master/reference-targets.js +1 -0
  8. package/dist-client/pages/master-axes.d.ts +1 -1
  9. package/dist-client/pages/master-axes.js +3 -1
  10. package/dist-client/route.js +6 -0
  11. package/dist-server/service/asset/index.d.ts +1 -1
  12. package/dist-server/service/energy/electricity-tariff-band.d.ts +54 -0
  13. package/dist-server/service/energy/electricity-tariff-band.js +141 -0
  14. package/dist-server/service/energy/electricity-tariff-resolver.d.ts +37 -0
  15. package/dist-server/service/energy/electricity-tariff-resolver.js +203 -0
  16. package/dist-server/service/energy/electricity-tariff.d.ts +57 -0
  17. package/dist-server/service/energy/electricity-tariff.js +127 -0
  18. package/dist-server/service/energy/index.d.ts +5 -0
  19. package/dist-server/service/energy/index.js +9 -0
  20. package/dist-server/service/energy/tariff-rules.d.ts +163 -0
  21. package/dist-server/service/energy/tariff-rules.js +395 -0
  22. package/dist-server/service/equipment/index.d.ts +1 -1
  23. package/dist-server/service/index.d.ts +5 -2
  24. package/dist-server/service/index.js +6 -0
  25. package/dist-server/service/master-axis.js +8 -0
  26. package/dist-server/service/personnel/index.d.ts +1 -1
  27. package/dist-server/service/recipe/index.d.ts +1 -1
  28. package/dist-server/service/status/master-status.js +5 -1
  29. package/helps/ops-master/electricity-tariff-band.ko.md +16 -0
  30. package/helps/ops-master/electricity-tariff-band.md +16 -0
  31. package/helps/ops-master/electricity-tariff.ko.md +16 -0
  32. package/helps/ops-master/electricity-tariff.md +16 -0
  33. package/package.json +5 -5
  34. package/translations/en.json +40 -1
  35. package/translations/es.json +40 -1
  36. package/translations/ja.json +40 -1
  37. package/translations/ko.json +40 -1
  38. package/translations/ms.json +40 -1
  39. package/translations/zh.json +40 -1
@@ -0,0 +1,13 @@
1
+ import { MasterPageBase, MasterSpec } from './master-page-base.js';
2
+ /**
3
+ * 시간대 요금 구간 — 「계절 × 요일 × 시각 → 단가」 한 줄.
4
+ *
5
+ * 구간 코드는 요금제가 정하고(자유), 요금제끼리 견주는 것은 부하 등급이다. 공휴일(`holiday`)은 요일보다 앞선다.
6
+ *
7
+ * 시각은 현장의 벽시계(`HH:mm`, 끝은 제외 · 하루의 끝은 `24:00`)이고, 자정을 넘는 구간은 두 줄로 적는다. 계절은
8
+ * `MM-DD` 둘이고 둘 다 비우면 일 년 내내다. 한 요금제의 구간이 하루를 빈틈없이 덮는지는 `electricityTariffIssues` 가
9
+ * 본다 — 편집하는 동안에는 늘 빈 시간이 있으므로 저장을 막지 않는다.
10
+ */
11
+ export declare class OpsMasterElectricityTariffBand extends MasterPageBase {
12
+ protected get spec(): MasterSpec;
13
+ }
@@ -0,0 +1,50 @@
1
+ import { __decorate } from "tslib";
2
+ import { customElement } from 'lit/decorators.js';
3
+ import { EFFECTIVE, IDENTITY, MasterPageBase } from './master-page-base.js';
4
+ import { TARIFF_DAY_KIND_OPTIONS, TARIFF_LOAD_CLASS_OPTIONS, withBlank } from './master-options.js';
5
+ /**
6
+ * 시간대 요금 구간 — 「계절 × 요일 × 시각 → 단가」 한 줄.
7
+ *
8
+ * 구간 코드는 요금제가 정하고(자유), 요금제끼리 견주는 것은 부하 등급이다. 공휴일(`holiday`)은 요일보다 앞선다.
9
+ *
10
+ * 시각은 현장의 벽시계(`HH:mm`, 끝은 제외 · 하루의 끝은 `24:00`)이고, 자정을 넘는 구간은 두 줄로 적는다. 계절은
11
+ * `MM-DD` 둘이고 둘 다 비우면 일 년 내내다. 한 요금제의 구간이 하루를 빈틈없이 덮는지는 `electricityTariffIssues` 가
12
+ * 본다 — 편집하는 동안에는 늘 빈 시간이 있으므로 저장을 막지 않는다.
13
+ */
14
+ let OpsMasterElectricityTariffBand = class OpsMasterElectricityTariffBand extends MasterPageBase {
15
+ get spec() {
16
+ return {
17
+ key: 'electricityTariffBand',
18
+ title: 'electricity-tariff-band',
19
+ help: 'ops-master/electricity-tariff-band',
20
+ query: 'electricityTariffBandList',
21
+ mutation: 'updateMultipleElectricityTariffBand',
22
+ columns: [
23
+ ...IDENTITY,
24
+ {
25
+ name: 'tariffName',
26
+ label: 'tariff',
27
+ type: 'reference',
28
+ reference: { queryName: 'electricityTariffList' },
29
+ width: 160
30
+ },
31
+ /* 구간 코드는 요금제가 정한다 — `punta` · `on-peak` · `super-off-peak` …(자유). 견주기는 부하 등급으로. */
32
+ { name: 'band', label: 'band-code', type: 'string', width: 120 },
33
+ { name: 'loadClass', label: 'load-class', type: 'select', options: TARIFF_LOAD_CLASS_OPTIONS, width: 130 },
34
+ { name: 'seasonFrom', label: 'season-from', type: 'string', width: 100 },
35
+ { name: 'seasonTo', label: 'season-to', type: 'string', width: 100 },
36
+ { name: 'dayKind', label: 'day-kind', type: 'select', options: withBlank(TARIFF_DAY_KIND_OPTIONS), width: 130 },
37
+ { name: 'fromTime', label: 'from-time', type: 'string', width: 90 },
38
+ { name: 'toTime', label: 'to-time', type: 'string', width: 90 },
39
+ { name: 'energyChargePerKWh', label: 'energy-charge-per-kwh', type: 'number', width: 150 },
40
+ { name: 'demandChargePerKW', label: 'tou-demand-charge-per-kw', type: 'number', width: 170 },
41
+ ...EFFECTIVE
42
+ ]
43
+ };
44
+ }
45
+ };
46
+ OpsMasterElectricityTariffBand = __decorate([
47
+ customElement('ops-master-electricity-tariff-band')
48
+ ], OpsMasterElectricityTariffBand);
49
+ export { OpsMasterElectricityTariffBand };
50
+ //# sourceMappingURL=electricity-tariff-band.js.map
@@ -0,0 +1,10 @@
1
+ import { MasterPageBase, MasterSpec } from './master-page-base.js';
2
+ /**
3
+ * 전기 요금제 — 이 현장이 공급자와 맺은 요금 계약.
4
+ *
5
+ * 시간대 요금이면 사용량 단가는 구간 화면(`ops-master-electricity-tariff-band`)에 적고 여기는 비운다. 단일 단가
6
+ * 요금제면 여기에 적고 구간은 두지 않는다. 계약전력은 수전 자리의 속성이라 여기 없다(`energy/electricity-tariff.ts`).
7
+ */
8
+ export declare class OpsMasterElectricityTariff extends MasterPageBase {
9
+ protected get spec(): MasterSpec;
10
+ }
@@ -0,0 +1,41 @@
1
+ import { __decorate } from "tslib";
2
+ import { customElement } from 'lit/decorators.js';
3
+ import { EFFECTIVE, IDENTITY, MasterPageBase } from './master-page-base.js';
4
+ /**
5
+ * 전기 요금제 — 이 현장이 공급자와 맺은 요금 계약.
6
+ *
7
+ * 시간대 요금이면 사용량 단가는 구간 화면(`ops-master-electricity-tariff-band`)에 적고 여기는 비운다. 단일 단가
8
+ * 요금제면 여기에 적고 구간은 두지 않는다. 계약전력은 수전 자리의 속성이라 여기 없다(`energy/electricity-tariff.ts`).
9
+ */
10
+ let OpsMasterElectricityTariff = class OpsMasterElectricityTariff extends MasterPageBase {
11
+ get spec() {
12
+ return {
13
+ key: 'electricityTariff',
14
+ title: 'electricity-tariff',
15
+ help: 'ops-master/electricity-tariff',
16
+ query: 'electricityTariffList',
17
+ mutation: 'updateMultipleElectricityTariff',
18
+ columns: [
19
+ ...IDENTITY,
20
+ { name: 'supplier', label: 'supplier', type: 'string', width: 160 },
21
+ {
22
+ name: 'incomingLocation',
23
+ label: 'incoming-location',
24
+ type: 'reference',
25
+ reference: { queryName: 'operationalLocations' },
26
+ width: 150
27
+ },
28
+ { name: 'currency', label: 'currency', type: 'string', width: 90 },
29
+ { name: 'demandChargePerKW', label: 'facility-demand-charge-per-kw', type: 'number', width: 170 },
30
+ { name: 'holidayCalendar', label: 'holiday-calendar', type: 'string', width: 150 },
31
+ { name: 'energyChargePerKWh', label: 'flat-energy-charge-per-kwh', type: 'number', width: 170 },
32
+ ...EFFECTIVE
33
+ ]
34
+ };
35
+ }
36
+ };
37
+ OpsMasterElectricityTariff = __decorate([
38
+ customElement('ops-master-electricity-tariff')
39
+ ], OpsMasterElectricityTariff);
40
+ export { OpsMasterElectricityTariff };
41
+ //# sourceMappingURL=electricity-tariff.js.map
@@ -38,3 +38,7 @@ export declare const INTENT_OPTIONS: readonly ["transport", "process", "dwell"];
38
38
  * 있는 칸에만 붙인다.
39
39
  */
40
40
  export declare function withBlank(options: readonly string[]): string[];
41
+ /** 부하 등급 — 가벼운 → 무거운. */
42
+ export declare const TARIFF_LOAD_CLASS_OPTIONS: readonly ["super-off-peak", "off-peak", "mid-peak", "on-peak"];
43
+ /** 어느 날에 쓰이나 — 비우면 `all`. `holiday` 는 요금제의 공휴일 달력의 날. */
44
+ export declare const TARIFF_DAY_KIND_OPTIONS: readonly ["all", "weekday", "saturday", "sunday", "holiday"];
@@ -51,4 +51,17 @@ void _contractIsInIntent;
51
51
  export function withBlank(options) {
52
52
  return ['', ...options];
53
53
  }
54
+ /*
55
+ * ── 전기 요금 구간의 값 (2026-11-27) ─────────────────────────────────────────
56
+ *
57
+ * 이 값의 주인은 계약이다(`@operato/ops-contract` `tariff.ts` 의 `TARIFF_LOAD_CLASSES` · `TARIFF_DAY_KINDS`). 0.9.48 이 발행되기
58
+ * 전까지 설치된 계약에 없으므로 거울을 두고, `test/tariff-rules.test.ts` 가 서버의 사본과 같은지 확인한다. 발행되면 위의
59
+ * `DOMAIN_SYSTEMS` 처럼 계약에서 가져오고 이 거울을 지운다.
60
+ *
61
+ * 구간 코드(`band`)는 고르는 칸이 아니다 — 요금제가 정하는 자유 코드다(ADR-0239 결정 7).
62
+ */
63
+ /** 부하 등급 — 가벼운 → 무거운. */
64
+ export const TARIFF_LOAD_CLASS_OPTIONS = ['super-off-peak', 'off-peak', 'mid-peak', 'on-peak'];
65
+ /** 어느 날에 쓰이나 — 비우면 `all`. `holiday` 는 요금제의 공휴일 달력의 날. */
66
+ export const TARIFF_DAY_KIND_OPTIONS = ['all', 'weekday', 'saturday', 'sunday', 'holiday'];
54
67
  //# sourceMappingURL=master-options.js.map
@@ -17,6 +17,7 @@
17
17
  export const REFERENCE_PAGE = {
18
18
  operationalLocations: 'ops-master-operational-location',
19
19
  stopReasonList: 'ops-master-stop-reason',
20
+ electricityTariffList: 'ops-master-electricity-tariff',
20
21
  materialDefinitions: 'ops-master-material-definition',
21
22
  materialClasses: 'ops-master-material-class',
22
23
  routeDefinitions: 'ops-master-route-definition',
@@ -18,7 +18,7 @@
18
18
  * 순서는 뜻이 없다. 새 축이 생기면 여기에 더하고 `pages/master/` 에 화면을 만든다. 여기에만 더하면
19
19
  * 옛 주소가 없는 화면으로 간다.
20
20
  */
21
- export declare const MASTER_AXIS_KEYS: readonly ["personnelClass", "person", "equipmentClass", "equipment", "stopReason", "physicalAssetClass", "physicalAsset", "materialClass", "materialDefinition", "operationalLocation", "operationDefinition", "testSpecification"];
21
+ export declare const MASTER_AXIS_KEYS: readonly ["personnelClass", "person", "equipmentClass", "equipment", "stopReason", "physicalAssetClass", "physicalAsset", "materialClass", "materialDefinition", "operationalLocation", "operationDefinition", "testSpecification", "electricityTariff", "electricityTariffBand"];
22
22
  export type MasterAxisKey = (typeof MASTER_AXIS_KEYS)[number];
23
23
  /** 아는 축인가. 모르는 이름이면 옛 주소를 새 주소로 보내지 않는다. */
24
24
  export declare function isMasterAxisKey(key: string): key is MasterAxisKey;
@@ -30,7 +30,9 @@ export const MASTER_AXIS_KEYS = [
30
30
  'materialDefinition',
31
31
  'operationalLocation',
32
32
  'operationDefinition',
33
- 'testSpecification'
33
+ 'testSpecification',
34
+ 'electricityTariff',
35
+ 'electricityTariffBand'
34
36
  ];
35
37
  /** 아는 축인가. 모르는 이름이면 옛 주소를 새 주소로 보내지 않는다. */
36
38
  export function isMasterAxisKey(key) {
@@ -49,6 +49,12 @@ export default function route(page) {
49
49
  case 'ops-master-recipe-definition':
50
50
  import('./pages/master/recipe-definition');
51
51
  return 'ops-master-recipe-definition';
52
+ case 'ops-master-electricity-tariff':
53
+ import('./pages/master/electricity-tariff');
54
+ return 'ops-master-electricity-tariff';
55
+ case 'ops-master-electricity-tariff-band':
56
+ import('./pages/master/electricity-tariff-band');
57
+ return 'ops-master-electricity-tariff-band';
52
58
  /*
53
59
  * 옛 주소 — `ops-master-list?axis=person`.
54
60
  *
@@ -2,5 +2,5 @@ import { AssetQuery } from './asset-query';
2
2
  import { PhysicalAsset } from './physical-asset';
3
3
  import { PhysicalAssetClass } from './physical-asset-class';
4
4
  import { PhysicalAssetClassResolver, PhysicalAssetResolver } from './asset-master-resolver';
5
- export declare const entities: (typeof PhysicalAssetClass | typeof PhysicalAsset)[];
5
+ export declare const entities: (typeof PhysicalAsset | typeof PhysicalAssetClass)[];
6
6
  export declare const resolvers: (typeof PhysicalAssetClassResolver | typeof PhysicalAssetResolver | typeof AssetQuery)[];
@@ -0,0 +1,54 @@
1
+ import { Domain } from '@things-factory/shell';
2
+ import { User } from '@things-factory/auth-base';
3
+ /**
4
+ * **시간대 요금 구간** — 요금제 하나의 「계절 × 요일 × 시각 → 단가」 한 줄.
5
+ *
6
+ * ── 왜 JSON 칸이 아니라 행인가 ──────────────────────────────────────────────
7
+ * 그리드의 `json` 칸은 글자를 `JSON.parse` 하고 실패하면 **오류 없이 `null`** 로 둔다(설비 근무 달력이 그렇게
8
+ * 값을 잃었다 — `pages/master/equipment.ts`). 단가가 조용히 사라지면 그 시간의 요금이 0 이 된다. 그래서 한 구간을
9
+ * 한 행으로 두고 칸마다 검사한다(`tariffBandRowIssues`).
10
+ *
11
+ * 시각은 현장의 벽시계다. 자정을 넘는 구간은 두 행으로 적는다(`tariff-rules.ts`).
12
+ */
13
+ export declare class ElectricityTariffBand {
14
+ readonly id: string;
15
+ domain?: Domain;
16
+ domainId?: string;
17
+ /** 구간 이름 — 요금제 안에서 하나. 예: `summer-weekday-peak-am`. */
18
+ name: string;
19
+ description?: string;
20
+ /** 어느 요금제의 구간인가 — `ElectricityTariff.name`. */
21
+ tariffName: string;
22
+ /**
23
+ * 구간 코드 — **요금제가 정한다**(`punta` · `on-peak` · `super-off-peak` …). 나라 · 전력사마다 구간의 수와 이름이 다르므로 닫지 않는다
24
+ * (ADR-0239 결정 7). 요금제끼리 견줄 때는 `loadClass` 를 본다.
25
+ */
26
+ band: string;
27
+ /** 부하 등급 — `super-off-peak` · `off-peak` · `mid-peak` · `on-peak`(가벼운 → 무거운, 계약 `TARIFF_LOAD_CLASSES`). 요금제끼리 견주는 축. */
28
+ loadClass?: string;
29
+ /** 계절 시작 `MM-DD` — 끝과 함께 비우면 일 년 내내. 해를 넘어도 된다(11-01~02-28). */
30
+ seasonFrom?: string;
31
+ /** 계절 끝 `MM-DD`(그날을 포함한다). */
32
+ seasonTo?: string;
33
+ /**
34
+ * `all` · `weekday` · `saturday` · `sunday` · `holiday` (계약 `TARIFF_DAY_KINDS`). 비우면 `all`.
35
+ * `holiday` 는 요금제의 공휴일 달력(`ElectricityTariff.holidayCalendar`)의 날이고 요일보다 앞선다. 공휴일을 일요일처럼 매기는 나라는 두 줄을 적는다.
36
+ */
37
+ dayKind?: string;
38
+ /** 시작 시각 `HH:mm`(포함). */
39
+ fromTime: string;
40
+ /** 끝 시각 `HH:mm`(제외). 하루의 끝은 `24:00`. */
41
+ toTime: string;
42
+ /** 이 구간의 사용량 단가 — 요금제의 통화로. */
43
+ energyChargePerKWh: number;
44
+ /** 시간대별 기본요금 — 이 구간의 최대수요 1kW 당. 요금제의 설비 기본요금에 **더해진다**. 없으면 비운다. */
45
+ demandChargePerKW?: number;
46
+ effectiveStart?: Date;
47
+ effectiveEnd?: Date;
48
+ createdAt?: Date;
49
+ updatedAt?: Date;
50
+ creator?: User;
51
+ creatorId?: string;
52
+ updater?: User;
53
+ updaterId?: string;
54
+ }
@@ -0,0 +1,141 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ElectricityTariffBand = 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
+ * ── 왜 JSON 칸이 아니라 행인가 ──────────────────────────────────────────────
13
+ * 그리드의 `json` 칸은 글자를 `JSON.parse` 하고 실패하면 **오류 없이 `null`** 로 둔다(설비 근무 달력이 그렇게
14
+ * 값을 잃었다 — `pages/master/equipment.ts`). 단가가 조용히 사라지면 그 시간의 요금이 0 이 된다. 그래서 한 구간을
15
+ * 한 행으로 두고 칸마다 검사한다(`tariffBandRowIssues`).
16
+ *
17
+ * 시각은 현장의 벽시계다. 자정을 넘는 구간은 두 행으로 적는다(`tariff-rules.ts`).
18
+ */
19
+ let ElectricityTariffBand = class ElectricityTariffBand {
20
+ };
21
+ exports.ElectricityTariffBand = ElectricityTariffBand;
22
+ tslib_1.__decorate([
23
+ (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
24
+ (0, type_graphql_1.Field)(type => type_graphql_1.ID),
25
+ tslib_1.__metadata("design:type", String)
26
+ ], ElectricityTariffBand.prototype, "id", void 0);
27
+ tslib_1.__decorate([
28
+ (0, typeorm_1.ManyToOne)(type => shell_1.Domain),
29
+ (0, type_graphql_1.Field)(type => shell_1.Domain),
30
+ tslib_1.__metadata("design:type", shell_1.Domain)
31
+ ], ElectricityTariffBand.prototype, "domain", void 0);
32
+ tslib_1.__decorate([
33
+ (0, typeorm_1.RelationId)((band) => band.domain),
34
+ tslib_1.__metadata("design:type", String)
35
+ ], ElectricityTariffBand.prototype, "domainId", void 0);
36
+ tslib_1.__decorate([
37
+ (0, typeorm_1.Column)(),
38
+ (0, type_graphql_1.Field)({ description: 'band name, unique within its tariff' }),
39
+ tslib_1.__metadata("design:type", String)
40
+ ], ElectricityTariffBand.prototype, "name", void 0);
41
+ tslib_1.__decorate([
42
+ (0, typeorm_1.Column)({ nullable: true }),
43
+ (0, type_graphql_1.Field)({ nullable: true }),
44
+ tslib_1.__metadata("design:type", String)
45
+ ], ElectricityTariffBand.prototype, "description", void 0);
46
+ tslib_1.__decorate([
47
+ (0, typeorm_1.Column)(),
48
+ (0, type_graphql_1.Field)({ description: 'the tariff this band belongs to' }),
49
+ tslib_1.__metadata("design:type", String)
50
+ ], ElectricityTariffBand.prototype, "tariffName", void 0);
51
+ tslib_1.__decorate([
52
+ (0, typeorm_1.Column)(),
53
+ (0, type_graphql_1.Field)({ description: "the tariff's own band code (punta, on-peak, super-off-peak ...)" }),
54
+ tslib_1.__metadata("design:type", String)
55
+ ], ElectricityTariffBand.prototype, "band", void 0);
56
+ tslib_1.__decorate([
57
+ (0, typeorm_1.Column)({ nullable: true }),
58
+ (0, type_graphql_1.Field)({ nullable: true, description: 'super-off-peak | off-peak | mid-peak | on-peak — for comparing bands across tariffs' }),
59
+ tslib_1.__metadata("design:type", String)
60
+ ], ElectricityTariffBand.prototype, "loadClass", void 0);
61
+ tslib_1.__decorate([
62
+ (0, typeorm_1.Column)({ nullable: true }),
63
+ (0, type_graphql_1.Field)({ nullable: true, description: 'season start, MM-DD; empty with seasonTo means all year' }),
64
+ tslib_1.__metadata("design:type", String)
65
+ ], ElectricityTariffBand.prototype, "seasonFrom", void 0);
66
+ tslib_1.__decorate([
67
+ (0, typeorm_1.Column)({ nullable: true }),
68
+ (0, type_graphql_1.Field)({ nullable: true, description: 'season end, MM-DD, inclusive' }),
69
+ tslib_1.__metadata("design:type", String)
70
+ ], ElectricityTariffBand.prototype, "seasonTo", void 0);
71
+ tslib_1.__decorate([
72
+ (0, typeorm_1.Column)({ nullable: true }),
73
+ (0, type_graphql_1.Field)({ nullable: true, description: 'all | weekday | saturday | sunday | holiday' }),
74
+ tslib_1.__metadata("design:type", String)
75
+ ], ElectricityTariffBand.prototype, "dayKind", void 0);
76
+ tslib_1.__decorate([
77
+ (0, typeorm_1.Column)(),
78
+ (0, type_graphql_1.Field)({ description: 'start time, HH:mm local wall clock, inclusive' }),
79
+ tslib_1.__metadata("design:type", String)
80
+ ], ElectricityTariffBand.prototype, "fromTime", void 0);
81
+ tslib_1.__decorate([
82
+ (0, typeorm_1.Column)(),
83
+ (0, type_graphql_1.Field)({ description: 'end time, HH:mm local wall clock, exclusive; 24:00 ends the day' }),
84
+ tslib_1.__metadata("design:type", String)
85
+ ], ElectricityTariffBand.prototype, "toTime", void 0);
86
+ tslib_1.__decorate([
87
+ (0, typeorm_1.Column)({ type: 'float' }),
88
+ (0, type_graphql_1.Field)(type => type_graphql_1.Float, { description: 'energy charge per kWh in this band, in the tariff currency' }),
89
+ tslib_1.__metadata("design:type", Number)
90
+ ], ElectricityTariffBand.prototype, "energyChargePerKWh", void 0);
91
+ tslib_1.__decorate([
92
+ (0, typeorm_1.Column)({ type: 'float', nullable: true }),
93
+ (0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true, description: 'time-of-use demand charge per kW in this band, on top of the facility charge' }),
94
+ tslib_1.__metadata("design:type", Number)
95
+ ], ElectricityTariffBand.prototype, "demandChargePerKW", void 0);
96
+ tslib_1.__decorate([
97
+ (0, typeorm_1.Column)({ nullable: true }),
98
+ (0, type_graphql_1.Field)({ nullable: true }),
99
+ tslib_1.__metadata("design:type", Date)
100
+ ], ElectricityTariffBand.prototype, "effectiveStart", void 0);
101
+ tslib_1.__decorate([
102
+ (0, typeorm_1.Column)({ nullable: true }),
103
+ (0, type_graphql_1.Field)({ nullable: true }),
104
+ tslib_1.__metadata("design:type", Date)
105
+ ], ElectricityTariffBand.prototype, "effectiveEnd", void 0);
106
+ tslib_1.__decorate([
107
+ (0, typeorm_1.CreateDateColumn)(),
108
+ (0, type_graphql_1.Field)({ nullable: true }),
109
+ tslib_1.__metadata("design:type", Date)
110
+ ], ElectricityTariffBand.prototype, "createdAt", void 0);
111
+ tslib_1.__decorate([
112
+ (0, typeorm_1.UpdateDateColumn)(),
113
+ (0, type_graphql_1.Field)({ nullable: true }),
114
+ tslib_1.__metadata("design:type", Date)
115
+ ], ElectricityTariffBand.prototype, "updatedAt", void 0);
116
+ tslib_1.__decorate([
117
+ (0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
118
+ (0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true }),
119
+ tslib_1.__metadata("design:type", auth_base_1.User)
120
+ ], ElectricityTariffBand.prototype, "creator", void 0);
121
+ tslib_1.__decorate([
122
+ (0, typeorm_1.RelationId)((band) => band.creator),
123
+ tslib_1.__metadata("design:type", String)
124
+ ], ElectricityTariffBand.prototype, "creatorId", void 0);
125
+ tslib_1.__decorate([
126
+ (0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
127
+ (0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true }),
128
+ tslib_1.__metadata("design:type", auth_base_1.User)
129
+ ], ElectricityTariffBand.prototype, "updater", void 0);
130
+ tslib_1.__decorate([
131
+ (0, typeorm_1.RelationId)((band) => band.updater),
132
+ tslib_1.__metadata("design:type", String)
133
+ ], ElectricityTariffBand.prototype, "updaterId", void 0);
134
+ exports.ElectricityTariffBand = ElectricityTariffBand = tslib_1.__decorate([
135
+ (0, typeorm_1.Entity)({ name: 'ops_electricity_tariff_band' }),
136
+ (0, typeorm_1.Index)('ix_ops_electricity_tariff_band_0', (band) => [band.domain, band.tariffName, band.name], {
137
+ unique: true
138
+ }),
139
+ (0, type_graphql_1.ObjectType)({ description: 'One time-of-use band of an electricity tariff' })
140
+ ], ElectricityTariffBand);
141
+ //# sourceMappingURL=electricity-tariff-band.js.map
@@ -0,0 +1,37 @@
1
+ import { ListParam } from '@things-factory/shell';
2
+ import { MasterPatch } from '../master-crud';
3
+ import { ElectricityTariff } from './electricity-tariff';
4
+ import { ElectricityTariffBand } from './electricity-tariff-band';
5
+ declare class ElectricityTariffList {
6
+ items: ElectricityTariff[];
7
+ total: number;
8
+ }
9
+ declare class ElectricityTariffBandList {
10
+ items: ElectricityTariffBand[];
11
+ total: number;
12
+ }
13
+ /** 계약의 문제 하나 — 화면은 `code` 를 자기 말로 옮긴다(`tariff-issue.<code>`). `text` 는 번역이 없을 때의 영어 한 줄. */
14
+ declare class ElectricityTariffIssue {
15
+ field: string;
16
+ code: string;
17
+ params?: Record<string, string | number>;
18
+ text: string;
19
+ }
20
+ declare class ElectricityTariffIssues {
21
+ tariffName: string;
22
+ bandCount: number;
23
+ issues: ElectricityTariffIssue[];
24
+ }
25
+ export declare class ElectricityTariffResolver {
26
+ electricityTariffList(params: ListParam, context: ResolverContext): Promise<ElectricityTariffList>;
27
+ updateMultipleElectricityTariff(patches: MasterPatch[], context: ResolverContext): Promise<ElectricityTariff[]>;
28
+ electricityTariffBandList(params: ListParam, context: ResolverContext): Promise<ElectricityTariffBandList>;
29
+ updateMultipleElectricityTariffBand(patches: MasterPatch[], context: ResolverContext): Promise<ElectricityTariffBand[]>;
30
+ /**
31
+ * 요금제마다 행의 문제와, 구간이 하루를 빈틈없이 덮는지 — **저장을 막지 않는 점검**이다(편집하는 동안에는 늘 빈 시간이 있다).
32
+ *
33
+ * 지금 쓰이는(끝이 지나지 않은) 요금제와 구간만 본다.
34
+ */
35
+ electricityTariffIssues(context: ResolverContext): Promise<ElectricityTariffIssues[]>;
36
+ }
37
+ export {};
@@ -0,0 +1,203 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ElectricityTariffResolver = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const type_graphql_1 = require("type-graphql");
6
+ const shell_1 = require("@things-factory/shell");
7
+ const master_crud_1 = require("../master-crud");
8
+ const master_axis_1 = require("../master-axis");
9
+ const master_list_1 = require("../master-list");
10
+ const electricity_tariff_1 = require("./electricity-tariff");
11
+ const electricity_tariff_band_1 = require("./electricity-tariff-band");
12
+ /* 규칙의 주인은 계약이다 — `tariff-rules.ts` 는 0.9.48 발행 전까지의 글자 그대로의 사본(그 파일 머리). */
13
+ const tariff_rules_1 = require("./tariff-rules");
14
+ let ElectricityTariffList = class ElectricityTariffList {
15
+ };
16
+ tslib_1.__decorate([
17
+ (0, type_graphql_1.Field)(type => [electricity_tariff_1.ElectricityTariff]),
18
+ tslib_1.__metadata("design:type", Array)
19
+ ], ElectricityTariffList.prototype, "items", void 0);
20
+ tslib_1.__decorate([
21
+ (0, type_graphql_1.Field)(type => type_graphql_1.Int),
22
+ tslib_1.__metadata("design:type", Number)
23
+ ], ElectricityTariffList.prototype, "total", void 0);
24
+ ElectricityTariffList = tslib_1.__decorate([
25
+ (0, type_graphql_1.ObjectType)()
26
+ ], ElectricityTariffList);
27
+ let ElectricityTariffBandList = class ElectricityTariffBandList {
28
+ };
29
+ tslib_1.__decorate([
30
+ (0, type_graphql_1.Field)(type => [electricity_tariff_band_1.ElectricityTariffBand]),
31
+ tslib_1.__metadata("design:type", Array)
32
+ ], ElectricityTariffBandList.prototype, "items", void 0);
33
+ tslib_1.__decorate([
34
+ (0, type_graphql_1.Field)(type => type_graphql_1.Int),
35
+ tslib_1.__metadata("design:type", Number)
36
+ ], ElectricityTariffBandList.prototype, "total", void 0);
37
+ ElectricityTariffBandList = tslib_1.__decorate([
38
+ (0, type_graphql_1.ObjectType)()
39
+ ], ElectricityTariffBandList);
40
+ /** 계약의 문제 하나 — 화면은 `code` 를 자기 말로 옮긴다(`tariff-issue.<code>`). `text` 는 번역이 없을 때의 영어 한 줄. */
41
+ let ElectricityTariffIssue = class ElectricityTariffIssue {
42
+ };
43
+ tslib_1.__decorate([
44
+ (0, type_graphql_1.Field)(),
45
+ tslib_1.__metadata("design:type", String)
46
+ ], ElectricityTariffIssue.prototype, "field", void 0);
47
+ tslib_1.__decorate([
48
+ (0, type_graphql_1.Field)(),
49
+ tslib_1.__metadata("design:type", String)
50
+ ], ElectricityTariffIssue.prototype, "code", void 0);
51
+ tslib_1.__decorate([
52
+ (0, type_graphql_1.Field)(type => shell_1.ScalarObject, { nullable: true }),
53
+ tslib_1.__metadata("design:type", Object)
54
+ ], ElectricityTariffIssue.prototype, "params", void 0);
55
+ tslib_1.__decorate([
56
+ (0, type_graphql_1.Field)(),
57
+ tslib_1.__metadata("design:type", String)
58
+ ], ElectricityTariffIssue.prototype, "text", void 0);
59
+ ElectricityTariffIssue = tslib_1.__decorate([
60
+ (0, type_graphql_1.ObjectType)({ description: 'One tariff issue - the contract TariffIssue, with its English line' })
61
+ ], ElectricityTariffIssue);
62
+ let ElectricityTariffIssues = class ElectricityTariffIssues {
63
+ };
64
+ tslib_1.__decorate([
65
+ (0, type_graphql_1.Field)(),
66
+ tslib_1.__metadata("design:type", String)
67
+ ], ElectricityTariffIssues.prototype, "tariffName", void 0);
68
+ tslib_1.__decorate([
69
+ (0, type_graphql_1.Field)(type => type_graphql_1.Int),
70
+ tslib_1.__metadata("design:type", Number)
71
+ ], ElectricityTariffIssues.prototype, "bandCount", void 0);
72
+ tslib_1.__decorate([
73
+ (0, type_graphql_1.Field)(type => [ElectricityTariffIssue]),
74
+ tslib_1.__metadata("design:type", Array)
75
+ ], ElectricityTariffIssues.prototype, "issues", void 0);
76
+ ElectricityTariffIssues = tslib_1.__decorate([
77
+ (0, type_graphql_1.ObjectType)({ description: 'Whether one tariff and its bands are sound and cover every day without gap or overlap' })
78
+ ], ElectricityTariffIssues);
79
+ const withText = (issue) => ({ ...issue, text: (0, tariff_rules_1.tariffIssueText)(issue) });
80
+ /**
81
+ * 저장하기 전에 행마다 본다 — **고친 행은 저장된 값과 합친 모양으로** 본다.
82
+ *
83
+ * 그리드는 고친 칸만 보낸다. 그것만 보면 「요금제 이름이 없다」 같은 거짓 문제가 나고, 반대로 합치지 않고 통과시키면
84
+ * 끝 시각만 고쳐 시작보다 앞서게 만든 행이 들어온다. 지우는 패치는 값을 다시 말하지 않으므로 보지 않는다.
85
+ *
86
+ * 거절은 이름 있는 거절(`Refusal`)이다 — 코드는 `tariff-<계약 문제 코드>`, 낱말 키는 `error.tariff-<코드>`. 한 행의 첫 문제만 말한다.
87
+ */
88
+ async function refuseBrokenRows(manager, domain, entity, patches, issuesOf) {
89
+ for (const patch of patches) {
90
+ const flag = String(patch.cuFlag ?? 'M').toUpperCase();
91
+ if (flag === '-')
92
+ continue;
93
+ const { cuFlag, ...values } = patch;
94
+ const stored = flag === '+' || !patch.id
95
+ ? {}
96
+ : ((await manager.getRepository(entity).findOne({ where: { domain: { id: domain.id }, id: patch.id } })) ?? {});
97
+ const merged = { ...stored, ...values };
98
+ const [first] = issuesOf(merged);
99
+ if (first) {
100
+ throw new shell_1.Refusal(`tariff-${first.code}`, { row: String(merged.name ?? ''), field: first.field, ...(first.params ?? {}) }, `"${String(merged.name ?? '')}" — ${(0, tariff_rules_1.tariffIssueText)(first)}`);
101
+ }
102
+ }
103
+ }
104
+ let ElectricityTariffResolver = class ElectricityTariffResolver {
105
+ async electricityTariffList(params, context) {
106
+ const { items, total } = await (0, master_list_1.listMaster)('electricityTariff', params, context.state.domain);
107
+ return { items: items, total };
108
+ }
109
+ async updateMultipleElectricityTariff(patches, context) {
110
+ const { domain, user, tx } = context.state;
111
+ const axis = (0, master_axis_1.masterAxisOf)('electricityTariff');
112
+ await refuseBrokenRows(tx, domain, axis.entity, patches, tariff_rules_1.tariffIssues);
113
+ return (await (0, master_crud_1.saveMasterPatches)(tx, domain, axis.entity, patches, user, { hasEffectivePeriod: axis.hasEffectivePeriod }));
114
+ }
115
+ async electricityTariffBandList(params, context) {
116
+ const { items, total } = await (0, master_list_1.listMaster)('electricityTariffBand', params, context.state.domain);
117
+ return { items: items, total };
118
+ }
119
+ async updateMultipleElectricityTariffBand(patches, context) {
120
+ const { domain, user, tx } = context.state;
121
+ const axis = (0, master_axis_1.masterAxisOf)('electricityTariffBand');
122
+ await refuseBrokenRows(tx, domain, axis.entity, patches, tariff_rules_1.tariffBandIssues);
123
+ /* 가리키는 요금제가 없으면 받지 않는다 — 그 구간은 어느 계약의 단가도 아니다. */
124
+ const named = [...new Set(patches.filter(p => String(p.cuFlag ?? '').toUpperCase() !== '-' && p.tariffName).map(p => String(p.tariffName).trim()))];
125
+ for (const name of named) {
126
+ const found = await tx.getRepository(electricity_tariff_1.ElectricityTariff).findOne({ where: { domain: { id: domain.id }, name } });
127
+ if (!found)
128
+ throw new shell_1.Refusal('tariff-unknown-tariff', { tariff: name }, `no tariff "${name}" - register the tariff first`);
129
+ }
130
+ return (await (0, master_crud_1.saveMasterPatches)(tx, domain, axis.entity, patches, user, { hasEffectivePeriod: axis.hasEffectivePeriod }));
131
+ }
132
+ /**
133
+ * 요금제마다 행의 문제와, 구간이 하루를 빈틈없이 덮는지 — **저장을 막지 않는 점검**이다(편집하는 동안에는 늘 빈 시간이 있다).
134
+ *
135
+ * 지금 쓰이는(끝이 지나지 않은) 요금제와 구간만 본다.
136
+ */
137
+ async electricityTariffIssues(context) {
138
+ const { domain } = context.state;
139
+ const now = new Date();
140
+ const tariffs = (0, tariff_rules_1.activeBands)(await (0, shell_1.getRepository)(electricity_tariff_1.ElectricityTariff).find({ where: { domain: { id: domain.id } } }), now);
141
+ const bands = (0, tariff_rules_1.activeBands)(await (0, shell_1.getRepository)(electricity_tariff_band_1.ElectricityTariffBand).find({ where: { domain: { id: domain.id } } }), now);
142
+ return tariffs.map(tariff => {
143
+ const mine = bands.filter(b => b.tariffName === tariff.name);
144
+ return {
145
+ tariffName: tariff.name,
146
+ bandCount: mine.length,
147
+ issues: [...(0, tariff_rules_1.tariffIssues)(tariff), ...(0, tariff_rules_1.tariffCoverageIssues)(tariff, mine)].map(withText)
148
+ };
149
+ });
150
+ }
151
+ };
152
+ exports.ElectricityTariffResolver = ElectricityTariffResolver;
153
+ tslib_1.__decorate([
154
+ (0, type_graphql_1.Directive)('@privilege(category: "ops-master", privilege: "query", domainOwnerGranted: true)'),
155
+ (0, type_graphql_1.Query)(returns => ElectricityTariffList, { description: 'Electricity tariffs of this site' }),
156
+ tslib_1.__param(0, (0, type_graphql_1.Args)(type => shell_1.ListParam)),
157
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
158
+ tslib_1.__metadata("design:type", Function),
159
+ tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
160
+ tslib_1.__metadata("design:returntype", Promise)
161
+ ], ElectricityTariffResolver.prototype, "electricityTariffList", null);
162
+ tslib_1.__decorate([
163
+ (0, type_graphql_1.Directive)('@privilege(category: "ops-master", privilege: "mutation", domainOwnerGranted: true)'),
164
+ (0, type_graphql_1.Directive)('@transaction'),
165
+ (0, type_graphql_1.Mutation)(returns => [electricity_tariff_1.ElectricityTariff], { description: 'To create, change or retire electricity tariffs' }),
166
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('patches', type => [shell_1.ScalarObject])),
167
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
168
+ tslib_1.__metadata("design:type", Function),
169
+ tslib_1.__metadata("design:paramtypes", [Array, Object]),
170
+ tslib_1.__metadata("design:returntype", Promise)
171
+ ], ElectricityTariffResolver.prototype, "updateMultipleElectricityTariff", null);
172
+ tslib_1.__decorate([
173
+ (0, type_graphql_1.Directive)('@privilege(category: "ops-master", privilege: "query", domainOwnerGranted: true)'),
174
+ (0, type_graphql_1.Query)(returns => ElectricityTariffBandList, { description: 'Time-of-use bands of the electricity tariffs of this site' }),
175
+ tslib_1.__param(0, (0, type_graphql_1.Args)(type => shell_1.ListParam)),
176
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
177
+ tslib_1.__metadata("design:type", Function),
178
+ tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
179
+ tslib_1.__metadata("design:returntype", Promise)
180
+ ], ElectricityTariffResolver.prototype, "electricityTariffBandList", null);
181
+ tslib_1.__decorate([
182
+ (0, type_graphql_1.Directive)('@privilege(category: "ops-master", privilege: "mutation", domainOwnerGranted: true)'),
183
+ (0, type_graphql_1.Directive)('@transaction'),
184
+ (0, type_graphql_1.Mutation)(returns => [electricity_tariff_band_1.ElectricityTariffBand], { description: 'To create, change or retire time-of-use bands' }),
185
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('patches', type => [shell_1.ScalarObject])),
186
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
187
+ tslib_1.__metadata("design:type", Function),
188
+ tslib_1.__metadata("design:paramtypes", [Array, Object]),
189
+ tslib_1.__metadata("design:returntype", Promise)
190
+ ], ElectricityTariffResolver.prototype, "updateMultipleElectricityTariffBand", null);
191
+ tslib_1.__decorate([
192
+ (0, type_graphql_1.Directive)('@privilege(category: "ops-master", privilege: "query", domainOwnerGranted: true)'),
193
+ (0, type_graphql_1.Query)(returns => [ElectricityTariffIssues], { description: 'Row issues, gaps and overlaps in the time-of-use bands of each tariff' }),
194
+ tslib_1.__param(0, (0, type_graphql_1.Ctx)()),
195
+ tslib_1.__metadata("design:type", Function),
196
+ tslib_1.__metadata("design:paramtypes", [Object]),
197
+ tslib_1.__metadata("design:returntype", Promise)
198
+ ], ElectricityTariffResolver.prototype, "electricityTariffIssues", null);
199
+ exports.ElectricityTariffResolver = ElectricityTariffResolver = tslib_1.__decorate([
200
+ (0, type_graphql_1.Resolver)(electricity_tariff_1.ElectricityTariff),
201
+ (0, type_graphql_1.UseMiddleware)(shell_1.SpeakRefusals)
202
+ ], ElectricityTariffResolver);
203
+ //# sourceMappingURL=electricity-tariff-resolver.js.map