Skip to content

Commit

Permalink
paid_on_fyle field added to expense table (#372)
Browse files Browse the repository at this point in the history
* paid_on_fyle field added to expense table

* script for mark paid on fyle
  • Loading branch information
Ashutosh619-sudo authored Jun 19, 2024
1 parent d06b3cc commit 684f932
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 14 deletions.
18 changes: 18 additions & 0 deletions apps/fyle/migrations/0019_expense_paid_on_fyle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.14 on 2024-06-18 16:19

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('fyle', '0018_auto_20240213_0450'),
]

operations = [
migrations.AddField(
model_name='expense',
name='paid_on_fyle',
field=models.BooleanField(default=False, help_text='Expense Payment status on Fyle'),
),
]
1 change: 1 addition & 0 deletions apps/fyle/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ class Expense(models.Model):
paid_on_xero = models.BooleanField(
help_text="Expense Payment status on Xero", default=False
)
paid_on_fyle = models.BooleanField(help_text="Expense Payment status on Fyle", default=False)
tax_amount = models.FloatField(null=True, help_text="Tax Amount")
tax_group_id = models.CharField(null=True, max_length=255, help_text="Tax Group ID")
accounting_export_summary = JSONField(default=dict)
Expand Down
6 changes: 6 additions & 0 deletions apps/xero/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,7 @@ def process_reimbursements(workspace_id):
).all()

reimbursement_ids = []
expenses_paid_on_fyle = []

if reimbursements:
for reimbursement in reimbursements:
Expand All @@ -805,6 +806,7 @@ def process_reimbursements(workspace_id):

if all_expense_paid:
reimbursement_ids.append(reimbursement.reimbursement_id)
expenses_paid_on_fyle.extend(expenses)

if reimbursement_ids:
reimbursements_list = []
Expand All @@ -815,6 +817,10 @@ def process_reimbursements(workspace_id):
platform.reimbursements.bulk_post_reimbursements(reimbursements_list)
platform.reimbursements.sync()

for expense in expenses_paid_on_fyle:
expense.paid_on_fyle = True
expense.save()


