Skip to content

Commit

Permalink
add more income codes, add debug for transactions (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
cageyv authored Nov 4, 2023
1 parent 3f2d266 commit 44f0174
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions scb_parser.py
Original file line number Diff line number Diff line change
@@ -53,10 +53,11 @@ def parse_transations(source):
amount=float(amount.replace(",", ""))

# Apply logic for determining the sign of the amount
if code_channel.startswith('X1'):
amount *= 1 # positive for X1. X1 - means income
income_codes = ["X1", "XB"]
if any(code_channel.startswith(code) for code in income_codes):
amount = abs(amount) # positive for X1. X1 - means income
else:
amount *= -1 # negative for others. Others - means expense
amount = -abs(amount) # negative for others. Others - means expense

# Description formating. Remove DESC :
description = description.replace("DESC : ", "")
@@ -108,10 +109,14 @@ def verify_amounts(parsed_data, total):

if debit_total != total["debit"]:
logging.error(f'Debit total amount {debit_total} is not equal to the source total amount {total["debit"]}')
for i in debit_transactions:
logging.debug(f'Debit transactions: {i}')
return False

if credit_total != total["credit"]:
logging.error(f'Credit total amount {credit_total} is not equal to the source total amount {credit_total != total["credit"]}')
for i in credit_transactions:
logging.debug(f'Credit transactions: {i}')
return False

if debit_total_items != total["items_debit"]:

0 comments on commit 44f0174

Please sign in to comment.