From c73d6741424e4a7e6c38b7748d70a2b87145e40d Mon Sep 17 00:00:00 2001 From: ruuushhh <66899387+ruuushhh@users.noreply.github.com> Date: Mon, 20 May 2024 11:22:25 +0530 Subject: [PATCH] Fix: Add order to Vendor Search (#614) --- apps/quickbooks_online/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/quickbooks_online/models.py b/apps/quickbooks_online/models.py index 4b5fcdf1..67dcda2c 100644 --- a/apps/quickbooks_online/models.py +++ b/apps/quickbooks_online/models.py @@ -461,7 +461,7 @@ def create_qbo_expense(expense_group: ExpenseGroup): if workspace_general_settings.map_merchant_to_vendor and expense_group.fund_source == 'CCC': merchant = expense.vendor if expense.vendor else '' - entity = DestinationAttribute.objects.filter(value__iexact=merchant, attribute_type='VENDOR', workspace_id=expense_group.workspace_id, active=True).first() + entity = DestinationAttribute.objects.filter(value__iexact=merchant, attribute_type='VENDOR', workspace_id=expense_group.workspace_id, active=True).order_by('-updated_at').first() if not entity: entity_id = DestinationAttribute.objects.filter(value='Debit Card Misc', workspace_id=expense_group.workspace_id).first().destination_id @@ -596,7 +596,7 @@ def create_credit_card_purchase(expense_group: ExpenseGroup, map_merchant_to_ven if map_merchant_to_vendor: merchant = expense.vendor if expense.vendor else '' - entity = DestinationAttribute.objects.filter(value__iexact=merchant, attribute_type='VENDOR', workspace_id=expense_group.workspace_id, active=True).first() + entity = DestinationAttribute.objects.filter(value__iexact=merchant, attribute_type='VENDOR', workspace_id=expense_group.workspace_id, active=True).order_by('-updated_at').first() if not entity: entity_id = DestinationAttribute.objects.filter(value='Credit Card Misc', workspace_id=expense_group.workspace_id).first().destination_id