aeat.application.storage.calc_sheets._theme module

Shared visual design system for modelo workbook exports.

This module is the single source of truth for the export look — the font family and the role→style palette — consumed identically by both transports (the offline openpyxl materializer in _workbook_export and the online Google-Sheets apply adapter in _calc_sheets_apply). Centralising the design here is what makes “uniform application across all exports” structural rather than coincidental: neither transport hard-codes a colour or a font; both import WORKBOOK_FONT_FAMILY and ROLE_STYLES and translate the same declarative RoleStyle into their respective formatting API. The palette mirrors the calm, boxed look of the official AEAT paper modelo: a slate header band, light blue-grey section banners, pale-yellow operator-input boxes, light-grey computed/protected cells, and a green-accented final result.

The colours are stored as plain RRGGBB hex; hex_to_rgb_floats() converts to the 0..1 channel floats the Sheets API wants, and openpyxl consumes the hex directly (prefixed with the opaque alpha FF).

class StyleRole(*values)[source]

Bases: StrEnum

The closed set of presentation roles a styled range can carry.

Each role maps to exactly one RoleStyle in ROLE_STYLES; the engine tags ranges with a role and both transports resolve the role to concrete fill / font / alignment through this module.

HEADER
SECTION_BANNER
INPUT
COMPUTED
RESULT
TITLE
BODY
class RoleStyle(fill_hex, font_hex, bold, align, wrap=False)[source]

Bases: object

A declarative cell style independent of any rendering backend.

fill_hex / font_hex are RRGGBB (or None for “no fill” / “default ink”); bold toggles weight; align is the horizontal alignment; wrap requests text wrapping (the renderer auto-grows row height to fit).

Parameters:
  • fill_hex (str | None)

  • font_hex (str | None)

  • bold (bool)

  • align (Literal['left', 'center', 'right'])

  • wrap (bool)

fill_hex: str | None
font_hex: str | None
bold: bool
align: Literal['left', 'center', 'right']
wrap: bool
hex_to_rgb_floats(value)[source]

Convert an RRGGBB hex string to the Sheets API {red,green,blue} floats.

Parameters:

value (str) – A six-character RRGGBB hex colour (case-insensitive).

Return type:

dict[str, float]

Returns:

A mapping with red / green / blue keys, each a 0..1 float.

openpyxl_argb(value)[source]

Return the opaque AARRGGBB form openpyxl fills / fonts expect.

Return type:

str

Parameters:

value (str)