From 65494bfc0a9ec7db17abae57bbcd9ecf98ce2b6a Mon Sep 17 00:00:00 2001 From: Dave Date: Fri, 24 Jun 2022 11:12:38 +0200 Subject: [PATCH] Jinja function for selling price on item label --- msp/hooks.py | 6 ++++++ msp/things.py | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 msp/things.py diff --git a/msp/hooks.py b/msp/hooks.py index f0057f1..da38cfb 100644 --- a/msp/hooks.py +++ b/msp/hooks.py @@ -18,6 +18,12 @@ app_license = "GPLv3" # app_include_css = "/assets/msp/css/msp.css" app_include_js = "/assets/msp/js/customer_quick_entry.js" +jenv = { + "methods": [ + "jinja_get_item_price:msp.things.get_item_price_for_label" + ] +} + # include js, css files in header of web template # web_include_css = "/assets/msp/css/msp.css" # web_include_js = "/assets/msp/js/msp.js" diff --git a/msp/things.py b/msp/things.py new file mode 100644 index 0000000..518f9da --- /dev/null +++ b/msp/things.py @@ -0,0 +1,53 @@ +from erpnext.stock.doctype import item +import frappe + + +def set_item_group_warehouse(): + pass + +def get_item_goups_without_default_warehouse(): + igs = frappe.db.sql(""" + select + ig.name, + id.default_warehouse + from `tabItem Group` ig + left join `tabItem Default` id on id.parent = ig.name + where id.default_warehouse IS NULL; + """) + print(igs) + +def get_item_group_for_item(item): + pass + + +@frappe.whitelist() +def get_item_price_for_label(item_code): + pl = frappe.db.get_single_value("Selling Settings", "selling_price_list") + sp = frappe.get_all("Item Price", filters={"price_list": pl, "item_code": item_code, "selling": 1}, fields=["name", "price_list_rate"]) + if len(sp) == 1: + + amount = sp[0]["price_list_rate"] + if amount == 0: + return + thousands_separator = "." + fractional_separator = "," + currency = "{:,.2f} €".format(amount) + + if thousands_separator == ".": + main_currency, fractional_currency = currency.split(".")[0], currency.split(".")[1] + new_main_currency = main_currency.replace(",", ".") + currency = new_main_currency + fractional_separator + fractional_currency + + return currency + else: + return + +@frappe.whitelist() +def get_warehouse_for_label(item_code): + return + +@frappe.whitelist() +def get_qr_code(data, format=None): + import segno + +