Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
itemized_split['amount{}'.format(i)] = amount
# Yup. Weird:
itemized_split['percentAmount{}'.format(i)] = amount
itemized_split['merchant{}'.format(i)] = trans.merchant
# Yup weird. '0' means new?
itemized_split['txnId{}'.format(i)] = 0
if not ignore_category:
itemized_split['category{}'.format(i)] = trans.category
itemized_split['categoryId{}'.format(i)] = (
trans.category_id)
logger.debug('Sending a "split" transaction request: {}'.format(
itemized_split))
response = mint_client.post(
'{}{}'.format(
MINT_ROOT_URL,
UPDATE_TRANS_ENDPOINT),
data=itemized_split).text
updateProgress.next()
logger.debug('Received response: {}'.format(response))
num_requests += 1
updateProgress.finish()
dur = s_to_time(time.time() - start_time)
logger.info('Sent {} updates to Mint in {}'.format(num_requests, dur))
'note': trans.note,
'merchant': trans.merchant,
'token': mint_client.token,
}
if not ignore_category:
modify_trans = {
**modify_trans,
'category': trans.category,
'catId': trans.category_id,
}
logger.debug('Sending a "modify" transaction request: {}'.format(
modify_trans))
response = mint_client.post(
'{}{}'.format(
MINT_ROOT_URL,
UPDATE_TRANS_ENDPOINT),
data=modify_trans).text
updateProgress.next()
logger.debug('Received response: {}'.format(response))
num_requests += 1
else:
# Split the existing transaction into many.
# If the existing transaction is a:
# - credit: positive amount is credit, negative debit
# - debit: positive amount is debit, negative credit
itemized_split = {
'txnId': '{}:0'.format(orig_trans.id),
'task': 'split',
'data': '', # Yup this is weird.
'token': mint_client.token,
}
'merchant': trans.merchant,
'token': mint_client.token,
}
if not ignore_category:
modify_trans = {
**modify_trans,
'category': trans.category,
'catId': trans.category_id,
}
logger.debug(
'Sending a "modify" transaction request: {}'.format(
modify_trans))
response = mint_client.post(
'{}{}'.format(
MINT_ROOT_URL,
UPDATE_TRANS_ENDPOINT),
data=modify_trans).text
updateProgress.next()
logger.debug('Received response: {}'.format(response))
num_requests += 1
else:
# Split the existing transaction into many.
# If the existing transaction is a:
# - credit: positive amount is credit, negative debit
# - debit: positive amount is debit, negative credit
itemized_split = {
'txnId': '{}:0'.format(orig_trans.id),
'task': 'split',
'data': '', # Yup this is weird.
'token': mint_client.token,
}
'merchant': trans.merchant,
'token': mint_client.token,
}
if not ignore_category:
modify_trans = {
**modify_trans,
'category': trans.category,
'catId': trans.category_id,
}
logger.debug(
'Sending a "modify" transaction request: {}'.format(
modify_trans))
response = mint_client.post(
'{}{}'.format(
MINT_ROOT_URL,
UPDATE_TRANS_ENDPOINT),
data=modify_trans).text
updateProgress.next()
logger.debug('Received response: {}'.format(response))
num_requests += 1
else:
# Split the existing transaction into many.
# If the existing transaction is a:
# - credit: positive amount is credit, negative debit
# - debit: positive amount is debit, negative credit
itemized_split = {
'txnId': '{}:0'.format(orig_trans.id),
'task': 'split',
'data': '', # Yup this is weird.
'token': mint_client.token,
}
# Yup. Weird:
itemized_split['percentAmount{}'.format(i)] = amount
itemized_split['merchant{}'.format(i)] = trans.merchant
# Yup weird. '0' means new?
itemized_split['txnId{}'.format(i)] = 0
if not ignore_category:
itemized_split['category{}'.format(i)] = trans.category
itemized_split['categoryId{}'.format(i)] = (
trans.category_id)
logger.debug(
'Sending a "split" transaction request: {}'.format(
itemized_split))
response = mint_client.post(
'{}{}'.format(
MINT_ROOT_URL,
UPDATE_TRANS_ENDPOINT),
data=itemized_split)
json_resp = response.json()
# The first id is always the original transaction (now
# parent transaction id).
new_trans_ids = json_resp['txnId'][1:]
assert len(new_trans_ids) == len(new_trans)
for itemized_id, trans in zip(new_trans_ids, new_trans):
# Now send the note for each itemized transaction.
itemized_note = {
'task': 'txnedit',
'txnId': '{}:0'.format(itemized_id),
'note': trans.note,
'token': mint_client.token,
}
note_response = mint_client.post(
json_resp = response.json()
# The first id is always the original transaction (now
# parent transaction id).
new_trans_ids = json_resp['txnId'][1:]
assert len(new_trans_ids) == len(new_trans)
for itemized_id, trans in zip(new_trans_ids, new_trans):
# Now send the note for each itemized transaction.
itemized_note = {
'task': 'txnedit',
'txnId': '{}:0'.format(itemized_id),
'note': trans.note,
'token': mint_client.token,
}
note_response = mint_client.post(
'{}{}'.format(
MINT_ROOT_URL,
UPDATE_TRANS_ENDPOINT),
data=itemized_note)
logger.debug(
'Received note response: {}'.format(
note_response.text))
updateProgress.next()
logger.debug('Received response: {}'.format(response.text))
num_requests += 1
updateProgress.finish()
logger.info('Sent {} updates to Mint'.format(num_requests))