Skip to content

Commit

Permalink
Add export url (#388)
Browse files Browse the repository at this point in the history
* Add export url

* fix tests

* Fix comments

---------

Co-authored-by: GitHub Actions <[email protected]>
  • Loading branch information
ruuushhh and GitHub Actions committed Aug 6, 2024
1 parent 3ab1af1 commit a00e3d9
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 22 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
submodules: recursive
- name: Bring up Services and Run Tests
run: |
docker-compose -f docker-compose-pipeline.yml build
docker-compose -f docker-compose-pipeline.yml up -d
docker-compose -f docker-compose-pipeline.yml exec -T api pytest tests/ --cov --cov-report=xml --cov-fail-under=85
docker compose -f docker-compose-pipeline.yml build
docker compose -f docker-compose-pipeline.yml up -d
docker compose -f docker-compose-pipeline.yml exec -T api pytest tests/ --cov --cov-report=xml --cov-fail-under=85
echo "STATUS=$(cat pytest-coverage.txt | grep 'Required test' | awk '{ print $1 }')" >> $GITHUB_ENV
echo "FAILED=$(cat test-reports/report.xml | awk -F'=' '{print $5}' | awk -F' ' '{gsub(/"/, "", $1); print $1}')" >> $GITHUB_ENV
env:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ jobs:
submodules: recursive
- name: Bring up Services and test for token health
run: |
docker-compose -f docker-compose-pipeline.yml build
docker-compose -f docker-compose-pipeline.yml up -d
docker-compose -f docker-compose-pipeline.yml exec -T api pytest tests/ --cov=. --cov-report=xml --cov-fail-under=85 --junit-xml=test-reports/report.xml | tee pytest-coverage.txt
docker compose -f docker-compose-pipeline.yml build
docker compose -f docker-compose-pipeline.yml up -d
docker compose -f docker-compose-pipeline.yml exec -T api pytest tests/ --cov=. --cov-report=xml --cov-fail-under=85 --junit-xml=test-reports/report.xml | tee pytest-coverage.txt
echo "STATUS=$(cat pytest-coverage.txt | grep 'Required test' | awk '{ print $1 }')" >> $GITHUB_ENV
echo "FAILED=$(cat test-reports/report.xml | awk -F'=' '{print $5}' | awk -F' ' '{gsub(/"/, "", $1); print $1}')" >> $GITHUB_ENV
env:
Expand Down
18 changes: 18 additions & 0 deletions apps/fyle/migrations/0020_expensegroup_export_url.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.14 on 2024-08-03 14:06

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('fyle', '0019_expense_paid_on_fyle'),
]

operations = [
migrations.AddField(
model_name='expensegroup',
name='export_url',
field=models.CharField(help_text='Xero URL for the exported expenses', max_length=255, null=True),
),
]
1 change: 1 addition & 0 deletions apps/fyle/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ class ExpenseGroup(models.Model):
employee_name = models.CharField(
max_length=100, help_text="Expense Group Employee Name", null=True
)
export_url = models.CharField(max_length=255, help_text='Xero URL for the exported expenses', null=True)
created_at = models.DateTimeField(auto_now_add=True, help_text="Created at")
exported_at = models.DateTimeField(help_text="Exported at", null=True)
updated_at = models.DateTimeField(auto_now=True, help_text="Updated at")
Expand Down
5 changes: 4 additions & 1 deletion apps/xero/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
from typing import List

from django.db import transaction
from apps.fyle.helpers import get_filter_credit_expenses
from fyle_accounting_mappings.models import DestinationAttribute, ExpenseAttribute, Mapping
from fyle_integrations_platform_connector import PlatformConnector
from xerosdk.exceptions import UnsuccessfulAuthentication, WrongParamsError

