diff --git a/erpnext/accounts/doctype/coupon_code/__init__.py b/erpnext/accounts/doctype/coupon_code/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/accounts/doctype/coupon_code/coupon_code.js b/erpnext/accounts/doctype/coupon_code/coupon_code.js new file mode 100644 index 0000000000..0bf097f8d5 --- /dev/null +++ b/erpnext/accounts/doctype/coupon_code/coupon_code.js @@ -0,0 +1,35 @@ +// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors +// For license information, please see license.txt + +frappe.ui.form.on('Coupon Code', { + coupon_name:function(frm){ + if (frm.doc.__islocal===1) { + frm.trigger("make_coupon_code"); + } + }, + coupon_type:function(frm){ + if (frm.doc.__islocal===1) { + frm.trigger("make_coupon_code"); + } + }, + make_coupon_code: function(frm) { + var coupon_name=frm.doc.coupon_name; + var coupon_code; + if (frm.doc.coupon_type=='Gift Card') { + coupon_code=Math.random().toString(12).substring(2, 12).toUpperCase(); + } + else if(frm.doc.coupon_type=='Promotional'){ + coupon_name=coupon_name.replace(/\s/g,''); + coupon_code=coupon_name.toUpperCase().slice(0,8); + } + frm.doc.coupon_code=coupon_code; + frm.refresh_field('coupon_code'); + }, + refresh: function(frm) { + if (frm.doc.pricing_rule) { + frm.add_custom_button(__("Add/Edit Coupon Conditions"), function(){ + frappe.set_route("Form", "Pricing Rule", frm.doc.pricing_rule); + }); + } + } +}); diff --git a/erpnext/accounts/doctype/coupon_code/coupon_code.json b/erpnext/accounts/doctype/coupon_code/coupon_code.json new file mode 100644 index 0000000000..fafc63531f --- /dev/null +++ b/erpnext/accounts/doctype/coupon_code/coupon_code.json @@ -0,0 +1,175 @@ +{ + "allow_import": 1, + "autoname": "field:coupon_name", + "creation": "2018-01-22 14:34:39.701832", + "doctype": "DocType", + "document_type": "Other", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "coupon_name", + "coupon_type", + "customer", + "column_break_4", + "coupon_code", + "pricing_rule", + "uses", + "valid_from", + "valid_upto", + "maximum_use", + "used", + "column_break_11", + "description", + "amended_from" + ], + "fields": [ + { + "fieldname": "coupon_name", + "fieldtype": "Data", + "label": "Coupon Name", + "reqd": 1, + "unique": 1 + }, + { + "fieldname": "coupon_type", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Coupon Type", + "options": "Promotional\nGift Card", + "reqd": 1 + }, + { + "depends_on": "eval: doc.coupon_type == \"Gift Card\"", + "fieldname": "customer", + "fieldtype": "Link", + "label": "Customer", + "options": "Customer" + }, + { + "fieldname": "column_break_4", + "fieldtype": "Column Break" + }, + { + "description": "To be used to get discount", + "fieldname": "coupon_code", + "fieldtype": "Data", + "label": "Coupon Code", + "no_copy": 1, + "set_only_once": 1, + "unique": 1 + }, + { + "fieldname": "pricing_rule", + "fieldtype": "Link", + "label": "Pricing Rule", + "options": "Pricing Rule" + }, + { + "fieldname": "uses", + "fieldtype": "Section Break", + "label": "Uses" + }, + { + "fieldname": "valid_from", + "fieldtype": "Date", + "in_list_view": 1, + "label": "Valid From" + }, + { + "fieldname": "valid_upto", + "fieldtype": "Date", + "label": "Valid Upto" + }, + { + "depends_on": "eval: doc.coupon_type == \"Promotional\"", + "fieldname": "maximum_use", + "fieldtype": "Int", + "label": "Maximum Use" + }, + { + "default": "0", + "fieldname": "used", + "fieldtype": "Int", + "label": "Used", + "no_copy": 1, + "read_only": 1 + }, + { + "fieldname": "column_break_11", + "fieldtype": "Column Break" + }, + { + "fieldname": "description", + "fieldtype": "Text Editor", + "label": "Coupon Description" + }, + { + "fieldname": "amended_from", + "fieldtype": "Link", + "label": "Amended From", + "no_copy": 1, + "options": "Coupon Code", + "print_hide": 1, + "read_only": 1 + } + ], + "modified": "2019-10-15 14:12:22.686986", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Coupon Code", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1, + "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts User", + "share": 1, + "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Manager", + "share": 1, + "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Website Manager", + "share": 1, + "write": 1 + } + ], + "sort_field": "modified", + "sort_order": "DESC", + "title_field": "coupon_name", + "track_changes": 1 +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/coupon_code/coupon_code.py b/erpnext/accounts/doctype/coupon_code/coupon_code.py new file mode 100644 index 0000000000..7829c9320d --- /dev/null +++ b/erpnext/accounts/doctype/coupon_code/coupon_code.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors +# For license information, please see license.txt + +from __future__ import unicode_literals +import frappe +from frappe import _ +from frappe.model.document import Document +from frappe.utils import (strip) +class CouponCode(Document): + def autoname(self): + self.coupon_name = strip(self.coupon_name) + self.name = self.coupon_name + + if not self.coupon_code: + if self.coupon_type == "Promotional": + self.coupon_code =''.join([i for i in self.coupon_name if not i.isdigit()])[0:8].upper() + elif self.coupon_type == "Gift Card": + self.coupon_code = frappe.generate_hash()[:10].upper() + + def validate(self): + if self.coupon_type == "Gift Card": + self.maximum_use = 1 + if not self.customer: + frappe.throw(_("Please select the customer.")) diff --git a/erpnext/accounts/doctype/coupon_code/test_coupon_code.js b/erpnext/accounts/doctype/coupon_code/test_coupon_code.js new file mode 100644 index 0000000000..460fedc97f --- /dev/null +++ b/erpnext/accounts/doctype/coupon_code/test_coupon_code.js @@ -0,0 +1,23 @@ +/* eslint-disable */ +// rename this file from _test_[name] to test_[name] to activate +// and remove above this line + +QUnit.test("test: Coupon Code", function (assert) { + let done = assert.async(); + + // number of asserts + assert.expect(1); + + frappe.run_serially([ + // insert a new Coupon Code + () => frappe.tests.make('Coupon Code', [ + // values to be set + {key: 'value'} + ]), + () => { + assert.equal(cur_frm.doc.key, 'value'); + }, + () => done() + ]); + +}); diff --git a/erpnext/accounts/doctype/coupon_code/test_coupon_code.py b/erpnext/accounts/doctype/coupon_code/test_coupon_code.py new file mode 100644 index 0000000000..990b896fde --- /dev/null +++ b/erpnext/accounts/doctype/coupon_code/test_coupon_code.py @@ -0,0 +1,132 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors +# See license.txt +from __future__ import unicode_literals + +import frappe +import unittest +from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order +from erpnext.stock.get_item_details import get_item_details +from frappe.test_runner import make_test_objects + +def test_create_test_data(): + frappe.set_user("Administrator") + # create test item + if not frappe.db.exists("Item","_Test Tesla Car"): + item = frappe.get_doc({ + "description": "_Test Tesla Car", + "doctype": "Item", + "has_batch_no": 0, + "has_serial_no": 0, + "inspection_required": 0, + "is_stock_item": 1, + "opening_stock":100, + "is_sub_contracted_item": 0, + "item_code": "_Test Tesla Car", + "item_group": "_Test Item Group", + "item_name": "_Test Tesla Car", + "apply_warehouse_wise_reorder_level": 0, + "warehouse":"_Test Warehouse - _TC", + "gst_hsn_code": "999800", + "valuation_rate": 5000, + "standard_rate":5000, + "item_defaults": [{ + "company": "_Test Company", + "default_warehouse": "_Test Warehouse - _TC", + "default_price_list":"_Test Price List", + "expense_account": "_Test Account Cost for Goods Sold - _TC", + "buying_cost_center": "_Test Cost Center - _TC", + "selling_cost_center": "_Test Cost Center - _TC", + "income_account": "Sales - _TC" + }], + "show_in_website": 1, + "route":"-test-tesla-car", + "website_warehouse": "_Test Warehouse - _TC" + }) + item.insert() + # create test item price + item_price = frappe.get_list('Item Price', filters={'item_code': '_Test Tesla Car', 'price_list': '_Test Price List'}, fields=['name']) + if len(item_price)==0: + item_price = frappe.get_doc({ + "doctype": "Item Price", + "item_code": "_Test Tesla Car", + "price_list": "_Test Price List", + "price_list_rate": 5000 + }) + item_price.insert() + # create test item pricing rule + if not frappe.db.exists("Pricing Rule","_Test Pricing Rule for _Test Item"): + item_pricing_rule = frappe.get_doc({ + "doctype": "Pricing Rule", + "title": "_Test Pricing Rule for _Test Item", + "apply_on": "Item Code", + "items": [{ + "item_code": "_Test Tesla Car" + }], + "warehouse":"_Test Warehouse - _TC", + "coupon_code_based":1, + "selling": 1, + "rate_or_discount": "Discount Percentage", + "discount_percentage": 30, + "company": "_Test Company", + "currency":"INR", + "for_price_list":"_Test Price List" + }) + item_pricing_rule.insert() + # create test item sales partner + if not frappe.db.exists("Sales Partner","_Test Coupon Partner"): + sales_partner = frappe.get_doc({ + "doctype": "Sales Partner", + "partner_name":"_Test Coupon Partner", + "commission_rate":2, + "referral_code": "COPART" + }) + sales_partner.insert() + # create test item coupon code + if not frappe.db.exists("Coupon Code","SAVE30"): + coupon_code = frappe.get_doc({ + "doctype": "Coupon Code", + "coupon_name":"SAVE30", + "coupon_code":"SAVE30", + "pricing_rule": "_Test Pricing Rule for _Test Item", + "valid_from": "2014-01-01", + "maximum_use":1, + "used":0 + }) + coupon_code.insert() + + +class TestCouponCode(unittest.TestCase): + def setUp(self): + test_create_test_data() + + def tearDown(self): + frappe.set_user("Administrator") + + def test_1_check_coupon_code_used_before_so(self): + coupon_code = frappe.get_doc("Coupon Code", frappe.db.get_value("Coupon Code", {"coupon_name":"SAVE30"})) + # reset used coupon code count + coupon_code.used=0 + coupon_code.save() + # check no coupon code is used before sales order is made + self.assertEqual(coupon_code.get("used"),0) + + def test_2_sales_order_with_coupon_code(self): + so = make_sales_order(customer="_Test Customer",selling_price_list="_Test Price List",item_code="_Test Tesla Car", rate=5000,qty=1, do_not_submit=True) + so = frappe.get_doc('Sales Order', so.name) + # check item price before coupon code is applied + self.assertEqual(so.items[0].rate, 5000) + so.coupon_code='SAVE30' + so.sales_partner='_Test Coupon Partner' + so.save() + # check item price after coupon code is applied + self.assertEqual(so.items[0].rate, 3500) + so.submit() + + def test_3_check_coupon_code_used_after_so(self): + doc = frappe.get_doc("Coupon Code", frappe.db.get_value("Coupon Code", {"coupon_name":"SAVE30"})) + # check no coupon code is used before sales order is made + self.assertEqual(doc.get("used"),1) + + + diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.json b/erpnext/accounts/doctype/pricing_rule/pricing_rule.json index 02102120c8..971d308368 100644 --- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.json +++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.json @@ -1,2627 +1,616 @@ { - "allow_copy": 0, - "allow_events_in_timeline": 0, - "allow_guest_to_view": 0, - "allow_import": 1, - "allow_rename": 1, - "autoname": "field:title", - "beta": 0, - "creation": "2014-02-21 15:02:51", - "custom": 0, - "docstatus": 0, - "doctype": "DocType", - "document_type": "", - "editable_grid": 0, + "allow_import": 1, + "allow_rename": 1, + "autoname": "field:title", + "creation": "2014-02-21 15:02:51", + "doctype": "DocType", + "engine": "InnoDB", + "field_order": [ + "applicability_section", + "title", + "disable", + "apply_on", + "price_or_product_discount", + "warehouse", + "column_break_7", + "items", + "item_groups", + "brands", + "mixed_conditions", + "is_cumulative", + "coupon_code_based", + "section_break_18", + "apply_rule_on_other", + "column_break_17", + "other_item_code", + "other_item_group", + "other_brand", + "section_break_7", + "selling", + "buying", + "column_break_11", + "applicable_for", + "customer", + "customer_group", + "territory", + "sales_partner", + "campaign", + "supplier", + "supplier_group", + "section_break_19", + "min_qty", + "max_qty", + "column_break_21", + "min_amt", + "max_amt", + "section_break_23", + "valid_from", + "valid_upto", + "col_break1", + "company", + "currency", + "margin", + "margin_type", + "column_break_33", + "margin_rate_or_amount", + "price_discount_scheme_section", + "rate_or_discount", + "apply_discount_on", + "col_break2", + "rate", + "discount_amount", + "discount_percentage", + "for_price_list", + "product_discount_scheme_section", + "same_item", + "free_item", + "free_qty", + "column_break_51", + "free_item_uom", + "free_item_rate", + "section_break_13", + "threshold_percentage", + "priority", + "column_break_66", + "apply_multiple_pricing_rules", + "apply_discount_on_rate", + "validate_applied_rule", + "rule_description", + "help_section", + "pricing_rule_help", + "reference_section", + "promotional_scheme_id", + "promotional_scheme" + ], "fields": [ { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "", - "fetch_if_empty": 0, - "fieldname": "applicability_section", - "fieldtype": "Section Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, + "fieldname": "applicability_section", + "fieldtype": "Section Break" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fetch_if_empty": 0, - "fieldname": "title", - "fieldtype": "Data", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Title", - "length": 0, - "no_copy": 1, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 1, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, + "fieldname": "title", + "fieldtype": "Data", + "label": "Title", + "no_copy": 1, + "reqd": 1, "unique": 1 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fetch_if_empty": 0, - "fieldname": "disable", - "fieldtype": "Check", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Disable", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "default": "Item Code", - "fetch_if_empty": 0, - "fieldname": "apply_on", - "fieldtype": "Select", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 1, - "in_standard_filter": 1, - "label": "Apply On", - "length": 0, - "no_copy": 0, - "options": "\nItem Code\nItem Group\nBrand\nTransaction", - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 1, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fetch_if_empty": 0, - "fieldname": "price_or_product_discount", - "fieldtype": "Select", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Price or Product Discount", - "length": 0, - "no_copy": 0, - "options": "Price\nProduct", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 1, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "eval:doc.apply_on != 'Transaction'", - "fetch_if_empty": 0, - "fieldname": "warehouse", - "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Warehouse", - "length": 0, - "no_copy": 0, - "options": "Warehouse", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 1, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fetch_if_empty": 0, - "fieldname": "column_break_7", - "fieldtype": "Column Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "eval:doc.apply_on == 'Item Code'", - "fetch_if_empty": 0, - "fieldname": "items", - "fieldtype": "Table", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Apply Rule On Item Code", - "length": 0, - "no_copy": 0, - "options": "Pricing Rule Item Code", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "eval:doc.apply_on == 'Item Group'", - "fetch_if_empty": 0, - "fieldname": "item_groups", - "fieldtype": "Table", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Apply Rule On Item Group", - "length": 0, - "no_copy": 0, - "options": "Pricing Rule Item Group", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "eval:doc.apply_on == 'Brand'", - "fetch_if_empty": 0, - "fieldname": "brands", - "fieldtype": "Table", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Apply Rule On Brand", - "length": 0, - "no_copy": 0, - "options": "Pricing Rule Brand", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "eval:doc.apply_on != 'Transaction'", - "description": "Conditions will be applied on all the selected items combined. ", - "fetch_if_empty": 0, - "fieldname": "mixed_conditions", - "fieldtype": "Check", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Mixed Conditions", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "", - "fetch_if_empty": 0, - "fieldname": "is_cumulative", - "fieldtype": "Check", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Is Cumulative", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 1, - "columns": 0, - "depends_on": "eval:doc.apply_on != 'Transaction'", - "fetch_if_empty": 0, - "fieldname": "section_break_18", - "fieldtype": "Section Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Discount on Other Item", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fetch_if_empty": 0, - "fieldname": "apply_rule_on_other", - "fieldtype": "Select", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Apply Rule On Other", - "length": 0, - "no_copy": 0, - "options": "\nItem Code\nItem Group\nBrand", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fetch_if_empty": 0, - "fieldname": "column_break_17", - "fieldtype": "Column Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "eval:doc.apply_rule_on_other == 'Item Code'", - "fetch_if_empty": 0, - "fieldname": "other_item_code", - "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Item Code", - "length": 0, - "no_copy": 0, - "options": "Item", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "eval:doc.apply_rule_on_other == 'Item Group'", - "fetch_if_empty": 0, - "fieldname": "other_item_group", - "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Item Group", - "length": 0, - "no_copy": 0, - "options": "Item Group", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "eval:doc.apply_rule_on_other == 'Brand'", - "fetch_if_empty": 0, - "fieldname": "other_brand", - "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Brand", - "length": 0, - "no_copy": 0, - "options": "Brand", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fetch_if_empty": 0, - "fieldname": "section_break_7", - "fieldtype": "Section Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Party Information", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fetch_if_empty": 0, - "fieldname": "selling", - "fieldtype": "Check", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Selling", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fetch_if_empty": 0, - "fieldname": "buying", - "fieldtype": "Check", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Buying", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fetch_if_empty": 0, - "fieldname": "column_break_11", - "fieldtype": "Column Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "eval: doc.buying || doc.selling", - "fetch_if_empty": 0, - "fieldname": "applicable_for", - "fieldtype": "Select", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Applicable For", - "length": 0, - "no_copy": 0, - "options": "\nCustomer\nCustomer Group\nTerritory\nSales Partner\nCampaign\nSupplier\nSupplier Group", - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "eval:doc.applicable_for==\"Customer\"", - "fetch_if_empty": 0, - "fieldname": "customer", - "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Customer", - "length": 0, - "no_copy": 0, - "options": "Customer", - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "eval:doc.applicable_for==\"Customer Group\"", - "fetch_if_empty": 0, - "fieldname": "customer_group", - "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Customer Group", - "length": 0, - "no_copy": 0, - "options": "Customer Group", - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "eval:doc.applicable_for==\"Territory\"", - "fetch_if_empty": 0, - "fieldname": "territory", - "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Territory", - "length": 0, - "no_copy": 0, - "options": "Territory", - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "eval:doc.applicable_for==\"Sales Partner\"", - "fetch_if_empty": 0, - "fieldname": "sales_partner", - "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Sales Partner", - "length": 0, - "no_copy": 0, - "options": "Sales Partner", - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "eval:doc.applicable_for==\"Campaign\"", - "fetch_if_empty": 0, - "fieldname": "campaign", - "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Campaign", - "length": 0, - "no_copy": 0, - "options": "Campaign", - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "eval:doc.applicable_for==\"Supplier\"", - "fetch_if_empty": 0, - "fieldname": "supplier", - "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Supplier", - "length": 0, - "no_copy": 0, - "options": "Supplier", - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "eval:doc.applicable_for==\"Supplier Group\"", - "fetch_if_empty": 0, - "fieldname": "supplier_group", - "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Supplier Group", - "length": 0, - "no_copy": 0, - "options": "Supplier Group", - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "", - "fetch_if_empty": 0, - "fieldname": "section_break_19", - "fieldtype": "Section Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Quantity and Amount", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fetch_if_empty": 0, - "fieldname": "min_qty", - "fieldtype": "Float", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Min Qty", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fetch_if_empty": 0, - "fieldname": "max_qty", - "fieldtype": "Float", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Max Qty", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fetch_if_empty": 0, - "fieldname": "column_break_21", - "fieldtype": "Column Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "default": "0", - "fetch_if_empty": 0, - "fieldname": "min_amt", - "fieldtype": "Currency", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Min Amt", - "length": 0, - "no_copy": 0, - "options": "currency", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "default": "0", - "fetch_if_empty": 0, - "fieldname": "max_amt", - "fieldtype": "Currency", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Max Amt", - "length": 0, - "no_copy": 0, - "options": "currency", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fetch_if_empty": 0, - "fieldname": "section_break_23", - "fieldtype": "Section Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Period Settings", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "default": "Today", - "fetch_if_empty": 0, - "fieldname": "valid_from", - "fieldtype": "Date", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Valid From", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fetch_if_empty": 0, - "fieldname": "valid_upto", - "fieldtype": "Date", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Valid Upto", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fetch_if_empty": 0, - "fieldname": "col_break1", - "fieldtype": "Column Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "length": 0, - "no_copy": 0, - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fetch_if_empty": 0, - "fieldname": "company", - "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Company", - "length": 0, - "no_copy": 0, - "options": "Company", - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 1, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "", - "fetch_if_empty": 0, - "fieldname": "currency", - "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Currency", - "length": 0, - "no_copy": 0, - "options": "Currency", - "permlevel": 0, - "precision": "", - "print_hide": 1, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 1, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "eval: doc.selling == 1", - "fetch_if_empty": 0, - "fieldname": "margin", - "fieldtype": "Section Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Margin", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "default": "Percentage", - "fetch_if_empty": 0, - "fieldname": "margin_type", - "fieldtype": "Select", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Margin Type", - "length": 0, - "no_copy": 0, - "options": "\nPercentage\nAmount", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fetch_if_empty": 0, - "fieldname": "column_break_33", - "fieldtype": "Column Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "default": "0", - "depends_on": "eval:doc.margin_type", - "fetch_if_empty": 0, - "fieldname": "margin_rate_or_amount", - "fieldtype": "Float", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Margin Rate or Amount", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "eval:doc.price_or_product_discount == 'Price'", - "fetch_if_empty": 0, - "fieldname": "price_discount_scheme_section", - "fieldtype": "Section Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Price Discount Scheme", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "default": "Discount Percentage", - "fetch_if_empty": 0, - "fieldname": "rate_or_discount", - "fieldtype": "Select", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Rate or Discount", - "length": 0, - "no_copy": 0, - "options": "\nRate\nDiscount Percentage\nDiscount Amount", - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 1, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "default": "Grand Total", - "depends_on": "eval:doc.apply_on == 'Transaction' && doc.rate_or_discount != 'Rate'", - "fetch_if_empty": 0, - "fieldname": "apply_discount_on", - "fieldtype": "Select", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Apply Discount On", - "length": 0, - "no_copy": 0, - "options": "Grand Total\nNet Total", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "", - "fetch_if_empty": 0, - "fieldname": "col_break2", - "fieldtype": "Column Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "length": 0, - "no_copy": 0, - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "eval:doc.rate_or_discount==\"Rate\"", - "fetch_if_empty": 0, - "fieldname": "rate", - "fieldtype": "Currency", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Rate", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "default": "0", - "depends_on": "eval:doc.rate_or_discount==\"Discount Amount\"", - "fetch_if_empty": 0, - "fieldname": "discount_amount", - "fieldtype": "Currency", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Discount Amount", - "length": 0, - "no_copy": 0, - "options": "currency", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "eval:doc.rate_or_discount==\"Discount Percentage\"", - "fetch_if_empty": 0, - "fieldname": "discount_percentage", - "fieldtype": "Float", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Discount Percentage", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "eval:doc.rate_or_discount==\"Discount Percentage\"", - "fetch_if_empty": 0, - "fieldname": "for_price_list", - "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "For Price List", - "length": 0, - "no_copy": 0, - "options": "Price List", - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "eval:doc.price_or_product_discount == 'Product'", - "fetch_if_empty": 0, - "fieldname": "product_discount_scheme_section", - "fieldtype": "Section Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Product Discount Scheme", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "eval:!doc.mixed_conditions", - "fetch_if_empty": 0, - "fieldname": "same_item", - "fieldtype": "Check", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Same Item", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "eval:!doc.same_item || doc.mixed_conditions", - "fetch_if_empty": 0, - "fieldname": "free_item", - "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Free Item", - "length": 0, - "no_copy": 0, - "options": "Item", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fetch_if_empty": 0, - "fieldname": "free_qty", - "fieldtype": "Float", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Qty", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fetch_if_empty": 0, - "fieldname": "column_break_51", - "fieldtype": "Column Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fetch_if_empty": 0, - "fieldname": "free_item_uom", - "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "UOM", - "length": 0, - "no_copy": 0, - "options": "UOM", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fetch_if_empty": 0, - "fieldname": "free_item_rate", - "fieldtype": "Currency", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Rate", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 1, - "columns": 0, - "depends_on": "", - "fetch_if_empty": 0, - "fieldname": "section_break_13", - "fieldtype": "Section Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Advanced Settings", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "description": "System will notify to increase or decrease quantity or amount ", - "fetch_if_empty": 0, - "fieldname": "threshold_percentage", - "fieldtype": "Percent", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Threshold for Suggestion", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "description": "Higher the number, higher the priority", - "fetch_if_empty": 0, - "fieldname": "priority", - "fieldtype": "Select", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Priority", - "length": 0, - "no_copy": 0, - "options": "\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20", - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fetch_if_empty": 0, - "fieldname": "column_break_66", - "fieldtype": "Column Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fetch_if_empty": 0, - "fieldname": "apply_multiple_pricing_rules", - "fieldtype": "Check", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Apply Multiple Pricing Rules", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "eval:in_list(['Discount Percentage', 'Discount Amount'], doc.rate_or_discount) && doc.apply_multiple_pricing_rules", - "fetch_if_empty": 0, - "fieldname": "apply_discount_on_rate", - "fieldtype": "Check", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Apply Discount on Rate", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "eval:doc.price_or_product_discount == 'Price'", - "description": "", - "fetch_if_empty": 0, - "fieldname": "validate_applied_rule", - "fieldtype": "Check", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Validate Applied Rule", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "validate_applied_rule", - "fetch_if_empty": 0, - "fieldname": "rule_description", - "fieldtype": "Small Text", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Rule Description", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fetch_if_empty": 0, - "fieldname": "help_section", - "fieldtype": "Section Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "", - "length": 0, - "no_copy": 0, - "options": "Simple", - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fetch_if_empty": 0, - "fieldname": "pricing_rule_help", - "fieldtype": "HTML", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Pricing Rule Help", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fetch_if_empty": 0, - "fieldname": "reference_section", - "fieldtype": "Section Break", - "hidden": 1, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Reference", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fetch_if_empty": 0, - "fieldname": "promotional_scheme_id", - "fieldtype": "Data", - "hidden": 1, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Promotional Scheme Id", - "length": 0, - "no_copy": 1, - "permlevel": 0, - "precision": "", - "print_hide": 1, - "print_hide_if_no_value": 0, - "read_only": 1, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fetch_if_empty": 0, - "fieldname": "promotional_scheme", - "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Promotional Scheme", - "length": 0, - "no_copy": 0, - "options": "Promotional Scheme", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + }, + { + "default": "0", + "fieldname": "disable", + "fieldtype": "Check", + "label": "Disable" + }, + { + "default": "Item Code", + "fieldname": "apply_on", + "fieldtype": "Select", + "in_list_view": 1, + "in_standard_filter": 1, + "label": "Apply On", + "options": "\nItem Code\nItem Group\nBrand\nTransaction", + "reqd": 1 + }, + { + "fieldname": "price_or_product_discount", + "fieldtype": "Select", + "label": "Price or Product Discount", + "options": "Price\nProduct", + "reqd": 1 + }, + { + "depends_on": "eval:doc.apply_on != 'Transaction'", + "fieldname": "warehouse", + "fieldtype": "Link", + "label": "Warehouse", + "options": "Warehouse", + "search_index": 1 + }, + { + "fieldname": "column_break_7", + "fieldtype": "Column Break" + }, + { + "depends_on": "eval:doc.apply_on == 'Item Code'", + "fieldname": "items", + "fieldtype": "Table", + "label": "Apply Rule On Item Code", + "options": "Pricing Rule Item Code" + }, + { + "depends_on": "eval:doc.apply_on == 'Item Group'", + "fieldname": "item_groups", + "fieldtype": "Table", + "label": "Apply Rule On Item Group", + "options": "Pricing Rule Item Group" + }, + { + "depends_on": "eval:doc.apply_on == 'Brand'", + "fieldname": "brands", + "fieldtype": "Table", + "label": "Apply Rule On Brand", + "options": "Pricing Rule Brand" + }, + { + "default": "0", + "depends_on": "eval:doc.apply_on != 'Transaction'", + "description": "Conditions will be applied on all the selected items combined. ", + "fieldname": "mixed_conditions", + "fieldtype": "Check", + "label": "Mixed Conditions" + }, + { + "default": "0", + "fieldname": "is_cumulative", + "fieldtype": "Check", + "label": "Is Cumulative" + }, + { + "default": "0", + "fieldname": "coupon_code_based", + "fieldtype": "Check", + "label": "Coupon Code Based" + }, + { + "collapsible": 1, + "depends_on": "eval:doc.apply_on != 'Transaction'", + "fieldname": "section_break_18", + "fieldtype": "Section Break", + "label": "Discount on Other Item" + }, + { + "fieldname": "apply_rule_on_other", + "fieldtype": "Select", + "label": "Apply Rule On Other", + "options": "\nItem Code\nItem Group\nBrand" + }, + { + "fieldname": "column_break_17", + "fieldtype": "Column Break" + }, + { + "depends_on": "eval:doc.apply_rule_on_other == 'Item Code'", + "fieldname": "other_item_code", + "fieldtype": "Link", + "label": "Item Code", + "options": "Item" + }, + { + "depends_on": "eval:doc.apply_rule_on_other == 'Item Group'", + "fieldname": "other_item_group", + "fieldtype": "Link", + "label": "Item Group", + "options": "Item Group" + }, + { + "depends_on": "eval:doc.apply_rule_on_other == 'Brand'", + "fieldname": "other_brand", + "fieldtype": "Link", + "label": "Brand", + "options": "Brand" + }, + { + "fieldname": "section_break_7", + "fieldtype": "Section Break", + "label": "Party Information" + }, + { + "default": "0", + "fieldname": "selling", + "fieldtype": "Check", + "label": "Selling" + }, + { + "default": "0", + "fieldname": "buying", + "fieldtype": "Check", + "label": "Buying" + }, + { + "fieldname": "column_break_11", + "fieldtype": "Column Break" + }, + { + "depends_on": "eval: doc.buying || doc.selling", + "fieldname": "applicable_for", + "fieldtype": "Select", + "label": "Applicable For", + "options": "\nCustomer\nCustomer Group\nTerritory\nSales Partner\nCampaign\nSupplier\nSupplier Group" + }, + { + "depends_on": "eval:doc.applicable_for==\"Customer\"", + "fieldname": "customer", + "fieldtype": "Link", + "label": "Customer", + "options": "Customer" + }, + { + "depends_on": "eval:doc.applicable_for==\"Customer Group\"", + "fieldname": "customer_group", + "fieldtype": "Link", + "label": "Customer Group", + "options": "Customer Group" + }, + { + "depends_on": "eval:doc.applicable_for==\"Territory\"", + "fieldname": "territory", + "fieldtype": "Link", + "label": "Territory", + "options": "Territory" + }, + { + "depends_on": "eval:doc.applicable_for==\"Sales Partner\"", + "fieldname": "sales_partner", + "fieldtype": "Link", + "label": "Sales Partner", + "options": "Sales Partner" + }, + { + "depends_on": "eval:doc.applicable_for==\"Campaign\"", + "fieldname": "campaign", + "fieldtype": "Link", + "label": "Campaign", + "options": "Campaign" + }, + { + "depends_on": "eval:doc.applicable_for==\"Supplier\"", + "fieldname": "supplier", + "fieldtype": "Link", + "label": "Supplier", + "options": "Supplier" + }, + { + "depends_on": "eval:doc.applicable_for==\"Supplier Group\"", + "fieldname": "supplier_group", + "fieldtype": "Link", + "label": "Supplier Group", + "options": "Supplier Group" + }, + { + "fieldname": "section_break_19", + "fieldtype": "Section Break", + "label": "Quantity and Amount" + }, + { + "fieldname": "min_qty", + "fieldtype": "Float", + "label": "Min Qty" + }, + { + "fieldname": "max_qty", + "fieldtype": "Float", + "label": "Max Qty" + }, + { + "fieldname": "column_break_21", + "fieldtype": "Column Break" + }, + { + "default": "0", + "fieldname": "min_amt", + "fieldtype": "Currency", + "label": "Min Amt", + "options": "currency" + }, + { + "default": "0", + "fieldname": "max_amt", + "fieldtype": "Currency", + "label": "Max Amt", + "options": "currency" + }, + { + "fieldname": "section_break_23", + "fieldtype": "Section Break", + "label": "Period Settings" + }, + { + "default": "Today", + "fieldname": "valid_from", + "fieldtype": "Date", + "label": "Valid From" + }, + { + "fieldname": "valid_upto", + "fieldtype": "Date", + "label": "Valid Upto" + }, + { + "fieldname": "col_break1", + "fieldtype": "Column Break" + }, + { + "fieldname": "company", + "fieldtype": "Link", + "label": "Company", + "options": "Company", + "remember_last_selected_value": 1 + }, + { + "fieldname": "currency", + "fieldtype": "Link", + "label": "Currency", + "options": "Currency", + "print_hide": 1, + "reqd": 1 + }, + { + "depends_on": "eval: doc.selling == 1", + "fieldname": "margin", + "fieldtype": "Section Break", + "label": "Margin" + }, + { + "default": "Percentage", + "fieldname": "margin_type", + "fieldtype": "Select", + "label": "Margin Type", + "options": "\nPercentage\nAmount" + }, + { + "fieldname": "column_break_33", + "fieldtype": "Column Break" + }, + { + "default": "0", + "depends_on": "eval:doc.margin_type", + "fieldname": "margin_rate_or_amount", + "fieldtype": "Float", + "label": "Margin Rate or Amount" + }, + { + "depends_on": "eval:doc.price_or_product_discount == 'Price'", + "fieldname": "price_discount_scheme_section", + "fieldtype": "Section Break", + "label": "Price Discount Scheme" + }, + { + "default": "Discount Percentage", + "fieldname": "rate_or_discount", + "fieldtype": "Select", + "label": "Rate or Discount", + "options": "\nRate\nDiscount Percentage\nDiscount Amount", + "reqd": 1 + }, + { + "default": "Grand Total", + "depends_on": "eval:doc.apply_on == 'Transaction' && doc.rate_or_discount != 'Rate'", + "fieldname": "apply_discount_on", + "fieldtype": "Select", + "label": "Apply Discount On", + "options": "Grand Total\nNet Total" + }, + { + "fieldname": "col_break2", + "fieldtype": "Column Break" + }, + { + "depends_on": "eval:doc.rate_or_discount==\"Rate\"", + "fieldname": "rate", + "fieldtype": "Currency", + "label": "Rate" + }, + { + "default": "0", + "depends_on": "eval:doc.rate_or_discount==\"Discount Amount\"", + "fieldname": "discount_amount", + "fieldtype": "Currency", + "label": "Discount Amount", + "options": "currency" + }, + { + "depends_on": "eval:doc.rate_or_discount==\"Discount Percentage\"", + "fieldname": "discount_percentage", + "fieldtype": "Float", + "label": "Discount Percentage" + }, + { + "depends_on": "eval:doc.rate_or_discount!=\"Rate\"", + "fieldname": "for_price_list", + "fieldtype": "Link", + "label": "For Price List", + "options": "Price List" + }, + { + "depends_on": "eval:doc.price_or_product_discount == 'Product'", + "fieldname": "product_discount_scheme_section", + "fieldtype": "Section Break", + "label": "Product Discount Scheme" + }, + { + "default": "0", + "depends_on": "eval:!doc.mixed_conditions", + "fieldname": "same_item", + "fieldtype": "Check", + "label": "Same Item" + }, + { + "depends_on": "eval:!doc.same_item || doc.mixed_conditions", + "fieldname": "free_item", + "fieldtype": "Link", + "label": "Free Item", + "options": "Item" + }, + { + "fieldname": "free_qty", + "fieldtype": "Float", + "label": "Qty" + }, + { + "fieldname": "column_break_51", + "fieldtype": "Column Break" + }, + { + "fieldname": "free_item_uom", + "fieldtype": "Link", + "label": "UOM", + "options": "UOM" + }, + { + "fieldname": "free_item_rate", + "fieldtype": "Currency", + "label": "Rate" + }, + { + "collapsible": 1, + "fieldname": "section_break_13", + "fieldtype": "Section Break", + "label": "Advanced Settings" + }, + { + "description": "System will notify to increase or decrease quantity or amount ", + "fieldname": "threshold_percentage", + "fieldtype": "Percent", + "label": "Threshold for Suggestion" + }, + { + "description": "Higher the number, higher the priority", + "fieldname": "priority", + "fieldtype": "Select", + "label": "Priority", + "options": "\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20" + }, + { + "fieldname": "column_break_66", + "fieldtype": "Column Break" + }, + { + "default": "0", + "fieldname": "apply_multiple_pricing_rules", + "fieldtype": "Check", + "label": "Apply Multiple Pricing Rules" + }, + { + "default": "0", + "depends_on": "eval:in_list(['Discount Percentage', 'Discount Amount'], doc.rate_or_discount) && doc.apply_multiple_pricing_rules", + "fieldname": "apply_discount_on_rate", + "fieldtype": "Check", + "label": "Apply Discount on Rate" + }, + { + "default": "0", + "depends_on": "eval:doc.price_or_product_discount == 'Price'", + "fieldname": "validate_applied_rule", + "fieldtype": "Check", + "label": "Validate Applied Rule" + }, + { + "depends_on": "validate_applied_rule", + "fieldname": "rule_description", + "fieldtype": "Small Text", + "label": "Rule Description" + }, + { + "fieldname": "help_section", + "fieldtype": "Section Break", + "options": "Simple" + }, + { + "fieldname": "pricing_rule_help", + "fieldtype": "HTML", + "label": "Pricing Rule Help" + }, + { + "fieldname": "reference_section", + "fieldtype": "Section Break", + "hidden": 1, + "label": "Reference" + }, + { + "fieldname": "promotional_scheme_id", + "fieldtype": "Data", + "hidden": 1, + "label": "Promotional Scheme Id", + "no_copy": 1, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "promotional_scheme", + "fieldtype": "Link", + "label": "Promotional Scheme", + "options": "Promotional Scheme" } - ], - "has_web_view": 0, - "hide_heading": 0, - "hide_toolbar": 0, - "icon": "fa fa-gift", - "idx": 1, - "image_view": 0, - "in_create": 0, - "is_submittable": 0, - "issingle": 0, - "istable": 0, - "max_attachments": 0, - "modified": "2019-03-25 13:20:11.773190", - "modified_by": "Administrator", - "module": "Accounts", - "name": "Pricing Rule", - "owner": "Administrator", + ], + "icon": "fa fa-gift", + "idx": 1, + "modified": "2019-10-15 12:39:40.399792", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Pricing Rule", + "owner": "Administrator", "permissions": [ { - "amend": 0, - "cancel": 0, - "create": 1, - "delete": 1, - "email": 0, - "export": 1, - "if_owner": 0, - "import": 1, - "permlevel": 0, - "print": 0, - "read": 1, - "report": 1, - "role": "Accounts Manager", - "set_user_permissions": 0, - "share": 1, - "submit": 0, + "create": 1, + "delete": 1, + "export": 1, + "import": 1, + "read": 1, + "report": 1, + "role": "Accounts Manager", + "share": 1, "write": 1 - }, + }, { - "amend": 0, - "cancel": 0, - "create": 1, - "delete": 1, - "email": 0, - "export": 0, - "if_owner": 0, - "import": 0, - "permlevel": 0, - "print": 0, - "read": 1, - "report": 1, - "role": "Sales Manager", - "set_user_permissions": 0, - "share": 1, - "submit": 0, + "create": 1, + "delete": 1, + "read": 1, + "report": 1, + "role": "Sales Manager", + "share": 1, "write": 1 - }, + }, { - "amend": 0, - "cancel": 0, - "create": 1, - "delete": 1, - "email": 0, - "export": 0, - "if_owner": 0, - "import": 0, - "permlevel": 0, - "print": 0, - "read": 1, - "report": 1, - "role": "Purchase Manager", - "set_user_permissions": 0, - "share": 1, - "submit": 0, + "create": 1, + "delete": 1, + "read": 1, + "report": 1, + "role": "Purchase Manager", + "share": 1, "write": 1 - }, + }, { - "amend": 0, - "cancel": 0, - "create": 1, - "delete": 1, - "email": 0, - "export": 0, - "if_owner": 0, - "import": 0, - "permlevel": 0, - "print": 0, - "read": 1, - "report": 1, - "role": "Website Manager", - "set_user_permissions": 0, - "share": 1, - "submit": 0, + "create": 1, + "delete": 1, + "read": 1, + "report": 1, + "role": "Website Manager", + "share": 1, "write": 1 - }, + }, { - "amend": 0, - "cancel": 0, - "create": 1, - "delete": 1, - "email": 0, - "export": 1, - "if_owner": 0, - "import": 1, - "permlevel": 0, - "print": 0, - "read": 1, - "report": 1, - "role": "System Manager", - "set_user_permissions": 0, - "share": 1, - "submit": 0, + "create": 1, + "delete": 1, + "export": 1, + "import": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1, "write": 1 } - ], - "quick_entry": 0, - "read_only": 0, - "read_only_onload": 0, - "show_name_in_global_search": 1, - "sort_field": "modified", - "sort_order": "DESC", - "title_field": "", - "track_changes": 0, - "track_seen": 0, - "track_views": 0 + ], + "show_name_in_global_search": 1, + "sort_field": "modified", + "sort_order": "DESC" } \ No newline at end of file diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py index a94d127f62..17762755f4 100644 --- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py +++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py @@ -249,6 +249,9 @@ def get_pricing_rule_for_item(args, price_list_rate=0, doc=None): if pricing_rule.mixed_conditions or pricing_rule.apply_rule_on_other: continue + if pricing_rule.coupon_code_based==1 and args.coupon_code==None: + return item_details + if (not pricing_rule.validate_applied_rule and pricing_rule.price_or_product_discount == "Price"): apply_price_discount_pricing_rule(pricing_rule, item_details, args) diff --git a/erpnext/accounts/doctype/pricing_rule/utils.py b/erpnext/accounts/doctype/pricing_rule/utils.py index bbabac4302..ef26c2e7bf 100644 --- a/erpnext/accounts/doctype/pricing_rule/utils.py +++ b/erpnext/accounts/doctype/pricing_rule/utils.py @@ -531,4 +531,32 @@ def validate_pricing_rule_for_different_cond(doc): for d in doc.get("items"): validate_pricing_rule_on_items(doc, d, True) - return doc \ No newline at end of file + return doc + +def validate_coupon_code(coupon_name): + from frappe.utils import today,getdate + coupon=frappe.get_doc("Coupon Code",coupon_name) + if coupon.valid_from: + if coupon.valid_from > getdate(today()) : + frappe.throw(_("Sorry,coupon code validity has not started")) + elif coupon.valid_upto: + if coupon.valid_upto < getdate(today()) : + frappe.throw(_("Sorry,coupon code validity has expired")) + elif coupon.used>=coupon.maximum_use: + frappe.throw(_("Sorry,coupon code are exhausted")) + else: + return + +def update_coupon_code_count(coupon_name,transaction_type): + coupon=frappe.get_doc("Coupon Code",coupon_name) + if coupon: + if transaction_type=='used': + if coupon.used0: + coupon.used=coupon.used-1 + coupon.save(ignore_permissions=True) \ No newline at end of file diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py index 20f8737f54..59936d5116 100644 --- a/erpnext/accounts/party.py +++ b/erpnext/accounts/party.py @@ -12,7 +12,7 @@ from frappe.utils import (add_days, getdate, formatdate, date_diff, from frappe.contacts.doctype.address.address import (get_address_display, get_default_address, get_company_address) from frappe.contacts.doctype.contact.contact import get_contact_details, get_default_contact -from erpnext.exceptions import PartyFrozen, InvalidAccountCurrency +from erpnext.exceptions import PartyFrozen, PartyDisabled, InvalidAccountCurrency from erpnext.accounts.utils import get_fiscal_year from erpnext import get_company_currency @@ -446,7 +446,9 @@ def validate_party_frozen_disabled(party_type, party_name): if party_type and party_name: if party_type in ("Customer", "Supplier"): party = frappe.get_cached_value(party_type, party_name, ["is_frozen", "disabled"], as_dict=True) - if party.get("is_frozen"): + if party.disabled: + frappe.throw(_("{0} {1} is disabled").format(party_type, party_name), PartyDisabled) + elif party.get("is_frozen"): frozen_accounts_modifier = frappe.db.get_single_value( 'Accounts Settings', 'frozen_accounts_modifier') if not frozen_accounts_modifier in frappe.get_roles(): frappe.throw(_("{0} {1} is frozen").format(party_type, party_name), PartyFrozen) diff --git a/erpnext/buying/doctype/supplier/test_supplier.py b/erpnext/buying/doctype/supplier/test_supplier.py index 227a3dfee8..a377ec90f8 100644 --- a/erpnext/buying/doctype/supplier/test_supplier.py +++ b/erpnext/buying/doctype/supplier/test_supplier.py @@ -5,6 +5,7 @@ from __future__ import unicode_literals import frappe, unittest from erpnext.accounts.party import get_due_date +from erpnext.exceptions import PartyDisabled from frappe.test_runner import make_test_records test_dependencies = ['Payment Term', 'Payment Terms Template'] @@ -70,7 +71,7 @@ class TestSupplier(unittest.TestCase): po = create_purchase_order(do_not_save=True) - self.assertRaises(frappe.ValidationError, po.save) + self.assertRaises(PartyDisabled, po.save) frappe.db.set_value("Supplier", "_Test Supplier", "disabled", 0) diff --git a/erpnext/exceptions.py b/erpnext/exceptions.py index fb3a5cb55d..d92af5d722 100644 --- a/erpnext/exceptions.py +++ b/erpnext/exceptions.py @@ -5,3 +5,4 @@ import frappe class PartyFrozen(frappe.ValidationError): pass class InvalidAccountCurrency(frappe.ValidationError): pass class InvalidCurrency(frappe.ValidationError): pass +class PartyDisabled(frappe.ValidationError):pass diff --git a/erpnext/healthcare/page/patient_history/patient_history.js b/erpnext/healthcare/page/patient_history/patient_history.js index 87fe7edd29..fe5b7bc488 100644 --- a/erpnext/healthcare/page/patient_history/patient_history.js +++ b/erpnext/healthcare/page/patient_history/patient_history.js @@ -234,7 +234,7 @@ var show_patient_vital_charts = function(patient, me, btn_show_id, pts, title) { Temperature\ BMI"; + data-pts='' data-title='BMI'>BMI"; me.page.main.find(".show_chart_btns").html(show_chart_btns_html); var data = r.message; let labels = [], datasets = []; @@ -275,7 +275,7 @@ var show_patient_vital_charts = function(patient, me, btn_show_id, pts, title) { datasets.push({name: "Heart Rate / Pulse", values: pulse, chartType:'line'}); datasets.push({name: "Respiratory Rate", values: respiratory_rate, chartType:'line'}); } - new Chart( ".patient_vital_charts", { + new frappe.Chart( ".patient_vital_charts", { data: { labels: labels, datasets: datasets @@ -283,7 +283,7 @@ var show_patient_vital_charts = function(patient, me, btn_show_id, pts, title) { title: title, type: 'axis-mixed', // 'axis-mixed', 'bar', 'line', 'pie', 'percentage' - height: 150, + height: 200, colors: ['purple', '#ffa3ef', 'light-blue'], tooltipOptions: { diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index a9b19eddd7..5a2f3bc9b8 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -1233,7 +1233,8 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ "is_return": cint(me.frm.doc.is_return), "update_stock": in_list(['Sales Invoice', 'Purchase Invoice'], me.frm.doc.doctype) ? cint(me.frm.doc.update_stock) : 0, "conversion_factor": me.frm.doc.conversion_factor, - "pos_profile": me.frm.doc.doctype == 'Sales Invoice' ? me.frm.doc.pos_profile : '' + "pos_profile": me.frm.doc.doctype == 'Sales Invoice' ? me.frm.doc.pos_profile : '', + "coupon_code": me.frm.doc.coupon_code }; }, @@ -1742,6 +1743,15 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ frappe.model.set_value(me.frm.doctype + " Item", item.name, "warehouse", me.frm.doc.set_warehouse); }); } + }, + coupon_code: function() { + var me = this; + frappe.run_serially([ + () => this.frm.doc.ignore_pricing_rule=1, + () => me.ignore_pricing_rule(), + () => this.frm.doc.ignore_pricing_rule=0, + () => me.apply_pricing_rule() + ]); } }); diff --git a/erpnext/public/js/shopping_cart.js b/erpnext/public/js/shopping_cart.js index 5a0526814f..44a8cd0067 100644 --- a/erpnext/public/js/shopping_cart.js +++ b/erpnext/public/js/shopping_cart.js @@ -5,6 +5,19 @@ frappe.provide("erpnext.shopping_cart"); var shopping_cart = erpnext.shopping_cart; +var getParams = function (url) { + var params = []; + var parser = document.createElement('a'); + parser.href = url; + var query = parser.search.substring(1); + var vars = query.split('&'); + for (var i = 0; i < vars.length; i++) { + var pair = vars[i].split('='); + params[pair[0]] = decodeURIComponent(pair[1]); + } + return params; +}; + frappe.ready(function() { var full_name = frappe.session && frappe.session.user_fullname; // update user @@ -12,7 +25,32 @@ frappe.ready(function() { $('.navbar li[data-label="User"] a') .html(' ' + full_name); } + // set coupon code and sales partner code + var url_args = getParams(window.location.href); + + var referral_coupon_code = url_args['cc']; + var referral_sales_partner = url_args['sp']; + + var d = new Date(); + // expires within 30 minutes + d.setTime(d.getTime() + (0.02 * 24 * 60 * 60 * 1000)); + var expires = "expires="+d.toUTCString(); + if (referral_coupon_code) { + document.cookie = "referral_coupon_code=" + referral_coupon_code + ";" + expires + ";path=/"; + } + if (referral_sales_partner) { + document.cookie = "referral_sales_partner=" + referral_sales_partner + ";" + expires + ";path=/"; + } + referral_coupon_code=frappe.get_cookie("referral_coupon_code"); + referral_sales_partner=frappe.get_cookie("referral_sales_partner"); + + if (referral_coupon_code && $(".tot_quotation_discount").val()==undefined ) { + $(".txtcoupon").val(referral_coupon_code); + } + if (referral_sales_partner) { + $(".txtreferral_sales_partner").val(referral_sales_partner); + } // update login shopping_cart.show_shoppingcart_dropdown(); shopping_cart.set_cart_count(); diff --git a/erpnext/regional/doctype/datev_settings/__init__.py b/erpnext/regional/doctype/datev_settings/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/regional/doctype/datev_settings/datev_settings.js b/erpnext/regional/doctype/datev_settings/datev_settings.js new file mode 100644 index 0000000000..69747b0b89 --- /dev/null +++ b/erpnext/regional/doctype/datev_settings/datev_settings.js @@ -0,0 +1,8 @@ +// Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors +// For license information, please see license.txt + +frappe.ui.form.on('DATEV Settings', { + // refresh: function(frm) { + + // } +}); diff --git a/erpnext/regional/doctype/datev_settings/datev_settings.json b/erpnext/regional/doctype/datev_settings/datev_settings.json new file mode 100644 index 0000000000..6860ed3fda --- /dev/null +++ b/erpnext/regional/doctype/datev_settings/datev_settings.json @@ -0,0 +1,105 @@ +{ + "autoname": "field:client", + "creation": "2019-08-13 23:56:34.259906", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "client", + "column_break_2", + "client_number", + "section_break_4", + "consultant", + "column_break_6", + "consultant_number" + ], + "fields": [ + { + "fieldname": "client", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Client", + "options": "Company", + "reqd": 1, + "unique": 1 + }, + { + "fieldname": "client_number", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Client ID", + "reqd": 1 + }, + { + "fieldname": "consultant", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Consultant", + "options": "Supplier" + }, + { + "fieldname": "consultant_number", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Consultant ID", + "reqd": 1 + }, + { + "fieldname": "column_break_2", + "fieldtype": "Column Break" + }, + { + "fieldname": "section_break_4", + "fieldtype": "Section Break" + }, + { + "fieldname": "column_break_6", + "fieldtype": "Column Break" + } + ], + "modified": "2019-08-14 00:03:26.616460", + "modified_by": "Administrator", + "module": "Regional", + "name": "DATEV Settings", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1, + "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts Manager", + "share": 1, + "write": 1 + }, + { + "create": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts User", + "share": 1 + } + ], + "quick_entry": 1, + "sort_field": "modified", + "sort_order": "DESC", + "track_changes": 1 +} \ No newline at end of file diff --git a/erpnext/regional/doctype/datev_settings/datev_settings.py b/erpnext/regional/doctype/datev_settings/datev_settings.py new file mode 100644 index 0000000000..cff5bba58f --- /dev/null +++ b/erpnext/regional/doctype/datev_settings/datev_settings.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors +# For license information, please see license.txt + +from __future__ import unicode_literals +# import frappe +from frappe.model.document import Document + +class DATEVSettings(Document): + pass diff --git a/erpnext/regional/doctype/datev_settings/test_datev_settings.py b/erpnext/regional/doctype/datev_settings/test_datev_settings.py new file mode 100644 index 0000000000..0271329f4d --- /dev/null +++ b/erpnext/regional/doctype/datev_settings/test_datev_settings.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and Contributors +# See license.txt +from __future__ import unicode_literals + +# import frappe +import unittest + +class TestDATEVSettings(unittest.TestCase): + pass diff --git a/erpnext/regional/report/datev/datev.py b/erpnext/regional/report/datev/datev.py index 50aed084ab..ee8735fb1f 100644 --- a/erpnext/regional/report/datev/datev.py +++ b/erpnext/regional/report/datev/datev.py @@ -8,6 +8,7 @@ Provide a report and downloadable CSV according to the German DATEV format. all required columns. Used to import the data into the DATEV Software. """ from __future__ import unicode_literals +import datetime import json from six import string_types import frappe @@ -17,24 +18,28 @@ import pandas as pd def execute(filters=None): """Entry point for frappe.""" - validate_filters(filters) + validate(filters) result = get_gl_entries(filters, as_dict=0) columns = get_columns() return columns, result -def validate_filters(filters): - """Make sure all mandatory filters are present.""" +def validate(filters): + """Make sure all mandatory filters and settings are present.""" if not filters.get('company'): - frappe.throw(_('{0} is mandatory').format(_('Company'))) + frappe.throw(_('Company is a mandatory filter.')) if not filters.get('from_date'): - frappe.throw(_('{0} is mandatory').format(_('From Date'))) + frappe.throw(_('From Date is a mandatory filter.')) if not filters.get('to_date'): - frappe.throw(_('{0} is mandatory').format(_('To Date'))) + frappe.throw(_('To Date is a mandatory filter.')) + try: + frappe.get_doc('DATEV Settings', filters.get('company')) + except frappe.DoesNotExistError: + frappe.throw(_('Please create DATEV Settings for Company {}.').format(filters.get('company'))) def get_columns(): """Return the list of columns that will be shown in query report.""" @@ -158,13 +163,84 @@ def get_gl_entries(filters, as_dict): return gl_entries -def get_datev_csv(data): +def get_datev_csv(data, filters): """ Fill in missing columns and return a CSV in DATEV Format. + For automatic processing, DATEV requires the first line of the CSV file to + hold meta data such as the length of account numbers oder the category of + the data. + Arguments: data -- array of dictionaries + filters -- dict """ + header = [ + # A = DATEV format + # DTVF = created by DATEV software, + # EXTF = created by other software + "EXTF", + # B = version of the DATEV format + # 141 = 1.41, + # 510 = 5.10, + # 720 = 7.20 + "510", + # C = Data category + # 21 = Transaction batch (Buchungsstapel), + # 67 = Buchungstextkonstanten, + # 16 = Debitors/Creditors, + # 20 = Account names (Kontenbeschriftungen) + "21", + # D = Format name + # Buchungsstapel, + # Buchungstextkonstanten, + # Debitoren/Kreditoren, + # Kontenbeschriftungen + "Buchungsstapel", + # E = Format version (regarding format name) + "", + # F = Generated on + datetime.datetime.now().strftime("%Y%m%d"), + # G = Imported on -- stays empty + "", + # H = Origin (SV = other (?), RE = KARE) + "SV", + # I = Exported by + frappe.session.user, + # J = Imported by -- stays empty + "", + # K = Tax consultant number (Beraternummer) + frappe.get_value("DATEV Settings", filters.get("company"), "consultant_number") or "", + "", + # L = Tax client number (Mandantennummer) + frappe.get_value("DATEV Settings", filters.get("company"), "client_number") or "", + "", + # M = Start of the fiscal year (Wirtschaftsjahresbeginn) + frappe.utils.formatdate(frappe.defaults.get_user_default("year_start_date"), "yyyyMMdd"), + # N = Length of account numbers (Sachkontenlänge) + "4", + # O = Transaction batch start date (YYYYMMDD) + frappe.utils.formatdate(filters.get('from_date'), "yyyyMMdd"), + # P = Transaction batch end date (YYYYMMDD) + frappe.utils.formatdate(filters.get('to_date'), "yyyyMMdd"), + # Q = Description (for example, "January - February 2019 Transactions") + "{} - {} Buchungsstapel".format( + frappe.utils.formatdate(filters.get('from_date'), "MMMM yyyy"), + frappe.utils.formatdate(filters.get('to_date'), "MMMM yyyy") + ), + # R = Diktatkürzel + "", + # S = Buchungstyp + # 1 = Transaction batch (Buchungsstapel), + # 2 = Annual financial statement (Jahresabschluss) + "1", + # T = Rechnungslegungszweck + "", + # U = Festschreibung + "", + # V = Kontoführungs-Währungskennzeichen des Geldkontos + frappe.get_value("Company", filters.get("company"), "default_currency") + ] columns = [ # All possible columns must tbe listed here, because DATEV requires them to # be present in the CSV. @@ -324,9 +400,10 @@ def get_datev_csv(data): data_df = pd.DataFrame.from_records(data) result = empty_df.append(data_df) - result["Belegdatum"] = pd.to_datetime(result["Belegdatum"]) + result['Belegdatum'] = pd.to_datetime(result['Belegdatum']) - return result.to_csv( + header = ';'.join(header).encode('latin_1') + data = result.to_csv( sep=b';', # European decimal seperator decimal=',', @@ -342,6 +419,7 @@ def get_datev_csv(data): columns=columns ) + return header + b'\r\n' + data @frappe.whitelist() def download_datev_csv(filters=None): @@ -359,15 +437,9 @@ def download_datev_csv(filters=None): if isinstance(filters, string_types): filters = json.loads(filters) - validate_filters(filters) + validate(filters) data = get_gl_entries(filters, as_dict=1) - filename = 'DATEV_Buchungsstapel_{}-{}_bis_{}'.format( - filters.get('company'), - filters.get('from_date'), - filters.get('to_date') - ) - - frappe.response['result'] = get_datev_csv(data) - frappe.response['doctype'] = filename + frappe.response['result'] = get_datev_csv(data, filters) + frappe.response['doctype'] = 'EXTF_Buchungsstapel' frappe.response['type'] = 'csv' diff --git a/erpnext/selling/doctype/customer/test_customer.py b/erpnext/selling/doctype/customer/test_customer.py index 42c7d99e41..87fdaa366f 100644 --- a/erpnext/selling/doctype/customer/test_customer.py +++ b/erpnext/selling/doctype/customer/test_customer.py @@ -8,7 +8,7 @@ import unittest from erpnext.accounts.party import get_due_date from frappe.test_runner import make_test_records -from erpnext.exceptions import PartyFrozen +from erpnext.exceptions import PartyFrozen, PartyDisabled from frappe.utils import flt from erpnext.selling.doctype.customer.customer import get_credit_limit, get_customer_outstanding from erpnext.tests.utils import create_test_contact_and_address @@ -178,7 +178,7 @@ class TestCustomer(unittest.TestCase): so = make_sales_order(do_not_save=True) - self.assertRaises(frappe.ValidationError, so.save) + self.assertRaises(PartyDisabled, so.save) frappe.db.set_value("Customer", "_Test Customer", "disabled", 0) diff --git a/erpnext/selling/doctype/quotation/quotation.json b/erpnext/selling/doctype/quotation/quotation.json index 1b8954578f..ea04715524 100644 --- a/erpnext/selling/doctype/quotation/quotation.json +++ b/erpnext/selling/doctype/quotation/quotation.json @@ -1904,7 +1904,7 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, - "label": "Additional Discount", + "label": "Additional Discount and Coupon Code", "length": 0, "no_copy": 0, "permlevel": 0, @@ -1920,6 +1920,74 @@ "translatable": 0, "unique": 0 }, + { + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fetch_if_empty": 0, + "fieldname": "coupon_code", + "fieldtype": "Link", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Coupon Code", + "length": 0, + "no_copy": 0, + "options": "Coupon Code", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "translatable": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fetch_if_empty": 0, + "fieldname": "referral_sales_partner", + "fieldtype": "Link", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Referral Sales Partner", + "length": 0, + "no_copy": 0, + "options": "Sales Partner", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "translatable": 0, + "unique": 0 + }, { "allow_bulk_edit": 0, "allow_in_quick_entry": 0, @@ -3263,7 +3331,7 @@ "istable": 0, "max_attachments": 1, "menu_index": 0, - "modified": "2019-06-26 01:00:21.545591", + "modified": "2019-10-14 01:00:21.545591", "modified_by": "Administrator", "module": "Selling", "name": "Quotation", diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py index 46009f45e4..4a56e40400 100644 --- a/erpnext/selling/doctype/quotation/quotation.py +++ b/erpnext/selling/doctype/quotation/quotation.py @@ -142,6 +142,9 @@ def _make_sales_order(source_name, target_doc=None, ignore_permissions=False): if customer: target.customer = customer.name target.customer_name = customer.customer_name + if source.referral_sales_partner: + target.sales_partner=source.referral_sales_partner + target.commission_rate=frappe.get_value('Sales Partner', source.referral_sales_partner, 'commission_rate') target.ignore_pricing_rule = 1 target.flags.ignore_permissions = ignore_permissions target.run_method("set_missing_values") diff --git a/erpnext/selling/doctype/sales_order/sales_order.json b/erpnext/selling/doctype/sales_order/sales_order.json index 3885b13eae..78e7b4abb8 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.json +++ b/erpnext/selling/doctype/sales_order/sales_order.json @@ -79,6 +79,7 @@ "loyalty_points", "loyalty_amount", "section_break_48", + "coupon_code", "apply_discount_on", "base_discount_amount", "column_break_50", @@ -678,7 +679,13 @@ "collapsible_depends_on": "discount_amount", "fieldname": "section_break_48", "fieldtype": "Section Break", - "label": "Additional Discount" + "label": "Additional Discount and Coupon Code" + }, + { + "fieldname": "coupon_code", + "fieldtype": "Link", + "label": "Coupon Code", + "options": "Coupon Code" }, { "default": "Grand Total", @@ -1185,7 +1192,7 @@ "icon": "fa fa-file-text", "idx": 105, "is_submittable": 1, - "modified": "2019-10-10 08:46:07.540565", + "modified": "2019-10-14 08:46:07.540565", "modified_by": "Administrator", "module": "Selling", "name": "Sales Order", @@ -1262,4 +1269,4 @@ "title_field": "title", "track_changes": 1, "track_seen": 1 -} \ No newline at end of file +} diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py index 80784ea61f..af78ab250d 100755 --- a/erpnext/selling/doctype/sales_order/sales_order.py +++ b/erpnext/selling/doctype/sales_order/sales_order.py @@ -46,6 +46,10 @@ class SalesOrder(SellingController): self.validate_serial_no_based_delivery() validate_inter_company_party(self.doctype, self.customer, self.company, self.inter_company_order_reference) + if self.coupon_code: + from erpnext.accounts.doctype.pricing_rule.utils import validate_coupon_code + validate_coupon_code(self.coupon_code) + from erpnext.stock.doctype.packed_item.packed_item import make_packing_list make_packing_list(self) @@ -177,6 +181,9 @@ class SalesOrder(SellingController): self.update_blanket_order() update_linked_doc(self.doctype, self.name, self.inter_company_order_reference) + if self.coupon_code: + from erpnext.accounts.doctype.pricing_rule.utils import update_coupon_code_count + update_coupon_code_count(self.coupon_code,'used') def on_cancel(self): super(SalesOrder, self).on_cancel() @@ -195,7 +202,10 @@ class SalesOrder(SellingController): self.update_blanket_order() unlink_inter_company_doc(self.doctype, self.name, self.inter_company_order_reference) - + if self.coupon_code: + from erpnext.accounts.doctype.pricing_rule.utils import update_coupon_code_count + update_coupon_code_count(self.coupon_code,'cancelled') + def update_project(self): if frappe.db.get_single_value('Selling Settings', 'sales_update_frequency') != "Each Transaction": return diff --git a/erpnext/setup/doctype/sales_partner/sales_partner.js b/erpnext/setup/doctype/sales_partner/sales_partner.js index 7164add495..5656d43e85 100644 --- a/erpnext/setup/doctype/sales_partner/sales_partner.js +++ b/erpnext/setup/doctype/sales_partner/sales_partner.js @@ -24,5 +24,11 @@ frappe.ui.form.on('Sales Partner', { } } }; + }, + referral_code:function(frm){ + if (frm.doc.referral_code) { + frm.doc.referral_code=frm.doc.referral_code.toUpperCase(); + frm.refresh_field('referral_code'); + } } }); diff --git a/erpnext/setup/doctype/sales_partner/sales_partner.json b/erpnext/setup/doctype/sales_partner/sales_partner.json index 28cdd3e10c..0bf9d71114 100644 --- a/erpnext/setup/doctype/sales_partner/sales_partner.json +++ b/erpnext/setup/doctype/sales_partner/sales_partner.json @@ -510,6 +510,73 @@ "translatable": 0, "unique": 0 }, + { + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fetch_if_empty": 0, + "fieldname": "column_break_16", + "fieldtype": "Column Break", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "translatable": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "depends_on": "", + "description": "To Track inbound purchase", + "fetch_if_empty": 0, + "fieldname": "referral_code", + "fieldtype": "Data", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Referral Code", + "length": 8, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "translatable": 0, + "unique": 1 + }, { "allow_bulk_edit": 0, "allow_in_quick_entry": 0, @@ -779,7 +846,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2019-03-21 16:26:45.447265", + "modified": "2019-10-14 16:26:45.447265", "modified_by": "Administrator", "module": "Setup", "name": "Sales Partner", diff --git a/erpnext/shopping_cart/cart.py b/erpnext/shopping_cart/cart.py index 40cb7c8700..f850bc1707 100644 --- a/erpnext/shopping_cart/cart.py +++ b/erpnext/shopping_cart/cart.py @@ -537,3 +537,29 @@ def get_address_territory(address_name): def show_terms(doc): return doc.tc_name + +@frappe.whitelist(allow_guest=True) +def apply_coupon_code(applied_code,applied_referral_sales_partner): + quotation = True + if applied_code: + coupon_list=frappe.get_all('Coupon Code', filters={"docstatus": ("<", "2"), 'coupon_code':applied_code }, fields=['name']) + if coupon_list: + coupon_name=coupon_list[0].name + from erpnext.accounts.doctype.pricing_rule.utils import validate_coupon_code + validate_coupon_code(coupon_name) + quotation = _get_cart_quotation() + quotation.coupon_code=coupon_name + quotation.flags.ignore_permissions = True + quotation.save() + if applied_referral_sales_partner: + sales_partner_list=frappe.get_all('Sales Partner', filters={'docstatus': 0, 'referral_code':applied_referral_sales_partner }, fields=['name']) + if sales_partner_list: + sales_partner_name=sales_partner_list[0].name + quotation.referral_sales_partner=sales_partner_name + quotation.flags.ignore_permissions = True + quotation.save() + else: + frappe.throw(_("Please enter valid coupon code !!")) + else: + frappe.throw(_("Please enter coupon code !!")) + return quotation \ No newline at end of file diff --git a/erpnext/shopping_cart/doctype/shopping_cart_settings/shopping_cart_settings.json b/erpnext/shopping_cart/doctype/shopping_cart_settings/shopping_cart_settings.json index 8b9299e42e..e828f54878 100644 --- a/erpnext/shopping_cart/doctype/shopping_cart_settings/shopping_cart_settings.json +++ b/erpnext/shopping_cart/doctype/shopping_cart_settings/shopping_cart_settings.json @@ -275,6 +275,40 @@ "translatable": 0, "unique": 0 }, + { + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "depends_on": "", + "fetch_if_empty": 0, + "fieldname": "show_apply_coupon_code_in_website", + "fieldtype": "Check", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Show Apply Coupon Code", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "translatable": 0, + "unique": 0 + }, { "allow_bulk_edit": 0, "allow_in_quick_entry": 0, @@ -679,7 +713,7 @@ "issingle": 1, "istable": 0, "max_attachments": 0, - "modified": "2019-01-26 13:54:24.575322", + "modified": "2019-10-14 13:54:24.575322", "modified_by": "Administrator", "module": "Shopping Cart", "name": "Shopping Cart Settings", diff --git a/erpnext/templates/includes/cart.js b/erpnext/templates/includes/cart.js index 4c35dd04a2..456bc7e413 100644 --- a/erpnext/templates/includes/cart.js +++ b/erpnext/templates/includes/cart.js @@ -20,6 +20,7 @@ $.extend(shopping_cart, { shopping_cart.bind_change_qty(); shopping_cart.bind_change_notes(); shopping_cart.bind_dropdown_cart_buttons(); + shopping_cart.bind_coupon_code(); }, bind_address_select: function() { @@ -193,6 +194,29 @@ $.extend(shopping_cart, { } } }); + }, + + bind_coupon_code: function() { + $(".bt-coupon").on("click", function() { + shopping_cart.apply_coupon_code(this); + }); + }, + + apply_coupon_code: function(btn) { + return frappe.call({ + type: "POST", + method: "erpnext.shopping_cart.cart.apply_coupon_code", + btn: btn, + args : { + applied_code : $('.txtcoupon').val(), + applied_referral_sales_partner: $('.txtreferral_sales_partner').val() + }, + callback: function(r) { + if (r && r.message){ + location.reload(); + } + } + }); } }); diff --git a/erpnext/templates/includes/cart/cart_address.html b/erpnext/templates/includes/cart/cart_address.html index 2c90f8cb87..e857ce1be0 100644 --- a/erpnext/templates/includes/cart/cart_address.html +++ b/erpnext/templates/includes/cart/cart_address.html @@ -4,6 +4,16 @@ {% set select_address = True %} {% endif %} +{% set show_coupon_code = frappe.db.get_single_value('Shopping Cart Settings', 'show_apply_coupon_code_in_website') %} +{% if show_coupon_code == 1%} +
+
+ + + +
+
+{% endif %}
{{ _("Shipping Address") }}
diff --git a/erpnext/templates/includes/order/order_taxes.html b/erpnext/templates/includes/order/order_taxes.html index 1d26700cc4..4a32aa4744 100644 --- a/erpnext/templates/includes/order/order_taxes.html +++ b/erpnext/templates/includes/order/order_taxes.html @@ -22,6 +22,71 @@ {% endif %} {% endfor %} +{% if doc.doctype == 'Quotation' %} +{% if doc.coupon_code %} + + + {{ _("Discount") }} + + + {% set tot_quotation_discount = [] %} + {%- for item in doc.items -%} + {% if tot_quotation_discount.append((((item.price_list_rate * item.qty) + * item.discount_percentage) / 100)) %}{% endif %} + {% endfor %} + {{ frappe.utils.fmt_money((tot_quotation_discount | sum),currency=doc.currency) }} + + +{% endif %} +{% endif %} + +{% if doc.doctype == 'Sales Order' %} +{% if doc.coupon_code %} + + + {{ _("Total Amount") }} + + + + {% set total_amount = [] %} + {%- for item in doc.items -%} + {% if total_amount.append((item.price_list_rate * item.qty)) %}{% endif %} + {% endfor %} + {{ frappe.utils.fmt_money((total_amount | sum),currency=doc.currency) }} + + + + + + {{ _("Applied Coupon Code") }} + + + + {%- for row in frappe.get_all(doctype="Coupon Code", + fields=["coupon_code"], filters={ "name":doc.coupon_code}) -%} + {{ row.coupon_code }} + {% endfor %} + + + + + + {{ _("Discount") }} + + + + {% set tot_SO_discount = [] %} + {%- for item in doc.items -%} + {% if tot_SO_discount.append((((item.price_list_rate * item.qty) + * item.discount_percentage) / 100)) %}{% endif %} + {% endfor %} + {{ frappe.utils.fmt_money((tot_SO_discount | sum),currency=doc.currency) }} + + + +{% endif %} +{% endif %} + {{ _("Grand Total") }} diff --git a/erpnext/utilities/web_form/addresses/addresses.json b/erpnext/utilities/web_form/addresses/addresses.json index 1d3acc54c1..2f5e180731 100644 --- a/erpnext/utilities/web_form/addresses/addresses.json +++ b/erpnext/utilities/web_form/addresses/addresses.json @@ -1,166 +1,196 @@ { - "accept_payment": 0, - "allow_comments": 0, - "allow_delete": 0, - "allow_edit": 1, - "allow_incomplete": 0, - "allow_multiple": 1, - "allow_print": 0, - "amount": 0.0, - "creation": "2016-06-24 15:50:33.196990", - "doc_type": "Address", - "docstatus": 0, - "doctype": "Web Form", - "idx": 0, - "is_standard": 1, - "login_required": 1, - "max_attachment_size": 0, - "modified": "2016-12-07 04:17:02.020768", - "modified_by": "Administrator", - "module": "Utilities", - "name": "addresses", - "owner": "Administrator", - "published": 1, - "route": "address", - "show_sidebar": 0, - "sidebar_items": [], - "success_url": "/addresses", - "title": "Address", + "accept_payment": 0, + "allow_comments": 0, + "allow_delete": 0, + "allow_edit": 1, + "allow_incomplete": 0, + "allow_multiple": 1, + "allow_print": 0, + "amount": 0.0, + "amount_based_on_field": 0, + "creation": "2016-06-24 15:50:33.196990", + "doc_type": "Address", + "docstatus": 0, + "doctype": "Web Form", + "idx": 0, + "is_standard": 1, + "login_required": 1, + "max_attachment_size": 0, + "modified": "2019-10-15 06:55:30.405119", + "modified_by": "Administrator", + "module": "Utilities", + "name": "addresses", + "owner": "Administrator", + "published": 1, + "route": "address", + "route_to_success_link": 0, + "show_attachments": 0, + "show_in_grid": 0, + "show_sidebar": 0, + "sidebar_items": [], + "success_url": "/addresses", + "title": "Address", "web_form_fields": [ { - "description": "", - "fieldname": "address_title", - "fieldtype": "Data", - "hidden": 0, - "label": "Address Title", - "max_length": 0, - "max_value": 0, - "read_only": 0, - "reqd": 0 - }, + "allow_read_on_all_link_options": 0, + "description": "", + "fieldname": "address_title", + "fieldtype": "Data", + "hidden": 0, + "label": "Address Title", + "max_length": 0, + "max_value": 0, + "read_only": 0, + "reqd": 0, + "show_in_filter": 0 + }, { - "fieldname": "address_type", - "fieldtype": "Select", - "hidden": 0, - "label": "Address Type", - "max_length": 0, - "max_value": 0, - "options": "Billing\nShipping\nOffice\nPersonal\nPlant\nPostal\nShop\nSubsidiary\nWarehouse\nOther", - "read_only": 0, - "reqd": 1 - }, + "allow_read_on_all_link_options": 0, + "fieldname": "address_type", + "fieldtype": "Select", + "hidden": 0, + "label": "Address Type", + "max_length": 0, + "max_value": 0, + "options": "Billing\nShipping\nOffice\nPersonal\nPlant\nPostal\nShop\nSubsidiary\nWarehouse\nOther", + "read_only": 0, + "reqd": 1, + "show_in_filter": 0 + }, { - "fieldname": "address_line1", - "fieldtype": "Data", - "hidden": 0, - "label": "Address Line 1", - "max_length": 0, - "max_value": 0, - "read_only": 0, - "reqd": 1 - }, + "allow_read_on_all_link_options": 0, + "fieldname": "address_line1", + "fieldtype": "Data", + "hidden": 0, + "label": "Address Line 1", + "max_length": 0, + "max_value": 0, + "read_only": 0, + "reqd": 1, + "show_in_filter": 0 + }, { - "fieldname": "address_line2", - "fieldtype": "Data", - "hidden": 0, - "label": "Address Line 2", - "max_length": 0, - "max_value": 0, - "read_only": 0, - "reqd": 0 - }, + "allow_read_on_all_link_options": 0, + "fieldname": "address_line2", + "fieldtype": "Data", + "hidden": 0, + "label": "Address Line 2", + "max_length": 0, + "max_value": 0, + "read_only": 0, + "reqd": 0, + "show_in_filter": 0 + }, { - "fieldname": "city", - "fieldtype": "Data", - "hidden": 0, - "label": "City/Town", - "max_length": 0, - "max_value": 0, - "read_only": 0, - "reqd": 1 - }, + "allow_read_on_all_link_options": 0, + "fieldname": "city", + "fieldtype": "Data", + "hidden": 0, + "label": "City/Town", + "max_length": 0, + "max_value": 0, + "read_only": 0, + "reqd": 1, + "show_in_filter": 0 + }, { - "fieldname": "state", - "fieldtype": "Data", - "hidden": 0, - "label": "State", - "max_length": 0, - "max_value": 0, - "read_only": 0, - "reqd": 0 - }, + "allow_read_on_all_link_options": 0, + "fieldname": "state", + "fieldtype": "Data", + "hidden": 0, + "label": "State", + "max_length": 0, + "max_value": 0, + "read_only": 0, + "reqd": 0, + "show_in_filter": 0 + }, { - "fieldname": "pincode", - "fieldtype": "Data", - "hidden": 0, - "label": "Postal Code", - "max_length": 0, - "max_value": 0, - "read_only": 0, - "reqd": 0 - }, + "allow_read_on_all_link_options": 0, + "fieldname": "pincode", + "fieldtype": "Data", + "hidden": 0, + "label": "Postal Code", + "max_length": 0, + "max_value": 0, + "read_only": 0, + "reqd": 0, + "show_in_filter": 0 + }, { - "fieldname": "country", - "fieldtype": "Link", - "hidden": 0, - "label": "Country", - "max_length": 0, - "max_value": 0, - "options": "Country", - "read_only": 0, - "reqd": 1 - }, + "allow_read_on_all_link_options": 1, + "fieldname": "country", + "fieldtype": "Link", + "hidden": 0, + "label": "Country", + "max_length": 0, + "max_value": 0, + "options": "Country", + "read_only": 0, + "reqd": 1, + "show_in_filter": 0 + }, { - "fieldtype": "Column Break", - "hidden": 0, - "max_length": 0, - "max_value": 0, - "read_only": 0, - "reqd": 0 - }, + "allow_read_on_all_link_options": 0, + "fieldtype": "Column Break", + "hidden": 0, + "max_length": 0, + "max_value": 0, + "read_only": 0, + "reqd": 0, + "show_in_filter": 0 + }, { - "fieldname": "email_id", - "fieldtype": "Data", - "hidden": 0, - "label": "Email Address", - "max_length": 0, - "max_value": 0, - "read_only": 0, - "reqd": 0 - }, + "allow_read_on_all_link_options": 0, + "fieldname": "email_id", + "fieldtype": "Data", + "hidden": 0, + "label": "Email Address", + "max_length": 0, + "max_value": 0, + "read_only": 0, + "reqd": 0, + "show_in_filter": 0 + }, { - "fieldname": "phone", - "fieldtype": "Data", - "hidden": 0, - "label": "Phone", - "max_length": 0, - "max_value": 0, - "read_only": 0, - "reqd": 1 - }, + "allow_read_on_all_link_options": 0, + "fieldname": "phone", + "fieldtype": "Data", + "hidden": 0, + "label": "Phone", + "max_length": 0, + "max_value": 0, + "read_only": 0, + "reqd": 1, + "show_in_filter": 0 + }, { - "default": "0", - "description": "", - "fieldname": "is_primary_address", - "fieldtype": "Check", - "hidden": 0, - "label": "Preferred Billing Address", - "max_length": 0, - "max_value": 0, - "read_only": 0, - "reqd": 0 - }, + "allow_read_on_all_link_options": 0, + "default": "0", + "description": "", + "fieldname": "is_primary_address", + "fieldtype": "Check", + "hidden": 0, + "label": "Preferred Billing Address", + "max_length": 0, + "max_value": 0, + "read_only": 0, + "reqd": 0, + "show_in_filter": 0 + }, { - "default": "0", - "description": "", - "fieldname": "is_shipping_address", - "fieldtype": "Check", - "hidden": 0, - "label": "Preferred Shipping Address", - "max_length": 0, - "max_value": 0, - "read_only": 0, - "reqd": 0 + "allow_read_on_all_link_options": 0, + "default": "0", + "description": "", + "fieldname": "is_shipping_address", + "fieldtype": "Check", + "hidden": 0, + "label": "Preferred Shipping Address", + "max_length": 0, + "max_value": 0, + "read_only": 0, + "reqd": 0, + "show_in_filter": 0 } ] } \ No newline at end of file