🏒 Account Implementation

Praktische implementatie van de Core Library binnen de Account-entiteit.

← Terug naar Core Library

πŸ“– Introductie

Deze pagina beschrijft de implementatie van de Core Library binnen de Account-entiteit. De scriptlaag ( brenkeAccount) bevat alle entity-specifieke logica bovenop de centrale Core Library.

πŸ‘‰ Core Library = foundation layer
πŸ‘‰ Account script = entity logica

πŸ—οΈ Architectuur

1. Global wrapper

  • brenkeAccount namespace
  • Voorkomt conflicten met andere scripts

2. Core dependency layer

  • brenke.core.*
  • Herbruikbare business logica

3. Entity logic layer

  • Account-specifieke rules
  • Event handlers (OnLoad, OnChange, OnSave)

πŸš€ OnLoad – initialisatie

  • Wachten op Core Library ( waitForGlobal)
  • Default values instellen
  • Event handlers registreren
  • Country / ISO initialisatie
πŸ‘‰ Voorbeelden:
  • setDefaultLookupFromEnv
  • updateCountryIso2
  • addOnChangeSafe

πŸ”„ Field event handling

Alle field events volgen een standaard patroon:

  1. Notifications verwijderen
  2. Check β€œdisable scripting”
  3. Business logica uitvoeren
  4. Validatie via Core Library

Voorbeeld – Phone validation

  • Phone.isValid
  • Phone.format
  • Notifier.showFieldNotification

πŸ“Š Business rules

Customer Type

  • Customer vs Prospect
  • Dynamische required fields
  • Form locking

Adres handling

  • Postcode validatie
  • Auto-fill straat en stad
  • Provincie mapping

Copy Address

  • Address1 β†’ Address2
  • Toggle veld ondersteuning

πŸ”Œ Core Library usage

Field

  • Field.getValue
  • Field.setValue
  • Field.setRequired

Validation

  • Phone.isValid
  • Postcode.isValid
  • DutchValidation.isKvK

UI

  • UI.setAllFieldsDisabled
  • UI.setSectionFieldsDisabled

Notifications

  • Notifier.showFieldNotification
  • Notifier.clearAlerts

⚠️ Error handling pattern

  • try/catch in alle functies
  • Logging via Logger.logError
  • Unieke IDs (ACC001, ACC002, ...)
⚠️ Gebruik consistente error codes voor debugging en support.

🎯 Design principles

  • Thin controller (entity script)
  • Logica in Core Library
  • Geen duplicatie
  • Consistente validatie
  • Centrale logging

πŸ”— Source code

πŸ‘‰ Download de source code:
⬇️ Download Account Library