Skip to content

Commit

Permalink
Fix Attachments (#547)
Browse files Browse the repository at this point in the history
  • Loading branch information
ruuushhh authored Apr 24, 2024
1 parent 1582677 commit d9b7631
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions apps/netsuite/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,11 +371,21 @@ def upload_attachments_and_update_export(expenses: List[Expense], task_log: Task

for expense in expenses:
if expense.file_ids and len(expense.file_ids):
# Grabbing 1st attachment since we can upload only 1 attachment per expense
payload = [{'id': expense.file_ids[0]}]
attachments = platform.files.bulk_generate_file_urls(payload)
files_list = []
attachments = []

file_ids = expense.file_ids

for file_id in file_ids:
files_list.append({'id': file_id})

attachment = attachments[0] if len(attachments) else None
attachments = platform.files.bulk_generate_file_urls(files_list)

# Filter HTML attachments
attachments = list(filter(lambda attachment: attachment['content_type'] != 'text/html', attachments))

# Grabbing 1st attachment since we can upload only 1 attachment per expense
attachment = attachments[0] if len(attachments) else None

if attachment:
netsuite_connection.connection.files.post({
Expand Down

0 comments on commit d9b7631

Please sign in to comment.