Skip to content

Commit

Permalink
feat: bulkdiscount
Browse files Browse the repository at this point in the history
  • Loading branch information
sahilk25 committed Jul 1, 2021
1 parent cb0b53a commit ab8a366
Show file tree
Hide file tree
Showing 11 changed files with 325 additions and 23 deletions.
Empty file.
84 changes: 84 additions & 0 deletions erpnext/selling/doctype/bulk_discount/bulk_discount.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{
"creation": "2021-06-29 23:42:47.804616",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"minimum_qty",
"maximum_qty",
"column_break_3",
"discount_type",
"discount_percentage",
"discount_amount",
"amended_from"
],
"fields": [
{
"fieldname": "minimum_qty",
"fieldtype": "Int",
"in_list_view": 1,
"label": "Minimum Qty"
},
{
"fieldname": "maximum_qty",
"fieldtype": "Int",
"in_list_view": 1,
"label": "Maximum Qty"
},
{
"fieldname": "column_break_3",
"fieldtype": "Column Break"
},
{
"fieldname": "discount_type",
"fieldtype": "Select",
"in_list_view": 1,
"label": "Discount type",
"options": "\nPercentage\nAmount"
},
{
"depends_on": "eval:doc.discount_type==\"Percentage\"",
"fieldname": "discount_percentage",
"fieldtype": "Percent",
"in_list_view": 1,
"label": "Discount Percentage"
},
{
"depends_on": "eval:doc.discount_type==\"Amount\"",
"fieldname": "discount_amount",
"fieldtype": "Currency",
"in_list_view": 1,
"label": "Discount Amount"
},
{
"fieldname": "amended_from",
"fieldtype": "Link",
"label": "Amended From",
"no_copy": 1,
"options": "Bulk Discount",
"print_hide": 1,
"read_only": 1
},
{
"fieldname": "amended_from",
"fieldtype": "Link",
"label": "Amended From",
"no_copy": 1,
"options": "Bulk Discount",
"print_hide": 1,
"read_only": 1
}
],
"is_submittable": 1,
"istable": 1,
"modified": "2021-06-30 01:01:34.307743",
"modified_by": "Administrator",
"module": "Selling",
"name": "Bulk Discount",
"owner": "Administrator",
"permissions": [],
"quick_entry": 1,
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 1
}
10 changes: 10 additions & 0 deletions erpnext/selling/doctype/bulk_discount/bulk_discount.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2021, 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 BulkDiscount(Document):
pass
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt

frappe.ui.form.on('Bulk Discount Scheme', {
// refresh: function(frm) {

// }
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"autoname": "field:scheme_name",
"creation": "2021-06-29 23:42:53.901998",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"scheme_name",
"bulk_disount",
"amended_from"
],
"fields": [
{
"fieldname": "bulk_disount",
"fieldtype": "Table",
"label": "Bulk Disount",
"options": "Bulk Discount"
},
{
"fieldname": "amended_from",
"fieldtype": "Link",
"label": "Amended From",
"no_copy": 1,
"options": "Bulk Discount Scheme",
"print_hide": 1,
"read_only": 1
},
{
"fieldname": "scheme_name",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Name",
"reqd": 1,
"unique": 1
}
],
"is_submittable": 1,
"modified": "2021-06-29 23:53:29.887064",
"modified_by": "Administrator",
"module": "Selling",
"name": "Bulk Discount Scheme",
"name_case": "UPPER CASE",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"share": 1,
"submit": 1,
"write": 1
}
],
"quick_entry": 1,
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2021, 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 BulkDiscountScheme(Document):
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and Contributors
# See license.txt
from __future__ import unicode_literals

# import frappe
import unittest

