Ejemplo n.º 1
0
 def banks(self):
     self.setCentralWidget(Banks(self))
     self.enableTools("bank")
Ejemplo n.º 2
0
# ch13_9.py
from banks import Banks  # 導入banks模組的Banks類別

jamesbank = Banks('James')  # 定義Banks類別物件
print("James's banks = ", jamesbank.bank_title())  # 列印銀行名稱
jamesbank.save_money(500)  # 存錢
jamesbank.get_balance()  # 列出存款金額
Ejemplo n.º 3
0
 def _load_banks(self):
     log.info( "Loading bank statements" )
     if not self.banks:
         self.banks = Banks()
         for bank_name, bank in c['banks'].items():
             self.banks.load_bank(bank_name)
Ejemplo n.º 4
0
 def close(self):
     self.mainWindows.setCentralWidget(Banks(self.mainWindows))
Ejemplo n.º 5
0
class Dispatch(dispatch.Dispatch):
    """See dispatch.Dispatch for method documentation."""
    _undocumented=["nop"]
    banks = None
    def __init__(self, kwargs={}):

        # Pick our display module but don't instantiate our display
        # class yet. We'll do that in the actual command methods
        # below.
        self.display = display_cl # cli is the default display
        if kwargs.setdefault('csv', None):
            self.display = display_csv # but the user can choose csv
    def _load_banks(self):
        log.info( "Loading bank statements" )
        if not self.banks:
            self.banks = Banks()
            for bank_name, bank in c['banks'].items():
                self.banks.load_bank(bank_name)

    def audit(self, **kwargs):
        """Look for problems in the ledger file."""

        self._load_banks()

        for name, bank in self.banks.items():
            self.monthly_bal(accounts = bank)

    def monthly_bal(self, **kwargs):
        "check ending balances of statements against the ledger."

        """kwargs['accounts'] is a bank object (or just a list of
        accounts, I guess)

        """

        # If a set of accounts hasn't been provided, load them here.
        if not kwargs.setdefault('accounts', None):
            self._load_banks()
            for name, bank in self.banks.items():
                self.monthly_bal(accounts = bank)
            return

        # do the monthly balance thing for all the accounts
        accountant = Monthly_Balancer()
        for name, account in kwargs['accounts'].items():
            accountant.monthly_bal(account, self.display.Monthly_Bal())

    def reconcile(self, **kwargs):
        """Match transactions in the ledger and bank statements.

        This might be useful: 

         * ledger -f Chase_Bank-Preferred_Business_Checking.ledger --sort 'date' print
         * ledger -f main.ledger --sort 'date' print

        """


        # If a set of accounts hasn't been provided, load them here.
        if not kwargs.setdefault('accounts', None):
            self._load_banks()
            for name, bank in self.banks.items():
                kwargs['accounts'] = bank
                self.reconcile(**kwargs)
            return

        begin_date = ""
        if 'begin_date' in kwargs and kwargs['begin_date']: begin_date = " -b " + kwargs['begin_date']

        for name, account in kwargs['accounts'].items():
            log.info( "Loading ledger." )
            ledger = Ledger(search=account.ledger_account, opts = "--related-all" + begin_date)
            ledger.load()
            reconciler = Reconciler(ledger, account)
            reconciler.reconcile()

    def nop(self, **kwargs):
        """Do nothing. Used for tests. Limits execution to main.

        We need a way to test main, and this command helps us do
        that. You can safely ignore it. I mostly do.

        """
        pass