initial commit
This commit is contained in:
+27
@@ -0,0 +1,27 @@
|
||||
#!/bin/python
|
||||
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
|
||||
from src.reader import reader_b4w, reader_raw
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Eine App um den Überblick über Finanzen zu behalten"
|
||||
)
|
||||
parser.add_argument("input", help="Pfad einer einzulesenden Umsatzdatei (CSV)")
|
||||
args = parser.parse_args()
|
||||
|
||||
path = Path(args.input)
|
||||
|
||||
data_raw = reader_raw(path)
|
||||
|
||||
print(data_raw[:10])
|
||||
|
||||
data = reader_b4w(path)
|
||||
print(data[:10])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,19 @@
|
||||
#!/bin/python
|
||||
|
||||
from datetime import date
|
||||
from decimal import Decimal
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
IBAN_PATTERN = r"^[A-Z]{2}\d{2}[A-Z0-9]{11,30}$"
|
||||
|
||||
|
||||
class B4wExport(BaseModel):
|
||||
id: int = Field(alias="Id1", description="internal B4w ID")
|
||||
account_iban: str = Field(alias="OwnrAcctIBAN", pattern=IBAN_PATTERN)
|
||||
date_valid: date = Field(alias="ValDt")
|
||||
amount: Decimal = Field(alias="Amt")
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, d: dict) -> B4wExport:
|
||||
return cls.model_validate(d)
|
||||
@@ -0,0 +1,19 @@
|
||||
#!/bin/python
|
||||
|
||||
|
||||
import csv
|
||||
from pathlib import Path
|
||||
|
||||
from src.models import B4wExport
|
||||
|
||||
|
||||
def reader_raw(path: Path):
|
||||
with path.open() as fid:
|
||||
return list(csv.DictReader(fid))
|
||||
|
||||
def reader_b4w(path: Path):
|
||||
raw = reader_raw(path)
|
||||
return list(map(B4wExport.from_dict, raw))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user