Initial commit
This commit is contained in:
commit
c534d5ce80
163 files changed
+11500
No files matched your search
@@ -0,0 +1,109 @@
|
||||
// ==========================================
|
||||
// INFRASTRUCTURE: ПУБЛИЧНЫЕ ДАННЫЕ КОМПАНИЙ
|
||||
// ==========================================
|
||||
#import "../domain/company.typ": company-profile
|
||||
#import "../domain/document.typ": fail
|
||||
|
||||
#let available-companies() = ("scientia", "technology", "too", "test-company")
|
||||
|
||||
#let company-data-path(id) = {
|
||||
if id == "scientia" {
|
||||
path("../../companies/scientia/data.json")
|
||||
} else if id == "technology" {
|
||||
path("../../companies/technology/data.json")
|
||||
} else if id == "too" {
|
||||
path("../../companies/too/data.json")
|
||||
} else if id == "test-company" {
|
||||
path("../../companies/test-company/data.json")
|
||||
} else {
|
||||
fail(
|
||||
"load-company.id",
|
||||
"неизвестная компания " + repr(id) + "; доступны " + available-companies().join(", "),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#let internal-asset(value) = {
|
||||
let value = if value == "" { none } else { value }
|
||||
if value == none {
|
||||
none
|
||||
} else if type(value) == path or type(value) == content {
|
||||
value
|
||||
} else if type(value) == str and value.starts-with("companies/") {
|
||||
path("../../" + value)
|
||||
} else if type(value) == str {
|
||||
fail("company-asset", "путь должен начинаться с companies/: " + repr(value))
|
||||
} else {
|
||||
fail("company-asset", "ожидались none, str, path или content")
|
||||
}
|
||||
}
|
||||
|
||||
#let external-resource(value, field) = {
|
||||
if value == none or type(value) == path or type(value) == content {
|
||||
value
|
||||
} else {
|
||||
fail("load-company." + field, "ожидались none, path или content")
|
||||
}
|
||||
}
|
||||
|
||||
#let normalize-company-data(id, raw) = {
|
||||
let jurisdiction = if id == "too" { "KZ" } else { "RU" }
|
||||
let color-value = raw.at("brand-color", default: "#e39f49")
|
||||
let brand-color = if type(color-value) == color { color-value } else { rgb(color-value) }
|
||||
|
||||
company-profile(
|
||||
id,
|
||||
(
|
||||
name: raw.at("name"),
|
||||
short-name: raw.at("short-name", default: raw.at("name")),
|
||||
jurisdiction: jurisdiction,
|
||||
inn: raw.at("inn", default: none),
|
||||
kpp: raw.at("kpp", default: none),
|
||||
ogrn: raw.at("ogrn", default: none),
|
||||
bin: raw.at("bin", default: none),
|
||||
kbe: raw.at("kbe", default: none),
|
||||
),
|
||||
contacts: (
|
||||
email: raw.at("email", default: none),
|
||||
website: raw.at("website", default: none),
|
||||
phone: raw.at("phone", default: none),
|
||||
address: raw.at("address", default: none),
|
||||
address-en: raw.at("address_en", default: none),
|
||||
city: raw.at("city", default: none),
|
||||
summary: raw.at("company_info", default: none),
|
||||
),
|
||||
banking: (
|
||||
bank: raw.at("bank", default: none),
|
||||
correspondent-account: raw.at("ks", default: none),
|
||||
bik: raw.at("bik", default: none),
|
||||
),
|
||||
brand: (color: brand-color),
|
||||
director: (
|
||||
title: raw.at("director-title", default: "Директор"),
|
||||
name: raw.at("director-name", default: none),
|
||||
),
|
||||
resources: (
|
||||
logo: internal-asset(raw.at("logo_image", default: none)),
|
||||
signature: internal-asset(raw.at("sign_image", default: none)),
|
||||
stamp: internal-asset(raw.at("stamp_image", default: none)),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
#let load-company(
|
||||
id,
|
||||
logo: auto,
|
||||
signature: auto,
|
||||
stamp: auto,
|
||||
) = {
|
||||
if type(id) != str {
|
||||
fail("load-company.id", "ожидалась строка")
|
||||
}
|
||||
let company = normalize-company-data(id, json(company-data-path(id)))
|
||||
let resources = company.resources
|
||||
if logo != auto { resources.insert("logo", external-resource(logo, "logo")) }
|
||||
if signature != auto { resources.insert("signature", external-resource(signature, "signature")) }
|
||||
if stamp != auto { resources.insert("stamp", external-resource(stamp, "stamp")) }
|
||||
company.insert("resources", resources)
|
||||
company
|
||||
}
|
||||
Reference in new issue
Block a user