24 lines
721 B
Python
24 lines
721 B
Python
#!/usr/bin/env python3
|
|
"""
|
|
Cron script: save monthly net worth snapshot.
|
|
Run by systemd timer pfm-snapshot.timer on 1st of each month at 00:05.
|
|
"""
|
|
|
|
import sys
|
|
import os
|
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
|
|
from app import create_app
|
|
from app.services.report_service import take_net_worth_snapshot
|
|
|
|
app = create_app()
|
|
|
|
if __name__ == '__main__':
|
|
with app.app_context():
|
|
print('[snapshot] Saving net worth snapshot...')
|
|
snap = take_net_worth_snapshot()
|
|
print(f'[snapshot] Net worth on {snap.snapshot_date}: '
|
|
f'assets={snap.total_assets}, '
|
|
f'liabilities={snap.total_liabilities}, '
|
|
f'net={snap.net_worth}')
|