From fec5bf2e28319a3454b6c6d570442abb5253482e Mon Sep 17 00:00:00 2001 From: ljain112 Date: Thu, 11 Jul 2024 18:40:00 +0530 Subject: [PATCH] fix: optimise function `update_gst_category` --- .../doctype/gst_settings/gst_settings.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/india_compliance/gst_india/doctype/gst_settings/gst_settings.py b/india_compliance/gst_india/doctype/gst_settings/gst_settings.py index 74a6d81128..af064e4a82 100644 --- a/india_compliance/gst_india/doctype/gst_settings/gst_settings.py +++ b/india_compliance/gst_india/doctype/gst_settings/gst_settings.py @@ -365,9 +365,21 @@ def update_gst_category(): # party-wise addresses category_map = {} + gstin_wise_detail = {} + for address in address_without_category: - gstin_info = get_gstin_info(address.gstin) - gst_category = gstin_info.gst_category + gstin = address.gstin + + if gstin not in gstin_wise_detail: + gstin_info = get_gstin_info(gstin) + gstin_wise_detail[gstin] = gstin_info + + gstin_info = gstin_wise_detail[gstin] + + if not gstin_info: + continue + + gst_category = gstin_wise_detail[gstin].get("gst_category") category_map.setdefault(gst_category, []).append(address.name)