Skip to content

Commit

Permalink
is_simplify_report_closure_enabled integrated (#199)
Browse files Browse the repository at this point in the history
This reverts commit b4e7626.
  • Loading branch information
vishalpandeynits authored Jan 25, 2023
1 parent b4e7626 commit 5872f29
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 11 deletions.
19 changes: 19 additions & 0 deletions apps/fyle/migrations/0016_auto_20230117_0616.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 3.1.14 on 2023-01-17 06:16

import apps.fyle.models
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('fyle', '0015_auto_20221104_1049'),
]

operations = [
migrations.AlterField(
model_name='expensegroupsettings',
name='ccc_expense_state',
field=models.CharField(choices=[('APPROVED', 'APPROVED'), ('PAID', 'PAID'), ('PAYMENT_PROCESSING', 'PAYMENT_PROCESSING')], default=apps.fyle.models.get_default_ccc_expense_state, help_text='state at which the ccc expenses are fetched (PAYMENT_PROCESSING /PAID)', max_length=100, null=True),
),
]
10 changes: 9 additions & 1 deletion apps/fyle/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,14 @@ def get_default_ccc_expense_group_fields():
def get_default_expense_state():
return 'PAYMENT_PROCESSING'

def get_default_ccc_expense_state():
return 'PAID'

CCC_EXPENSE_STATE = (
('APPROVED', 'APPROVED'),
('PAID', 'PAID'),
('PAYMENT_PROCESSING', 'PAYMENT_PROCESSING')
)

