/* * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ import {SCMetaTranslations, SCTranslations} from '../../general/i18n'; import {SCISO8601Date} from '../../general/time'; import {SCOrganizationWithoutReferences} from '../organization'; import {SCPersonWithoutReferences} from '../person'; import {SCInPlace} from './place'; import {SCThing, SCThingMeta, SCThingTranslatableProperties, SCThingWithoutReferences} from './thing'; /** * Default price without distinction */ export interface SCPriceGroup { /** * Default price of the thing * * @sortable price * @float */ default: number; } /** * Price distinctions for academic context */ export interface SCAcademicPriceGroup extends SCPriceGroup { /** * Price for employees * * @sortable price * @float */ employee?: number; /** * Price for guests * * @sortable price * @float */ guest?: number; /** * Price for students * * @sortable price * @float */ student?: number; } /** * A thing without references that can be offered */ export interface SCThingThatCanBeOfferedWithoutReferences extends SCThingWithoutReferences { /** * Translations of a thing that can be offered */ translations?: SCTranslations; } /** * A thing that can be offered */ export interface SCThingThatCanBeOffered extends SCThing, SCThingThatCanBeOfferedWithoutReferences { /** * List of offers for that thing */ offers?: Array>; /** * Translations of a thing that can be offered */ translations?: SCTranslations; } /** * Offer of a thing */ export interface SCThingThatCanBeOfferedOffer extends SCInPlace { /** * Availability of an offer */ availability: SCThingThatCanBeOfferedAvailability; /** * The time when the thing becomes unavailable as an SCISO8601Date formatted string. */ availabilityEnds?: SCISO8601Date; /** * The time when the thing becomes available as an SCISO8601Date formatted string. */ availabilityStarts?: SCISO8601Date; /** * List of prices that are distinct for specific groups */ prices: T; /** * Provider of an offer */ provider: SCThingThatCanBeOfferedProvider; } /** * Translatable properties of a thing that can be offered */ export interface SCThingThatCanBeOfferedTranslatableProperties extends SCThingTranslatableProperties { /** * Availability of an offer * * @keyword */ 'offers[].availability'?: string; } /** * Entity responsible for the offer */ export type SCThingThatCanBeOfferedProvider = | SCOrganizationWithoutReferences | SCPersonWithoutReferences; /** * Availability of an Offer */ export type SCThingThatCanBeOfferedAvailability = | 'in stock' | 'out of stock' | 'online only' | 'limited availability'; /** * Meta information about a thing without references that accepts payments */ export class SCThingThatCanBeOfferedMeta implements SCMetaTranslations> { /** * Instance */ protected static _instance = new Map(); /** * Translations of fields */ fieldTranslations = { de: { ...SCThingMeta.getInstance().fieldTranslations.de, offers: 'Angebote', }, en: { ...SCThingMeta.getInstance().fieldTranslations.en, offers: 'offers', }, }; /** * Translations of values of fields */ fieldValueTranslations = { de: { ...SCThingMeta.getInstance().fieldValueTranslations.de, }, en: { ...SCThingMeta.getInstance().fieldValueTranslations.en, }, }; // tslint:disable:static-this /** * Function to retrieve typed singleton instance (including generics) */ public static getInstance(): SCThingThatCanBeOfferedMeta { if (!SCThingThatCanBeOfferedMeta._instance.has(this.name)) { SCThingThatCanBeOfferedMeta._instance.set(this.name, new SCThingThatCanBeOfferedMeta()); } return SCThingThatCanBeOfferedMeta._instance .get(this.name) as SCThingThatCanBeOfferedMeta; } protected constructor() { } }