Skip to content

Commit

Permalink
get_cc_movements for getting credit card movements
Browse files Browse the repository at this point in the history
  • Loading branch information
ruicovelo committed Sep 30, 2020
1 parent 59e6311 commit dac2e07
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions mymoney/bpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
LOGINPAGE = "https://bpinet.bancobpi.pt/BPINET/Login.aspx"
MAINPAGE = "https://bpinet.bancobpi.pt/BPINet_Contas/Movimentos.aspx"
GETTRANSACTIONS_URL = "https://bpinet.bancobpi.pt/BPINet_Contas/Movimentos.aspx"
GETCCTRANSACTIONS_URL = "https://bpinet.bancobpi.pt/BPINet_Cartoes/SaldosEMovimentos.aspx"

# These inputs change name often
# Hopefully only a small part of the name we can match to these regexps
Expand Down Expand Up @@ -214,6 +215,29 @@ def get_movements(self):

return transactions

def get_cc_movements(self, invert_sign=False):
target_url = GETCCTRANSACTIONS_URL
page = self.bank.get_page(target_url)
soup = BeautifulSoup(page, features="html.parser")
transactions = []
movements_lines = soup.find_all('tr')
for movement_line in movements_lines:
columns = movement_line.find_all('td')
movement = []
for column in columns:
movement.append(column.get_text().strip())
if len(movement) > 0:
transaction = BPITransaction(
date=movement[2],
valuedate=movement[1],
description=movement[0],
value=movement[3],
)
if invert_sign:
transaction.value = -1 * transaction.value
transactions.append(transaction)

return transactions

class BPITransaction(Transaction):
def parse_value(self, value):
Expand Down

0 comments on commit dac2e07

Please sign in to comment.