Skip to content

Commit

Permalink
fix: Added modified on and created on values to fetched item cls codes
Browse files Browse the repository at this point in the history
  • Loading branch information
GichanaMayaka committed Aug 5, 2024
1 parent 62ea869 commit 5881ab0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions kenya_compliance/kenya_compliance/background_tasks/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,14 +327,16 @@ def update_item_classification_codes(response: dict) -> None:

for item_classification in code_list:
if item_classification["itemClsCd"] in existing_classifications:
# Prefer Raw SQL since using the ORM caused performance degradation. Still under investigation
update_query = f"""
UPDATE `tab{ITEM_CLASSIFICATIONS_DOCTYPE_NAME}`
SET itemclscd = '{item_classification["itemClsCd"]}',
itemclslvl = '{item_classification["itemClsLvl"]}',
itemclsnm = '{item_classification["itemClsNm"].replace("'", " ")}',
taxtycd = '{item_classification["taxTyCd"]}',
useyn = '{1 if item_classification["useYn"] == "Y" else 0}',
mjrtgyn = '{1 if item_classification["mjrTgYn"] == "Y" else 0}'
mjrtgyn = '{1 if item_classification["mjrTgYn"] == "Y" else 0}',
modified = SYSDATE()
WHERE name = '{item_classification["itemClsCd"]}';
"""

Expand All @@ -343,15 +345,16 @@ def update_item_classification_codes(response: dict) -> None:
else:
insert_query = f"""
INSERT INTO `tab{ITEM_CLASSIFICATIONS_DOCTYPE_NAME}`
(name, itemclscd, itemclslvl, itemclsnm, taxtycd, useyn, mjrtgyn)
(name, itemclscd, itemclslvl, itemclsnm, taxtycd, useyn, mjrtgyn, creation)
VALUES
('{item_classification["itemClsCd"]}',
'{item_classification["itemClsCd"]}',
'{item_classification["itemClsLvl"]}',
'{item_classification["itemClsNm"].replace("'", " ")}',
'{item_classification["taxTyCd"]}',
'{1 if item_classification["useYn"] == "Y" else 0}',
'{1 if item_classification["mjrTgYn"] == "Y" else 0}');
'{1 if item_classification["mjrTgYn"] == "Y" else 0}',
SYSDATE());
"""

frappe.db.sql(insert_query)
Expand Down

0 comments on commit 5881ab0

Please sign in to comment.