from apps.fyle.actions import update_complete_expenses, update_expenses_in_progress
from apps.fyle.enums import FundSourceEnum, FyleAttributeEnum
from apps.fyle.helpers import get_filter_credit_expenses
from apps.fyle.models import Expense, ExpenseGroup, ExpenseGroupSettings
from apps.fyle.tasks import post_accounting_export_summary
from apps.mappings.models import GeneralMapping, TenantMapping
Expand Down Expand Up @@ -947,5 +947,8 @@ def generate_export_url_and_update_expense(expense_group: ExpenseGroup, export_t
url = 'https://go.xero.com'
logger.error('Error while generating export url %s', error)

expense_group.export_url = url
expense_group.save()

update_complete_expenses(expense_group.expenses.all(), url)
post_accounting_export_summary(workspace.fyle_org_id, workspace.id, expense_group.fund_source)
31 changes: 16 additions & 15 deletions tests/sql_fixtures/reset_db_fixtures/reset_db.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
-- PostgreSQL database dump
--

-- Dumped from database version 15.6 (Debian 15.6-1.pgdg120+2)
-- Dumped from database version 15.7 (Debian 15.7-1.pgdg120+1)
-- Dumped by pg_dump version 15.7 (Debian 15.7-1.pgdg120+1)

SET statement_timeout = 0;
Expand Down Expand Up @@ -832,7 +832,8 @@ CREATE TABLE public.expense_groups (
updated_at timestamp with time zone NOT NULL,
workspace_id integer NOT NULL,
response_logs jsonb,
employee_name character varying(100)
employee_name character varying(100),
export_url character varying(255)
);


Expand Down Expand Up @@ -2630,6 +2631,7 @@ COPY public.django_migrations (id, app, name, applied) FROM stdin;
150 tasks 0009_error_repetition_count 2024-05-07 09:15:02.757657+00
151 workspaces 0038_alter_workspace_onboarding_state 2024-05-07 09:15:02.787555+00
152 fyle 0019_expense_paid_on_fyle 2024-06-18 16:26:06.802359+00
153 fyle 0020_expensegroup_export_url 2024-08-03 14:33:54.988078+00
\.


Expand Down Expand Up @@ -4834,17 +4836,17 @@ COPY public.expense_group_settings (id, reimbursable_expense_group_fields, corpo
-- Data for Name: expense_groups; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.expense_groups (id, fund_source, description, created_at, exported_at, updated_at, workspace_id, response_logs, employee_name) FROM stdin;
2 PERSONAL {"report_id": "rpE2JyATZhDe", "fund_source": "PERSONAL", "claim_number": "C/2022/05/R/16", "employee_email": "[email protected]"} 2022-08-02 20:26:22.944108+00 2022-08-02 20:27:44.873229+00 2022-08-02 20:27:44.873778+00 1 \N \N
4 PERSONAL {"report_id": "rpKuJtEv6h0n", "fund_source": "PERSONAL", "claim_number": "C/2022/06/R/1", "employee_email": "[email protected]"} 2022-08-02 20:26:22.953025+00 2022-08-02 20:27:48.929649+00 2022-08-02 20:27:48.929826+00 1 \N \N
1 PERSONAL {"report_id": "rp9EvDF8Umk6", "fund_source": "PERSONAL", "claim_number": "C/2022/06/R/2", "employee_email": "[email protected]"} 2022-08-02 20:26:22.939437+00 2022-08-02 20:27:52.017417+00 2022-08-02 20:27:52.017711+00 1 \N \N
3 PERSONAL {"report_id": "rpNeZt3cv9wz", "fund_source": "PERSONAL", "claim_number": "C/2022/06/R/3", "employee_email": "[email protected]"} 2022-08-02 20:26:22.948473+00 2022-08-02 20:27:55.12672+00 2022-08-02 20:27:55.127073+00 1 \N \N
10 CCC {"spent_at": "2022-05-25", "report_id": "rpVvNQvE2wbm", "expense_id": "txBMQRkBQciI", "fund_source": "CCC", "claim_number": "C/2022/05/R/13", "employee_email": "[email protected]"} 2022-08-02 20:26:22.974361+00 2022-08-02 20:27:59.397949+00 2022-08-02 20:27:59.39816+00 1 \N \N
5 CCC {"spent_at": "2022-05-24", "report_id": "rp5lITpxFLxE", "expense_id": "txkw3dt3umkN", "fund_source": "CCC", "claim_number": "C/2022/05/R/12", "employee_email": "[email protected]"} 2022-08-02 20:26:22.956314+00 2022-08-02 20:28:03.682322+00 2022-08-02 20:28:03.682555+00 1 \N \N
8 CCC {"spent_at": "2022-05-25", "report_id": "rprwGgzOZyfR", "expense_id": "tx1FW3uxYZG6", "fund_source": "CCC", "claim_number": "C/2022/05/R/15", "employee_email": "[email protected]"} 2022-08-02 20:26:22.966799+00 2022-08-02 20:28:07.656716+00 2022-08-02 20:28:07.657378+00 1 \N \N
6 CCC {"spent_at": "2022-05-25", "report_id": "rpLawO11bFib", "expense_id": "txjIqTCtkkC8", "fund_source": "CCC", "claim_number": "C/2022/05/R/18", "employee_email": "[email protected]"} 2022-08-02 20:26:22.959403+00 2022-08-02 20:28:11.748729+00 2022-08-02 20:28:11.748944+00 1 \N \N
9 CCC {"spent_at": "2021-01-01", "report_id": "rpv1txzAsgr3", "expense_id": "txUPRc3VwxOP", "fund_source": "CCC", "claim_number": "C/2022/05/R/17", "employee_email": "[email protected]"} 2022-08-02 20:26:22.97121+00 2022-08-02 20:28:16.115273+00 2022-08-02 20:28:16.115482+00 1 \N \N
7 CCC {"spent_at": "2022-05-25", "report_id": "rpnG3lZYDsHU", "expense_id": "txVXhyVB8mgK", "fund_source": "CCC", "claim_number": "C/2022/05/R/14", "employee_email": "[email protected]"} 2022-08-02 20:26:22.962947+00 2022-08-02 20:28:20.026921+00 2022-08-02 20:28:20.027277+00 1 \N \N
COPY public.expense_groups (id, fund_source, description, created_at, exported_at, updated_at, workspace_id, response_logs, employee_name, export_url) FROM stdin;
2 PERSONAL {"report_id": "rpE2JyATZhDe", "fund_source": "PERSONAL", "claim_number": "C/2022/05/R/16", "employee_email": "[email protected]"} 2022-08-02 20:26:22.944108+00 2022-08-02 20:27:44.873229+00 2022-08-02 20:27:44.873778+00 1 \N \N \N
4 PERSONAL {"report_id": "rpKuJtEv6h0n", "fund_source": "PERSONAL", "claim_number": "C/2022/06/R/1", "employee_email": "[email protected]"} 2022-08-02 20:26:22.953025+00 2022-08-02 20:27:48.929649+00 2022-08-02 20:27:48.929826+00 1 \N \N \N
1 PERSONAL {"report_id": "rp9EvDF8Umk6", "fund_source": "PERSONAL", "claim_number": "C/2022/06/R/2", "employee_email": "[email protected]"} 2022-08-02 20:26:22.939437+00 2022-08-02 20:27:52.017417+00 2022-08-02 20:27:52.017711+00 1 \N \N \N
3 PERSONAL {"report_id": "rpNeZt3cv9wz", "fund_source": "PERSONAL", "claim_number": "C/2022/06/R/3", "employee_email": "[email protected]"} 2022-08-02 20:26:22.948473+00 2022-08-02 20:27:55.12672+00 2022-08-02 20:27:55.127073+00 1 \N \N \N
10 CCC {"spent_at": "2022-05-25", "report_id": "rpVvNQvE2wbm", "expense_id": "txBMQRkBQciI", "fund_source": "CCC", "claim_number": "C/2022/05/R/13", "employee_email": "[email protected]"} 2022-08-02 20:26:22.974361+00 2022-08-02 20:27:59.397949+00 2022-08-02 20:27:59.39816+00 1 \N \N \N
5 CCC {"spent_at": "2022-05-24", "report_id": "rp5lITpxFLxE", "expense_id": "txkw3dt3umkN", "fund_source": "CCC", "claim_number": "C/2022/05/R/12", "employee_email": "[email protected]"} 2022-08-02 20:26:22.956314+00 2022-08-02 20:28:03.682322+00 2022-08-02 20:28:03.682555+00 1 \N \N \N
8 CCC {"spent_at": "2022-05-25", "report_id": "rprwGgzOZyfR", "expense_id": "tx1FW3uxYZG6", "fund_source": "CCC", "claim_number": "C/2022/05/R/15", "employee_email": "[email protected]"} 2022-08-02 20:26:22.966799+00 2022-08-02 20:28:07.656716+00 2022-08-02 20:28:07.657378+00 1 \N \N \N
6 CCC {"spent_at": "2022-05-25", "report_id": "rpLawO11bFib", "expense_id": "txjIqTCtkkC8", "fund_source": "CCC", "claim_number": "C/2022/05/R/18", "employee_email": "[email protected]"} 2022-08-02 20:26:22.959403+00 2022-08-02 20:28:11.748729+00 2022-08-02 20:28:11.748944+00 1 \N \N \N
9 CCC {"spent_at": "2021-01-01", "report_id": "rpv1txzAsgr3", "expense_id": "txUPRc3VwxOP", "fund_source": "CCC", "claim_number": "C/2022/05/R/17", "employee_email": "[email protected]"} 2022-08-02 20:26:22.97121+00 2022-08-02 20:28:16.115273+00 2022-08-02 20:28:16.115482+00 1 \N \N \N
7 CCC {"spent_at": "2022-05-25", "report_id": "rpnG3lZYDsHU", "expense_id": "txVXhyVB8mgK", "fund_source": "CCC", "claim_number": "C/2022/05/R/14", "employee_email": "[email protected]"} 2022-08-02 20:26:22.962947+00 2022-08-02 20:28:20.026921+00 2022-08-02 20:28:20.027277+00 1 \N \N \N
\.


Expand Down Expand Up @@ -5167,7 +5169,7 @@ SELECT pg_catalog.setval('public.django_content_type_id_seq', 40, true);
-- Name: django_migrations_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--

SELECT pg_catalog.setval('public.django_migrations_id_seq', 152, true);
SELECT pg_catalog.setval('public.django_migrations_id_seq', 153, true);


--
Expand Down Expand Up @@ -6784,4 +6786,3 @@ ALTER TABLE ONLY public.xero_credentials
--
-- PostgreSQL database dump complete
--

0 comments on commit a00e3d9

Please sign in to comment.