def test_read_cash_bochk2(self): filename = get_current_path() + '\\samples\\sample_cash2 _ 16112016.xls' port_values = {} read_cash_bochk(filename, port_values) cash_entries = port_values['cash'] cash_transactions = port_values['cash_transactions'] self.verify_cash2(cash_entries, cash_transactions)
def test_read_cash_bochk4(self): # the in house fund, it has cash consoliation (two HKD accounts, savings # and current account) filename = get_current_path() + '\\samples\\Cash Stt _30042018.xlsx' port_values = {} read_cash_bochk(filename, port_values) consolidate_cash(port_values) self.verify_cash4(port_values['cash'], port_values['cash_transactions'])
def test_get_date_from_file(self): cash_file = get_current_path() + '\\samples\\Cash _ 15112016.xls' holdings_file = get_current_path( ) + '\\samples\\Holding _ 12072016.xls' port_values = {} read_cash_bochk(cash_file, port_values) read_holdings_bochk(holdings_file, port_values) self.assertEqual(datetime(2016, 11, 15), port_values['cash_date']) self.assertEqual(datetime(2016, 7, 12), port_values['holding_date'])
def test_cash_error4(self): holdings_file = get_current_path( ) + '\\samples\\sample_holdings2 _ 16112016.xls' cash_file = get_current_path( ) + '\\samples\\cash_error4 _ 16112016.xls' port_values = {} directory = get_current_path() + '\\samples' read_cash_bochk(cash_file, port_values) read_holdings_bochk(holdings_file, port_values) with self.assertRaises(InvalidCashAccountName): write_csv(port_values, directory)
def handle_bochk_cash(bochk_cash_files, cash_date, output_dir): """ Read a list of BOC HK bank statement files, produce a csv file that reflects the cash holding of all accounts. Note: sometimes we have multiple bank statements for the same account, then the account with a later date overrides others for the same account. """ cash_entries = [] for filename in bochk_cash_files: port_values = {} read_cash_bochk(filename, port_values) update_cash_entries(port_values, cash_entries) port_values = {} port_values['cash'] = cash_entries port_values['cash_date'] = cash_date return write_cash_csv(port_values, output_dir, 'trustee_bochk_')
def test_update_cash_entries(self): file1 = join( get_current_path(), 'samples', 'BOC Bank Statement 2016-11-30 (CLASS A-HK SUB FUND I) -HKD.xls') file2 = join( get_current_path(), 'samples', 'BOC Bank Statement 2016-12-13 (CLASS A-HK SUB FUND I) (HKD).xls') file3 = join( get_current_path(), 'samples', 'BOC Bank Statement 2016-12-15 (CLASS A-HK SUB FUND I) (USD).xls') file4 = join(get_current_path(), 'samples', 'BOC Bank Statement 2013-12-31 (CLASS A-HK) -HKD.xls') cash_entries = [] file_list = [file1, file2, file3, file4] cash_entries = [] for filename in file_list: port_values = {} read_cash_bochk(filename, port_values) update_cash_entries(port_values, cash_entries) self.assertTrue(len(cash_entries), 3) matched = 0 for cash_entry in cash_entries: if cash_entry['Account Name'] == 'CLT-CLI HK BR (CLASS A- HK) TRUST FUND - SUB FUND I' \ and cash_entry['Currency'] == 'HKD': self.verify_cash1(cash_entry) matched = matched + 1 elif cash_entry['Account Name'] == 'CLT-CLI HK BR (CLASS A- HK) TRUST FUND - SUB FUND I' \ and cash_entry['Currency'] == 'USD': self.verify_cash2(cash_entry) matched = matched + 1 elif cash_entry['Account Name'] == 'CLT-CLI HK BR (CLASS A- HK) TRUST FUND' \ and cash_entry['Currency'] == 'HKD': self.verify_cash3(cash_entry) matched = matched + 1 self.assertEqual(matched, 3)
def test_cash_error3(self): filename = get_current_path() + '\\samples\\cash_error3 _ 16112016.xls' port_values = {} with self.assertRaises(InvalidCashTransaction): read_cash_bochk(filename, port_values)