Skip to content

Declarations & Legal Compliance Engine

The Declarations & Legal Compliance Engine manages the formal accession, statutory verification, and democratic governance processes required for Polish Energy Cooperatives (Spółdzielnie Energetyczne) under the Ministry of Climate and Environment regulatory framework.


Functions Matrix (10 Functions)

Function NameInbound TriggerCore Responsibility
get-company-declaration-schemaClient GETFetches dynamic JSON form schema defined by cooperative
approve-declaration-schemaAdmin POSTBoard approval of schema revisions before public availability
get-member-declarationClient GETRetrieves declaration state, verification timeline, and attachments
submit-member-declarationMember POSTSubmits formal accession declaration into approval queue
update-member-declarationMember PATCHUpdates form fields following a correction request
review-member-declarationBoard Officer POSTTransitions declaration to APPROVED, REJECTED, or CORRECTION_REQUIRED
upload-declarationMultipart POSTUploads signed physical scans or digital signatures to declarations bucket
generate-resolution-documentAdmin POSTRenders statutory voting resolution documents (Uchwały)
generate-prefilled-docxClient POSTInjects member/installation parameters into .docx legal contracts
docx-to-htmlClient POSTConverts .docx legal templates into responsive web preview HTML

Member Declaration Lifecycle

stateDiagram-v2
    [*] --> Draft: Member opens accession wizard
    Draft --> Submitted: submit-member-declaration
    Submitted --> UnderReview: Board assigns inspector
    
    UnderReview --> CorrectionRequired: review-member-declaration (CORRECTION)
    CorrectionRequired --> Submitted: update-member-declaration
    
    UnderReview --> Approved: review-member-declaration (APPROVE)
    UnderReview --> Rejected: review-member-declaration (REJECT)
    
    Approved --> ResolutionGenerated: generate-resolution-document
    ResolutionGenerated --> ActiveMember: Accession Finalized

Dynamic Declaration Schemas

Energy cooperatives can customize accession questionnaire fields (e.g. asking for heat pump capacity, building insulation level, or EV charger specs) without code deployments.

get-company-declaration-schema Schema Format

{
"coop_id": "b1b2c3d4-e5f6-7a8b-9c0d-1e2f3a4b5c6d",
"version": 3,
"status": "PUBLISHED",
"fields": [
{
"id": "ppe_number",
"label": "Numer PPE (Punkt Poboru Energii)",
"type": "string",
"required": true,
"validation_regex": "^PL[0-9]{16}$"
},
{
"id": "pv_installed_kwp",
"label": "Moc zainstalowana PV (kWp)",
"type": "number",
"min": 0,
"max": 500,
"required": true
},
{
"id": "has_battery_storage",
"label": "Czy posiadasz magazyn energii?",
"type": "boolean",
"required": false
}
]
}

Document Generation Engine

1. generate-prefilled-docx

  • Input: Template ID (.docx stored in declarations bucket) and JSON parameter map.
  • Engine: High-speed AST token replacer that replaces tags such as {{member_name}}, {{pesel}}, {{ppe_number}}, and {{coop_name}}.
  • Output: Generated Word document saved to storage bucket with secure download link.

2. generate-resolution-document

  • Creates formal voting resolutions pursuant to the Polish Act on Cooperatives (Prawo spółdzielcze).
  • Generates audit stamps with SHA-256 integrity hashes of voting tallies and member signature blocks.

3. docx-to-html

  • Lightweight Deno converter extracting formatting, tables, lists, and signature blocks from .docx structures.
  • Enables native in-app document viewing inside the Flutter app without requiring external document viewers.