IF Commons GitHub

period

concept

A span of time of one scope (a month of a ledger, a reporting quarter) that takes changes while it is open and is closed when its figures are final

Model contract. Written in commons/data/models/contract/mod.ts:88. Identified by periodId.

Governance: attributes

closedAtinstantoptional

When it was closed

Becomes the column closed_at of period.

Written at commons/data/models/contract/mod.ts:97

closedBytextoptional

Who closed it

Becomes the column closed_by of period.

Written at commons/data/models/contract/mod.ts:96

endsOninstantrequired

Where it ends, not included

Becomes the column ends_on of period.

Written at commons/data/models/contract/mod.ts:94

periodIdidentifierrequired

What identifies the period: its scope and span

Becomes the column period_id of period.

Written at commons/data/models/contract/mod.ts:91

reasontextoptional

Why it was opened again, where it was

Becomes the column reason of period.

Written at commons/data/models/contract/mod.ts:98

scopetextrequired

What it is a period of

Becomes the column scope of period.

Written at commons/data/models/contract/mod.ts:92

startsOninstantrequired

Where it starts

Becomes the column starts_on of period.

Written at commons/data/models/contract/mod.ts:93

statuscode of periodStatusrequired

Whether it takes changes

Becomes the column status of period.

Written at commons/data/models/contract/mod.ts:95

Logical: the table

Projects to the table period with the primary key period_id.

ColumnTypeNullRoleFrom
closed_attimestamptrueattributeperiod.closedAt
closed_bytexttrueattributeperiod.closedBy
ends_ontimestampfalseattributeperiod.endsOn
period_idtextfalseattributeperiod.periodId
reasontexttrueattributeperiod.reason
scopetextfalseattributeperiod.scope
starts_ontimestampfalseattributeperiod.startsOn
statustextfalseattributeperiod.status

Physical: SQL

CREATE TABLE IF NOT EXISTS "period" (
    "period_id" VARCHAR NOT NULL PRIMARY KEY,
    "scope" VARCHAR NOT NULL,
    "starts_on" TIMESTAMPTZ NOT NULL,
    "ends_on" TIMESTAMPTZ NOT NULL,
    "status" VARCHAR NOT NULL,
    "closed_by" VARCHAR,
    "closed_at" TIMESTAMPTZ,
    "reason" VARCHAR,
    CONSTRAINT "period_scope_starts_on_uq" UNIQUE ("scope", "starts_on"),
    CONSTRAINT "period_status_ck" CHECK ("status" IN ('open', 'closed', 'reopened'))
);

Physical: the typed table

Read and written from TypeScript with the types the model gives: import { period } from "@intellectual-frontiers/data/sql/typed/models". Generated in commons/data/sql/typed/models/contract.auto.ts: do not edit.

import { from } from "@intellectual-frontiers/data/sql/typed";
import { period } from "@intellectual-frontiers/data/sql/typed/models";

const rows = await from(period).select((s) => ({ periodId: s.period.periodId, scope: s.period.scope })).run(runner);

Titles, headings, exports, tables, columns and requirements. Esc closes.