From f4c32cb1489b93b941e2fb5c52a05f7c731a5731 Mon Sep 17 00:00:00 2001 From: ruuushhh <66899387+ruuushhh@users.noreply.github.com> Date: Tue, 24 Sep 2024 11:20:47 +0530 Subject: [PATCH] fix: Bill Number (Add Safety) (#672) Co-authored-by: GitHub Actions --- apps/quickbooks_online/models.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/quickbooks_online/models.py b/apps/quickbooks_online/models.py index 5b213c5a..567921b5 100644 --- a/apps/quickbooks_online/models.py +++ b/apps/quickbooks_online/models.py @@ -191,6 +191,10 @@ def get_bill_number(expense_group: ExpenseGroup): bill_number_field = 'expense_number' bill_number = expense_group.expenses.first().__getattribute__(bill_number_field) + + count = Bill.objects.filter(bill_number=bill_number, expense_group__workspace_id=expense_group.workspace.id).count() + if count > 0: + bill_number = '{} - {}'.format(bill_number, count) return bill_number