Sunday, March 30, 2025

Finance and Accounting Automation - Account Reconciliation Tool

 Notes:

  • What problem does it solve?: Automates account reconciliation by comparing transactions from two different sources (e.g., bank and ledger).

  • How can businesses benefit from customizing the code?: Businesses can define reconciliation rules based on their specific chart of accounts or transaction types.

  • How can businesses adopt the solution further?: Integrate with banking APIs or accounting software for automatic transaction matching.

Actual Python Code:

import pandas as pd


class AccountReconciliation:

    def __init__(self, bank_transactions, ledger_transactions):

        self.bank_transactions = pd.DataFrame(bank_transactions)

        self.ledger_transactions = pd.DataFrame(ledger_transactions)


    def reconcile(self):

        matched = pd.merge(self.bank_transactions, self.ledger_transactions, on=['Amount', 'Description'], how='inner')

        unmatched_bank = self.bank_transactions[~self.bank_transactions['Transaction_ID'].isin(matched['Transaction_ID'])]

        unmatched_ledger = self.ledger_transactions[~self.ledger_transactions['Transaction_ID'].isin(matched['Transaction_ID'])]

        

        print("Matched Transactions:")

        print(matched)

        print("\nUnmatched Bank Transactions:")

        print(unmatched_bank)

        print("\nUnmatched Ledger Transactions:")

        print(unmatched_ledger)

        return matched, unmatched_bank, unmatched_ledger


# Example usage

bank_transactions = [{'Transaction_ID': 1, 'Amount': 100, 'Description': 'Payment to Vendor'},

                     {'Transaction_ID': 2, 'Amount': 50, 'Description': 'Refund'},

                     {'Transaction_ID': 3, 'Amount': 200, 'Description': 'Payment to Vendor'}]


ledger_transactions = [{'Transaction_ID': 1, 'Amount': 100, 'Description': 'Payment to Vendor'},

                       {'Transaction_ID': 2, 'Amount': 200, 'Description': 'Payment to Vendor'},

                       {'Transaction_ID': 3, 'Amount': 50, 'Description': 'Refund'}]


reconciliation = AccountReconciliation(bank_transactions, ledger_transactions)

reconciliation.reconcile()



No comments:

Post a Comment

IoT (Internet of Things) Automation - Smart Energy Usage Tracker

  Notes: Problem Solved: Logs and analyzes power usage from smart meters. Customization Benefits: Track per-device energy and set ale...