class TestBulkDiscountScheme(unittest.TestCase):
pass
47 changes: 44 additions & 3 deletions erpnext/selling/doctype/quoting_sheet/quoting_sheet.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,38 @@
// Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
frappe.ui.form.on('Quoting Sheet', {
item_code: function (frm) {
if (frm.doc.currency == frappe.sys_defaults.currency) {
frm.set_value("conversion_rate", 1.0);
onload: (frm) => {
frm.set_query("bom", () => {
if (frm.doc.item_code) {
return {
filters: {
"item": frm.doc.item_code
}
};
}
});
},
bom: function (frm) {
if (frm.doc.bom) {
frappe.call({
method: "get_raw_materials",
doc: frm.doc,
callback: () => {
frm.refresh_field("raw_material_items");
frm.refresh_field("rm_cost");
},
});
}
},
bulk_discount_scheme: function (frm) {
if (frm.doc.bulk_discount_scheme) {
frappe.call({
method: "get_bulk_discount",
doc: frm.doc,
callback: () => {
frm.refresh_field("bulk_discount");
},
});
}
},

Expand Down Expand Up @@ -42,14 +71,26 @@ frappe.ui.form.on("Quoting Sheet Item", {
if (row.qty && row.rate) {
let amount = row.qty * row.rate;
frappe.model.set_value(cdt, cdn, "amount", amount);
frm.trigger("calculate_total_raw_material_cost");
}
},

calculate_total_raw_material_cost: function (frm) {
frappe.call({
method: "calculate_total_raw_material_cost",
doc: frm.doc,
callback: () => {
frm.refresh_field("rm_cost");
}
});
},

rate: function (frm, cdt, cdn) {
let row = locals[cdt][cdn];
if (row.qty && row.rate) {
let amount = row.qty * row.rate;
frappe.model.set_value(cdt, cdn, "amount", amount);
frm.trigger("calculate_total_raw_material_cost");
}
},

Expand Down
45 changes: 30 additions & 15 deletions erpnext/selling/doctype/quoting_sheet/quoting_sheet.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"lead",
"column_break_4",
"currency",
"conversion_rate",
"qty",
"bom",
"section_break_8",
"raw_material_items",
"update_rate",
Expand All @@ -22,8 +22,10 @@
"column_break_13",
"shipping_cost",
"section_break_15",
"profit_markup",
"profit_margin",
"bulk_discounting_section",
"bulk_discount_scheme",
"bulk_discount",
"section_break_16",
"total_price",
"column_break_17",
Expand Down Expand Up @@ -74,12 +76,6 @@
"fieldtype": "Currency",
"label": "Shipping Cost"
},
{
"default": "0",
"fieldname": "profit_markup",
"fieldtype": "Percent",
"label": "Profit Markup Percent"
},
{
"default": "0",
"fieldname": "total_price",
Expand All @@ -94,12 +90,6 @@
"label": "Price Per Unit",
"read_only": 1
},
{
"fieldname": "conversion_rate",
"fieldtype": "Float",
"label": "Conversion Rate",
"reqd": 1
},
{
"fieldname": "currency",
"fieldtype": "Link",
Expand Down Expand Up @@ -171,10 +161,34 @@
"fieldname": "update_rate",
"fieldtype": "Button",
"label": "Update Rate"
},
{
"fieldname": "bom",
"fieldtype": "Link",
"label": "BOM",
"options": "BOM"
},
{
"fieldname": "bulk_discount",
"fieldtype": "Table",
"label": "Bulk Discount",
"options": "Bulk Discount"
},
{
"fieldname": "bulk_discount_scheme",
"fieldtype": "Link",
"label": "Bulk Discount Scheme",
"options": "Bulk Discount Scheme"
},
{
"default": "0",
"fieldname": "profit_margin",
"fieldtype": "Percent",
"label": "Profit Margin Percent"
}
],
"is_submittable": 1,
"modified": "2021-06-02 23:07:43.385905",
"modified": "2021-06-30 00:52:43.372602",
"modified_by": "Administrator",
"module": "Selling",
"name": "Quoting Sheet",
Expand All @@ -191,6 +205,7 @@
"report": 1,
"role": "System Manager",
"share": 1,
"submit": 1,
"write": 1
}
],
Expand Down
Loading

0 comments on commit ab8a366

Please sign in to comment.