From 20567ef13586f2738db10a49b10315460f83a939 Mon Sep 17 00:00:00 2001 From: mb Date: Thu, 28 Mar 2024 13:06:02 +0530 Subject: [PATCH] bug fix --- invoice_sync/fixtures/custom_field.json | 272 ++++++++++++++++++++++++ invoice_sync/hooks.py | 1 + invoice_sync/invoice_sync/invoice.py | 8 +- 3 files changed, 279 insertions(+), 2 deletions(-) create mode 100644 invoice_sync/fixtures/custom_field.json diff --git a/invoice_sync/fixtures/custom_field.json b/invoice_sync/fixtures/custom_field.json new file mode 100644 index 0000000..5925c96 --- /dev/null +++ b/invoice_sync/fixtures/custom_field.json @@ -0,0 +1,272 @@ +[ + { + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "collapsible_depends_on": null, + "columns": 0, + "default": null, + "depends_on": null, + "description": null, + "docstatus": 0, + "doctype": "Custom Field", + "dt": "Supplier", + "fetch_from": null, + "fetch_if_empty": 0, + "fieldname": "custom_email", + "fieldtype": "Data", + "hidden": 0, + "hide_border": 0, + "hide_days": 0, + "hide_seconds": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_preview": 0, + "in_standard_filter": 0, + "insert_after": "country", + "is_system_generated": 0, + "is_virtual": 0, + "label": "Email", + "length": 0, + "mandatory_depends_on": null, + "modified": "2024-03-19 15:01:11.049563", + "module": "Invoice Sync", + "name": "Supplier-custom_email", + "no_copy": 0, + "non_negative": 0, + "options": "Country", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "print_width": null, + "read_only": 0, + "read_only_depends_on": null, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "sort_options": 0, + "translatable": 0, + "unique": 0, + "width": null + }, + { + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "collapsible_depends_on": null, + "columns": 0, + "default": null, + "depends_on": null, + "description": null, + "docstatus": 0, + "doctype": "Custom Field", + "dt": "Supplier", + "fetch_from": null, + "fetch_if_empty": 0, + "fieldname": "custom_mobileno", + "fieldtype": "Data", + "hidden": 0, + "hide_border": 0, + "hide_days": 0, + "hide_seconds": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_preview": 0, + "in_standard_filter": 0, + "insert_after": "custom_email", + "is_system_generated": 0, + "is_virtual": 0, + "label": "mobile no", + "length": 0, + "mandatory_depends_on": null, + "modified": "2024-03-19 15:01:10.908553", + "module": "Invoice Sync", + "name": "Supplier-custom_mobileno", + "no_copy": 0, + "non_negative": 0, + "options": "Country", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "print_width": null, + "read_only": 0, + "read_only_depends_on": null, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "sort_options": 0, + "translatable": 0, + "unique": 0, + "width": null + }, + { + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "collapsible_depends_on": null, + "columns": 0, + "default": null, + "depends_on": null, + "description": null, + "docstatus": 0, + "doctype": "Custom Field", + "dt": "Supplier", + "fetch_from": null, + "fetch_if_empty": 0, + "fieldname": "custom_commision", + "fieldtype": "Data", + "hidden": 0, + "hide_border": 0, + "hide_days": 0, + "hide_seconds": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_preview": 0, + "in_standard_filter": 0, + "insert_after": "default_price_list", + "is_system_generated": 0, + "is_virtual": 0, + "label": "Commision", + "length": 0, + "mandatory_depends_on": null, + "modified": "2024-03-19 15:01:10.152141", + "module": "Invoice Sync", + "name": "Supplier-custom_commision", + "no_copy": 0, + "non_negative": 0, + "options": null, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "print_width": null, + "read_only": 0, + "read_only_depends_on": null, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "sort_options": 0, + "translatable": 1, + "unique": 0, + "width": null + }, + { + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "collapsible_depends_on": null, + "columns": 0, + "default": null, + "depends_on": null, + "description": null, + "docstatus": 0, + "doctype": "Custom Field", + "dt": "Sales Invoice", + "fetch_from": null, + "fetch_if_empty": 0, + "fieldname": "custom_supplier_id", + "fieldtype": "Link", + "hidden": 0, + "hide_border": 0, + "hide_days": 0, + "hide_seconds": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_preview": 0, + "in_standard_filter": 0, + "insert_after": "custom_uuid", + "is_system_generated": 0, + "is_virtual": 0, + "label": "supplier_id", + "length": 0, + "mandatory_depends_on": null, + "modified": "2024-03-19 15:01:10.614071", + "module": "Invoice Sync", + "name": "Sales Invoice-custom_supplier_id", + "no_copy": 0, + "non_negative": 0, + "options": "Supplier", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "print_width": null, + "read_only": 0, + "read_only_depends_on": null, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "sort_options": 0, + "translatable": 0, + "unique": 0, + "width": null + }, + { + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "collapsible_depends_on": null, + "columns": 0, + "default": null, + "depends_on": null, + "description": null, + "docstatus": 0, + "doctype": "Custom Field", + "dt": "Sales Invoice", + "fetch_from": null, + "fetch_if_empty": 0, + "fieldname": "custom_payment_method", + "fieldtype": "Select", + "hidden": 0, + "hide_border": 0, + "hide_days": 0, + "hide_seconds": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_preview": 0, + "in_standard_filter": 0, + "insert_after": "custom_supplier_id", + "is_system_generated": 0, + "is_virtual": 0, + "label": "payment_method", + "length": 0, + "mandatory_depends_on": null, + "modified": "2024-03-19 15:01:10.327273", + "module": "Invoice Sync", + "name": "Sales Invoice-custom_payment_method", + "no_copy": 0, + "non_negative": 0, + "options": "cash\ncard", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "print_width": null, + "read_only": 0, + "read_only_depends_on": null, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "sort_options": 0, + "translatable": 0, + "unique": 0, + "width": null + } +] \ No newline at end of file diff --git a/invoice_sync/hooks.py b/invoice_sync/hooks.py index 70c983b..8416f6b 100644 --- a/invoice_sync/hooks.py +++ b/invoice_sync/hooks.py @@ -219,3 +219,4 @@ app_license = "mit" # auth_hooks = [ # "invoice_sync.auth.validate" # ] +fixtures = [ {"dt": "Custom Field","filters": [["module", "=", "Invoice Sync"]] }] diff --git a/invoice_sync/invoice_sync/invoice.py b/invoice_sync/invoice_sync/invoice.py index 295f82c..8bcfe3d 100644 --- a/invoice_sync/invoice_sync/invoice.py +++ b/invoice_sync/invoice_sync/invoice.py @@ -141,7 +141,7 @@ def customer(customer, customer_type, phone, email,is_supplier=False): } - return Response(json.dumps({"data":data}), status=200, mimetype='application/json') + return Response(json.dumps({"data":data}), status=409, mimetype='application/json') else: suplr_already_exist=xhiveframework.get_all("Supplier", fields=["name as id", "supplier_name", "custom_email as email", "custom_mobileno as phone"], @@ -175,7 +175,11 @@ def customer(customer, customer_type, phone, email,is_supplier=False): @xhiveframework.whitelist() def create_invoice(customer_id, supplier_id, payment_method, items): invoice_items = [] + company = xhiveframework.defaults.get_defaults().company + doc=xhiveframework.get_doc("Company",company) + income_account =doc.default_income_account + # return income_account for item in items: item_code = item["item_name"] @@ -187,7 +191,7 @@ def create_invoice(customer_id, supplier_id, payment_method, items): "qty": item.get("quantity", 0), "rate": item.get("rate", 0), "uom": item.get("uom", "Nos"), - "income_account": item.get("income_account", "Sales - erp") + "income_account": item.get("income_account",income_account) } else: invoice_item = {