def create_missing_currency(workspace_id: int):
"""
Expand Down
9 changes: 9 additions & 0 deletions sql/scripts/026-mark-paid-on-fyle.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
rollback;
begin;

update expenses e
set paid_on_fyle = 't'
from reimbursements r
where e.settlement_id = r.settlement_id
and e.paid_on_xero = 't'
and r.state = 'COMPLETE';
30 changes: 16 additions & 14 deletions tests/sql_fixtures/reset_db_fixtures/reset_db.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
--

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

SET statement_timeout = 0;
SET lock_timeout = 0;
Expand Down Expand Up @@ -939,7 +939,8 @@ CREATE TABLE public.expenses (
posted_at timestamp with time zone,
accounting_export_summary jsonb NOT NULL,
previous_export_state character varying(255),
workspace_id integer
workspace_id integer,
paid_on_fyle boolean NOT NULL
);


Expand Down Expand Up @@ -2628,6 +2629,7 @@ COPY public.django_migrations (id, app, name, applied) FROM stdin;
149 fyle_integrations_imports 0001_initial 2024-05-07 09:15:02.744843+00
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
\.


Expand Down Expand Up @@ -4868,17 +4870,17 @@ COPY public.expense_groups_expenses (id, expensegroup_id, expense_id) FROM stdin
-- Data for Name: expenses; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.expenses (id, employee_email, category, sub_category, project, expense_id, expense_number, claim_number, amount, currency, foreign_amount, foreign_currency, settlement_id, reimbursable, state, vendor, cost_center, purpose, report_id, spent_at, approved_at, expense_created_at, expense_updated_at, created_at, updated_at, fund_source, verified_at, custom_properties, paid_on_xero, org_id, file_ids, corporate_card_id, tax_amount, tax_group_id, billable, employee_name, posted_at, accounting_export_summary, previous_export_state, workspace_id) FROM stdin;
1 [email protected] Food \N \N txaaVBj3yKGW E/2022/06/T/4 C/2022/06/R/2 1 USD \N \N setrunCck8hLH t PAYMENT_PROCESSING \N \N \N rp9EvDF8Umk6 2022-06-27 17:00:00+00 2022-06-27 09:06:52.951+00 2022-06-27 09:06:13.135764+00 2022-06-27 09:08:23.340321+00 2022-08-02 20:26:22.81033+00 2022-08-02 20:26:22.810363+00 PERSONAL \N {"Card": "", "Killua": "", "Classes": "", "avc_123": null, "New Field": "", "Multi field": "", "Testing This": "", "abc in [123]": null, "Postman Field": "", "Netsuite Class": ""} f orPJvXuoLqvJ {} \N \N \N f \N \N {} \N \N
2 [email protected] Food \N \N txB6D8k0Ws8a E/2022/06/T/2 C/2022/06/R/3 4 USD \N \N setrunCck8hLH t PAYMENT_PROCESSING \N \N \N rpNeZt3cv9wz 2022-06-27 17:00:00+00 2022-06-27 09:07:16.556+00 2022-06-27 09:05:45.738+00 2022-06-27 09:08:23.340321+00 2022-08-02 20:26:22.82716+00 2022-08-02 20:26:22.827194+00 PERSONAL \N {"Card": "", "Killua": "", "Classes": "", "avc_123": null, "New Field": "", "Multi field": "", "Testing This": "", "abc in [123]": null, "Postman Field": "", "Netsuite Class": ""} f orPJvXuoLqvJ {} \N \N \N f \N \N {} \N \N
3 [email protected] Food \N Bebe Rexha txGilVGolf60 E/2022/06/T/1 C/2022/06/R/1 10 USD \N \N setlpIUKpdvsT t PAYMENT_PROCESSING \N Adidas \N rpKuJtEv6h0n 2020-01-01 17:00:00+00 2022-06-08 04:28:30.61+00 2022-06-08 04:27:35.274447+00 2022-06-08 04:28:51.237261+00 2022-08-02 20:26:22.835984+00 2022-08-02 20:26:22.83608+00 PERSONAL \N {"Card": "", "Killua": "", "Classes": "", "avc_123": null, "New Field": "", "Multi field": "", "Testing This": "", "abc in [123]": null, "POSTMAN FIELD": "", "Netsuite Class": ""} f orPJvXuoLqvJ {} \N 1 tg0gTsClGjLp f \N \N {} \N \N
4 [email protected] Food \N \N txjIqTCtkkC8 E/2022/05/T/21 C/2022/05/R/18 100 USD \N \N set3ZMFXrDPL3 f PAYMENT_PROCESSING \N \N \N rpLawO11bFib 2022-05-25 17:00:00+00 2022-05-25 08:59:25.649+00 2022-05-25 08:59:07.718891+00 2022-05-25 09:04:05.66983+00 2022-08-02 20:26:22.844927+00 2022-08-02 20:26:22.844961+00 CCC \N {"Card": "", "Killua": "", "Classes": "", "avc_123": null, "New Field": "", "Multi field": "", "Testing This": "", "abc in [123]": null, "POSTMAN FIELD": "", "Netsuite Class": ""} f orPJvXuoLqvJ {} \N \N \N f \N \N {} \N \N
5 [email protected] WIP \N Bebe Rexha txUPRc3VwxOP E/2022/05/T/19 C/2022/05/R/17 101 USD \N \N setb1pSLMIok8 f PAYMENT_PROCESSING \N Adidas \N rpv1txzAsgr3 2021-01-01 17:00:00+00 2022-05-25 07:24:12.987+00 2022-05-25 07:21:40.598113+00 2022-05-25 07:25:00.848892+00 2022-08-02 20:26:22.857516+00 2022-08-02 20:26:22.857675+00 CCC \N {"Card": "", "Killua": "", "Classes": "", "avc_123": null, "New Field": "", "Multi field": "", "Testing This": "", "abc in [123]": null, "POSTMAN FIELD": "", "Netsuite Class": ""} f orPJvXuoLqvJ {} \N \N \N f \N \N {} \N \N
6 [email protected] Food \N \N txUDvDmEV4ep E/2022/05/T/18 C/2022/05/R/16 5 USD \N \N set33iAVXO7BA t PAYMENT_PROCESSING \N \N \N rpE2JyATZhDe 2020-05-25 17:00:00+00 2022-05-25 06:05:23.362+00 2022-05-25 06:04:46.557927+00 2022-05-25 06:05:47.36985+00 2022-08-02 20:26:22.870854+00 2022-08-02 20:26:22.87089+00 PERSONAL \N {"Card": "", "Killua": "", "Classes": "", "avc_123": null, "New Field": "", "Multi field": "", "Testing This": "", "abc in [123]": null, "POSTMAN FIELD": "", "Netsuite Class": ""} f orPJvXuoLqvJ {} \N \N \N f \N \N {} \N \N
7 [email protected] WIP \N Bebe Rexha tx1FW3uxYZG6 E/2022/05/T/16 C/2022/05/R/15 151 USD \N \N setzFn3FK5t80 f PAYMENT_PROCESSING \N Adidas \N rprwGgzOZyfR 2022-05-25 17:00:00+00 2022-05-25 03:41:49.042+00 2022-05-25 03:41:28.839711+00 2022-05-25 03:42:10.145663+00 2022-08-02 20:26:22.882803+00 2022-08-02 20:26:22.882836+00 CCC \N {"Card": "", "Killua": "", "Classes": "", "avc_123": null, "New Field": "", "Multi field": "", "Testing This": "", "abc in [123]": null, "POSTMAN FIELD": "", "Netsuite Class": ""} f orPJvXuoLqvJ {} \N \N \N f \N \N {} \N \N
8 [email protected] WIP \N Bebe Rexha txVXhyVB8mgK E/2022/05/T/15 C/2022/05/R/14 45 USD \N \N setsN8cLD9KIn f PAYMENT_PROCESSING \N Adidas \N rpnG3lZYDsHU 2022-05-25 17:00:00+00 2022-05-25 02:48:53.791+00 2022-05-25 02:48:37.432989+00 2022-05-25 02:49:18.189037+00 2022-08-02 20:26:22.894793+00 2022-08-02 20:26:22.894827+00 CCC \N {"Card": "", "Killua": "", "Classes": "", "avc_123": null, "New Field": "", "Multi field": "", "Testing This": "", "abc in [123]": null, "POSTMAN FIELD": "", "Netsuite Class": ""} f orPJvXuoLqvJ {} \N \N \N f \N \N {} \N \N
9 [email protected] WIP \N Bebe Rexha txBMQRkBQciI E/2022/05/T/14 C/2022/05/R/13 10 USD \N \N setanDKqMZfXB f PAYMENT_PROCESSING \N Adidas \N rpVvNQvE2wbm 2022-05-25 17:00:00+00 2022-05-25 02:38:40.858+00 2022-05-25 02:38:25.832419+00 2022-05-25 02:39:08.208877+00 2022-08-02 20:26:22.908632+00 2022-08-02 20:26:22.908661+00 CCC \N {"Card": "", "Killua": "", "Classes": "", "avc_123": null, "New Field": "", "Multi field": "", "Testing This": "", "abc in [123]": null, "POSTMAN FIELD": "", "Netsuite Class": ""} f orPJvXuoLqvJ {} \N \N \N f \N \N {} \N \N
10 [email protected] WIP \N Bebe Rexha txkw3dt3umkN E/2022/05/T/12 C/2022/05/R/12 101 USD \N \N setBe6qAlNXPU f PAYMENT_PROCESSING \N Adidas \N rp5lITpxFLxE 2022-05-24 17:00:00+00 2022-05-24 15:59:13.26+00 2022-05-24 15:55:50.369024+00 2022-05-24 16:00:27.982+00 2022-08-02 20:26:22.921466+00 2022-08-02 20:26:22.9215+00 CCC \N {"Card": "", "Killua": "", "Classes": "", "avc_123": null, "New Field": "", "Multi field": "", "Testing This": "", "abc in [123]": null, "POSTMAN FIELD": "", "Netsuite Class": ""} f orPJvXuoLqvJ {} \N 1 tg0gTsClGjLp f \N \N {} \N \N
COPY public.expenses (id, employee_email, category, sub_category, project, expense_id, expense_number, claim_number, amount, currency, foreign_amount, foreign_currency, settlement_id, reimbursable, state, vendor, cost_center, purpose, report_id, spent_at, approved_at, expense_created_at, expense_updated_at, created_at, updated_at, fund_source, verified_at, custom_properties, paid_on_xero, org_id, file_ids, corporate_card_id, tax_amount, tax_group_id, billable, employee_name, posted_at, accounting_export_summary, previous_export_state, workspace_id, paid_on_fyle) FROM stdin;
1 [email protected] Food \N \N txaaVBj3yKGW E/2022/06/T/4 C/2022/06/R/2 1 USD \N \N setrunCck8hLH t PAYMENT_PROCESSING \N \N \N rp9EvDF8Umk6 2022-06-27 17:00:00+00 2022-06-27 09:06:52.951+00 2022-06-27 09:06:13.135764+00 2022-06-27 09:08:23.340321+00 2022-08-02 20:26:22.81033+00 2022-08-02 20:26:22.810363+00 PERSONAL \N {"Card": "", "Killua": "", "Classes": "", "avc_123": null, "New Field": "", "Multi field": "", "Testing This": "", "abc in [123]": null, "Postman Field": "", "Netsuite Class": ""} f orPJvXuoLqvJ {} \N \N \N f \N \N {} \N \N f
2 [email protected] Food \N \N txB6D8k0Ws8a E/2022/06/T/2 C/2022/06/R/3 4 USD \N \N setrunCck8hLH t PAYMENT_PROCESSING \N \N \N rpNeZt3cv9wz 2022-06-27 17:00:00+00 2022-06-27 09:07:16.556+00 2022-06-27 09:05:45.738+00 2022-06-27 09:08:23.340321+00 2022-08-02 20:26:22.82716+00 2022-08-02 20:26:22.827194+00 PERSONAL \N {"Card": "", "Killua": "", "Classes": "", "avc_123": null, "New Field": "", "Multi field": "", "Testing This": "", "abc in [123]": null, "Postman Field": "", "Netsuite Class": ""} f orPJvXuoLqvJ {} \N \N \N f \N \N {} \N \N f
3 [email protected] Food \N Bebe Rexha txGilVGolf60 E/2022/06/T/1 C/2022/06/R/1 10 USD \N \N setlpIUKpdvsT t PAYMENT_PROCESSING \N Adidas \N rpKuJtEv6h0n 2020-01-01 17:00:00+00 2022-06-08 04:28:30.61+00 2022-06-08 04:27:35.274447+00 2022-06-08 04:28:51.237261+00 2022-08-02 20:26:22.835984+00 2022-08-02 20:26:22.83608+00 PERSONAL \N {"Card": "", "Killua": "", "Classes": "", "avc_123": null, "New Field": "", "Multi field": "", "Testing This": "", "abc in [123]": null, "POSTMAN FIELD": "", "Netsuite Class": ""} f orPJvXuoLqvJ {} \N 1 tg0gTsClGjLp f \N \N {} \N \N f
4 [email protected] Food \N \N txjIqTCtkkC8 E/2022/05/T/21 C/2022/05/R/18 100 USD \N \N set3ZMFXrDPL3 f PAYMENT_PROCESSING \N \N \N rpLawO11bFib 2022-05-25 17:00:00+00 2022-05-25 08:59:25.649+00 2022-05-25 08:59:07.718891+00 2022-05-25 09:04:05.66983+00 2022-08-02 20:26:22.844927+00 2022-08-02 20:26:22.844961+00 CCC \N {"Card": "", "Killua": "", "Classes": "", "avc_123": null, "New Field": "", "Multi field": "", "Testing This": "", "abc in [123]": null, "POSTMAN FIELD": "", "Netsuite Class": ""} f orPJvXuoLqvJ {} \N \N \N f \N \N {} \N \N f
5 [email protected] WIP \N Bebe Rexha txUPRc3VwxOP E/2022/05/T/19 C/2022/05/R/17 101 USD \N \N setb1pSLMIok8 f PAYMENT_PROCESSING \N Adidas \N rpv1txzAsgr3 2021-01-01 17:00:00+00 2022-05-25 07:24:12.987+00 2022-05-25 07:21:40.598113+00 2022-05-25 07:25:00.848892+00 2022-08-02 20:26:22.857516+00 2022-08-02 20:26:22.857675+00 CCC \N {"Card": "", "Killua": "", "Classes": "", "avc_123": null, "New Field": "", "Multi field": "", "Testing This": "", "abc in [123]": null, "POSTMAN FIELD": "", "Netsuite Class": ""} f orPJvXuoLqvJ {} \N \N \N f \N \N {} \N \N f
6 [email protected] Food \N \N txUDvDmEV4ep E/2022/05/T/18 C/2022/05/R/16 5 USD \N \N set33iAVXO7BA t PAYMENT_PROCESSING \N \N \N rpE2JyATZhDe 2020-05-25 17:00:00+00 2022-05-25 06:05:23.362+00 2022-05-25 06:04:46.557927+00 2022-05-25 06:05:47.36985+00 2022-08-02 20:26:22.870854+00 2022-08-02 20:26:22.87089+00 PERSONAL \N {"Card": "", "Killua": "", "Classes": "", "avc_123": null, "New Field": "", "Multi field": "", "Testing This": "", "abc in [123]": null, "POSTMAN FIELD": "", "Netsuite Class": ""} f orPJvXuoLqvJ {} \N \N \N f \N \N {} \N \N f
7 [email protected] WIP \N Bebe Rexha tx1FW3uxYZG6 E/2022/05/T/16 C/2022/05/R/15 151 USD \N \N setzFn3FK5t80 f PAYMENT_PROCESSING \N Adidas \N rprwGgzOZyfR 2022-05-25 17:00:00+00 2022-05-25 03:41:49.042+00 2022-05-25 03:41:28.839711+00 2022-05-25 03:42:10.145663+00 2022-08-02 20:26:22.882803+00 2022-08-02 20:26:22.882836+00 CCC \N {"Card": "", "Killua": "", "Classes": "", "avc_123": null, "New Field": "", "Multi field": "", "Testing This": "", "abc in [123]": null, "POSTMAN FIELD": "", "Netsuite Class": ""} f orPJvXuoLqvJ {} \N \N \N f \N \N {} \N \N f
8 [email protected] WIP \N Bebe Rexha txVXhyVB8mgK E/2022/05/T/15 C/2022/05/R/14 45 USD \N \N setsN8cLD9KIn f PAYMENT_PROCESSING \N Adidas \N rpnG3lZYDsHU 2022-05-25 17:00:00+00 2022-05-25 02:48:53.791+00 2022-05-25 02:48:37.432989+00 2022-05-25 02:49:18.189037+00 2022-08-02 20:26:22.894793+00 2022-08-02 20:26:22.894827+00 CCC \N {"Card": "", "Killua": "", "Classes": "", "avc_123": null, "New Field": "", "Multi field": "", "Testing This": "", "abc in [123]": null, "POSTMAN FIELD": "", "Netsuite Class": ""} f orPJvXuoLqvJ {} \N \N \N f \N \N {} \N \N f
9 [email protected] WIP \N Bebe Rexha txBMQRkBQciI E/2022/05/T/14 C/2022/05/R/13 10 USD \N \N setanDKqMZfXB f PAYMENT_PROCESSING \N Adidas \N rpVvNQvE2wbm 2022-05-25 17:00:00+00 2022-05-25 02:38:40.858+00 2022-05-25 02:38:25.832419+00 2022-05-25 02:39:08.208877+00 2022-08-02 20:26:22.908632+00 2022-08-02 20:26:22.908661+00 CCC \N {"Card": "", "Killua": "", "Classes": "", "avc_123": null, "New Field": "", "Multi field": "", "Testing This": "", "abc in [123]": null, "POSTMAN FIELD": "", "Netsuite Class": ""} f orPJvXuoLqvJ {} \N \N \N f \N \N {} \N \N f
10 [email protected] WIP \N Bebe Rexha txkw3dt3umkN E/2022/05/T/12 C/2022/05/R/12 101 USD \N \N setBe6qAlNXPU f PAYMENT_PROCESSING \N Adidas \N rp5lITpxFLxE 2022-05-24 17:00:00+00 2022-05-24 15:59:13.26+00 2022-05-24 15:55:50.369024+00 2022-05-24 16:00:27.982+00 2022-08-02 20:26:22.921466+00 2022-08-02 20:26:22.9215+00 CCC \N {"Card": "", "Killua": "", "Classes": "", "avc_123": null, "New Field": "", "Multi field": "", "Testing This": "", "abc in [123]": null, "POSTMAN FIELD": "", "Netsuite Class": ""} f orPJvXuoLqvJ {} \N 1 tg0gTsClGjLp f \N \N {} \N \N f
\.


Expand Down Expand Up @@ -5165,7 +5167,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', 151, true);
SELECT pg_catalog.setval('public.django_migrations_id_seq', 152, true);


--
Expand Down

0 comments on commit 684f932

Please sign in to comment.