CSV取込機能を実装し、Expenseモデルと関連するStore・ExpenseCategoryモデルを追加。CSVパーサーを作成し、出光CSVに対応。明細編集画面のAJAX保存機能を実装し、取込結果を表示する機能を追加。作業ログをdiary.mdに追記。

This commit is contained in:
president
2025-12-19 15:51:14 +09:00
parent 5fc2a31f50
commit 89caf3438a
11 changed files with 489 additions and 7 deletions

View File

@@ -0,0 +1,26 @@
from __future__ import annotations
from typing import Iterable
from .base import CSVParserBase
from .idemitsu import IdemitsuParser
PARSERS: list[CSVParserBase] = [
IdemitsuParser(),
]
def detect_parser(lines: Iterable[str]) -> CSVParserBase | None:
for line in lines:
for parser in PARSERS:
if parser.detect(line):
return parser
return None
def get_parser(lines: Iterable[str]) -> CSVParserBase:
parser = detect_parser(lines)
if parser is None:
raise ValueError('CSVブランドを判定できませんでした。')
return parser