diff --git a/monopoly/examples/example_statement.pdf b/monopoly/examples/example_statement.pdf new file mode 100644 index 00000000..da18a1ca Binary files /dev/null and b/monopoly/examples/example_statement.pdf differ diff --git a/monopoly/examples/ocbc_365_example.pdf b/monopoly/examples/ocbc_365_example.pdf deleted file mode 100644 index e4c1581f..00000000 Binary files a/monopoly/examples/ocbc_365_example.pdf and /dev/null differ diff --git a/monopoly/examples/single_statement.py b/monopoly/examples/single_statement.py index 4139ba1e..d53e99c6 100644 --- a/monopoly/examples/single_statement.py +++ b/monopoly/examples/single_statement.py @@ -1,12 +1,31 @@ -from monopoly.banks.ocbc import Ocbc +from monopoly.bank import BankBase +from monopoly.helpers.constants import AccountType, BankNames +from monopoly.statement import StatementConfig -def ocbc_example(): +# fmt: off +class MonopolyBank(BankBase): + """Dummy class to help with reading the example PDF statement""" + statement_config = StatementConfig( + bank_name=BankNames.EXAMPLE, + account_type=AccountType.CREDIT, + transaction_pattern=( + r"(?P\d+/\d+)\s*" + r"(?P.*?)\s*" + r"(?P[\d.,]+)$" + ), + transaction_date_format=r"%d/%m", + statement_date_pattern=r"\d{2}\-\d{2}\-\d{4}", + statement_date_format=r"%d-%m-%Y", + ) + + +def example(): """Example showing how monopoly can be used to extract data from a single bank statement """ - bank = Ocbc( - file_path="monopoly/examples/ocbc_365_example.pdf", + bank = MonopolyBank( + file_path="monopoly/examples/example_statement.pdf", ) # This runs Tesseract on the PDF and @@ -18,9 +37,9 @@ def ocbc_example(): print(transformed_df) # Files are saved to an output directory - # monopoly/output/OCBC-Credit-2023-08.csv + # monopoly/output/monopoly-credit-2023-08.csv bank.load(transformed_df, statement) if __name__ == "__main__": - ocbc_example() + example() diff --git a/monopoly/helpers/constants.py b/monopoly/helpers/constants.py index b5186c56..bb73550b 100644 --- a/monopoly/helpers/constants.py +++ b/monopoly/helpers/constants.py @@ -12,6 +12,7 @@ class BankNames(Enum): CITIBANK = "citibank" HSBC = "hsbc" OCBC = "ocbc" + EXAMPLE = "monopoly" class BankStatement(str, Enum):