refactor: make compatibility exports ruff clean
This commit is contained in:
@@ -1,15 +1,44 @@
|
||||
from . import shared
|
||||
from .accounts_write_services import *
|
||||
from .asset_account_services import *
|
||||
from .assets_service import *
|
||||
from .budgets_write_services import *
|
||||
from .category_rules_write_services import *
|
||||
from .categorization_services import *
|
||||
from .cross_transfer_service import *
|
||||
from .imports_service import *
|
||||
from .import_transfer_services import *
|
||||
from .reconciliation_service import *
|
||||
from .system_services import *
|
||||
from .transactions_write_services import *
|
||||
from .transaction_report_services import *
|
||||
from .uncategorized_workbench_service import *
|
||||
from __future__ import annotations
|
||||
|
||||
from . import accounts_write_services as _accounts_write_services
|
||||
from . import asset_account_services as _asset_account_services
|
||||
from . import assets_service as _assets_service
|
||||
from . import budgets_write_services as _budgets_write_services
|
||||
from . import category_rules_write_services as _category_rules_write_services
|
||||
from . import categorization_services as _categorization_services
|
||||
from . import cross_transfer_service as _cross_transfer_service
|
||||
from . import imports_service as _imports_service
|
||||
from . import import_transfer_services as _import_transfer_services
|
||||
from . import reconciliation_service as _reconciliation_service
|
||||
from . import shared as shared
|
||||
from . import system_services as _system_services
|
||||
from . import transactions_write_services as _transactions_write_services
|
||||
from . import transaction_report_services as _transaction_report_services
|
||||
from . import uncategorized_workbench_service as _uncategorized_workbench_service
|
||||
|
||||
_EXPORT_MODULES = (
|
||||
shared,
|
||||
_accounts_write_services,
|
||||
_asset_account_services,
|
||||
_assets_service,
|
||||
_budgets_write_services,
|
||||
_category_rules_write_services,
|
||||
_categorization_services,
|
||||
_cross_transfer_service,
|
||||
_imports_service,
|
||||
_import_transfer_services,
|
||||
_reconciliation_service,
|
||||
_system_services,
|
||||
_transactions_write_services,
|
||||
_transaction_report_services,
|
||||
_uncategorized_workbench_service,
|
||||
)
|
||||
|
||||
__all__: list[str] = ["shared"]
|
||||
for _module in _EXPORT_MODULES:
|
||||
for _name in dir(_module):
|
||||
if _name.startswith("_"):
|
||||
continue
|
||||
globals().setdefault(_name, getattr(_module, _name))
|
||||
if _name not in __all__:
|
||||
__all__.append(_name)
|
||||
|
||||
@@ -1,6 +1,17 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from .shared import *
|
||||
from .shared import (
|
||||
Any,
|
||||
VALID_ACCOUNT_TYPES,
|
||||
db,
|
||||
fail,
|
||||
new_id,
|
||||
normalize_liquidity_bucket,
|
||||
normalize_statement_status,
|
||||
now_iso,
|
||||
ok,
|
||||
row_to_dict,
|
||||
)
|
||||
|
||||
|
||||
def create_ledger_account(name: str, type: str = "bank", institution: str = "", currency: str = "KRW", active: bool = True, memo: str = "", account_number_masked: str = "", holder_name: str = "", last_balance: int | None = None, last_synced_at: str = "", statement_status: str = "unknown", liquidity_bucket: str = "other", db_path: str | None = None) -> dict[str, Any]:
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from .assets_service import (
|
||||
close_asset_snapshot,
|
||||
create_asset_snapshot,
|
||||
create_manual_asset,
|
||||
deactivate_manual_asset,
|
||||
get_asset_liquidity_report,
|
||||
get_asset_snapshot_report,
|
||||
get_net_worth_timeseries,
|
||||
list_manual_assets,
|
||||
preview_asset_snapshot_close,
|
||||
update_manual_asset,
|
||||
close_asset_snapshot as close_asset_snapshot,
|
||||
create_asset_snapshot as create_asset_snapshot,
|
||||
create_manual_asset as create_manual_asset,
|
||||
deactivate_manual_asset as deactivate_manual_asset,
|
||||
get_asset_liquidity_report as get_asset_liquidity_report,
|
||||
get_asset_snapshot_report as get_asset_snapshot_report,
|
||||
get_net_worth_timeseries as get_net_worth_timeseries,
|
||||
list_manual_assets as list_manual_assets,
|
||||
preview_asset_snapshot_close as preview_asset_snapshot_close,
|
||||
update_manual_asset as update_manual_asset,
|
||||
)
|
||||
from .accounts_write_services import update_ledger_account
|
||||
from .accounts_write_services import update_ledger_account as update_ledger_account
|
||||
|
||||
@@ -1,6 +1,22 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from .shared import *
|
||||
from .shared import (
|
||||
ASSET_BUCKETS,
|
||||
ASSET_BUCKET_ORDER,
|
||||
Any,
|
||||
LIABILITY_BUCKETS,
|
||||
current_kst_date,
|
||||
date,
|
||||
db,
|
||||
fail,
|
||||
new_id,
|
||||
normalize_date,
|
||||
normalize_liquidity_bucket,
|
||||
now_iso,
|
||||
ok,
|
||||
row_to_dict,
|
||||
sqlite3,
|
||||
)
|
||||
|
||||
def _valuation_policy() -> dict[str, Any]:
|
||||
return {
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from .shared import *
|
||||
from .shared import (
|
||||
Any,
|
||||
db,
|
||||
fail,
|
||||
new_id,
|
||||
normalize_month,
|
||||
now_iso,
|
||||
ok,
|
||||
row_to_dict,
|
||||
)
|
||||
|
||||
|
||||
def create_ledger_budget(month: str, category: str, amount: int | float, subcategory: str = "", person: str = "", currency: str = "KRW", memo: str = "", db_path: str | None = None) -> dict[str, Any]:
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from .shared import *
|
||||
from .shared import (
|
||||
Any,
|
||||
datetime,
|
||||
db,
|
||||
fail,
|
||||
now_iso,
|
||||
ok,
|
||||
re,
|
||||
row_to_dict,
|
||||
)
|
||||
|
||||
RULE_FIELDS = {"merchant", "counterparty", "description", "payment_method", "raw_summary", "branch", "memo"}
|
||||
RULE_MATCH_TYPES = {"contains", "equals", "regex", "starts_with", "ends_with"}
|
||||
@@ -68,11 +77,11 @@ def _rule_matches(rule: dict[str, Any], tx: dict[str, Any]) -> bool:
|
||||
|
||||
|
||||
from .category_rules_write_services import (
|
||||
create_category_rule,
|
||||
create_ledger_category,
|
||||
delete_category_rule,
|
||||
delete_ledger_category,
|
||||
update_category_rule,
|
||||
create_category_rule as create_category_rule,
|
||||
create_ledger_category as create_ledger_category,
|
||||
delete_category_rule as delete_category_rule,
|
||||
delete_ledger_category as delete_ledger_category,
|
||||
update_category_rule as update_category_rule,
|
||||
)
|
||||
|
||||
|
||||
@@ -275,11 +284,11 @@ def apply_categorization_rules(limit: int = 1000, only_uncategorized: bool = Tru
|
||||
return ok(applied_count=applied, preview=preview)
|
||||
|
||||
from .uncategorized_workbench_service import (
|
||||
apply_uncategorized_group_recommendation,
|
||||
apply_uncategorized_recommendation,
|
||||
get_uncategorized_merchant_summary,
|
||||
get_uncategorized_workbench,
|
||||
list_uncategorized_transactions,
|
||||
apply_uncategorized_group_recommendation as apply_uncategorized_group_recommendation,
|
||||
apply_uncategorized_recommendation as apply_uncategorized_recommendation,
|
||||
get_uncategorized_merchant_summary as get_uncategorized_merchant_summary,
|
||||
get_uncategorized_workbench as get_uncategorized_workbench,
|
||||
list_uncategorized_transactions as list_uncategorized_transactions,
|
||||
)
|
||||
|
||||
DEFAULT_LEDGER_CATEGORIES: list[dict[str, Any]] = [
|
||||
|
||||
@@ -1,6 +1,16 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from .shared import *
|
||||
from .shared import (
|
||||
Any,
|
||||
VALID_CASHFLOW_KINDS,
|
||||
VALID_TRANSACTION_TYPES,
|
||||
db,
|
||||
fail,
|
||||
new_id,
|
||||
now_iso,
|
||||
ok,
|
||||
row_to_dict,
|
||||
)
|
||||
|
||||
RULE_FIELDS = {"merchant", "counterparty", "description", "payment_method", "raw_summary", "branch", "memo"}
|
||||
RULE_MATCH_TYPES = {"contains", "equals", "regex", "starts_with", "ends_with"}
|
||||
|
||||
@@ -1,7 +1,24 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from .shared import *
|
||||
from .shared import _append_memo_tag, _memo_has_tag, _normalize_counterparty_for_match, _party_match_score
|
||||
from .shared import (
|
||||
Any,
|
||||
CROSS_TRANSFER_MATCH_TAG,
|
||||
CROSS_TRANSFER_REVIEW_TAG,
|
||||
_append_memo_tag,
|
||||
_memo_has_tag,
|
||||
_normalize_counterparty_for_match,
|
||||
_party_match_score,
|
||||
current_kst_date,
|
||||
date,
|
||||
datetime,
|
||||
db,
|
||||
fail,
|
||||
normalize_date,
|
||||
now_iso,
|
||||
ok,
|
||||
re,
|
||||
row_to_dict,
|
||||
)
|
||||
|
||||
def _build_cross_transfer_index(transactions: list[dict[str, Any]]) -> dict[tuple[str, int, str], list[dict[str, Any]]]:
|
||||
index: dict[tuple[str, int, str], list[dict[str, Any]]] = {}
|
||||
|
||||
@@ -1,27 +1,25 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from .shared import *
|
||||
from .shared import _append_memo_tag, _memo_has_tag, _normalize_counterparty_for_match, _party_match_score
|
||||
|
||||
from .imports_service import (
|
||||
import_kb_bank_pdf,
|
||||
import_seoulpay_xlsx,
|
||||
import_toss_bank_pdf,
|
||||
import_toss_securities_pdf,
|
||||
list_ledger_import_batches,
|
||||
preview_kb_bank_pdf_import,
|
||||
preview_ledger_csv_import,
|
||||
preview_seoulpay_xlsx_import,
|
||||
preview_toss_bank_pdf_import,
|
||||
preview_toss_securities_pdf_import,
|
||||
rollback_ledger_import_batch,
|
||||
import_kb_bank_pdf as import_kb_bank_pdf,
|
||||
import_seoulpay_xlsx as import_seoulpay_xlsx,
|
||||
import_toss_bank_pdf as import_toss_bank_pdf,
|
||||
import_toss_securities_pdf as import_toss_securities_pdf,
|
||||
list_ledger_import_batches as list_ledger_import_batches,
|
||||
preview_kb_bank_pdf_import as preview_kb_bank_pdf_import,
|
||||
preview_ledger_csv_import as preview_ledger_csv_import,
|
||||
preview_seoulpay_xlsx_import as preview_seoulpay_xlsx_import,
|
||||
preview_toss_bank_pdf_import as preview_toss_bank_pdf_import,
|
||||
preview_toss_securities_pdf_import as preview_toss_securities_pdf_import,
|
||||
rollback_ledger_import_batch as rollback_ledger_import_batch,
|
||||
)
|
||||
from .cross_transfer_service import (
|
||||
find_cancel_original_candidates,
|
||||
find_self_transfer_candidates,
|
||||
link_cancel_to_original,
|
||||
link_self_transfer_pair,
|
||||
list_cross_transfer_review_queue,
|
||||
preview_cross_account_transfers,
|
||||
run_cross_account_transfer_match,
|
||||
find_cancel_original_candidates as find_cancel_original_candidates,
|
||||
find_self_transfer_candidates as find_self_transfer_candidates,
|
||||
link_cancel_to_original as link_cancel_to_original,
|
||||
link_self_transfer_pair as link_self_transfer_pair,
|
||||
list_cross_transfer_review_queue as list_cross_transfer_review_queue,
|
||||
preview_cross_account_transfers as preview_cross_account_transfers,
|
||||
run_cross_account_transfer_match as run_cross_account_transfer_match,
|
||||
)
|
||||
|
||||
@@ -1,7 +1,27 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from .shared import *
|
||||
from .shared import _append_memo_tag, _memo_has_tag, _normalize_counterparty_for_match, _party_match_score
|
||||
from .shared import (
|
||||
Any,
|
||||
Path,
|
||||
csv,
|
||||
db,
|
||||
fail,
|
||||
json,
|
||||
make_dedupe_key,
|
||||
new_id,
|
||||
normalize_tags,
|
||||
now_iso,
|
||||
ok,
|
||||
parse_kb_bank_pdf,
|
||||
parse_seoulpay_xlsx,
|
||||
parse_toss_bank_pdf,
|
||||
parse_toss_securities_pdf,
|
||||
row_to_dict,
|
||||
seoulpay_transaction_preview,
|
||||
toss_bank_transaction_preview,
|
||||
toss_transaction_preview,
|
||||
transaction_preview,
|
||||
)
|
||||
|
||||
def preview_ledger_csv_import(file_path: str, source: str = "generic", db_path: str | None = None) -> dict[str, Any]:
|
||||
path=Path(file_path).expanduser()
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from .shared import *
|
||||
from .shared import (
|
||||
Any,
|
||||
BALANCE_RECONCILIATION_REFERENCE_RATIO,
|
||||
BALANCE_RECONCILIATION_TOLERANCE_KRW,
|
||||
RECONCILIATION_TARGET_STATUSES,
|
||||
db,
|
||||
fail,
|
||||
normalize_date,
|
||||
normalize_snapshot_at,
|
||||
now_iso,
|
||||
ok,
|
||||
sqlite3,
|
||||
)
|
||||
|
||||
|
||||
def _transaction_signed_amount(tx_type: str, amount: int) -> int:
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import csv
|
||||
import csv as csv
|
||||
import sqlite3 as sqlite3
|
||||
import hashlib
|
||||
import json
|
||||
import re
|
||||
import sqlite3
|
||||
from datetime import date, datetime, timedelta
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
@@ -12,16 +12,18 @@ from uuid import uuid4
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
from ..infrastructure.parsers import (
|
||||
parse_kb_bank_pdf,
|
||||
parse_seoulpay_xlsx,
|
||||
parse_toss_bank_pdf,
|
||||
parse_toss_securities_pdf,
|
||||
seoulpay_transaction_preview,
|
||||
toss_bank_transaction_preview,
|
||||
toss_transaction_preview,
|
||||
transaction_preview,
|
||||
parse_kb_bank_pdf as parse_kb_bank_pdf,
|
||||
parse_seoulpay_xlsx as parse_seoulpay_xlsx,
|
||||
parse_toss_bank_pdf as parse_toss_bank_pdf,
|
||||
parse_toss_securities_pdf as parse_toss_securities_pdf,
|
||||
seoulpay_transaction_preview as seoulpay_transaction_preview,
|
||||
toss_bank_transaction_preview as toss_bank_transaction_preview,
|
||||
toss_transaction_preview as toss_transaction_preview,
|
||||
transaction_preview as transaction_preview,
|
||||
)
|
||||
from ..infrastructure.sqlite import db, init_db, resolve_db_path
|
||||
from ..infrastructure.sqlite import db as db
|
||||
from ..infrastructure.sqlite import init_db as init_db
|
||||
from ..infrastructure.sqlite import resolve_db_path as resolve_db_path
|
||||
|
||||
VALID_TRANSACTION_TYPES = {"income", "expense", "transfer", "refund", "adjustment"}
|
||||
VALID_ACCOUNT_TYPES = {"bank", "card", "cash", "investment", "loan", "other"}
|
||||
|
||||
@@ -1,6 +1,24 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from .shared import *
|
||||
from .shared import (
|
||||
Any,
|
||||
BACKUP_RESTORE_POLICY,
|
||||
CASHFLOW_KIND_SQL,
|
||||
DEFAULT_LEDGER_BACKUP_DIR,
|
||||
KST,
|
||||
Path,
|
||||
current_kst_month,
|
||||
datetime,
|
||||
db,
|
||||
fail,
|
||||
hashlib,
|
||||
init_db,
|
||||
ok,
|
||||
resolve_db_path,
|
||||
row_to_dict,
|
||||
sqlite3,
|
||||
timedelta,
|
||||
)
|
||||
from .shared import _current_kst_datetime, _month_range
|
||||
|
||||
def health_check(db_path: str | None = None) -> dict[str, Any]:
|
||||
@@ -166,7 +184,7 @@ def get_ledger_backup_status(file_path: str, include_hash: bool = True, include_
|
||||
return fail("not_found", f"backup file not found: {path}", path=str(path), exists=False)
|
||||
return ok(backup=_ledger_db_status_for_path(path, include_hash=include_hash, include_integrity=include_integrity), restore_policy=BACKUP_RESTORE_POLICY)
|
||||
|
||||
from .accounts_write_services import create_ledger_account
|
||||
from .accounts_write_services import create_ledger_account as create_ledger_account
|
||||
|
||||
def list_ledger_accounts(active_only: bool = True, db_path: str | None = None) -> dict[str, Any]:
|
||||
sql = "SELECT * FROM accounts" + (" WHERE active=1" if active_only else "") + " ORDER BY name"
|
||||
|
||||
@@ -1,9 +1,20 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from .shared import *
|
||||
from .shared import (
|
||||
Any,
|
||||
CASHFLOW_KIND_SQL,
|
||||
date,
|
||||
db,
|
||||
normalize_date,
|
||||
normalize_month,
|
||||
ok,
|
||||
row_to_dict,
|
||||
)
|
||||
|
||||
from .budgets_write_services import create_ledger_budget
|
||||
from .transactions_write_services import create_ledger_transaction, delete_ledger_transaction, update_ledger_transaction
|
||||
from .budgets_write_services import create_ledger_budget as create_ledger_budget
|
||||
from .transactions_write_services import create_ledger_transaction as create_ledger_transaction
|
||||
from .transactions_write_services import delete_ledger_transaction as delete_ledger_transaction
|
||||
from .transactions_write_services import update_ledger_transaction as update_ledger_transaction
|
||||
|
||||
def list_ledger_transactions(start_date: str = "", end_date: str = "", type: str = "", category: str = "", person: str = "", account_id: str = "", include_deleted: bool = False, limit: int = 100, db_path: str | None = None) -> dict[str, Any]:
|
||||
clauses=[]; params=[]
|
||||
@@ -23,7 +34,7 @@ def list_ledger_transactions(start_date: str = "", end_date: str = "", type: str
|
||||
rows = conn.execute(sql, params).fetchall()
|
||||
return ok(transactions=[row_to_dict(r) for r in rows], count=len(rows))
|
||||
|
||||
from .reconciliation_service import get_balance_reconciliation_report
|
||||
from .reconciliation_service import get_balance_reconciliation_report as get_balance_reconciliation_report
|
||||
|
||||
def list_ledger_budgets(month: str = "", db_path: str | None = None) -> dict[str, Any]:
|
||||
clauses=[]; params=[]
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from .shared import *
|
||||
from .shared import (
|
||||
Any,
|
||||
VALID_TRANSACTION_TYPES,
|
||||
db,
|
||||
fail,
|
||||
make_dedupe_key,
|
||||
new_id,
|
||||
normalize_date,
|
||||
normalize_tags,
|
||||
now_iso,
|
||||
ok,
|
||||
row_to_dict,
|
||||
)
|
||||
|
||||
|
||||
def create_ledger_transaction(transaction_date: str = "", type: str = "expense", amount: int | float = 0, category: str = "", subcategory: str = "", merchant: str = "", description: str = "", account_id: str = "", payment_method: str = "", person: str = "", project: str = "", tags: Any = None, is_fixed: bool = False, currency: str = "KRW", posted_date: str = "", source: str = "manual", external_id: str = "", memo: str = "", dedupe: bool = True, transaction_datetime: str = "", counterparty: str = "", balance_after: int | None = None, branch: str = "", raw_summary: str = "", raw_payload: str = "", db_path: str | None = None) -> dict[str, Any]:
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from .shared import *
|
||||
from .shared import (
|
||||
Any,
|
||||
datetime,
|
||||
db,
|
||||
fail,
|
||||
now_iso,
|
||||
ok,
|
||||
re,
|
||||
row_to_dict,
|
||||
)
|
||||
|
||||
def _rule_matches(rule: dict[str, Any], tx: dict[str, Any]) -> bool:
|
||||
if rule.get("transaction_type") and rule.get("transaction_type") != tx.get("type", ""):
|
||||
|
||||
Reference in New Issue
Block a user