Skip to content

Commit

Permalink
send only active attributes in get destination_attributes (#346)
Browse files Browse the repository at this point in the history
  • Loading branch information
harshithaputtaswamy authored Oct 25, 2022
1 parent 15fc82c commit 35f1343
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
5 changes: 4 additions & 1 deletion apps/quickbooks_online/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ def sync_tax_codes(self):
'display_name': 'Tax Code',
'value': '{0} @{1}%'.format(tax_code['Name'], effective_tax_rate),
'destination_id': tax_code['Id'],
'active': True,
'detail': {
'tax_rate': effective_tax_rate,
'tax_refs': tax_rates
Expand Down Expand Up @@ -333,6 +334,7 @@ def create_vendor_destionation_attribute(self, vendor):
'display_name': 'vendor',
'value': vendor['DisplayName'],
'destination_id': vendor['Id'],
'active': vendor['Active'],
'detail': {
'email': vendor['PrimaryEmailAddr']['Address'] if 'PrimaryEmailAddr' in vendor else None
}
Expand Down Expand Up @@ -386,7 +388,8 @@ def sync_employees(self):
'display_name': 'employee',
'value': employee['DisplayName'],
'destination_id': employee['Id'],
'detail': detail
'detail': detail,
'active': True
})

DestinationAttribute.bulk_create_or_update_destination_attributes(
Expand Down
7 changes: 2 additions & 5 deletions apps/quickbooks_online/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -898,15 +898,12 @@ class DestinationAttributesView(generics.ListAPIView):

def get_queryset(self):
attribute_types = self.request.query_params.get('attribute_types').split(',')
active = self.request.query_params.get('active')
filters = {
'attribute_type__in' : attribute_types,
'workspace_id': self.kwargs['workspace_id']
'workspace_id': self.kwargs['workspace_id'],
'active': True
}

if active and active.lower() == 'true':
filters['active'] = True

return DestinationAttribute.objects.filter(**filters).order_by('value')


Expand Down

0 comments on commit 35f1343

Please sign in to comment.