Skip to content

Commit

Permalink
reimbursable expense field set
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyanshs7 committed Sep 12, 2024
1 parent 7d27cd5 commit 0e06bbc
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion apps/spotlight/service.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from dataclasses import dataclass
from typing import Callable, Dict
from django.db import transaction
import json

import requests

from apps.fyle.helpers import get_access_token
from apps.workspaces.models import FyleCredential
from apps.workspaces.models import ExportSettings, FyleCredential
from .prompts.support_genie import PROMPT as SUPPORT_GENIE_PROMPT
from .prompts.spotlight_prompt import PROMPT as SPOTLIGHT_PROMPT

Expand Down Expand Up @@ -65,6 +66,7 @@ class ActionService:
def _get_action_function_from_code(cls, *, code: str) -> Callable:
code_to_function_map = {
"trigger_export": cls.trigger_export,
"set_reimbursable_expenses_export_module_bill": cls.set_reimbursable_expenses_export_module_bill,
"set_customer_field_mapping_to_project": cls.set_customer_field_mapping_to_project,
"set_customer_field_mapping_to_cost_center": cls.set_customer_field_mapping_to_cost_center,
"set_class_field_mapping_to_project": cls.set_class_field_mapping_to_project,
Expand All @@ -84,6 +86,19 @@ def get_access_token(cls, *, workspace_id: int) -> str:
creds = FyleCredential.objects.get(workspace_id=workspace_id)
return get_access_token(creds.refresh_token)

@classmethod
def set_reimbursable_expenses_export_module_bill(cls, *, workspace_id: int):
with transaction.atomic():
export_settings = ExportSettings.objects.filter(
workspace_id=workspace_id
).first()
if export_settings is None:
return ActionResponse(message="Failed to set reimbursable expense export type set to Bill", is_success=False)
else:
export_settings.reimbursable_expenses_export_type = 'BILL'
export_settings.save()
return ActionResponse(message="Reimbursable expense export type set to Bill", is_success=True)

@classmethod
def trigger_export(cls, *, workspace_id: int):
access_token = cls.get_access_token(workspace_id=workspace_id)
Expand Down

0 comments on commit 0e06bbc

Please sign in to comment.