Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ruuushhh committed Feb 22, 2024
2 parents dff6848 + ed61812 commit 8283d65
Show file tree
Hide file tree
Showing 24 changed files with 2,679 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[run]
omit = ./venv/*, ms_business_central_api/*, *forms.py, *apps.py,*manage.py,*__init__.py,apps/*/migrations/*.py,*asgi*,*wsgi*,*admin.py,*urls.py,*settings.py, *gunicorn*,
omit = ./venv/*,*forms.py, *apps.py,*manage.py,*__init__.py,apps/*/migrations/*.py,*asgi*,*wsgi*,*admin.py,*urls.py,*settings.py, *gunicorn*,
68 changes: 68 additions & 0 deletions .github/workflows/production_deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Deploy to Production

on:
release:
types: [created]

jobs:
production_deploy:
runs-on: ubuntu-latest
environment: Production
steps:
- uses: actions/checkout@v2
- name: push to dockerhub
uses: fylein/docker-release-action@master
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
IMAGE_NAME: fyle_ms-business-central-api

- name: Install kustomize
run: |
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
sudo mv kustomize /usr/local/bin/
- name: Clone another repository
uses: actions/checkout@v2
with:
repository: ${{ secrets.PROD_DEPLOY_REPO }}
ref: master
path: ${{ secrets.PROD_DEPLOY_REPO }}
persist-credentials: false
token: ${{ secrets.DEPLOY_GIT_ACCESS_TOKEN }}

- name: Update Image Tag
run: |
NEW_TAG="v$(git rev-parse --short HEAD)"
cd ${{ secrets.PROD_DEPLOY_REPO }}/${{ secrets.US_EKS_CLUSTER_NAME }}/integrations
kustomize edit set image docker.io/${{ secrets.DOCKERHUB_USERNAME }}/fyle_ms-business-central-api=docker.io/${{ secrets.DOCKERHUB_USERNAME }}/fyle_ms-business-central-api:$NEW_TAG
- name: Commit and push changes
run: |
cd ${{ secrets.PROD_DEPLOY_REPO }}/
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
git add .
git commit -m "Update ms-business-central-api image tag"
git remote set-url origin https://x-access-token:${{ secrets.DEPLOY_GIT_ACCESS_TOKEN }}@github.com/${{ secrets.PROD_DEPLOY_REPO }}
git push origin master
git push origin master
- name: Create new Sentry release
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: fyle-technologies-private-limi
SENTRY_PROJECT: ms-business-central-api
SENTRY_DEPLOY_ENVIRONMENT: production
run: |
# Install Sentry CLI
curl -sL https://sentry.io/get-cli/ | bash
# Create new Sentry release
export SENTRY_RELEASE=$(sentry-cli releases propose-version)
sentry-cli releases new -p $SENTRY_PROJECT $SENTRY_RELEASE
sentry-cli releases set-commits --auto $SENTRY_RELEASE
sentry-cli releases finalize $SENTRY_RELEASE
# Create new deploy for this Sentry release
sentry-cli releases deploys $SENTRY_RELEASE new -e $SENTRY_DEPLOY_ENVIRONMENT
2 changes: 1 addition & 1 deletion apps/business_central/exports/base_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def get_vendor_or_employee_id(employee_field_mapping: str, mapping: EmployeeMapp
return "Employee", mapping.destination_employee.destination_id

if export_settings.reimbursable_expenses_export_type == 'PURCHASE_INVOICE' and accounting_export.fund_source == 'PERSONAL':
return mapping.destination_vendor.destination_id
return "", mapping.destination_vendor.destination_id
else:
if accounting_export.fund_source == 'PERSONAL':
return get_vendor_or_employee_id(export_settings.employee_field_mapping, mapping)
Expand Down
2 changes: 1 addition & 1 deletion apps/business_central/exports/purchase_invoice/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def create_or_update_object(self, accounting_export: AccountingExport, _: Advanc
:return: purchase invoices object
"""

vendor_id = self.get_account_id_type(accounting_export=accounting_export, export_settings=export_settings)
_, vendor_id = self.get_account_id_type(accounting_export=accounting_export, export_settings=export_settings)
amount = self.get_total_amount(accounting_export=accounting_export)
invoice_date = self.get_invoice_date(accounting_export=accounting_export)

Expand Down
8 changes: 7 additions & 1 deletion apps/fyle/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import traceback
from functools import wraps

from fyle.platform.exceptions import NoPrivilegeError
from fyle.platform.exceptions import NoPrivilegeError, RetryException

from apps.workspaces.models import FyleCredential

Expand All @@ -27,6 +27,12 @@ def wrapper(*args, **kwargs):
args[1].status = 'FAILED'
args[1].save()

except RetryException:
logger.info('Fyle Retry Exception occured')
args[1].detail = {'message': 'Fyle Retry Exception occured'}
args[1].status = 'FATAL'
args[1].save()

except Exception:
error = traceback.format_exc()
args[1].detail = {'error': error}
Expand Down
6 changes: 6 additions & 0 deletions apps/fyle/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,3 +235,9 @@ def get_fyle_orgs(refresh_token: str, cluster_domain: str):
api_url = '{0}/api/orgs/'.format(cluster_domain)

return get_request(api_url, {}, refresh_token)


def sync_dimensions(fyle_credentials: FyleCredential) -> None:
platform = PlatformConnector(fyle_credentials)

platform.import_fyle_dimensions()
6 changes: 5 additions & 1 deletion apps/mappings/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from dynamics.exceptions.dynamics_exceptions import InvalidTokenError
from fyle.platform.exceptions import InternalServerError
from fyle.platform.exceptions import InvalidTokenError as FyleInvalidTokenError
from fyle.platform.exceptions import WrongParamsError
from fyle.platform.exceptions import WrongParamsError, RetryException

from apps.mappings.models import ImportLog
from apps.workspaces.models import BusinessCentralCredentials
Expand Down Expand Up @@ -42,6 +42,10 @@ def new_fn(expense_attribute_instance, *args):
error['alert'] = False
import_log.status = 'FAILED'

except RetryException:
error['message'] = 'Fyle Retry Exception occured'
import_log.status = 'FATAL'

except InternalServerError:
error['message'] = 'Internal server error while importing to Fyle'
error['alert'] = True
Expand Down
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[pytest]
DJANGO_SETTINGS_MODULE = ms_business_central_api.tests.settings
python_files = tests.py test_*.py *_tests.py
addopts = -p no:warnings --strict-markers --no-migrations --create-db
addopts = -p no:warnings --strict-markers --no-migrations --create-db --cov=. --cov-config=.coveragerc
log_cli = 1
log_cli_level = INFO
log_cli_format = %(asctime)s [%(levelname)8s] %(name)s: %(message)s (%(filename)s:%(lineno)s)
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ gevent==23.9.1
gunicorn==20.1.0

# Platform SDK
fyle==0.36.0
fyle==0.36.1

# Business central sdk
ms-dynamics-business-central-sdk==1.4.2

# Reusable Fyle Packages
fyle-rest-auth==1.6.0
fyle-accounting-mappings==1.29.2
fyle-integrations-platform-connector==1.36.1
fyle-integrations-platform-connector==1.36.3

# Postgres Dependincies
psycopg2-binary==2.9.9
Expand Down
Loading

0 comments on commit 8283d65

Please sign in to comment.