generated from felixm/defaultpy
Implement flip sign support for Amex
This commit is contained in:
@@ -25,6 +25,7 @@ class CsvConfig(BaseModel):
|
|||||||
delimiter: str = ","
|
delimiter: str = ","
|
||||||
quotechar: str = '"'
|
quotechar: str = '"'
|
||||||
currency: str = "USD"
|
currency: str = "USD"
|
||||||
|
flip_amount: bool = False
|
||||||
|
|
||||||
|
|
||||||
class Config(BaseModel):
|
class Config(BaseModel):
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ def get_transactions(csv_file: str, config: CsvConfig) -> list[Transaction]:
|
|||||||
required fields date, amount and description via the CsvConfig."""
|
required fields date, amount and description via the CsvConfig."""
|
||||||
t = {field: row[index] for index, field in fields}
|
t = {field: row[index] for index, field in fields}
|
||||||
amount = t["amount"]
|
amount = t["amount"]
|
||||||
|
if config.flip_amount:
|
||||||
|
amount = flip_sign(amount)
|
||||||
return Transaction(
|
return Transaction(
|
||||||
currency=config.currency,
|
currency=config.currency,
|
||||||
debit=flip_sign(amount),
|
debit=flip_sign(amount),
|
||||||
|
|||||||
Reference in New Issue
Block a user