class ExpenseGroupSettings(models.Model):
"""
Expand All @@ -193,7 +201,7 @@ class ExpenseGroupSettings(models.Model):
max_length=100, default=get_default_expense_state,
help_text='state at which the reimbursable expenses are fetched (PAYMENT_PROCESSING / PAID)', null=True)
ccc_expense_state = models.CharField(
max_length=100, default=get_default_expense_state,
max_length=100, default=get_default_ccc_expense_state, choices=CCC_EXPENSE_STATE,
help_text='state at which the ccc expenses are fetched (PAYMENT_PROCESSING /PAID)', null=True)
reimbursable_export_date_type = models.CharField(max_length=100, default='current_date', help_text='Export Date')
ccc_export_date_type = models.CharField(max_length=100, default='spent_at', help_text='CCC Export Date')
Expand Down
3 changes: 2 additions & 1 deletion apps/fyle/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,14 @@ def async_create_expense_groups(workspace_id: int, fund_source: List[str], task_

if expenses:
workspace.last_synced_at = datetime.now()
reimbursable_expenses_count = len(expenses)
reimbursable_expenses_count += len(expenses)

if 'CCC' in fund_source:
expenses.extend(platform.expenses.get(
source_account_type=['PERSONAL_CORPORATE_CREDIT_CARD_ACCOUNT'],
state=expense_group_settings.ccc_expense_state,
settled_at=ccc_last_synced_at if expense_group_settings.ccc_expense_state == 'PAYMENT_PROCESSING' else None,
approved_at=ccc_last_synced_at if expense_group_settings.ccc_expense_state == 'APPROVED' else None,
filter_credit_expenses=filter_credit_expenses,
last_paid_at=ccc_last_synced_at if expense_group_settings.ccc_expense_state == 'PAID' else None
))
Expand Down
8 changes: 7 additions & 1 deletion apps/workspaces/apis/export_settings/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ class WorkspaceGeneralSettingsSerializer(serializers.ModelSerializer):

class Meta:
model = WorkspaceGeneralSettings
fields = ['reimbursable_expenses_object', 'corporate_credit_card_expenses_object', 'auto_map_employees']
fields = [
'reimbursable_expenses_object',
'corporate_credit_card_expenses_object',
'auto_map_employees',
'is_simplify_report_closure_enabled'
]
read_only_fields = ['is_simplify_report_closure_enabled']


class GeneralMappingsSerializer(serializers.ModelSerializer):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.1.14 on 2023-01-19 11:50

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('workspaces', '0031_auto_20221116_0649'),
]

operations = [
migrations.AddField(
model_name='workspacegeneralsettings',
name='is_simplify_report_closure_enabled',
field=models.BooleanField(default=False, help_text='Simplify report closure is enabled'),
),
]
1 change: 1 addition & 0 deletions apps/workspaces/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class WorkspaceGeneralSettings(models.Model):
skip_cards_mapping = models.BooleanField(default=False, help_text='Skip cards mapping')
import_tax_codes = models.BooleanField(default=False, help_text='Auto import tax codes to Fyle', null=True)
import_customers = models.BooleanField(default=False, help_text='Auto import customers to Fyle')
is_simplify_report_closure_enabled = models.BooleanField(default=False, help_text='Simplify report closure is enabled')
created_at = models.DateTimeField(auto_now_add=True, help_text='Created at')
updated_at = models.DateTimeField(auto_now=True, help_text='Updated at')
charts_of_accounts = ArrayField(
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ django-rest-framework==0.1.0
djangorestframework==3.11.2
enum34==1.1.10
future==0.18.2
fyle-accounting-mappings==1.20.0
fyle==0.30.0
fyle-accounting-mappings==1.22.0
fyle-integrations-platform-connector==1.22.0
fyle-rest-auth==1.3.1
gunicorn==20.0.4
Expand Down
7 changes: 7 additions & 0 deletions sql/scripts/017-set-ccc-expense-state.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
rollback;
begin;

update
expense_group_settings
set
ccc_expense_state = expense_state;
15 changes: 9 additions & 6 deletions tests/sql_fixtures/reset_db_fixtures/reset_db.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
-- PostgreSQL database dump
--

-- Dumped from database version 14.2 (Debian 14.2-1.pgdg110+1)
-- Dumped by pg_dump version 14.5 (Debian 14.5-1.pgdg100+1)
-- Dumped from database version 15.1 (Debian 15.1-1.pgdg110+1)
-- Dumped by pg_dump version 15.1 (Debian 15.1-1.pgdg100+1)

SET statement_timeout = 0;
SET lock_timeout = 0;
Expand Down Expand Up @@ -1387,7 +1387,8 @@ CREATE TABLE public.workspace_general_settings (
charts_of_accounts character varying(100)[] NOT NULL,
import_customers boolean NOT NULL,
change_accounting_period boolean NOT NULL,
auto_create_merchant_destination_entity boolean NOT NULL
auto_create_merchant_destination_entity boolean NOT NULL,
is_simplify_report_closure_enabled boolean NOT NULL
);


Expand Down Expand Up @@ -2415,6 +2416,8 @@ COPY public.django_migrations (id, app, name, applied) FROM stdin;
124 mappings 0007_auto_20221102_0630 2022-11-03 06:28:39.216754+00
125 workspaces 0030_auto_20221102_1924 2022-11-03 06:28:39.245951+00
126 fyle 0015_auto_20221104_1049 2022-11-04 11:04:25.882513+00
127 workspaces 0031_workspacegeneralsettings_is_simplify_report_closure_enabled 2023-01-11 06:28:22.8634+00
128 fyle 0016_auto_20230117_0616 2023-01-18 09:08:24.092416+00
\.


Expand Down Expand Up @@ -4816,8 +4819,8 @@ COPY public.users (password, last_login, id, email, user_id, full_name, active,
-- Data for Name: workspace_general_settings; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.workspace_general_settings (id, reimbursable_expenses_object, corporate_credit_card_expenses_object, created_at, updated_at, workspace_id, sync_fyle_to_xero_payments, sync_xero_to_fyle_payments, import_categories, auto_map_employees, auto_create_destination_entity, map_merchant_to_contact, skip_cards_mapping, import_tax_codes, charts_of_accounts, import_customers, change_accounting_period, auto_create_merchant_destination_entity) FROM stdin;
1 PURCHASE BILL BANK TRANSACTION 2022-08-02 20:25:24.644164+00 2022-08-02 20:25:24.644209+00 1 f t t EMAIL t t f t {EXPENSE} t t f
COPY public.workspace_general_settings (id, reimbursable_expenses_object, corporate_credit_card_expenses_object, created_at, updated_at, workspace_id, sync_fyle_to_xero_payments, sync_xero_to_fyle_payments, import_categories, auto_map_employees, auto_create_destination_entity, map_merchant_to_contact, skip_cards_mapping, import_tax_codes, charts_of_accounts, import_customers, change_accounting_period, auto_create_merchant_destination_entity, is_simplify_report_closure_enabled) FROM stdin;
1 PURCHASE BILL BANK TRANSACTION 2022-08-02 20:25:24.644164+00 2022-08-02 20:25:24.644209+00 1 f t t EMAIL t t f t {EXPENSE} t t f f
\.


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

SELECT pg_catalog.setval('public.django_migrations_id_seq', 126, true);
SELECT pg_catalog.setval('public.django_migrations_id_seq', 128, true);


--
Expand Down
1 change: 1 addition & 0 deletions tests/test_workspaces/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
'id':2,
'reimbursable_expenses_object':'PURCHASE BILL',
'corporate_credit_card_expenses_object':'BANK TRANSACTION',
'is_simplify_report_closure_enabled': True,
'sync_fyle_to_xero_payments':False,
'sync_xero_to_fyle_payments':True,
'map_merchant_to_contact':True,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"workspace_general_settings": {
"reimbursable_expenses_object": "PURCHASE BILL",
"corporate_credit_card_expenses_object": "BANK TRANSACTION",
"auto_map_employees": "EMAIL"
"auto_map_employees": "EMAIL",
'is_simplify_report_closure_enabled': True
},
"expense_group_settings": {
"reimbursable_expense_group_fields": [
Expand Down

0 comments on commit 5872f29

Please sign in to comment.