Skip to content

Commit

Permalink
add loggers and bug fixes (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
NileshPant1999 authored Jan 5, 2024
1 parent a3cf9b0 commit f065587
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
7 changes: 3 additions & 4 deletions apps/travelperk/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,8 @@ def attach_reciept_to_expense(expense_id: str, invoice: Invoice, imported_expens

file = platform_connection.v1beta.spender.files.create_file(file_payload)
generate_url = platform_connection.v1beta.spender.files.generate_file_urls({'data': {'id': file['data']['id']}})
download_path = 'tmp/{}-invoice.pdf'.format(expense_id)

file_content = download_file(invoice.pdf, download_path)
file_content = download_file(invoice.pdf)
upload_to_s3_presigned_url(file_content, generate_url['data']['upload_url'])

attached_reciept = platform_connection.v1beta.spender.expenses.attach_receipt({'data': {'id': expense_id, 'file_id': file['data']['id']}})
Expand Down Expand Up @@ -114,9 +113,9 @@ def create_expense_in_fyle(org_id: str, invoice: Invoice, invoice_lineitems: Inv
}
}

if expense.category in CATEGORY_MAP:
platform_connection = create_fyle_connection(org.id)
if expense.service in CATEGORY_MAP:
category_name = CATEGORY_MAP[expense.service]
platform_connection = create_fyle_connection(org.id)

query_params = {
'limit': 1,
Expand Down
2 changes: 1 addition & 1 deletion apps/travelperk/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(self, credentials_object: TravelperkCredential, org_id: int):

client_id = settings.TRAVELPERK_CLIENT_ID
client_secret = settings.TRAVELPERK_CLIENT_SECRET
environment = 'sandbox'
environment = settings.TRAVELPERK_ENVIRONMENT
refresh_token = credentials_object.refresh_token

self.connection = Travelperk(client_id, client_secret, refresh_token, environment)
Expand Down
6 changes: 5 additions & 1 deletion apps/travelperk/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@ class ConnectTravelperkView(generics.CreateAPIView):
Api Call to make Travelperk Connection in workato
"""

permission_classes = []
authentication_classes = []

def post(self, request, *args, **kwargs):

try:
Expand All @@ -270,7 +273,7 @@ def post(self, request, *args, **kwargs):
'invoice.issued'
]
}

connector = Workato()
configuration: TravelPerkConfiguration = TravelPerkConfiguration.objects.filter(org__id=kwargs['org_id']).first()

Expand Down Expand Up @@ -314,6 +317,7 @@ def create(self, request, *args, **kwargs):
# Custom processing of the webhook event data
with transaction.atomic():
# Extract invoice line items from the request data
logger.info("webhook data: {}".format(request.data))
invoice_lineitems_data = request.data.pop('lines')

# Create or update Invoice and related line items
Expand Down

0 comments on commit f065587

Please sign in to comment.