diff --git a/erpnext/accounts/report/purchase_partners_commission/purchase_partners_commission.json b/erpnext/accounts/report/purchase_partners_commission/purchase_partners_commission.json index f6d84aedb50..edc0115d5d1 100644 --- a/erpnext/accounts/report/purchase_partners_commission/purchase_partners_commission.json +++ b/erpnext/accounts/report/purchase_partners_commission/purchase_partners_commission.json @@ -15,7 +15,7 @@ "name": "Purchase Partners Commission", "owner": "Administrator", "prepared_report": 0, - "query": "SELECT\n purchase_partner as \"Purchase Partner:Link/Purchase Partner:220\",\n sum(base_net_total) as \"Invoiced Amount (Excl. Tax):Currency:220\",\n sum(amount_eligible_for_commission) as \"Amount Eligible for Commission:Currency:220\",\n sum(total_commission) as \"Total Commission:Currency:170\",\n sum(total_commission)*100 / sum(amount_eligible_for_commission) as \"Average Commission Rate:Percent:220\"\nFROM\n `tabPurchase Invoice`\nWHERE\n docstatus = 1\n AND IFNULL(base_net_total, 0) > 0\n AND IFNULL(total_commission, 0) > 0\nGROUP BY\n purchase_partner\nORDER BY\n sum(total_commission) DESC", + "query": "SELECT\n purchase_partner as \"Purchase Partner:Link/Purchase Partner:220\",\n sum(base_net_total) as \"Invoiced Amount (Excl. Tax):Currency:220\",\n sum(amount_eligible_for_commission) as \"Amount Eligible for Commission:Currency:220\",\n sum(total_commission) as \"Total Commission:Currency:170\",\n sum(total_commission)*100 / NULLIF(sum(amount_eligible_for_commission), 0) as \"Average Commission Rate:Percent:220\"\nFROM\n `tabPurchase Invoice`\nWHERE\n docstatus = 1\n AND IFNULL(base_net_total, 0) > 0\n AND IFNULL(total_commission, 0) > 0\nGROUP BY\n purchase_partner\nORDER BY\n sum(total_commission) DESC", "ref_doctype": "Purchase Invoice", "report_name": "Purchase Partners Commission", "report_type": "Query Report", diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py index 52f46691784..ea35a04b95d 100644 --- a/erpnext/controllers/buying_controller.py +++ b/erpnext/controllers/buying_controller.py @@ -391,9 +391,7 @@ class BuyingController(SubcontractingController): self.round_floats_in(self, ("amount_eligible_for_commission", "commission_rate")) if not (0 <= self.commission_rate <= 100.0): - from frappe import throw - - throw( + frappe.throw( "{} {}".format( _(self.meta.get_label("commission_rate")), _("must be between 0 and 100"), diff --git a/erpnext/public/js/controllers/buying.js b/erpnext/public/js/controllers/buying.js index 093910a21ea..bb214d8473f 100644 --- a/erpnext/public/js/controllers/buying.js +++ b/erpnext/public/js/controllers/buying.js @@ -474,8 +474,8 @@ erpnext.buying = { } purchase_partner() { - this.calculate_purchase_commission(); - } + this.calculate_purchase_commission(); + } commission_rate() { if ( @@ -509,8 +509,7 @@ erpnext.buying = { calculate_purchase_commission() { if (!this.frm.fields_dict.commission_rate || this.frm.doc.docstatus === 1) return; - if (this.frm.doc.commission_rate > 100) { - this.frm.set_value("commission_rate", 100); + if (this.frm.doc.commission_rate < 0 || this.frm.doc.commission_rate > 100) { frappe.throw( `${__( frappe.meta.get_label( @@ -518,7 +517,7 @@ erpnext.buying = { "commission_rate", this.frm.doc.name ) - )} ${__("cannot be greater than 100")}` + )} ${__("must be between 0 and 100")}` ); } diff --git a/erpnext/setup/doctype/purchase_partner/test_purchase_partner.py b/erpnext/setup/doctype/purchase_partner/test_purchase_partner.py index 5d32b4a75ab..5168ca536f5 100644 --- a/erpnext/setup/doctype/purchase_partner/test_purchase_partner.py +++ b/erpnext/setup/doctype/purchase_partner/test_purchase_partner.py @@ -2,7 +2,6 @@ # License: GNU General Public License v3. See license.txt import frappe -from frappe.tests import IntegrationTestCase from erpnext.buying.doctype.purchase_order.test_purchase_order import create_purchase_order from erpnext.tests.utils import ERPNextTestSuite diff --git a/erpnext/setup/setup_wizard/data/purchase_partner_type.txt b/erpnext/setup/setup_wizard/data/purchase_partner_type.txt new file mode 100644 index 00000000000..68e9b9ac732 --- /dev/null +++ b/erpnext/setup/setup_wizard/data/purchase_partner_type.txt @@ -0,0 +1,7 @@ +Channel Partner +Distributor +Dealer +Agent +Retailer +Implementation Partner +Reseller diff --git a/erpnext/setup/setup_wizard/operations/install_fixtures.py b/erpnext/setup/setup_wizard/operations/install_fixtures.py index 806db071963..5a297a23c50 100644 --- a/erpnext/setup/setup_wizard/operations/install_fixtures.py +++ b/erpnext/setup/setup_wizard/operations/install_fixtures.py @@ -328,6 +328,7 @@ def install(country=None): ("Industry Type", "industry", "industry_type.txt"), ("UTM Source", "name", "marketing_source.txt"), ("Sales Partner Type", "sales_partner_type", "sales_partner_type.txt"), + ("Purchase Partner Type", "purchase_partner_type", "purchase_partner_type.txt"), ): records += [{"doctype": doctype, title_field: title} for title in read_lines(filename)]