Skip to content

Commit

Permalink
Adding auto mapped flag setting support
Browse files Browse the repository at this point in the history
  • Loading branch information
Shwetabhk committed Apr 12, 2021
1 parent 29d3156 commit 9588043
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
19 changes: 18 additions & 1 deletion fyle_accounting_mappings/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,10 @@ def create_or_update_mapping(source_type: str, destination_type: str,

@staticmethod
def bulk_create_mappings(destination_attributes: List[DestinationAttribute], source_type: str,
destination_type: str, workspace_id: int):
destination_type: str, workspace_id: int, set_auto_mapped_flag: bool = True):
"""
Bulk create mappings
:param set_auto_mapped_flag: set auto mapped to expense attributes
:param destination_type: Destination Type
:param source_type: Source Type
:param destination_attributes: Destination Attributes List
Expand Down Expand Up @@ -372,4 +373,20 @@ def bulk_create_mappings(destination_attributes: List[DestinationAttribute], sou
)

mappings = Mapping.objects.bulk_create(mapping_batch, batch_size=50)

if set_auto_mapped_flag:
expense_attributes_to_be_updated = []

for mapping in mappings:
expense_attributes_to_be_updated.append(
ExpenseAttribute(
id=mapping.source.id,
auto_mapped=True
)
)

if expense_attributes_to_be_updated:
ExpenseAttribute.objects.bulk_update(
expense_attributes_to_be_updated, fields=['auto_mapped'], batch_size=50)

return mappings
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setuptools.setup(
name='fyle-accounting-mappings',
version='0.14.1',
version='0.15.0',
author='Shwetabh Kumar',
author_email='[email protected]',
description='Django application to store the fyle accounting mappings in a generic manner',
Expand Down

0 comments on commit 9588043

Please sign in to comment.