CSV取込機能を実装し、Expenseモデルと関連するStore・ExpenseCategoryモデルを追加。CSVパーサーを作成し、出光CSVに対応。明細編集画面のAJAX保存機能を実装し、取込結果を表示する機能を追加。作業ログをdiary.mdに追記。
This commit is contained in:
25
expenses/csv_parsers/base.py
Normal file
25
expenses/csv_parsers/base.py
Normal file
@@ -0,0 +1,25 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from datetime import date
|
||||
from typing import Iterable
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class ExpenseRow:
|
||||
use_date: date
|
||||
description: str
|
||||
amount: int
|
||||
note: str
|
||||
source: str
|
||||
source_hash: str
|
||||
|
||||
|
||||
class CSVParserBase:
|
||||
source: str = ''
|
||||
|
||||
def detect(self, header_line: str) -> bool:
|
||||
raise NotImplementedError
|
||||
|
||||
def parse(self, lines: Iterable[str]) -> list[ExpenseRow]:
|
||||
raise NotImplementedError
|
||||
Reference in New Issue
Block a user