Skip to content

Commit

Permalink
Merge branch 'master' into max-retry-payment
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashutosh619-sudo committed Sep 4, 2024
2 parents c557957 + 95a052e commit 1a8a3f7
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
15 changes: 15 additions & 0 deletions apps/sage_intacct/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,21 @@ def get_memo(expense_group: ExpenseGroup,
:param payment_type: The payment type to use in the memo.
:return: The memo.
"""

config = Configuration.objects.get(workspace_id=workspace_id)
if config.corporate_credit_card_expenses_object == 'CHARGE_CARD_TRANSACTION':
memo = 'Corporate Card Expense'
email = expense_group.description.get('employee_email')
if email:
memo = f'{memo} by {email}'

# Internal ID
count = ExportTable.objects.filter(memo__contains=memo, expense_group__workspace_id=workspace_id).count()
if count > 0:
memo = f'{memo} - {count}'

return memo

expense_fund_source = 'Reimbursable expense' if expense_group.fund_source == 'PERSONAL' \
else 'Corporate Credit Card expense'
unique_number = None
Expand Down
29 changes: 29 additions & 0 deletions tests/test_sageintacct/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,35 @@ def test_get_memo(db):

get_memo(expense_group, Bill, workspace_id)

expense_group = ExpenseGroup.objects.get(id=2)
workspace_id = expense_group.workspace.id

config = Configuration.objects.get(workspace_id=workspace_id)
config.corporate_credit_card_expenses_object = 'CHARGE_CARD_TRANSACTION'
config.save()

expense_group.description['employee_email'] = '[email protected]'
expense_group.save()

memo = get_memo(expense_group, ChargeCardTransaction, workspace_id)
assert memo == 'Corporate Card Expense by [email protected]'

ChargeCardTransaction.create_charge_card_transaction(expense_group)

memo = get_memo(expense_group, ChargeCardTransaction, workspace_id)
assert memo == 'Corporate Card Expense by [email protected] - 1'

for i in range(3):
expense_group = ExpenseGroup.objects.get(id=i + 1)
expense_group.description['employee_email'] = '[email protected]'
expense_group.save()

ChargeCardTransaction.create_charge_card_transaction(expense_group)

memo = get_memo(expense_group, ChargeCardTransaction, workspace_id)
assert memo == 'Corporate Card Expense by [email protected] - 3'


def test_get_item_id_or_none(db, mocker):
workspace_id = 1

Expand Down

0 comments on commit 1a8a3f7

Please sign in to comment.