dodil/erp-brick-ar
DODIL ERP brick: accounts receivable
src/brick_ar/infrastructure/clock.py
"""Business time: the one small port every 'today' in this brick goes through.
shared.yaml conventions.business_timezone says it is ONE value per bucket, stored beside platform_meta and read by every brick.
erp-platform has no such store yet, so until it has, the value is the brick's own ar_settings control row (read here and
nowhere else); moving it to the platform changes `business_timezone()` and nothing that calls `today()`. Which row is in force
is business_time's rule (the business date, not the UTC date).
"""
from datetime import date, datetime
from erp_platform import work
from brick_ar.infrastructure import business_time
def business_timezone(repo) -> str:
return business_time.resolve(repo.settings.rows("business_timezone"), work.now())[0]
def today(repo) -> date:
"""The date NOW (work.now(): a demo may move the clock) in the business time zone. "After today" means after this date,
everywhere a rule says it; an issue, credit or write-off date is never typed, it is this."""
return business_time.resolve(repo.settings.rows("business_timezone"), work.now())[1]
def now() -> datetime:
return work.now()