scitex_affairs
Business and personal affairs: catalogs, actuals, scenarios, reports, and plots.
- class scitex_affairs.AffairsConfig(schema_version, organization, currency, fiscal_year_start_month, catalog, scenarios, pricing_policies, sources=(), fx=None)[source]
Bases:
objectValidated single source of truth for business design facts.
-
catalog:
Mapping[str,CatalogItem]
-
fx:
Mapping[str,Any] |None …}.
- Type:
Live-rate source for prices in another currency, e.g. {“provider”
-
catalog:
- class scitex_affairs.CatalogItem(id, name, direction, model, price, description='', category='', status='draft', automated=None, attributes=None)[source]
Bases:
objectOne revenue or expense item.
- exception scitex_affairs.ConfigError[source]
Bases:
ValueErrorThe business design document is inconsistent or incomplete.
- class scitex_affairs.DiscountPhase(start, end, percent, status, label='')[source]
Bases:
objectA dated discount phase shared through a pricing policy.
- exception scitex_affairs.FxError[source]
Bases:
ConfigErrorA rate could not be obtained or the supplier’s answer was unusable.
- class scitex_affairs.FxRate(base, quote, rate, as_of, source, retrieved_at)[source]
Bases:
objectOne
base -> quoterate with everything needed to disclose it.
- class scitex_affairs.Price(amount, interval, unit, kind='fixed', list_amount=None, discount_percent=0.0, markup_percent=None, policy='', discount_schedule=(), currency='')[source]
Bases:
objectA catalog price in the configuration’s currency.
-
discount_schedule:
tuple[DiscountPhase,...]
-
discount_schedule:
- class scitex_affairs.Scenario(id, label, status, start_date, end_date, series)[source]
Bases:
objectAn explicitly optional set of hypothetical time series.
- scitex_affairs.catalog_frame(config)[source]
Return the catalog as a stable, renderer-independent DataFrame.
- Return type:
- scitex_affairs.fetch_rate(base, quote, provider='open.er-api.com', *, opener=<function _urlopen>, timeout=10.0)[source]
Fetch the current
base -> quoterate from a declared provider.Raises
FxErrorwhen the provider is unknown, unreachable, or answers with anything but a positive rate forquote.- Return type:
- scitex_affairs.financial_statement(report)[source]
Reduce an item-level report to revenue, expense, and net by period.
- Return type:
- scitex_affairs.load_config(source=None)[source]
Load a mapping or resolved YAML config.
Path precedence is explicit argument,
SCITEX_AFFAIRS_CONFIG, then$SCITEX_DIR/affairs/config.yaml(normally~/.scitex/affairs/config.yaml). Project-scope resolution is provided by the ecosystem-widescitex_configlocal-state primitive.- Return type:
- scitex_affairs.resolve_config_path(source=None)[source]
Resolve explicit, environment, then canonical SciTeX config paths.
- Return type:
- scitex_affairs.monthly_report(config, scenario_id, *, rates=None)[source]
Calculate the canonical monthly ledger for one optional scenario.
Amounts are in
config.currency. A price set in another currency is converted at a live rate fromconfig.fx["provider"](or fromrates, keyed by the price currency, when the caller already holds them). Converted rows record the rate, its as-of time and source; the rates used are also inreport.attrs["fx"]forfx.disclosure().- Return type:
- scitex_affairs.summarize(monthly, frequency='month', fiscal_year_start_month=1)[source]
Aggregate the canonical monthly ledger without losing stock semantics.
- Return type:
Configuration
Resolve, load, and validate the reviewable business design document.
- exception scitex_affairs.config.ConfigError[source]
The business design document is inconsistent or incomplete.
- class scitex_affairs.config.DiscountPhase(start, end, percent, status, label='')[source]
A dated discount phase shared through a pricing policy.
- class scitex_affairs.config.Price(amount, interval, unit, kind='fixed', list_amount=None, discount_percent=0.0, markup_percent=None, policy='', discount_schedule=(), currency='')[source]
A catalog price in the configuration’s currency.
-
discount_schedule:
tuple[DiscountPhase,...]
-
discount_schedule:
- class scitex_affairs.config.CatalogItem(id, name, direction, model, price, description='', category='', status='draft', automated=None, attributes=None)[source]
One revenue or expense item.
- class scitex_affairs.config.Scenario(id, label, status, start_date, end_date, series)[source]
An explicitly optional set of hypothetical time series.
- class scitex_affairs.config.AffairsConfig(schema_version, organization, currency, fiscal_year_start_month, catalog, scenarios, pricing_policies, sources=(), fx=None)[source]
Validated single source of truth for business design facts.
-
catalog:
Mapping[str,CatalogItem]
-
fx:
Mapping[str,Any] |None …}.
- Type:
Live-rate source for prices in another currency, e.g. {“provider”
-
catalog:
- scitex_affairs.config.resolve_config_path(source=None)[source]
Resolve explicit, environment, then canonical SciTeX config paths.
- Return type:
- scitex_affairs.config.load_config(source=None)[source]
Load a mapping or resolved YAML config.
Path precedence is explicit argument,
SCITEX_AFFAIRS_CONFIG, then$SCITEX_DIR/affairs/config.yaml(normally~/.scitex/affairs/config.yaml). Project-scope resolution is provided by the ecosystem-widescitex_configlocal-state primitive.- Return type:
Scenarios
Scenario calculation with explicit stock/flow time semantics.
- scitex_affairs.scenario.monthly_report(config, scenario_id, *, rates=None)[source]
Calculate the canonical monthly ledger for one optional scenario.
Amounts are in
config.currency. A price set in another currency is converted at a live rate fromconfig.fx["provider"](or fromrates, keyed by the price currency, when the caller already holds them). Converted rows record the rate, its as-of time and source; the rates used are also inreport.attrs["fx"]forfx.disclosure().- Return type:
Exchange rates
Live exchange rates for prices denominated in another currency.
A price may be set in one currency (for example USD, the SciTeX price list) while plans and accounts are kept in another (for example JPY). Converting between them needs a rate, and a stale or invented rate silently misstates every derived figure. So the rate is always fetched from a declared reference source, recorded with its source and timestamps on every converted figure, and a failure to fetch is an error, never a fallback.
The converted figure is an estimate. Actual billing happens in the price’s
own currency; what a customer is charged in another currency is set by their
card issuer’s rate and fees at settlement. disclosure() renders that
statement so every output that shows a converted figure can carry it.
- scitex_affairs.fx.PROVIDERS: dict[str, tuple[str, str]] = {'open.er-api.com': ('ExchangeRate-API (open.er-api.com)', 'https://open.er-api.com/v6/latest/{base}')}
id -> (display name, URL template taking the base code). ExchangeRate-API is the source SciTeX Hub uses for its yen reference column, so a figure computed here and one shown on scitex.ai agree on method.
- Type:
Reference sources
- scitex_affairs.fx.Opener
opener(url, timeout_seconds) -> response body bytes. Injectable so tests can serve a real JSON body without patching this module.
- exception scitex_affairs.fx.FxError[source]
A rate could not be obtained or the supplier’s answer was unusable.
- class scitex_affairs.fx.FxRate(base, quote, rate, as_of, source, retrieved_at)[source]
One
base -> quoterate with everything needed to disclose it.
- scitex_affairs.fx.fetch_rate(base, quote, provider='open.er-api.com', *, opener=<function _urlopen>, timeout=10.0)[source]
Fetch the current
base -> quoterate from a declared provider.Raises
FxErrorwhen the provider is unknown, unreachable, or answers with anything but a positive rate forquote.- Return type:
Descriptions and rendering
Pandas-first descriptions of catalogs and calculated ledgers.
- scitex_affairs.describe.catalog_frame(config)[source]
Return the catalog as a stable, renderer-independent DataFrame.
- Return type:
- scitex_affairs.describe.summarize(monthly, frequency='month', fiscal_year_start_month=1)[source]
Aggregate the canonical monthly ledger without losing stock semantics.
- Return type:
- scitex_affairs.describe.financial_statement(report)[source]
Reduce an item-level report to revenue, expense, and net by period.
- Return type:
Replaceable text and file renderers for pandas business reports.