Skip to content

Commit

Permalink
Fix: Removing condition for bank account in sync data (#179)
Browse files Browse the repository at this point in the history
* Fix: Removing condition for bank account in sync data

* fix line item balanceAccountType check

* bug fix

* bug fix

* Fix: Adding default ccc bank account (#180)

* Fix: Adding default ccc bank account

* removing bank account from import settings

* bug fixed

* change name

* renamed

* change name in JE
  • Loading branch information
Ashutosh619-sudo authored Dec 12, 2024
1 parent 4ed6d99 commit 5e21fca
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 5 deletions.
4 changes: 3 additions & 1 deletion apps/business_central/exports/journal_entry/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ def create_or_update_object(self, accounting_export: AccountingExport, _: Advanc
:return: purchase invoices object
"""
expense = accounting_export.expenses.first()

accounts_payable_account_id = export_settings.default_bank_account_id

if expense.fund_source == 'CCC':
accounts_payable_account_id = export_settings.default_ccc_bank_account_id

advance_setting = AdvancedSetting.objects.get(workspace_id=accounting_export.workspace_id)

document_number = expense.expense_number
Expand Down
1 change: 1 addition & 0 deletions apps/business_central/exports/journal_entry/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def __construct_journal_entry(self, body: JournalEntry, lineitems: List[JournalE

batch_journal_entry_payload.append(journal_entry_payload)

balance_account_type = 'G/L Account'
for lineitem in lineitems:
for dimension in lineitem.dimensions:
dimension['exported_module_id'] = lineitem.id
Expand Down
3 changes: 2 additions & 1 deletion apps/business_central/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ def format_business_central_fields(self, workspace_id):
"ACCOUNT",
"EMPLOYEE",
"LOCATION",
"COMPANY"
"COMPANY",
"BANK_ACCOUNT"
]
attributes = (
DestinationAttribute.objects.filter(
Expand Down
2 changes: 1 addition & 1 deletion apps/business_central/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def _sync_data(self, data, attribute_type, display_name, workspace_id, field_nam
attribute_type,
display_name,
value,
item['number'] if (item.get('number') and attribute_type != 'BANK_ACCOUNT') else item['id'],
item['number'] if item.get('number') else item['id'],
active,
detail
))
Expand Down
2 changes: 1 addition & 1 deletion apps/fyle/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def format_fyle_fields(self, workspace_id):
Get Fyle Fields
"""

attribute_types = ['CATEGORY', 'PROJECT', 'COST_CENTER', 'TAX_GROUP', 'CORPORATE_CARD', 'MERCHANT']
attribute_types = ['EMPLOYEE', 'CATEGORY', 'PROJECT', 'COST_CENTER', 'TAX_GROUP', 'CORPORATE_CARD', 'MERCHANT']

attributes = ExpenseAttribute.objects.filter(
~Q(attribute_type__in=attribute_types),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 4.1.2 on 2024-12-11 10:37

from django.db import migrations
import ms_business_central_api.models.fields


class Migration(migrations.Migration):

dependencies = [
('workspaces', '0004_importsetting_charts_of_accounts'),
]

operations = [
migrations.AddField(
model_name='exportsetting',
name='default_CCC_bank_account_id',
field=ms_business_central_api.models.fields.StringNullField(help_text='CCC Bank Account ID', max_length=255, null=True),
),
migrations.AddField(
model_name='exportsetting',
name='default_CCC_bank_account_name',
field=ms_business_central_api.models.fields.StringNullField(help_text='CCC Bank account name', max_length=255, null=True),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.1.2 on 2024-12-12 17:23

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('workspaces', '0005_exportsetting_default_ccc_bank_account_id_and_more'),
]

operations = [
migrations.RenameField(
model_name='exportsetting',
old_name='default_CCC_bank_account_id',
new_name='default_ccc_bank_account_id',
),
migrations.RenameField(
model_name='exportsetting',
old_name='default_CCC_bank_account_name',
new_name='default_ccc_bank_account_name',
),
]
2 changes: 2 additions & 0 deletions apps/workspaces/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ class ExportSetting(BaseModel):
)
default_bank_account_name = StringNullField(help_text='Bank account name')
default_bank_account_id = StringNullField(help_text='Bank Account ID')
default_ccc_bank_account_name = StringNullField(help_text='CCC Bank account name')
default_ccc_bank_account_id = StringNullField(help_text='CCC Bank Account ID')
reimbursable_expense_state = StringOptionsField(
choices=REIMBURSABLE_EXPENSE_STATE_CHOICES
)
Expand Down
4 changes: 3 additions & 1 deletion apps/workspaces/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,9 @@ def update(self, instance, validated):
mapping_settings = validated.pop('mapping_settings')
import_settings = validated.pop('import_settings')

if import_settings.get('charts_of_accounts') != instance.import_settings.charts_of_accounts:
import_setting_instance = ImportSetting.objects.filter(workspace_id=instance.id).first()

if import_setting_instance and import_settings.get('charts_of_accounts') != instance.import_settings.charts_of_accounts:
category_import_log = ImportLog.objects.filter(workspace_id=instance.id, attribute_type='CATEGORY').first()

if category_import_log:
Expand Down

0 comments on commit 5e21fca

Please sign in to comment.