-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementaion of sync method for fyle and bamboohr (#112)
* Implementaion of sync method for fyle and bamboohr * sync employees method added to platform connector * implementation of sync fyle and bamboo hr * removing api_token * indent correction * comment resolved * minor bug fix * better code * Import sync department (#115) * Syncing Department from Bamboohr to Fyle * resolved commented code * better optimized code * comment resolved * Employee and Approver Import (#116) * Employee and Approver Import * bug fix and comment resolved
- Loading branch information
1 parent
5762644
commit d9aa46f
Showing
10 changed files
with
270 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
apps/fyle_hrms_mappings/migrations/0003_auto_20231221_1815.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Generated by Django 3.1.14 on 2023-12-21 18:15 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('orgs', '0004_auto_20230627_1133'), | ||
('fyle_hrms_mappings', '0002_auto_20231221_1515'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterUniqueTogether( | ||
name='destinationattribute', | ||
unique_together={('destination_id', 'attribute_type', 'org')}, | ||
), | ||
migrations.AlterUniqueTogether( | ||
name='expenseattribute', | ||
unique_together={('value', 'attribute_type', 'org')}, | ||
), | ||
migrations.AlterModelTable( | ||
name='destinationattribute', | ||
table='destination_attributes', | ||
), | ||
migrations.AlterModelTable( | ||
name='expenseattribute', | ||
table='expense_attributes', | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from typing import Dict | ||
from apps.users.models import User | ||
from apps.fyle_hrms_mappings.models import DestinationAttribute | ||
from .base import FyleEmployeeImport | ||
from bamboosdk.bamboohrsdk import BambooHrSDK | ||
from apps.bamboohr.models import BambooHr | ||
|
||
|
||
class BambooHrEmployeeImport(FyleEmployeeImport): | ||
|
||
def __init__(self, org_id: int, user: User): | ||
super().__init__(org_id, user) | ||
bamboo_hr = BambooHr.objects.get(org_id__in=org_id) | ||
self.bamboohr_sdk = BambooHrSDK(api_token=bamboo_hr.api_token, sub_domain=bamboo_hr.sub_domain) | ||
|
||
def sync_hrms_employees(self): | ||
employees = self.bamboohr_sdk.employees.get_all() | ||
self.upsert_employees(employees) | ||
|
||
def upsert_employees(self, employees: Dict): | ||
attributes = [] | ||
for employee in employees['employees']: | ||
supervisor = [employee['supervisorEmail']] | ||
active_status = True if employee['status'] == 'Active' else False | ||
detail = { | ||
'email': employee['workEmail'] if employee['workEmail'] else None, | ||
'department_name': employee['department'] if employee['department'] else None, | ||
'full_name': employee['displayName'] if employee['displayName'] else None, | ||
'approver_emails': supervisor, | ||
} | ||
|
||
attributes.append({ | ||
'attribute_type': 'EMPLOYEE', | ||
'value': employee['displayName'], | ||
'destination_id': employee['id'], | ||
'detail': detail, | ||
'active': active_status | ||
}) | ||
|
||
DestinationAttribute.bulk_create_or_update_destination_attributes( | ||
attributes=attributes, attribute_type='EMPLOYEE', org_id=self.org_id, update=True) | ||
|
||
return [] |
Oops, something went wrong.