mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-06 15:00:27 +00:00
Merge branch 'hotfix' of https://github.com/frappe/erpnext into ewb
This commit is contained in:
@@ -90,11 +90,11 @@ class Lead(SellingController):
|
||||
return frappe.db.get_value("Customer", {"lead_name": self.name})
|
||||
|
||||
def has_opportunity(self):
|
||||
return frappe.db.get_value("Opportunity", {"lead": self.name, "status": ["!=", "Lost"]})
|
||||
return frappe.db.get_value("Opportunity", {"party_name": self.name, "status": ["!=", "Lost"]})
|
||||
|
||||
def has_quotation(self):
|
||||
return frappe.db.get_value("Quotation", {
|
||||
"lead": self.name,
|
||||
"party_name": self.name,
|
||||
"docstatus": 1,
|
||||
"status": ["!=", "Lost"]
|
||||
|
||||
|
||||
@@ -9,15 +9,22 @@ frappe.ui.form.on("Opportunity", {
|
||||
frm.custom_make_buttons = {
|
||||
'Quotation': 'Quotation',
|
||||
'Supplier Quotation': 'Supplier Quotation'
|
||||
}
|
||||
},
|
||||
customer: function(frm) {
|
||||
frm.trigger('set_contact_link');
|
||||
erpnext.utils.get_party_details(frm);
|
||||
},
|
||||
|
||||
frm.set_query("opportunity_from", function() {
|
||||
return{
|
||||
"filters": {
|
||||
"name": ["in", ["Customer", "Lead"]],
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
lead: function(frm) {
|
||||
frm.trigger('set_contact_link');
|
||||
party_name: function(frm) {
|
||||
if (frm.doc.opportunity_from == "Customer") {
|
||||
frm.trigger('set_contact_link');
|
||||
erpnext.utils.get_party_details(frm);
|
||||
}
|
||||
},
|
||||
|
||||
with_items: function(frm) {
|
||||
@@ -30,15 +37,14 @@ frappe.ui.form.on("Opportunity", {
|
||||
|
||||
contact_person: erpnext.utils.get_contact_details,
|
||||
|
||||
enquiry_from: function(frm) {
|
||||
frm.toggle_reqd("lead", frm.doc.enquiry_from==="Lead");
|
||||
frm.toggle_reqd("customer", frm.doc.enquiry_from==="Customer");
|
||||
opportunity_from: function(frm) {
|
||||
frm.toggle_reqd("party_name", frm.doc.opportunity_from);
|
||||
frm.trigger("set_dynamic_field_label");
|
||||
},
|
||||
|
||||
refresh: function(frm) {
|
||||
var doc = frm.doc;
|
||||
frm.events.enquiry_from(frm);
|
||||
frm.trigger('set_contact_link');
|
||||
frm.events.opportunity_from(frm);
|
||||
frm.trigger('toggle_mandatory');
|
||||
erpnext.toggle_naming_series();
|
||||
|
||||
@@ -75,13 +81,20 @@ frappe.ui.form.on("Opportunity", {
|
||||
},
|
||||
|
||||
set_contact_link: function(frm) {
|
||||
if(frm.doc.customer) {
|
||||
if(frm.doc.opportunity_from == "Customer" && frm.doc.party_name) {
|
||||
frappe.dynamic_link = {doc: frm.doc, fieldname: 'customer', doctype: 'Customer'}
|
||||
} else if(frm.doc.lead) {
|
||||
} else if(frm.doc.opportunity_from == "Lead" && frm.doc.party_name) {
|
||||
frappe.dynamic_link = {doc: frm.doc, fieldname: 'lead', doctype: 'Lead'}
|
||||
}
|
||||
},
|
||||
|
||||
set_dynamic_field_label: function(frm){
|
||||
|
||||
if (frm.doc.opportunity_from) {
|
||||
frm.set_df_property("party_name", "label", frm.doc.opportunity_from);
|
||||
}
|
||||
},
|
||||
|
||||
make_supplier_quotation: function(frm) {
|
||||
frappe.model.open_mapped_doc({
|
||||
method: "erpnext.crm.doctype.opportunity.opportunity.make_supplier_quotation",
|
||||
@@ -97,10 +110,6 @@ frappe.ui.form.on("Opportunity", {
|
||||
// TODO commonify this code
|
||||
erpnext.crm.Opportunity = frappe.ui.form.Controller.extend({
|
||||
onload: function() {
|
||||
if(!this.frm.doc.enquiry_from && this.frm.doc.customer)
|
||||
this.frm.doc.enquiry_from = "Customer";
|
||||
if(!this.frm.doc.enquiry_from && this.frm.doc.lead)
|
||||
this.frm.doc.enquiry_from = "Lead";
|
||||
|
||||
if(!this.frm.doc.status)
|
||||
set_multiple(this.frm.doc.doctype, this.frm.doc.name, { status:'Open' });
|
||||
@@ -148,7 +157,7 @@ erpnext.crm.Opportunity = frappe.ui.form.Controller.extend({
|
||||
$.extend(cur_frm.cscript, new erpnext.crm.Opportunity({frm: cur_frm}));
|
||||
|
||||
cur_frm.cscript.onload_post_render = function(doc, cdt, cdn) {
|
||||
if(doc.enquiry_from == 'Lead' && doc.lead)
|
||||
if(doc.opportunity_from == 'Lead' && doc.party_name)
|
||||
cur_frm.cscript.lead(doc, cdt, cdn);
|
||||
}
|
||||
|
||||
@@ -171,10 +180,10 @@ cur_frm.cscript.item_code = function(doc, cdt, cdn) {
|
||||
}
|
||||
|
||||
cur_frm.cscript.lead = function(doc, cdt, cdn) {
|
||||
cur_frm.toggle_display("contact_info", doc.customer || doc.lead);
|
||||
cur_frm.toggle_display("contact_info", doc.party_name);
|
||||
erpnext.utils.map_current_doc({
|
||||
method: "erpnext.crm.doctype.lead.lead.make_opportunity",
|
||||
source_name: cur_frm.doc.lead,
|
||||
source_name: cur_frm.doc.party_name,
|
||||
frm: cur_frm
|
||||
});
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "from_section",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@@ -54,6 +55,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"default": "",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "naming_series",
|
||||
"fieldtype": "Select",
|
||||
"hidden": 0,
|
||||
@@ -88,8 +90,9 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "enquiry_from",
|
||||
"fieldtype": "Select",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "opportunity_from",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
@@ -102,7 +105,7 @@
|
||||
"no_copy": 0,
|
||||
"oldfieldname": "enquiry_from",
|
||||
"oldfieldtype": "Select",
|
||||
"options": "\nLead\nCustomer",
|
||||
"options": "DocType",
|
||||
"permlevel": 0,
|
||||
"print_hide": 1,
|
||||
"print_hide_if_no_value": 0,
|
||||
@@ -122,9 +125,10 @@
|
||||
"bold": 1,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "eval:doc.enquiry_from===\"Customer\"",
|
||||
"fieldname": "customer",
|
||||
"fieldtype": "Link",
|
||||
"depends_on": "",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "party_name",
|
||||
"fieldtype": "Dynamic Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
@@ -132,54 +136,19 @@
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 1,
|
||||
"label": "Customer",
|
||||
"label": "Customer/Lead",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"oldfieldname": "customer",
|
||||
"oldfieldtype": "Link",
|
||||
"options": "Customer",
|
||||
"options": "opportunity_from",
|
||||
"permlevel": 0,
|
||||
"print_hide": 1,
|
||||
"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": 1,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "eval:doc.enquiry_from===\"Lead\"",
|
||||
"fieldname": "lead",
|
||||
"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": 1,
|
||||
"label": "Lead",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"oldfieldname": "lead",
|
||||
"oldfieldtype": "Link",
|
||||
"options": "Lead",
|
||||
"permlevel": 0,
|
||||
"print_hide": 1,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"reqd": 1,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
@@ -193,6 +162,8 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "",
|
||||
"fetch_from": "",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "customer_name",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
@@ -224,6 +195,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "column_break0",
|
||||
"fieldtype": "Column Break",
|
||||
"hidden": 0,
|
||||
@@ -256,6 +228,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "title",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 1,
|
||||
@@ -289,6 +262,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"default": "Sales",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "opportunity_type",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -324,6 +298,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"default": "Open",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "status",
|
||||
"fieldtype": "Select",
|
||||
"hidden": 0,
|
||||
@@ -359,6 +334,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "eval:doc.status===\"Lost\"",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "order_lost_reason",
|
||||
"fieldtype": "Small Text",
|
||||
"hidden": 0,
|
||||
@@ -390,6 +366,7 @@
|
||||
"bold": 1,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "mins_to_first_response",
|
||||
"fieldtype": "Float",
|
||||
"hidden": 0,
|
||||
@@ -423,6 +400,7 @@
|
||||
"collapsible": 1,
|
||||
"collapsible_depends_on": "contact_by",
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "next_contact",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@@ -456,6 +434,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"description": "",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "contact_by",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -492,6 +471,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"description": "",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "contact_date",
|
||||
"fieldtype": "Datetime",
|
||||
"hidden": 0,
|
||||
@@ -525,6 +505,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "column_break2",
|
||||
"fieldtype": "Column Break",
|
||||
"hidden": 0,
|
||||
@@ -557,6 +538,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "to_discuss",
|
||||
"fieldtype": "Small Text",
|
||||
"hidden": 0,
|
||||
@@ -590,6 +572,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "section_break_14",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@@ -622,6 +605,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "currency",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -655,6 +639,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "opportunity_amount",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
@@ -687,6 +672,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "with_items",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 0,
|
||||
@@ -719,6 +705,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "column_break_17",
|
||||
"fieldtype": "Column Break",
|
||||
"hidden": 0,
|
||||
@@ -751,6 +738,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"default": "Prospecting",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "sales_stage",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -785,6 +773,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"default": "100",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "probability",
|
||||
"fieldtype": "Percent",
|
||||
"hidden": 0,
|
||||
@@ -818,6 +807,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "with_items",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "items_section",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@@ -852,6 +842,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"description": "",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "items",
|
||||
"fieldtype": "Table",
|
||||
"hidden": 0,
|
||||
@@ -888,6 +879,7 @@
|
||||
"collapsible_depends_on": "next_contact_by",
|
||||
"columns": 0,
|
||||
"depends_on": "eval:doc.lead || doc.customer",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "contact_info",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@@ -921,6 +913,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "eval:doc.customer || doc.lead",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "customer_address",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -953,6 +946,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "address_display",
|
||||
"fieldtype": "Small Text",
|
||||
"hidden": 1,
|
||||
@@ -988,6 +982,7 @@
|
||||
"columns": 0,
|
||||
"depends_on": "customer",
|
||||
"description": "",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "territory",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -1022,6 +1017,7 @@
|
||||
"columns": 0,
|
||||
"depends_on": "customer",
|
||||
"description": "",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "customer_group",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -1056,6 +1052,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "column_break3",
|
||||
"fieldtype": "Column Break",
|
||||
"hidden": 0,
|
||||
@@ -1087,6 +1084,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "eval:doc.lead || doc.customer",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "contact_person",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -1120,6 +1118,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "customer",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "contact_display",
|
||||
"fieldtype": "Small Text",
|
||||
"hidden": 0,
|
||||
@@ -1152,6 +1151,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "eval:doc.lead || doc.customer",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "contact_email",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
@@ -1184,6 +1184,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "eval:doc.lead || doc.customer",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "contact_mobile",
|
||||
"fieldtype": "Small Text",
|
||||
"hidden": 0,
|
||||
@@ -1216,6 +1217,7 @@
|
||||
"collapsible": 1,
|
||||
"collapsible_depends_on": "",
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "more_info",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@@ -1249,6 +1251,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "source",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -1285,6 +1288,7 @@
|
||||
"columns": 0,
|
||||
"depends_on": "eval: doc.source==\"Campaign\"",
|
||||
"description": "Enter name of campaign if source of enquiry is campaign",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "campaign",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -1319,6 +1323,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "column_break1",
|
||||
"fieldtype": "Column Break",
|
||||
"hidden": 0,
|
||||
@@ -1351,6 +1356,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "company",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -1386,6 +1392,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"default": "Today",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "transaction_date",
|
||||
"fieldtype": "Date",
|
||||
"hidden": 0,
|
||||
@@ -1420,6 +1427,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "amended_from",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -1460,7 +1468,7 @@
|
||||
"issingle": 0,
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2018-10-01 09:28:43.990999",
|
||||
"modified": "2019-04-25 18:55:43.874656",
|
||||
"modified_by": "Administrator",
|
||||
"module": "CRM",
|
||||
"name": "Opportunity",
|
||||
@@ -1508,11 +1516,11 @@
|
||||
"quick_entry": 0,
|
||||
"read_only": 0,
|
||||
"read_only_onload": 0,
|
||||
"search_fields": "status,transaction_date,customer,lead,opportunity_type,territory,company",
|
||||
"search_fields": "status,transaction_date,party_name,opportunity_type,territory,company",
|
||||
"show_name_in_global_search": 1,
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"timeline_field": "customer",
|
||||
"timeline_field": "party_name",
|
||||
"title_field": "title",
|
||||
"track_changes": 0,
|
||||
"track_seen": 1,
|
||||
|
||||
@@ -16,8 +16,8 @@ sender_field = "contact_email"
|
||||
|
||||
class Opportunity(TransactionBase):
|
||||
def after_insert(self):
|
||||
if self.lead:
|
||||
frappe.get_doc("Lead", self.lead).set_status(update=True)
|
||||
if self.opportunity_from == "Lead":
|
||||
frappe.get_doc("Lead", self.party_name).set_status(update=True)
|
||||
|
||||
def validate(self):
|
||||
self._prev = frappe._dict({
|
||||
@@ -29,12 +29,8 @@ class Opportunity(TransactionBase):
|
||||
|
||||
self.make_new_lead_if_required()
|
||||
|
||||
if not self.enquiry_from:
|
||||
frappe.throw(_("Opportunity From field is mandatory"))
|
||||
|
||||
self.validate_item_details()
|
||||
self.validate_uom_is_integer("uom", "qty")
|
||||
self.validate_lead_cust()
|
||||
self.validate_cust_name()
|
||||
|
||||
if not self.title:
|
||||
@@ -45,7 +41,7 @@ class Opportunity(TransactionBase):
|
||||
|
||||
def make_new_lead_if_required(self):
|
||||
"""Set lead against new opportunity"""
|
||||
if not (self.lead or self.customer) and self.contact_email:
|
||||
if (not self.get("party_name")) and self.contact_email:
|
||||
# check if customer is already created agains the self.contact_email
|
||||
customer = frappe.db.sql("""select
|
||||
distinct `tabDynamic Link`.link_name as customer
|
||||
@@ -61,8 +57,8 @@ class Opportunity(TransactionBase):
|
||||
`tabDynamic Link`.link_doctype='Customer'
|
||||
""".format(self.contact_email), as_dict=True)
|
||||
if customer and customer[0].customer:
|
||||
self.customer = customer[0].customer
|
||||
self.enquiry_from = "Customer"
|
||||
self.party_name = customer[0].customer
|
||||
self.opportunity_from = "Customer"
|
||||
return
|
||||
|
||||
lead_name = frappe.db.get_value("Lead", {"email_id": self.contact_email})
|
||||
@@ -89,8 +85,8 @@ class Opportunity(TransactionBase):
|
||||
lead.insert(ignore_permissions=True)
|
||||
lead_name = lead.name
|
||||
|
||||
self.enquiry_from = "Lead"
|
||||
self.lead = lead_name
|
||||
self.opportunity_from = "Lead"
|
||||
self.party_name = lead_name
|
||||
|
||||
def declare_enquiry_lost(self,arg):
|
||||
if not self.has_active_quotation():
|
||||
@@ -137,10 +133,10 @@ class Opportunity(TransactionBase):
|
||||
return True
|
||||
|
||||
def validate_cust_name(self):
|
||||
if self.customer:
|
||||
self.customer_name = frappe.db.get_value("Customer", self.customer, "customer_name")
|
||||
elif self.lead:
|
||||
lead_name, company_name = frappe.db.get_value("Lead", self.lead, ["lead_name", "company_name"])
|
||||
if self.party_name and self.opportunity_from == 'Customer':
|
||||
self.customer_name = frappe.db.get_value("Customer", self.party_name, "customer_name")
|
||||
elif self.party_name and self.opportunity_from == 'Lead':
|
||||
lead_name, company_name = frappe.db.get_value("Lead", self.party_name, ["lead_name", "company_name"])
|
||||
self.customer_name = company_name or lead_name
|
||||
|
||||
def on_update(self):
|
||||
@@ -153,16 +149,16 @@ class Opportunity(TransactionBase):
|
||||
opts.description = ""
|
||||
opts.contact_date = self.contact_date
|
||||
|
||||
if self.customer:
|
||||
if self.party_name and self.opportunity_from == 'Customer':
|
||||
if self.contact_person:
|
||||
opts.description = 'Contact '+cstr(self.contact_person)
|
||||
else:
|
||||
opts.description = 'Contact customer '+cstr(self.customer)
|
||||
elif self.lead:
|
||||
opts.description = 'Contact customer '+cstr(self.party_name)
|
||||
elif self.party_name and self.opportunity_from == 'Lead':
|
||||
if self.contact_display:
|
||||
opts.description = 'Contact '+cstr(self.contact_display)
|
||||
else:
|
||||
opts.description = 'Contact lead '+cstr(self.lead)
|
||||
opts.description = 'Contact lead '+cstr(self.party_name)
|
||||
|
||||
opts.subject = opts.description
|
||||
opts.description += '. By : ' + cstr(self.contact_by)
|
||||
@@ -187,17 +183,6 @@ class Opportunity(TransactionBase):
|
||||
for key in item_fields:
|
||||
if not d.get(key): d.set(key, item.get(key))
|
||||
|
||||
def validate_lead_cust(self):
|
||||
if self.enquiry_from == 'Lead':
|
||||
if not self.lead:
|
||||
frappe.throw(_("Lead must be set if Opportunity is made from Lead"))
|
||||
else:
|
||||
self.customer = None
|
||||
elif self.enquiry_from == 'Customer':
|
||||
if not self.customer:
|
||||
msgprint(_("Customer is mandatory if 'Opportunity From' is selected as Customer"), raise_exception=1)
|
||||
else:
|
||||
self.lead = None
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_item_details(item_code):
|
||||
@@ -219,8 +204,11 @@ def make_quotation(source_name, target_doc=None):
|
||||
quotation = frappe.get_doc(target)
|
||||
|
||||
company_currency = frappe.get_cached_value('Company', quotation.company, "default_currency")
|
||||
party_account_currency = get_party_account_currency("Customer", quotation.customer,
|
||||
quotation.company) if quotation.customer else company_currency
|
||||
|
||||
if quotation.quotation_to == 'Customer' and quotation.party_name:
|
||||
party_account_currency = get_party_account_currency("Customer", quotation.party_name, quotation.company)
|
||||
else:
|
||||
party_account_currency = company_currency
|
||||
|
||||
quotation.currency = party_account_currency or company_currency
|
||||
|
||||
@@ -246,7 +234,7 @@ def make_quotation(source_name, target_doc=None):
|
||||
"Opportunity": {
|
||||
"doctype": "Quotation",
|
||||
"field_map": {
|
||||
"enquiry_from": "quotation_to",
|
||||
"opportunity_from": "quotation_to",
|
||||
"opportunity_type": "order_type",
|
||||
"name": "enq_no",
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
frappe.listview_settings['Opportunity'] = {
|
||||
add_fields: ["customer_name", "opportunity_type", "enquiry_from", "status"],
|
||||
add_fields: ["customer_name", "opportunity_type", "opportunity_from", "status"],
|
||||
get_indicator: function(doc) {
|
||||
var indicator = [__(doc.status), frappe.utils.guess_colour(doc.status), "status,=," + doc.status];
|
||||
if(doc.status=="Quotation") {
|
||||
|
||||
@@ -6,7 +6,7 @@ QUnit.test("test: opportunity", function (assert) {
|
||||
() => frappe.timeout(1),
|
||||
() => frappe.click_button('New'),
|
||||
() => frappe.timeout(1),
|
||||
() => cur_frm.set_value('enquiry_from', 'Customer'),
|
||||
() => cur_frm.set_value('opportunity_from', 'Customer'),
|
||||
() => cur_frm.set_value('customer', 'Test Customer 1'),
|
||||
|
||||
// check items
|
||||
|
||||
@@ -37,13 +37,13 @@ class TestOpportunity(unittest.TestCase):
|
||||
# new lead should be created against the new.opportunity@example.com
|
||||
opp_doc = frappe.get_doc(args).insert(ignore_permissions=True)
|
||||
|
||||
self.assertTrue(opp_doc.lead)
|
||||
self.assertEqual(opp_doc.enquiry_from, "Lead")
|
||||
self.assertEqual(frappe.db.get_value("Lead", opp_doc.lead, "email_id"),
|
||||
self.assertTrue(opp_doc.party_name)
|
||||
self.assertEqual(opp_doc.opportunity_from, "Lead")
|
||||
self.assertEqual(frappe.db.get_value("Lead", opp_doc.party_name, "email_id"),
|
||||
'new.opportunity@example.com')
|
||||
|
||||
# create new customer and create new contact against 'new.opportunity@example.com'
|
||||
customer = make_customer(opp_doc.lead).insert(ignore_permissions=True)
|
||||
customer = make_customer(opp_doc.party_name).insert(ignore_permissions=True)
|
||||
frappe.get_doc({
|
||||
"doctype": "Contact",
|
||||
"email_id": "new.opportunity@example.com",
|
||||
@@ -55,9 +55,9 @@ class TestOpportunity(unittest.TestCase):
|
||||
}).insert(ignore_permissions=True)
|
||||
|
||||
opp_doc = frappe.get_doc(args).insert(ignore_permissions=True)
|
||||
self.assertTrue(opp_doc.customer)
|
||||
self.assertEqual(opp_doc.enquiry_from, "Customer")
|
||||
self.assertEqual(opp_doc.customer, customer.name)
|
||||
self.assertTrue(opp_doc.party_name)
|
||||
self.assertEqual(opp_doc.opportunity_from, "Customer")
|
||||
self.assertEqual(opp_doc.party_name, customer.name)
|
||||
|
||||
def make_opportunity(**args):
|
||||
args = frappe._dict(args)
|
||||
@@ -65,17 +65,17 @@ def make_opportunity(**args):
|
||||
opp_doc = frappe.get_doc({
|
||||
"doctype": "Opportunity",
|
||||
"company": args.company or "_Test Company",
|
||||
"enquiry_from": args.enquiry_from or "Customer",
|
||||
"opportunity_from": args.opportunity_from or "Customer",
|
||||
"opportunity_type": "Sales",
|
||||
"with_items": args.with_items or 0,
|
||||
"transaction_date": today()
|
||||
})
|
||||
|
||||
if opp_doc.enquiry_from == 'Customer':
|
||||
opp_doc.customer = args.customer or "_Test Customer"
|
||||
if opp_doc.opportunity_from == 'Customer':
|
||||
opp_doc.party_name= args.customer or "_Test Customer"
|
||||
|
||||
if opp_doc.enquiry_from == 'Lead':
|
||||
opp_doc.customer = args.lead or "_T-Lead-00001"
|
||||
if opp_doc.opportunity_from == 'Lead':
|
||||
opp_doc.party_name = args.lead or "_T-Lead-00001"
|
||||
|
||||
if args.with_items:
|
||||
opp_doc.append('items', {
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
{
|
||||
"doctype": "Opportunity",
|
||||
"name": "_Test Opportunity 1",
|
||||
"enquiry_from": "Lead",
|
||||
"opportunity_from": "Lead",
|
||||
"enquiry_type": "Sales",
|
||||
"lead": "_T-Lead-00001",
|
||||
"party_name": "_T-Lead-00001",
|
||||
"transaction_date": "2013-12-12",
|
||||
"items": [{
|
||||
"item_name": "Test Item",
|
||||
|
||||
@@ -66,7 +66,7 @@ def get_columns():
|
||||
def get_communication_details(filters):
|
||||
communication_count = None
|
||||
communication_list = []
|
||||
opportunities = frappe.db.get_values('Opportunity', {'enquiry_from': 'Lead'},\
|
||||
opportunities = frappe.db.get_values('Opportunity', {'opportunity_from': 'Lead'},\
|
||||
['name', 'customer_name', 'lead', 'contact_email'], as_dict=1)
|
||||
|
||||
for d in opportunities:
|
||||
|
||||
@@ -56,7 +56,7 @@ def work(domain="Manufacturing"):
|
||||
def make_opportunity(domain):
|
||||
b = frappe.get_doc({
|
||||
"doctype": "Opportunity",
|
||||
"enquiry_from": "Customer",
|
||||
"opportunity_from": "Customer",
|
||||
"customer": get_random("Customer"),
|
||||
"opportunity_type": "Sales",
|
||||
"with_items": 1,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"allow_copy": 0,
|
||||
"allow_events_in_timeline": 0,
|
||||
"allow_guest_to_view": 0,
|
||||
"allow_import": 1,
|
||||
"allow_rename": 1,
|
||||
@@ -20,6 +21,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "max_amount",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
@@ -29,7 +31,7 @@
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Max Amount",
|
||||
"label": "Max Exemption Amount",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
@@ -39,7 +41,7 @@
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 1,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
@@ -52,6 +54,8 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"default": "1",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "is_active",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 0,
|
||||
@@ -88,7 +92,7 @@
|
||||
"issingle": 0,
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2018-06-19 16:33:48.419267",
|
||||
"modified": "2019-04-25 13:20:31.367158",
|
||||
"modified_by": "Administrator",
|
||||
"module": "HR",
|
||||
"name": "Employee Tax Exemption Category",
|
||||
@@ -159,6 +163,7 @@
|
||||
"show_name_in_global_search": 0,
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"track_changes": 1,
|
||||
"track_seen": 0
|
||||
"track_changes": 0,
|
||||
"track_seen": 0,
|
||||
"track_views": 0
|
||||
}
|
||||
@@ -10,6 +10,7 @@ frappe.ui.form.on('Employee Tax Exemption Declaration', {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
frm.set_query('payroll_period', function() {
|
||||
const fields = {'employee': 'Employee', 'company': 'Company'};
|
||||
|
||||
@@ -27,6 +28,7 @@ frappe.ui.form.on('Employee Tax Exemption Declaration', {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
frm.set_query('exemption_sub_category', 'declarations', function() {
|
||||
return {
|
||||
filters: {
|
||||
@@ -34,5 +36,16 @@ frappe.ui.form.on('Employee Tax Exemption Declaration', {
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
refresh: function(frm) {
|
||||
if(frm.doc.docstatus==1) {
|
||||
frm.add_custom_button(__('Submit Proof'), function() {
|
||||
frappe.model.open_mapped_doc({
|
||||
method: "erpnext.hr.doctype.employee_tax_exemption_declaration.employee_tax_exemption_declaration.make_proof_submission",
|
||||
frm: frm
|
||||
});
|
||||
}).addClass("btn-primary");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -55,9 +55,43 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_from": "employee.company",
|
||||
"fetch_from": "employee.employee_name",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "company",
|
||||
"fieldname": "employee_name",
|
||||
"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": "Employee Name",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"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_from": "employee.department",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "department",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
@@ -66,15 +100,15 @@
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Company",
|
||||
"label": "Department",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "Company",
|
||||
"options": "Department",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"read_only": 1,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
@@ -156,42 +190,9 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_from": "employee.company",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "total_exemption_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": "Total Exemption Amount",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"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_from": "employee.department",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "department",
|
||||
"fieldname": "company",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
@@ -200,15 +201,15 @@
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Department",
|
||||
"label": "Company",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "Department",
|
||||
"options": "Company",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 1,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
@@ -315,6 +316,136 @@
|
||||
"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_10",
|
||||
"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,
|
||||
"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": "total_declared_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": "Total Declared Amount",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"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": "column_break_12",
|
||||
"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": "total_exemption_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": "Total Exemption Amount",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"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
|
||||
}
|
||||
],
|
||||
"has_web_view": 0,
|
||||
@@ -327,7 +458,7 @@
|
||||
"issingle": 0,
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2019-04-23 15:50:48.693555",
|
||||
"modified": "2019-04-25 16:38:05.847925",
|
||||
"modified_by": "Administrator",
|
||||
"module": "HR",
|
||||
"name": "Employee Tax Exemption Declaration",
|
||||
|
||||
@@ -6,28 +6,61 @@ from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
from frappe import _
|
||||
from erpnext.hr.utils import validate_tax_declaration, calculate_annual_eligible_hra_exemption
|
||||
from frappe.utils import flt
|
||||
from frappe.model.mapper import get_mapped_doc
|
||||
from erpnext.hr.utils import validate_tax_declaration, get_total_exemption_amount, calculate_annual_eligible_hra_exemption
|
||||
|
||||
class DuplicateDeclarationError(frappe.ValidationError): pass
|
||||
|
||||
class EmployeeTaxExemptionDeclaration(Document):
|
||||
def validate(self):
|
||||
validate_tax_declaration(self.declarations)
|
||||
self.total_exemption_amount = 0
|
||||
self.validate_duplicate()
|
||||
self.set_total_declared_amount()
|
||||
self.set_total_exemption_amount()
|
||||
self.calculate_hra_exemption()
|
||||
for item in self.declarations:
|
||||
self.total_exemption_amount += item.amount
|
||||
|
||||
def before_submit(self):
|
||||
if frappe.db.exists({"doctype": "Employee Tax Exemption Declaration",
|
||||
"employee": self.employee,
|
||||
"payroll_period": self.payroll_period,
|
||||
"docstatus": 1}):
|
||||
frappe.throw(_("Tax Declaration of {0} for period {1} already submitted.")\
|
||||
.format(self.employee, self.payroll_period), frappe.DocstatusTransitionError)
|
||||
def validate_duplicate(self):
|
||||
duplicate = frappe.db.get_value("Employee Tax Exemption Declaration",
|
||||
filters = {
|
||||
"employee": self.employee,
|
||||
"payroll_period": self.payroll_period,
|
||||
"name": ["!=", self.name]
|
||||
}
|
||||
)
|
||||
if duplicate:
|
||||
frappe.throw(_("Duplicate Tax Declaration of {0} for period {1}")
|
||||
.format(self.employee, self.payroll_period), DuplicateDeclarationError)
|
||||
|
||||
def set_total_declared_amount(self):
|
||||
self.total_declared_amount = 0.0
|
||||
for d in self.declarations:
|
||||
self.total_declared_amount += flt(d.amount)
|
||||
|
||||
def set_total_exemption_amount(self):
|
||||
self.total_exemption_amount = get_total_exemption_amount(self.declarations)
|
||||
|
||||
def calculate_hra_exemption(self):
|
||||
hra_exemption = calculate_annual_eligible_hra_exemption(self)
|
||||
if hra_exemption:
|
||||
self.total_exemption_amount += hra_exemption["annual_exemption"]
|
||||
self.salary_structure_hra = hra_exemption["hra_amount"]
|
||||
self.annual_hra_exemption = hra_exemption["annual_exemption"]
|
||||
self.monthly_hra_exemption = hra_exemption["monthly_exemption"]
|
||||
self.salary_structure_hra, self.annual_hra_exemption, self.monthly_hra_exemption = 0, 0, 0
|
||||
if self.get("monthly_house_rent"):
|
||||
hra_exemption = calculate_annual_eligible_hra_exemption(self)
|
||||
if hra_exemption:
|
||||
self.total_exemption_amount += hra_exemption["annual_exemption"]
|
||||
self.salary_structure_hra = hra_exemption["hra_amount"]
|
||||
self.annual_hra_exemption = hra_exemption["annual_exemption"]
|
||||
self.monthly_hra_exemption = hra_exemption["monthly_exemption"]
|
||||
|
||||
@frappe.whitelist()
|
||||
def make_proof_submission(source_name, target_doc=None):
|
||||
doclist = get_mapped_doc("Employee Tax Exemption Declaration", source_name, {
|
||||
"Employee Tax Exemption Declaration": {
|
||||
"doctype": "Employee Tax Exemption Proof Submission",
|
||||
"field_no_map": ["monthly_house_rent", "monthly_hra_exemption"]
|
||||
},
|
||||
"Employee Tax Exemption Declaration Category": {
|
||||
"doctype": "Employee Tax Exemption Proof Submission Detail",
|
||||
"add_if_empty": True
|
||||
}
|
||||
}, target_doc)
|
||||
|
||||
return doclist
|
||||
|
||||
@@ -6,6 +6,7 @@ from __future__ import unicode_literals
|
||||
import frappe, erpnext
|
||||
import unittest
|
||||
from erpnext.hr.doctype.employee.test_employee import make_employee
|
||||
from erpnext.hr.doctype.employee_tax_exemption_declaration.employee_tax_exemption_declaration import DuplicateDeclarationError
|
||||
|
||||
class TestEmployeeTaxExemptionDeclaration(unittest.TestCase):
|
||||
def setUp(self):
|
||||
@@ -15,71 +16,71 @@ class TestEmployeeTaxExemptionDeclaration(unittest.TestCase):
|
||||
create_exemption_category()
|
||||
frappe.db.sql("""delete from `tabEmployee Tax Exemption Declaration`""")
|
||||
|
||||
def test_exemption_amount_greater_than_category_max(self):
|
||||
declaration = frappe.get_doc({
|
||||
"doctype": "Employee Tax Exemption Declaration",
|
||||
"employee": frappe.get_value("Employee", {"user_id":"employee@taxexepmtion.com"}, "name"),
|
||||
"payroll_period": "_Test Payroll Period",
|
||||
"declarations": [dict(exemption_sub_category = "_Test Sub Category",
|
||||
exemption_category = "_Test Category",
|
||||
amount = 150000)]
|
||||
})
|
||||
self.assertRaises(frappe.ValidationError, declaration.save)
|
||||
declaration = frappe.get_doc({
|
||||
"doctype": "Employee Tax Exemption Declaration",
|
||||
"payroll_period": "_Test Payroll Period",
|
||||
"employee": frappe.get_value("Employee", {"user_id":"employee@taxexepmtion.com"}, "name"),
|
||||
"declarations": [dict(exemption_sub_category = "_Test Sub Category",
|
||||
exemption_category = "_Test Category",
|
||||
amount = 90000)]
|
||||
})
|
||||
self.assertTrue(declaration.save)
|
||||
|
||||
def test_duplicate_category_in_declaration(self):
|
||||
declaration = frappe.get_doc({
|
||||
"doctype": "Employee Tax Exemption Declaration",
|
||||
"employee": frappe.get_value("Employee", {"user_id":"employee@taxexepmtion.com"}, "name"),
|
||||
"company": erpnext.get_default_company(),
|
||||
"payroll_period": "_Test Payroll Period",
|
||||
"declarations": [dict(exemption_sub_category = "_Test Sub Category",
|
||||
exemption_category = "_Test Category",
|
||||
amount = 100000),
|
||||
dict(exemption_sub_category = "_Test Sub Category",
|
||||
exemption_category = "_Test Category",
|
||||
amount = 50000),
|
||||
]
|
||||
"declarations": [
|
||||
dict(exemption_sub_category = "_Test Sub Category",
|
||||
exemption_category = "_Test Category",
|
||||
amount = 100000),
|
||||
dict(exemption_sub_category = "_Test Sub Category",
|
||||
exemption_category = "_Test Category",
|
||||
amount = 50000)
|
||||
]
|
||||
})
|
||||
self.assertRaises(frappe.ValidationError, declaration.save)
|
||||
|
||||
def test_duplicate_submission_for_payroll_period(self):
|
||||
def test_duplicate_entry_for_payroll_period(self):
|
||||
declaration = frappe.get_doc({
|
||||
"doctype": "Employee Tax Exemption Declaration",
|
||||
"employee": frappe.get_value("Employee", {"user_id":"employee@taxexepmtion.com"}, "name"),
|
||||
"company": erpnext.get_default_company(),
|
||||
"payroll_period": "_Test Payroll Period",
|
||||
"declarations": [dict(exemption_sub_category = "_Test Sub Category",
|
||||
exemption_category = "_Test Category",
|
||||
amount = 100000),
|
||||
dict(exemption_sub_category = "_Test1 Sub Category",
|
||||
exemption_category = "_Test Category",
|
||||
amount = 50000),
|
||||
]
|
||||
"declarations": [
|
||||
dict(exemption_sub_category = "_Test Sub Category",
|
||||
exemption_category = "_Test Category",
|
||||
amount = 100000),
|
||||
dict(exemption_sub_category = "_Test1 Sub Category",
|
||||
exemption_category = "_Test Category",
|
||||
amount = 50000),
|
||||
]
|
||||
}).insert()
|
||||
declaration.submit()
|
||||
self.assertEquals(declaration.docstatus, 1)
|
||||
|
||||
duplicate_declaration = frappe.get_doc({
|
||||
"doctype": "Employee Tax Exemption Declaration",
|
||||
"employee": frappe.get_value("Employee", {"user_id":"employee@taxexepmtion.com"}, "name"),
|
||||
"company": erpnext.get_default_company(),
|
||||
"payroll_period": "_Test Payroll Period",
|
||||
"declarations": [dict(exemption_sub_category = "_Test Sub Category",
|
||||
exemption_category = "_Test Category",
|
||||
amount = 100000)
|
||||
]
|
||||
}).insert()
|
||||
self.assertRaises(frappe.DocstatusTransitionError, duplicate_declaration.submit)
|
||||
"declarations": [
|
||||
dict(exemption_sub_category = "_Test Sub Category",
|
||||
exemption_category = "_Test Category",
|
||||
amount = 100000)
|
||||
]
|
||||
})
|
||||
self.assertRaises(DuplicateDeclarationError, duplicate_declaration.insert)
|
||||
duplicate_declaration.employee = frappe.get_value("Employee", {"user_id":"employee1@taxexepmtion.com"}, "name")
|
||||
self.assertTrue(duplicate_declaration.submit)
|
||||
self.assertTrue(duplicate_declaration.insert)
|
||||
|
||||
def test_exemption_amount(self):
|
||||
declaration = frappe.get_doc({
|
||||
"doctype": "Employee Tax Exemption Declaration",
|
||||
"employee": frappe.get_value("Employee", {"user_id":"employee@taxexepmtion.com"}, "name"),
|
||||
"company": erpnext.get_default_company(),
|
||||
"payroll_period": "_Test Payroll Period",
|
||||
"declarations": [
|
||||
dict(exemption_sub_category = "_Test Sub Category",
|
||||
exemption_category = "_Test Category",
|
||||
amount = 80000),
|
||||
dict(exemption_sub_category = "_Test1 Sub Category",
|
||||
exemption_category = "_Test Category",
|
||||
amount = 60000),
|
||||
]
|
||||
}).insert()
|
||||
|
||||
self.assertEqual(declaration.total_exemption_amount, 100000)
|
||||
|
||||
def create_payroll_period():
|
||||
if not frappe.db.exists("Payroll Period", "_Test Payroll Period"):
|
||||
|
||||
@@ -1,140 +1,179 @@
|
||||
{
|
||||
"allow_copy": 0,
|
||||
"allow_guest_to_view": 0,
|
||||
"allow_import": 0,
|
||||
"allow_rename": 0,
|
||||
"beta": 0,
|
||||
"creation": "2018-04-13 16:56:23.333041",
|
||||
"custom": 0,
|
||||
"docstatus": 0,
|
||||
"doctype": "DocType",
|
||||
"document_type": "",
|
||||
"editable_grid": 1,
|
||||
"engine": "InnoDB",
|
||||
"allow_copy": 0,
|
||||
"allow_events_in_timeline": 0,
|
||||
"allow_guest_to_view": 0,
|
||||
"allow_import": 0,
|
||||
"allow_rename": 0,
|
||||
"beta": 0,
|
||||
"creation": "2018-04-13 16:56:23.333041",
|
||||
"custom": 0,
|
||||
"docstatus": 0,
|
||||
"doctype": "DocType",
|
||||
"document_type": "",
|
||||
"editable_grid": 1,
|
||||
"engine": "InnoDB",
|
||||
"fields": [
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "exemption_sub_category",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Exemption Sub Category",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "Employee Tax Exemption Sub Category",
|
||||
"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,
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "exemption_sub_category",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Exemption Sub Category",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "Employee Tax Exemption Sub Category",
|
||||
"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,
|
||||
"fetch_from": "exemption_sub_category.exemption_category",
|
||||
"fieldname": "exemption_category",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Exemption Category",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "Employee Tax Exemption Category",
|
||||
"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,
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_from": "exemption_sub_category.exemption_category",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "exemption_category",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Exemption Category",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "Employee Tax Exemption Category",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 1,
|
||||
"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,
|
||||
"fieldname": "amount",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 0,
|
||||
"label": "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": 1,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_from": "exemption_sub_category.max_amount",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "max_amount",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Maximum Exemption Amount",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 1,
|
||||
"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": "amount",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Declared 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": 1,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
}
|
||||
],
|
||||
"has_web_view": 0,
|
||||
"hide_heading": 0,
|
||||
"hide_toolbar": 0,
|
||||
"idx": 0,
|
||||
"image_view": 0,
|
||||
"in_create": 0,
|
||||
"is_submittable": 0,
|
||||
"issingle": 0,
|
||||
"istable": 1,
|
||||
"max_attachments": 0,
|
||||
"modified": "2018-05-29 15:58:05.779031",
|
||||
"modified_by": "Administrator",
|
||||
"module": "HR",
|
||||
"name": "Employee Tax Exemption Declaration Category",
|
||||
"name_case": "",
|
||||
"owner": "Administrator",
|
||||
"permissions": [],
|
||||
"quick_entry": 1,
|
||||
"read_only": 0,
|
||||
"read_only_onload": 0,
|
||||
"show_name_in_global_search": 0,
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"track_changes": 1,
|
||||
"track_seen": 0
|
||||
],
|
||||
"has_web_view": 0,
|
||||
"hide_heading": 0,
|
||||
"hide_toolbar": 0,
|
||||
"idx": 0,
|
||||
"image_view": 0,
|
||||
"in_create": 0,
|
||||
"is_submittable": 0,
|
||||
"issingle": 0,
|
||||
"istable": 1,
|
||||
"max_attachments": 0,
|
||||
"modified": "2019-04-25 15:45:11.279158",
|
||||
"modified_by": "Administrator",
|
||||
"module": "HR",
|
||||
"name": "Employee Tax Exemption Declaration Category",
|
||||
"name_case": "",
|
||||
"owner": "Administrator",
|
||||
"permissions": [],
|
||||
"quick_entry": 1,
|
||||
"read_only": 0,
|
||||
"read_only_onload": 0,
|
||||
"show_name_in_global_search": 0,
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"track_changes": 1,
|
||||
"track_seen": 0,
|
||||
"track_views": 0
|
||||
}
|
||||
@@ -10,6 +10,7 @@ frappe.ui.form.on('Employee Tax Exemption Proof Submission', {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
frm.set_query('payroll_period', function() {
|
||||
if(frm.doc.employee && frm.doc.company){
|
||||
return {
|
||||
@@ -21,6 +22,7 @@ frappe.ui.form.on('Employee Tax Exemption Proof Submission', {
|
||||
frappe.msgprint(__("Please select Employee"));
|
||||
}
|
||||
});
|
||||
|
||||
frm.set_query('exemption_sub_category', 'tax_exemption_proofs', function() {
|
||||
return {
|
||||
filters: {
|
||||
@@ -29,11 +31,28 @@ frappe.ui.form.on('Employee Tax Exemption Proof Submission', {
|
||||
}
|
||||
});
|
||||
},
|
||||
employee: function(frm){
|
||||
if(frm.doc.employee){
|
||||
frm.add_fetch('employee', 'company', 'company');
|
||||
}else{
|
||||
frm.set_value('company', '');
|
||||
|
||||
refresh: function(frm) {
|
||||
if(frm.doc.docstatus === 0) {
|
||||
let filters = {
|
||||
docstatus: 1,
|
||||
company: frm.doc.company
|
||||
};
|
||||
if(frm.doc.employee) filters["employee"] = frm.doc.employee;
|
||||
if(frm.doc.payroll_period) filters["payroll_period"] = frm.doc.payroll_period;
|
||||
|
||||
frm.add_custom_button(__('Get Details From Declaration'), function() {
|
||||
erpnext.utils.map_current_doc({
|
||||
method: "erpnext.hr.doctype.employee_tax_exemption_declaration.employee_tax_exemption_declaration.make_proof_submission",
|
||||
source_doctype: "Employee Tax Exemption Declaration",
|
||||
target: frm,
|
||||
date_field: "creation",
|
||||
setters: {
|
||||
employee: frm.doc.employee || undefined
|
||||
},
|
||||
get_query_filters: filters
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
{
|
||||
"allow_copy": 0,
|
||||
"allow_events_in_timeline": 0,
|
||||
"allow_guest_to_view": 0,
|
||||
"allow_import": 0,
|
||||
"allow_rename": 0,
|
||||
"allow_import": 1,
|
||||
"allow_rename": 1,
|
||||
"autoname": "HR-TAX-PRF-.YYYY.-.#####",
|
||||
"beta": 0,
|
||||
"creation": "2018-04-13 17:24:11.456132",
|
||||
@@ -20,6 +21,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "employee",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -53,8 +55,10 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "company",
|
||||
"fieldtype": "Link",
|
||||
"fetch_from": "employee.employee_name",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "employee_name",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
@@ -62,10 +66,9 @@
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Company",
|
||||
"label": "Employee Name",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "Company",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
@@ -79,70 +82,6 @@
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "column_break_2",
|
||||
"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,
|
||||
"fieldname": "payroll_period",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Payroll Period",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "Payroll Period",
|
||||
"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,
|
||||
@@ -151,6 +90,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_from": "employee.department",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "department",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -184,8 +124,9 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "submission_date",
|
||||
"fieldtype": "Date",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "column_break_2",
|
||||
"fieldtype": "Column Break",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
@@ -193,7 +134,6 @@
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Submission Date",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
@@ -216,6 +156,273 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"default": "Today",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "submission_date",
|
||||
"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": "Submission Date",
|
||||
"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": 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": "payroll_period",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Payroll Period",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "Payroll Period",
|
||||
"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,
|
||||
"fetch_from": "employee.company",
|
||||
"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,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 1,
|
||||
"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": "section_break_5",
|
||||
"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,
|
||||
"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": "tax_exemption_proofs",
|
||||
"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": "Tax Exemption Proofs",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "Employee Tax Exemption Proof Submission Detail",
|
||||
"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_10",
|
||||
"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,
|
||||
"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": "total_actual_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": "Total Actual Amount",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"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": "column_break_12",
|
||||
"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": "exemption_amount",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
@@ -248,70 +455,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "section_break_5",
|
||||
"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,
|
||||
"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,
|
||||
"fieldname": "tax_exemption_proofs",
|
||||
"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": "Tax Exemption Proofs",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "Employee Tax Exemption Proof Submission Detail",
|
||||
"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,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "attachment_section",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@@ -344,6 +488,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "attachments",
|
||||
"fieldtype": "Attach",
|
||||
"hidden": 0,
|
||||
@@ -376,6 +521,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "amended_from",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -412,7 +558,7 @@
|
||||
"issingle": 0,
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2018-08-21 16:15:38.096846",
|
||||
"modified": "2019-04-25 17:06:36.569549",
|
||||
"modified_by": "Administrator",
|
||||
"module": "HR",
|
||||
"name": "Employee Tax Exemption Proof Submission",
|
||||
|
||||
@@ -6,20 +6,30 @@ from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
from frappe import _
|
||||
from erpnext.hr.utils import validate_tax_declaration, calculate_hra_exemption_for_period
|
||||
from frappe.utils import flt
|
||||
from erpnext.hr.utils import validate_tax_declaration, get_total_exemption_amount, calculate_hra_exemption_for_period
|
||||
|
||||
class EmployeeTaxExemptionProofSubmission(Document):
|
||||
def validate(self):
|
||||
validate_tax_declaration(self.tax_exemption_proofs)
|
||||
self.exemption_amount = 0
|
||||
self.set_total_actual_amount()
|
||||
self.set_total_exemption_amount()
|
||||
self.calculate_hra_exemption()
|
||||
for proof in self.tax_exemption_proofs:
|
||||
self.exemption_amount += proof.amount
|
||||
|
||||
def set_total_actual_amount(self):
|
||||
self.total_actual_amount = flt(self.get("house_rent_payment_amount"))
|
||||
for d in self.tax_exemption_proofs:
|
||||
self.total_actual_amount += flt(d.amount)
|
||||
|
||||
def set_total_exemption_amount(self):
|
||||
self.exemption_amount = get_total_exemption_amount(self.tax_exemption_proofs)
|
||||
|
||||
def calculate_hra_exemption(self):
|
||||
hra_exemption = calculate_hra_exemption_for_period(self)
|
||||
if hra_exemption:
|
||||
self.exemption_amount += hra_exemption["total_eligible_hra_exemption"]
|
||||
self.monthly_hra_exemption = hra_exemption["monthly_exemption"]
|
||||
self.monthly_house_rent = hra_exemption["monthly_house_rent"]
|
||||
self.total_eligible_hra_exemption = hra_exemption["total_eligible_hra_exemption"]
|
||||
self.monthly_hra_exemption, self.monthly_house_rent, self.total_eligible_hra_exemption = 0, 0, 0
|
||||
if self.get("house_rent_payment_amount"):
|
||||
hra_exemption = calculate_hra_exemption_for_period(self)
|
||||
if hra_exemption:
|
||||
self.exemption_amount += hra_exemption["total_eligible_hra_exemption"]
|
||||
self.monthly_hra_exemption = hra_exemption["monthly_exemption"]
|
||||
self.monthly_house_rent = hra_exemption["monthly_house_rent"]
|
||||
self.total_eligible_hra_exemption = hra_exemption["total_eligible_hra_exemption"]
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"allow_copy": 0,
|
||||
"allow_events_in_timeline": 0,
|
||||
"allow_guest_to_view": 0,
|
||||
"allow_import": 0,
|
||||
"allow_rename": 0,
|
||||
@@ -14,10 +15,12 @@
|
||||
"fields": [
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "exemption_sub_category",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -41,16 +44,18 @@
|
||||
"reqd": 1,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 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_from": "exemption_sub_category.exemption_category",
|
||||
"fetch_from": "exemption_sub_category.exemption_category",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "exemption_category",
|
||||
"fieldtype": "Read Only",
|
||||
"hidden": 0,
|
||||
@@ -74,15 +79,51 @@
|
||||
"reqd": 1,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 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_from": "exemption_sub_category.max_amount",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "max_amount",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Maximum Exemption Amount",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 1,
|
||||
"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": "type_of_proof",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
@@ -106,15 +147,17 @@
|
||||
"reqd": 1,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 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": "amount",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
@@ -124,7 +167,7 @@
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Amount",
|
||||
"label": "Actual Amount",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
@@ -134,10 +177,10 @@
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 1,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
}
|
||||
],
|
||||
@@ -151,7 +194,7 @@
|
||||
"issingle": 0,
|
||||
"istable": 1,
|
||||
"max_attachments": 0,
|
||||
"modified": "2018-05-16 22:42:59.750733",
|
||||
"modified": "2019-04-25 15:45:03.154904",
|
||||
"modified_by": "Administrator",
|
||||
"module": "HR",
|
||||
"name": "Employee Tax Exemption Proof Submission Detail",
|
||||
@@ -165,5 +208,6 @@
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"track_changes": 1,
|
||||
"track_seen": 0
|
||||
"track_seen": 0,
|
||||
"track_views": 0
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"allow_copy": 0,
|
||||
"allow_events_in_timeline": 0,
|
||||
"allow_guest_to_view": 0,
|
||||
"allow_import": 1,
|
||||
"allow_rename": 1,
|
||||
@@ -15,10 +16,12 @@
|
||||
"fields": [
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "exemption_category",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -26,8 +29,8 @@
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 1,
|
||||
"label": "Tax Exemption Category",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
@@ -42,14 +45,18 @@
|
||||
"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_from": "exemption_category.max_amount",
|
||||
"fetch_if_empty": 1,
|
||||
"fieldname": "max_amount",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
@@ -59,7 +66,7 @@
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Max Amount",
|
||||
"label": "Max Exemption Amount",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
@@ -69,17 +76,21 @@
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 1,
|
||||
"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": "1",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "is_active",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 0,
|
||||
@@ -102,6 +113,7 @@
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
}
|
||||
],
|
||||
@@ -115,7 +127,7 @@
|
||||
"issingle": 0,
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2018-05-09 13:25:01.595240",
|
||||
"modified": "2019-04-25 13:24:05.164877",
|
||||
"modified_by": "Administrator",
|
||||
"module": "HR",
|
||||
"name": "Employee Tax Exemption Sub Category",
|
||||
@@ -124,7 +136,6 @@
|
||||
"permissions": [
|
||||
{
|
||||
"amend": 0,
|
||||
"apply_user_permissions": 0,
|
||||
"cancel": 0,
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
@@ -144,7 +155,6 @@
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"apply_user_permissions": 0,
|
||||
"cancel": 0,
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
@@ -164,7 +174,6 @@
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"apply_user_permissions": 0,
|
||||
"cancel": 0,
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
@@ -189,6 +198,7 @@
|
||||
"show_name_in_global_search": 0,
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"track_changes": 1,
|
||||
"track_seen": 0
|
||||
"track_changes": 0,
|
||||
"track_seen": 0,
|
||||
"track_views": 0
|
||||
}
|
||||
@@ -4,7 +4,13 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe.utils import flt
|
||||
from frappe.model.document import Document
|
||||
|
||||
class EmployeeTaxExemptionSubCategory(Document):
|
||||
pass
|
||||
def validate(self):
|
||||
category_max_amount = frappe.db.get_value("Employee Tax Exemption Category", self.exemption_category, "max_amount")
|
||||
if flt(self.max_amount) > flt(category_max_amount):
|
||||
frappe.throw(_("Max Exemption Amount cannot be greater than maximum exemption amount {0} of Tax Exemption Category {1}")
|
||||
.format(category_max_amount, self.exemption_category))
|
||||
@@ -13,7 +13,8 @@ from frappe.utils import getdate, nowdate, add_days, add_months, flt, get_first_
|
||||
from erpnext.hr.doctype.salary_structure.salary_structure import make_salary_slip
|
||||
from erpnext.hr.doctype.payroll_entry.payroll_entry import get_month_details
|
||||
from erpnext.hr.doctype.employee.test_employee import make_employee
|
||||
from erpnext.hr.doctype.employee_tax_exemption_declaration.test_employee_tax_exemption_declaration import create_payroll_period, create_exemption_category
|
||||
from erpnext.hr.doctype.employee_tax_exemption_declaration.test_employee_tax_exemption_declaration \
|
||||
import create_payroll_period, create_exemption_category
|
||||
|
||||
class TestSalarySlip(unittest.TestCase):
|
||||
def setUp(self):
|
||||
@@ -36,8 +37,10 @@ class TestSalarySlip(unittest.TestCase):
|
||||
no_of_days = self.get_no_of_days()
|
||||
frappe.db.set_value("HR Settings", None, "include_holidays_in_total_working_days", 1)
|
||||
make_employee("test_employee@salary.com")
|
||||
frappe.db.set_value("Employee", frappe.get_value("Employee", {"employee_name":"test_employee@salary.com"}, "name"), "relieving_date", None)
|
||||
frappe.db.set_value("Employee", frappe.get_value("Employee", {"employee_name":"test_employee@salary.com"}, "name"), "status", "Active")
|
||||
frappe.db.set_value("Employee", frappe.get_value("Employee",
|
||||
{"employee_name":"test_employee@salary.com"}, "name"), "relieving_date", None)
|
||||
frappe.db.set_value("Employee", frappe.get_value("Employee",
|
||||
{"employee_name":"test_employee@salary.com"}, "name"), "status", "Active")
|
||||
ss = make_employee_salary_slip("test_employee@salary.com", "Monthly")
|
||||
|
||||
self.assertEqual(ss.total_working_days, no_of_days[0])
|
||||
@@ -53,8 +56,10 @@ class TestSalarySlip(unittest.TestCase):
|
||||
no_of_days = self.get_no_of_days()
|
||||
frappe.db.set_value("HR Settings", None, "include_holidays_in_total_working_days", 0)
|
||||
make_employee("test_employee@salary.com")
|
||||
frappe.db.set_value("Employee", frappe.get_value("Employee", {"employee_name":"test_employee@salary.com"}, "name"), "relieving_date", None)
|
||||
frappe.db.set_value("Employee", frappe.get_value("Employee", {"employee_name":"test_employee@salary.com"}, "name"), "status", "Active")
|
||||
frappe.db.set_value("Employee", frappe.get_value("Employee",
|
||||
{"employee_name":"test_employee@salary.com"}, "name"), "relieving_date", None)
|
||||
frappe.db.set_value("Employee", frappe.get_value("Employee",
|
||||
{"employee_name":"test_employee@salary.com"}, "name"), "status", "Active")
|
||||
ss = make_employee_salary_slip("test_employee@salary.com", "Monthly")
|
||||
|
||||
self.assertEqual(ss.total_working_days, no_of_days[0] - no_of_days[1])
|
||||
@@ -100,16 +105,21 @@ class TestSalarySlip(unittest.TestCase):
|
||||
self.assertEqual(ss.payment_days, (no_of_days[0] - getdate(date_of_joining).day + 1))
|
||||
|
||||
# set relieving date in the same month
|
||||
frappe.db.set_value("Employee", frappe.get_value("Employee", {"employee_name":"test_employee@salary.com"}, "name"), "date_of_joining", (add_days(nowdate(),-60)))
|
||||
frappe.db.set_value("Employee", frappe.get_value("Employee", {"employee_name":"test_employee@salary.com"}, "name"), "relieving_date", relieving_date)
|
||||
frappe.db.set_value("Employee", frappe.get_value("Employee", {"employee_name":"test_employee@salary.com"}, "name"), "status", "Left")
|
||||
frappe.db.set_value("Employee",frappe.get_value("Employee",
|
||||
{"employee_name":"test_employee@salary.com"}, "name"), "date_of_joining", (add_days(nowdate(),-60)))
|
||||
frappe.db.set_value("Employee", frappe.get_value("Employee",
|
||||
{"employee_name":"test_employee@salary.com"}, "name"), "relieving_date", relieving_date)
|
||||
frappe.db.set_value("Employee", frappe.get_value("Employee",
|
||||
{"employee_name":"test_employee@salary.com"}, "name"), "status", "Left")
|
||||
ss.save()
|
||||
|
||||
self.assertEqual(ss.total_working_days, no_of_days[0])
|
||||
self.assertEqual(ss.payment_days, getdate(relieving_date).day)
|
||||
|
||||
frappe.db.set_value("Employee", frappe.get_value("Employee", {"employee_name":"test_employee@salary.com"}, "name"), "relieving_date", None)
|
||||
frappe.db.set_value("Employee", frappe.get_value("Employee", {"employee_name":"test_employee@salary.com"}, "name"), "status", "Active")
|
||||
frappe.db.set_value("Employee", frappe.get_value("Employee",
|
||||
{"employee_name":"test_employee@salary.com"}, "name"), "relieving_date", None)
|
||||
frappe.db.set_value("Employee", frappe.get_value("Employee",
|
||||
{"employee_name":"test_employee@salary.com"}, "name"), "status", "Active")
|
||||
|
||||
def test_employee_salary_slip_read_permission(self):
|
||||
make_employee("test_employee@salary.com")
|
||||
@@ -168,17 +178,22 @@ class TestSalarySlip(unittest.TestCase):
|
||||
|
||||
def test_tax_for_payroll_period(self):
|
||||
data = {}
|
||||
# test the impact of tax exemption declaration, tax exemption proof submission and deduct check boxes in annual tax calculation
|
||||
# test the impact of tax exemption declaration, tax exemption proof submission
|
||||
# and deduct check boxes in annual tax calculation
|
||||
# as per assigned salary structure 40500 in monthly salary so 236000*5/100/12
|
||||
frappe.db.sql("""delete from `tabPayroll Period`""")
|
||||
frappe.db.sql("""delete from `tabSalary Component`""")
|
||||
payroll_period = create_payroll_period()
|
||||
create_tax_slab(payroll_period)
|
||||
employee = make_employee("test_tax@salary.slip")
|
||||
delete_docs = ["Salary Slip", "Additional Salary",
|
||||
"Employee Tax Exemption Declaration",
|
||||
"Employee Tax Exemption Proof Submission",
|
||||
"Employee Benefit Claim", "Salary Structure Assignment"]
|
||||
delete_docs = [
|
||||
"Salary Slip",
|
||||
"Additional Salary",
|
||||
"Employee Tax Exemption Declaration",
|
||||
"Employee Tax Exemption Proof Submission",
|
||||
"Employee Benefit Claim",
|
||||
"Salary Structure Assignment"
|
||||
]
|
||||
for doc in delete_docs:
|
||||
frappe.db.sql("delete from `tab%s` where employee='%s'" % (doc, employee))
|
||||
|
||||
@@ -298,12 +313,11 @@ def make_employee_salary_slip(user, payroll_frequency, salary_structure=None):
|
||||
|
||||
if not salary_slip:
|
||||
salary_slip = make_salary_slip(salary_structure_doc.name, employee = employee)
|
||||
salary_slip.employee_name = frappe.get_value("Employee", {"name":frappe.db.get_value("Employee", {"user_id": user})}, "employee_name")
|
||||
salary_slip.employee_name = frappe.get_value("Employee",
|
||||
{"name":frappe.db.get_value("Employee", {"user_id": user})}, "employee_name")
|
||||
salary_slip.payroll_frequency = payroll_frequency
|
||||
salary_slip.posting_date = nowdate()
|
||||
salary_slip.insert()
|
||||
# salary_slip.submit()
|
||||
# salary_slip = salary_slip.name
|
||||
|
||||
return salary_slip
|
||||
|
||||
@@ -338,99 +352,99 @@ def create_account(company):
|
||||
salary_account = frappe.db.get_value("Account", "Salary - " + frappe.get_cached_value('Company', company, 'abbr'))
|
||||
if not salary_account:
|
||||
frappe.get_doc({
|
||||
"doctype": "Account",
|
||||
"account_name": "Salary",
|
||||
"parent_account": "Indirect Expenses - " + frappe.get_cached_value('Company', company, 'abbr'),
|
||||
"company": company
|
||||
"doctype": "Account",
|
||||
"account_name": "Salary",
|
||||
"parent_account": "Indirect Expenses - " + frappe.get_cached_value('Company', company, 'abbr'),
|
||||
"company": company
|
||||
}).insert()
|
||||
return salary_account
|
||||
|
||||
def make_earning_salary_component(setup=False, test_tax=False):
|
||||
data = [
|
||||
{
|
||||
"salary_component": 'Basic Salary',
|
||||
"abbr":'BS',
|
||||
"condition": 'base > 10000',
|
||||
"formula": 'base*.5',
|
||||
"type": "Earning",
|
||||
"amount_based_on_formula": 1
|
||||
},
|
||||
{
|
||||
"salary_component": 'HRA',
|
||||
"abbr":'H',
|
||||
"amount": 3000,
|
||||
"type": "Earning"
|
||||
},
|
||||
{
|
||||
"salary_component": 'Special Allowance',
|
||||
"abbr":'SA',
|
||||
"condition": 'H < 10000',
|
||||
"formula": 'BS*.5',
|
||||
"type": "Earning",
|
||||
"amount_based_on_formula": 1
|
||||
},
|
||||
{
|
||||
"salary_component": "Leave Encashment",
|
||||
"abbr": 'LE',
|
||||
"is_additional_component": 1,
|
||||
"type": "Earning"
|
||||
}
|
||||
]
|
||||
if test_tax:
|
||||
data.extend([
|
||||
{
|
||||
"salary_component": 'Basic Salary',
|
||||
"abbr":'BS',
|
||||
"condition": 'base > 10000',
|
||||
"formula": 'base*.5',
|
||||
"salary_component": "Leave Travel Allowance",
|
||||
"abbr": 'B',
|
||||
"is_flexible_benefit": 1,
|
||||
"type": "Earning",
|
||||
"amount_based_on_formula": 1
|
||||
"pay_against_benefit_claim": 1,
|
||||
"max_benefit_amount": 100000
|
||||
},
|
||||
{
|
||||
"salary_component": 'HRA',
|
||||
"abbr":'H',
|
||||
"amount": 3000,
|
||||
"type": "Earning"
|
||||
},
|
||||
{
|
||||
"salary_component": 'Special Allowance',
|
||||
"abbr":'SA',
|
||||
"condition": 'H < 10000',
|
||||
"formula": 'BS*.5',
|
||||
"salary_component": "Medical Allowance",
|
||||
"abbr": 'B',
|
||||
"is_flexible_benefit": 1,
|
||||
"pay_against_benefit_claim": 0,
|
||||
"type": "Earning",
|
||||
"amount_based_on_formula": 1
|
||||
"max_benefit_amount": 15000
|
||||
},
|
||||
{
|
||||
"salary_component": "Leave Encashment",
|
||||
"abbr": 'LE',
|
||||
"salary_component": "Perfomance Bonus",
|
||||
"abbr": 'B',
|
||||
"is_additional_component": 1,
|
||||
"type": "Earning"
|
||||
}
|
||||
]
|
||||
if test_tax:
|
||||
data.extend([
|
||||
{
|
||||
"salary_component": "Leave Travel Allowance",
|
||||
"abbr": 'B',
|
||||
"is_flexible_benefit": 1,
|
||||
"type": "Earning",
|
||||
"pay_against_benefit_claim": 1,
|
||||
"max_benefit_amount": 100000
|
||||
},
|
||||
{
|
||||
"salary_component": "Medical Allowance",
|
||||
"abbr": 'B',
|
||||
"is_flexible_benefit": 1,
|
||||
"pay_against_benefit_claim": 0,
|
||||
"type": "Earning",
|
||||
"max_benefit_amount": 15000
|
||||
},
|
||||
{
|
||||
"salary_component": "Perfomance Bonus",
|
||||
"abbr": 'B',
|
||||
"is_additional_component": 1,
|
||||
"type": "Earning"
|
||||
}
|
||||
])
|
||||
])
|
||||
if setup or test_tax:
|
||||
make_salary_component(data, test_tax)
|
||||
data.append({
|
||||
"salary_component": 'Basic Salary',
|
||||
"abbr":'BS',
|
||||
"condition": 'base < 10000',
|
||||
"formula": 'base*.2',
|
||||
"type": "Earning",
|
||||
"amount_based_on_formula": 1
|
||||
})
|
||||
"salary_component": 'Basic Salary',
|
||||
"abbr":'BS',
|
||||
"condition": 'base < 10000',
|
||||
"formula": 'base*.2',
|
||||
"type": "Earning",
|
||||
"amount_based_on_formula": 1
|
||||
})
|
||||
return data
|
||||
|
||||
def make_deduction_salary_component(setup=False, test_tax=False):
|
||||
data = [
|
||||
{
|
||||
"salary_component": 'Professional Tax',
|
||||
"abbr":'PT',
|
||||
"condition": 'base > 10000',
|
||||
"formula": 'base*.1',
|
||||
"type": "Deduction",
|
||||
"amount_based_on_formula": 1
|
||||
},
|
||||
{
|
||||
"salary_component": 'TDS',
|
||||
"abbr":'T',
|
||||
"formula": 'base*.1',
|
||||
"type": "Deduction",
|
||||
"amount_based_on_formula": 1
|
||||
}
|
||||
]
|
||||
{
|
||||
"salary_component": 'Professional Tax',
|
||||
"abbr":'PT',
|
||||
"condition": 'base > 10000',
|
||||
"formula": 'base*.1',
|
||||
"type": "Deduction",
|
||||
"amount_based_on_formula": 1
|
||||
},
|
||||
{
|
||||
"salary_component": 'TDS',
|
||||
"abbr":'T',
|
||||
"formula": 'base*.1',
|
||||
"type": "Deduction",
|
||||
"amount_based_on_formula": 1
|
||||
}
|
||||
]
|
||||
if not test_tax:
|
||||
data.append({
|
||||
"salary_component": 'TDS',
|
||||
@@ -453,48 +467,63 @@ def get_tax_paid_in_period(employee):
|
||||
|
||||
def create_exemption_declaration(employee, payroll_period):
|
||||
create_exemption_category()
|
||||
declaration = frappe.get_doc({"doctype": "Employee Tax Exemption Declaration",
|
||||
"employee": employee,
|
||||
"payroll_period": payroll_period,
|
||||
"company": erpnext.get_default_company()})
|
||||
declaration.append("declarations", {"exemption_sub_category": "_Test Sub Category",
|
||||
"exemption_category": "_Test Category",
|
||||
"amount": 100000})
|
||||
declaration = frappe.get_doc({
|
||||
"doctype": "Employee Tax Exemption Declaration",
|
||||
"employee": employee,
|
||||
"payroll_period": payroll_period,
|
||||
"company": erpnext.get_default_company()
|
||||
})
|
||||
declaration.append("declarations", {
|
||||
"exemption_sub_category": "_Test Sub Category",
|
||||
"exemption_category": "_Test Category",
|
||||
"amount": 100000
|
||||
})
|
||||
declaration.submit()
|
||||
|
||||
def create_proof_submission(employee, payroll_period, amount):
|
||||
submission_date = add_months(payroll_period.start_date, random.randint(0, 11))
|
||||
proof_submission = frappe.get_doc({"doctype": "Employee Tax Exemption Proof Submission",
|
||||
"employee": employee,
|
||||
"payroll_period": payroll_period.name,
|
||||
"submission_date": submission_date})
|
||||
proof_submission.append("tax_exemption_proofs", {"exemption_sub_category": "_Test Sub Category",
|
||||
"exemption_category": "_Test Category", "type_of_proof": "Test", "amount": amount})
|
||||
proof_submission = frappe.get_doc({
|
||||
"doctype": "Employee Tax Exemption Proof Submission",
|
||||
"employee": employee,
|
||||
"payroll_period": payroll_period.name,
|
||||
"submission_date": submission_date
|
||||
})
|
||||
proof_submission.append("tax_exemption_proofs", {
|
||||
"exemption_sub_category": "_Test Sub Category",
|
||||
"exemption_category": "_Test Category",
|
||||
"type_of_proof": "Test", "amount": amount
|
||||
})
|
||||
proof_submission.submit()
|
||||
return submission_date
|
||||
|
||||
def create_benefit_claim(employee, payroll_period, amount, component):
|
||||
claim_date = add_months(payroll_period.start_date, random.randint(0, 11))
|
||||
frappe.get_doc({"doctype": "Employee Benefit Claim", "employee": employee,
|
||||
"claimed_amount": amount, "claim_date": claim_date, "earning_component":
|
||||
component}).submit()
|
||||
frappe.get_doc({
|
||||
"doctype": "Employee Benefit Claim",
|
||||
"employee": employee,
|
||||
"claimed_amount": amount,
|
||||
"claim_date": claim_date,
|
||||
"earning_component": component
|
||||
}).submit()
|
||||
return claim_date
|
||||
|
||||
def create_tax_slab(payroll_period):
|
||||
data = [{
|
||||
"from_amount": 250000,
|
||||
"to_amount": 500000,
|
||||
"percent_deduction": 5
|
||||
},
|
||||
{
|
||||
"from_amount": 500000,
|
||||
"to_amount": 1000000,
|
||||
"percent_deduction": 20
|
||||
},
|
||||
{
|
||||
"from_amount": 1000000,
|
||||
"percent_deduction": 30
|
||||
}]
|
||||
data = [
|
||||
{
|
||||
"from_amount": 250000,
|
||||
"to_amount": 500000,
|
||||
"percent_deduction": 5
|
||||
},
|
||||
{
|
||||
"from_amount": 500000,
|
||||
"to_amount": 1000000,
|
||||
"percent_deduction": 20
|
||||
},
|
||||
{
|
||||
"from_amount": 1000000,
|
||||
"percent_deduction": 30
|
||||
}
|
||||
]
|
||||
payroll_period.taxable_salary_slabs = []
|
||||
for item in data:
|
||||
payroll_period.append("taxable_salary_slabs", item)
|
||||
@@ -526,9 +555,13 @@ def create_salary_slips_for_payroll_period(employee, salary_structure, payroll_p
|
||||
|
||||
def create_additional_salary(employee, payroll_period, amount):
|
||||
salary_date = add_months(payroll_period.start_date, random.randint(0, 11))
|
||||
frappe.get_doc({"doctype": "Additional Salary", "employee": employee,
|
||||
"company": erpnext.get_default_company(),
|
||||
"salary_component": "Perfomance Bonus",
|
||||
"payroll_date": salary_date,
|
||||
"amount": amount, "type": "Earning"}).submit()
|
||||
frappe.get_doc({
|
||||
"doctype": "Additional Salary",
|
||||
"employee": employee,
|
||||
"company": erpnext.get_default_company(),
|
||||
"salary_component": "Perfomance Bonus",
|
||||
"payroll_date": salary_date,
|
||||
"amount": amount,
|
||||
"type": "Earning"
|
||||
}).submit()
|
||||
return salary_date
|
||||
|
||||
@@ -220,16 +220,30 @@ def get_employee_leave_policy(employee):
|
||||
|
||||
def validate_tax_declaration(declarations):
|
||||
subcategories = []
|
||||
for declaration in declarations:
|
||||
if declaration.exemption_sub_category in subcategories:
|
||||
frappe.throw(_("More than one selection for {0} not \
|
||||
allowed").format(declaration.exemption_sub_category), frappe.ValidationError)
|
||||
subcategories.append(declaration.exemption_sub_category)
|
||||
max_amount = frappe.db.get_value("Employee Tax Exemption Sub Category", \
|
||||
declaration.exemption_sub_category, "max_amount")
|
||||
if declaration.amount > max_amount:
|
||||
frappe.throw(_("Max exemption amount for {0} is {1}").format(\
|
||||
declaration.exemption_sub_category, max_amount), frappe.ValidationError)
|
||||
for d in declarations:
|
||||
if d.exemption_sub_category in subcategories:
|
||||
frappe.throw(_("More than one selection for {0} not allowed").format(d.exemption_sub_category))
|
||||
subcategories.append(d.exemption_sub_category)
|
||||
|
||||
def get_total_exemption_amount(declarations):
|
||||
exemptions = frappe._dict()
|
||||
for d in declarations:
|
||||
exemptions.setdefault(d.exemption_category, frappe._dict())
|
||||
category_max_amount = exemptions.get(d.exemption_category).max_amount
|
||||
if not category_max_amount:
|
||||
category_max_amount = frappe.db.get_value("Employee Tax Exemption Category", d.exemption_category, "max_amount")
|
||||
exemptions.get(d.exemption_category).max_amount = category_max_amount
|
||||
sub_category_exemption_amount = d.max_amount \
|
||||
if (d.max_amount and flt(d.amount) > flt(d.max_amount)) else d.amount
|
||||
|
||||
exemptions.get(d.exemption_category).setdefault("total_exemption_amount", 0.0)
|
||||
exemptions.get(d.exemption_category).total_exemption_amount += flt(sub_category_exemption_amount)
|
||||
|
||||
if category_max_amount and exemptions.get(d.exemption_category).total_exemption_amount > category_max_amount:
|
||||
exemptions.get(d.exemption_category).total_exemption_amount = category_max_amount
|
||||
|
||||
total_exemption_amount = sum([flt(d.total_exemption_amount) for d in exemptions.values()])
|
||||
return total_exemption_amount
|
||||
|
||||
def get_leave_period(from_date, to_date, company):
|
||||
leave_period = frappe.db.sql("""
|
||||
|
||||
@@ -28,7 +28,7 @@ def make_opportunity(buyer_name, email_id):
|
||||
lead.save(ignore_permissions=True)
|
||||
|
||||
o = frappe.new_doc("Opportunity")
|
||||
o.enquiry_from = "Lead"
|
||||
o.opportunity_from = "Lead"
|
||||
o.lead = frappe.get_all("Lead", filters={"email_id": email_id}, fields = ["name"])[0]["name"]
|
||||
o.save(ignore_permissions=True)
|
||||
|
||||
|
||||
@@ -590,6 +590,7 @@ erpnext.patches.v10_0.item_barcode_childtable_migrate # 16-02-2019
|
||||
erpnext.patches.v11_0.make_italian_localization_fields # 26-03-2019
|
||||
erpnext.patches.v11_1.make_job_card_time_logs
|
||||
erpnext.patches.v11_1.set_variant_based_on
|
||||
erpnext.patches.v11_1.move_customer_lead_to_dynamic_column
|
||||
erpnext.patches.v11_1.woocommerce_set_creation_user
|
||||
erpnext.patches.v11_1.delete_bom_browser
|
||||
erpnext.patches.v11_1.set_salary_details_submittable
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
|
||||
def execute():
|
||||
frappe.reload_doctype("Quotation")
|
||||
frappe.db.sql(""" UPDATE `tabQuotation` set party_name = lead WHERE quotation_to = 'Lead' """)
|
||||
frappe.db.sql(""" UPDATE `tabQuotation` set party_name = customer WHERE quotation_to = 'Customer' """)
|
||||
|
||||
frappe.reload_doctype("Opportunity")
|
||||
frappe.db.sql(""" UPDATE `tabOpportunity` set party_name = lead WHERE opportunity_from = 'Lead' """)
|
||||
frappe.db.sql(""" UPDATE `tabOpportunity` set party_name = customer WHERE opportunity_from = 'Customer' """)
|
||||
@@ -1154,6 +1154,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
"brand": d.brand,
|
||||
"qty": d.qty,
|
||||
"uom": d.uom,
|
||||
"stock_uom": d.stock_uom,
|
||||
"parenttype": d.parenttype,
|
||||
"parent": d.parent,
|
||||
"pricing_rule": d.pricing_rule,
|
||||
|
||||
@@ -388,18 +388,18 @@ def make_custom_fields(update=True):
|
||||
'Employee Tax Exemption Declaration':[
|
||||
dict(fieldname='hra_section', label='HRA Exemption',
|
||||
fieldtype='Section Break', insert_after='declarations'),
|
||||
dict(fieldname='salary_structure_hra', label='HRA as per Salary Structure',
|
||||
fieldtype='Currency', insert_after='hra_section', read_only=1),
|
||||
dict(fieldname='monthly_house_rent', label='Monthly House Rent',
|
||||
fieldtype='Currency', insert_after='salary_structure_hra'),
|
||||
fieldtype='Currency', insert_after='hra_section'),
|
||||
dict(fieldname='rented_in_metro_city', label='Rented in Metro City',
|
||||
fieldtype='Check', insert_after='monthly_house_rent'),
|
||||
fieldtype='Check', insert_after='monthly_house_rent', depends_on='monthly_house_rent'),
|
||||
dict(fieldname='salary_structure_hra', label='HRA as per Salary Structure',
|
||||
fieldtype='Currency', insert_after='rented_in_metro_city', read_only=1, depends_on='monthly_house_rent'),
|
||||
dict(fieldname='hra_column_break', fieldtype='Column Break',
|
||||
insert_after='rented_in_metro_city'),
|
||||
insert_after='salary_structure_hra', depends_on='monthly_house_rent'),
|
||||
dict(fieldname='annual_hra_exemption', label='Annual HRA Exemption',
|
||||
fieldtype='Currency', insert_after='hra_column_break', read_only=1),
|
||||
fieldtype='Currency', insert_after='hra_column_break', read_only=1, depends_on='monthly_house_rent'),
|
||||
dict(fieldname='monthly_hra_exemption', label='Monthly HRA Exemption',
|
||||
fieldtype='Currency', insert_after='annual_hra_exemption', read_only=1)
|
||||
fieldtype='Currency', insert_after='annual_hra_exemption', read_only=1, depends_on='monthly_house_rent')
|
||||
],
|
||||
'Employee Tax Exemption Proof Submission': [
|
||||
dict(fieldname='hra_section', label='HRA Exemption',
|
||||
@@ -407,19 +407,19 @@ def make_custom_fields(update=True):
|
||||
dict(fieldname='house_rent_payment_amount', label='House Rent Payment Amount',
|
||||
fieldtype='Currency', insert_after='hra_section'),
|
||||
dict(fieldname='rented_in_metro_city', label='Rented in Metro City',
|
||||
fieldtype='Check', insert_after='house_rent_payment_amount'),
|
||||
fieldtype='Check', insert_after='house_rent_payment_amount', depends_on='house_rent_payment_amount'),
|
||||
dict(fieldname='rented_from_date', label='Rented From Date',
|
||||
fieldtype='Date', insert_after='rented_in_metro_city'),
|
||||
fieldtype='Date', insert_after='rented_in_metro_city', depends_on='house_rent_payment_amount'),
|
||||
dict(fieldname='rented_to_date', label='Rented To Date',
|
||||
fieldtype='Date', insert_after='rented_from_date'),
|
||||
fieldtype='Date', insert_after='rented_from_date', depends_on='house_rent_payment_amount'),
|
||||
dict(fieldname='hra_column_break', fieldtype='Column Break',
|
||||
insert_after='rented_to_date'),
|
||||
insert_after='rented_to_date', depends_on='house_rent_payment_amount'),
|
||||
dict(fieldname='monthly_house_rent', label='Monthly House Rent',
|
||||
fieldtype='Currency', insert_after='hra_column_break', read_only=1),
|
||||
fieldtype='Currency', insert_after='hra_column_break', read_only=1, depends_on='house_rent_payment_amount'),
|
||||
dict(fieldname='monthly_hra_exemption', label='Monthly Eligible Amount',
|
||||
fieldtype='Currency', insert_after='monthly_house_rent', read_only=1),
|
||||
fieldtype='Currency', insert_after='monthly_house_rent', read_only=1, depends_on='house_rent_payment_amount'),
|
||||
dict(fieldname='total_eligible_hra_exemption', label='Total Eligible HRA Exemption',
|
||||
fieldtype='Currency', insert_after='monthly_hra_exemption', read_only=1)
|
||||
fieldtype='Currency', insert_after='monthly_hra_exemption', read_only=1, depends_on='house_rent_payment_amount')
|
||||
],
|
||||
'Supplier': [
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe, re, json
|
||||
from frappe import _
|
||||
from frappe.utils import cstr, flt, date_diff, getdate
|
||||
from frappe.utils import cstr, flt, date_diff, nowdate
|
||||
from erpnext.regional.india import states, state_numbers
|
||||
from erpnext.controllers.taxes_and_totals import get_itemised_tax, get_itemised_taxable_amount
|
||||
from erpnext.controllers.accounts_controller import get_taxes_and_charges
|
||||
@@ -152,24 +152,40 @@ def get_regional_address_details(out, doctype, company):
|
||||
def calculate_annual_eligible_hra_exemption(doc):
|
||||
basic_component = frappe.get_cached_value('Company', doc.company, "basic_component")
|
||||
hra_component = frappe.get_cached_value('Company', doc.company, "hra_component")
|
||||
if not (basic_component and hra_component):
|
||||
frappe.throw(_("Please mention Basic and HRA component in Company"))
|
||||
|
||||
annual_exemption, monthly_exemption, hra_amount = 0, 0, 0
|
||||
if hra_component and basic_component:
|
||||
assignment = get_salary_assignment(doc.employee, getdate())
|
||||
if assignment and frappe.db.exists("Salary Detail", {
|
||||
"parent": assignment.salary_structure,
|
||||
"salary_component": hra_component, "parentfield": "earnings"}):
|
||||
basic_amount, hra_amount = get_component_amt_from_salary_slip(doc.employee,
|
||||
assignment.salary_structure, basic_component, hra_component)
|
||||
if hra_amount:
|
||||
if doc.monthly_house_rent:
|
||||
annual_exemption = calculate_hra_exemption(assignment.salary_structure,
|
||||
basic_amount, hra_amount, doc.monthly_house_rent,
|
||||
doc.rented_in_metro_city)
|
||||
if annual_exemption > 0:
|
||||
monthly_exemption = annual_exemption / 12
|
||||
else:
|
||||
annual_exemption = 0
|
||||
return {"hra_amount": hra_amount, "annual_exemption": annual_exemption, "monthly_exemption": monthly_exemption}
|
||||
assignment = get_salary_assignment(doc.employee, nowdate())
|
||||
|
||||
if assignment:
|
||||
hra_component_exists = frappe.db.exists("Salary Detail", {
|
||||
"parent": assignment.salary_structure,
|
||||
"salary_component": hra_component,
|
||||
"parentfield": "earnings",
|
||||
"parenttype": "Salary Structure"
|
||||
})
|
||||
if hra_component_exists:
|
||||
basic_amount, hra_amount = get_component_amt_from_salary_slip(doc.employee,
|
||||
assignment.salary_structure, basic_component, hra_component)
|
||||
if hra_amount:
|
||||
if doc.monthly_house_rent:
|
||||
annual_exemption = calculate_hra_exemption(assignment.salary_structure,
|
||||
basic_amount, hra_amount, doc.monthly_house_rent,
|
||||
doc.rented_in_metro_city)
|
||||
if annual_exemption > 0:
|
||||
monthly_exemption = annual_exemption / 12
|
||||
else:
|
||||
annual_exemption = 0
|
||||
elif doc.docstatus == 1:
|
||||
frappe.throw(_("Salary Structure must be submitted before submission of Tax Ememption Declaration"))
|
||||
|
||||
return frappe._dict({
|
||||
"hra_amount": hra_amount,
|
||||
"annual_exemption": annual_exemption,
|
||||
"monthly_exemption": monthly_exemption
|
||||
})
|
||||
|
||||
def get_component_amt_from_salary_slip(employee, salary_structure, basic_component, hra_component):
|
||||
salary_slip = make_salary_slip(salary_structure, employee=employee)
|
||||
@@ -189,8 +205,10 @@ def calculate_hra_exemption(salary_structure, basic, monthly_hra, monthly_house_
|
||||
frequency = frappe.get_value("Salary Structure", salary_structure, "payroll_frequency")
|
||||
# case 1: The actual amount allotted by the employer as the HRA.
|
||||
exemptions.append(get_annual_component_pay(frequency, monthly_hra))
|
||||
|
||||
actual_annual_rent = monthly_house_rent * 12
|
||||
annual_basic = get_annual_component_pay(frequency, basic)
|
||||
|
||||
# case 2: Actual rent paid less 10% of the basic salary.
|
||||
exemptions.append(flt(actual_annual_rent) - flt(annual_basic * 0.1))
|
||||
# case 3: 50% of the basic salary, if the employee is staying in a metro city (40% for a non-metro city).
|
||||
@@ -213,15 +231,25 @@ def get_annual_component_pay(frequency, amount):
|
||||
def validate_house_rent_dates(doc):
|
||||
if not doc.rented_to_date or not doc.rented_from_date:
|
||||
frappe.throw(_("House rented dates required for exemption calculation"))
|
||||
|
||||
if date_diff(doc.rented_to_date, doc.rented_from_date) < 14:
|
||||
frappe.throw(_("House rented dates should be atleast 15 days apart"))
|
||||
proofs = frappe.db.sql("""select name from `tabEmployee Tax Exemption Proof Submission`
|
||||
where docstatus=1 and employee='{0}' and payroll_period='{1}' and
|
||||
(rented_from_date between '{2}' and '{3}' or rented_to_date between
|
||||
'{2}' and '{3}')""".format(doc.employee, doc.payroll_period,
|
||||
doc.rented_from_date, doc.rented_to_date))
|
||||
|
||||
proofs = frappe.db.sql("""
|
||||
select name
|
||||
from `tabEmployee Tax Exemption Proof Submission`
|
||||
where
|
||||
docstatus=1 and employee=%(employee)s and payroll_period=%(payroll_period)s
|
||||
and (rented_from_date between %(from_date)s and %(to_date)s or rented_to_date between %(from_date)s and %(to_date)s)
|
||||
""", {
|
||||
"employee": doc.employee,
|
||||
"payroll_period": doc.payroll_period,
|
||||
"from_date": doc.rented_from_date,
|
||||
"to_date": doc.rented_to_date
|
||||
})
|
||||
|
||||
if proofs:
|
||||
frappe.throw(_("House rent paid days overlap with {0}").format(proofs[0][0]))
|
||||
frappe.throw(_("House rent paid days overlapping with {0}").format(proofs[0][0]))
|
||||
|
||||
def calculate_hra_exemption_for_period(doc):
|
||||
monthly_rent, eligible_hra = 0, 0
|
||||
|
||||
@@ -104,10 +104,6 @@ class Customer(TransactionBase):
|
||||
if self.lead_name:
|
||||
frappe.db.set_value('Lead', self.lead_name, 'status', 'Converted', update_modified=False)
|
||||
|
||||
for doctype in ('Opportunity', 'Quotation'):
|
||||
for d in frappe.get_all(doctype, {'lead': self.lead_name}):
|
||||
frappe.db.set_value(doctype, d.name, 'customer', self.name, update_modified=False)
|
||||
|
||||
def create_lead_address_contact(self):
|
||||
if self.lead_name:
|
||||
# assign lead address to customer (if already not set)
|
||||
|
||||
@@ -6,6 +6,10 @@ def get_data():
|
||||
'heatmap': True,
|
||||
'heatmap_message': _('This is based on transactions against this Customer. See timeline below for details'),
|
||||
'fieldname': 'customer',
|
||||
'non_standard_fieldnames': {
|
||||
'Quotation': 'party_name',
|
||||
'Opportunity': 'party_name'
|
||||
},
|
||||
'transactions': [
|
||||
{
|
||||
'label': _('Pre Sales'),
|
||||
|
||||
@@ -8,15 +8,27 @@ frappe.ui.form.on('Quotation', {
|
||||
setup: function(frm) {
|
||||
frm.custom_make_buttons = {
|
||||
'Sales Order': 'Make Sales Order'
|
||||
}
|
||||
},
|
||||
|
||||
frm.set_query("quotation_to", function() {
|
||||
return{
|
||||
"filters": {
|
||||
"name": ["in", ["Customer", "Lead"]],
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
refresh: function(frm) {
|
||||
frm.trigger("set_label");
|
||||
frm.trigger("set_dynamic_field_label");
|
||||
},
|
||||
|
||||
quotation_to: function(frm) {
|
||||
frm.trigger("set_label");
|
||||
frm.trigger("toggle_reqd_lead_customer");
|
||||
frm.trigger("set_dynamic_field_label");
|
||||
},
|
||||
|
||||
set_label: function(frm) {
|
||||
@@ -28,10 +40,6 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
|
||||
onload: function(doc, dt, dn) {
|
||||
var me = this;
|
||||
this._super(doc, dt, dn);
|
||||
if(doc.customer && !doc.quotation_to)
|
||||
doc.quotation_to = "Customer";
|
||||
else if(doc.lead && !doc.quotation_to)
|
||||
doc.quotation_to = "Lead";
|
||||
|
||||
},
|
||||
refresh: function(doc, dt, dn) {
|
||||
@@ -97,25 +105,28 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
|
||||
|
||||
},
|
||||
|
||||
quotation_to: function() {
|
||||
var me = this;
|
||||
if (this.frm.doc.quotation_to == "Lead") {
|
||||
this.frm.set_value("customer", null);
|
||||
this.frm.set_value("contact_person", null);
|
||||
} else if (this.frm.doc.quotation_to == "Customer") {
|
||||
this.frm.set_value("lead", null);
|
||||
set_dynamic_field_label: function(){
|
||||
if (this.frm.doc.quotation_to == "Customer")
|
||||
{
|
||||
this.frm.set_df_property("party_name", "label", "Customer");
|
||||
this.frm.fields_dict.party_name.get_query = null;
|
||||
}
|
||||
|
||||
this.toggle_reqd_lead_customer();
|
||||
if (this.frm.doc.quotation_to == "Lead")
|
||||
{
|
||||
this.frm.set_df_property("party_name", "label", "Lead");
|
||||
|
||||
this.frm.fields_dict.party_name.get_query = function() {
|
||||
return{ query: "erpnext.controllers.queries.lead_query" }
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
toggle_reqd_lead_customer: function() {
|
||||
var me = this;
|
||||
|
||||
this.frm.toggle_reqd("lead", this.frm.doc.quotation_to == "Lead");
|
||||
this.frm.toggle_reqd("customer", this.frm.doc.quotation_to == "Customer");
|
||||
|
||||
// to overwrite the customer_filter trigger from queries.js
|
||||
this.frm.toggle_reqd("party_name", this.frm.doc.quotation_to);
|
||||
this.frm.set_query('customer_address', erpnext.queries.address_query);
|
||||
this.frm.set_query('shipping_address_name', erpnext.queries.address_query);
|
||||
},
|
||||
@@ -163,10 +174,6 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
|
||||
|
||||
cur_frm.script_manager.make(erpnext.selling.QuotationController);
|
||||
|
||||
cur_frm.fields_dict.lead.get_query = function(doc,cdt,cdn) {
|
||||
return{ query: "erpnext.controllers.queries.lead_query" }
|
||||
}
|
||||
|
||||
cur_frm.cscript['Make Sales Order'] = function() {
|
||||
frappe.model.open_mapped_doc({
|
||||
method: "erpnext.selling.doctype.quotation.quotation.make_sales_order",
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "customer_section",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@@ -53,6 +54,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"default": "{customer_name}",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "title",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 1,
|
||||
@@ -86,6 +88,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"default": "",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "naming_series",
|
||||
"fieldtype": "Select",
|
||||
"hidden": 0,
|
||||
@@ -121,8 +124,9 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"default": "Customer",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "quotation_to",
|
||||
"fieldtype": "Select",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
@@ -135,7 +139,7 @@
|
||||
"no_copy": 0,
|
||||
"oldfieldname": "quotation_to",
|
||||
"oldfieldtype": "Select",
|
||||
"options": "\nLead\nCustomer",
|
||||
"options": "DocType",
|
||||
"permlevel": 0,
|
||||
"print_hide": 1,
|
||||
"print_hide_if_no_value": 0,
|
||||
@@ -155,9 +159,10 @@
|
||||
"bold": 1,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "eval:doc.quotation_to == \"Customer\"",
|
||||
"fieldname": "customer",
|
||||
"fieldtype": "Link",
|
||||
"depends_on": "",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "party_name",
|
||||
"fieldtype": "Dynamic Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
@@ -165,12 +170,12 @@
|
||||
"in_global_search": 1,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 1,
|
||||
"label": "Customer",
|
||||
"label": "Customer/Lead",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"oldfieldname": "customer",
|
||||
"oldfieldtype": "Link",
|
||||
"options": "Customer",
|
||||
"options": "quotation_to",
|
||||
"permlevel": 0,
|
||||
"print_hide": 1,
|
||||
"print_hide_if_no_value": 0,
|
||||
@@ -183,41 +188,6 @@
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 1,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "eval:doc.quotation_to == \"Lead\"",
|
||||
"fieldname": "lead",
|
||||
"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": 1,
|
||||
"label": "Lead",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"oldfieldname": "lead",
|
||||
"oldfieldtype": "Link",
|
||||
"options": "Lead",
|
||||
"permlevel": 0,
|
||||
"print_hide": 1,
|
||||
"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,
|
||||
@@ -226,6 +196,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_from": "customer.customer_name",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "customer_name",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 1,
|
||||
@@ -258,6 +229,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "column_break1",
|
||||
"fieldtype": "Column Break",
|
||||
"hidden": 0,
|
||||
@@ -290,6 +262,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "amended_from",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -326,6 +299,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"description": "",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "company",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -362,6 +336,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"default": "Today",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "transaction_date",
|
||||
"fieldtype": "Date",
|
||||
"hidden": 0,
|
||||
@@ -396,6 +371,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "valid_till",
|
||||
"fieldtype": "Date",
|
||||
"hidden": 0,
|
||||
@@ -429,6 +405,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"default": "Sales",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "order_type",
|
||||
"fieldtype": "Select",
|
||||
"hidden": 0,
|
||||
@@ -465,6 +442,7 @@
|
||||
"collapsible_depends_on": "",
|
||||
"columns": 0,
|
||||
"depends_on": "eval:(doc.customer || doc.lead)",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "contact_section",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@@ -497,6 +475,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "customer_address",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -529,6 +508,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "address_display",
|
||||
"fieldtype": "Small Text",
|
||||
"hidden": 0,
|
||||
@@ -563,6 +543,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "eval:doc.customer",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "contact_person",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -597,6 +578,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "contact_display",
|
||||
"fieldtype": "Small Text",
|
||||
"hidden": 0,
|
||||
@@ -628,6 +610,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "contact_mobile",
|
||||
"fieldtype": "Small Text",
|
||||
"hidden": 0,
|
||||
@@ -659,6 +642,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "contact_email",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 1,
|
||||
@@ -692,6 +676,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "customer",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "col_break98",
|
||||
"fieldtype": "Column Break",
|
||||
"hidden": 0,
|
||||
@@ -723,6 +708,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "shipping_address_name",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -755,6 +741,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "shipping_address",
|
||||
"fieldtype": "Small Text",
|
||||
"hidden": 0,
|
||||
@@ -788,6 +775,7 @@
|
||||
"columns": 0,
|
||||
"depends_on": "customer",
|
||||
"description": "",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "customer_group",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 1,
|
||||
@@ -823,6 +811,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"description": "",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "territory",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -855,6 +844,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 1,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "currency_and_price_list",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@@ -887,6 +877,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "currency",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -923,6 +914,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"description": "Rate at which customer's currency is converted to company's base currency",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "conversion_rate",
|
||||
"fieldtype": "Float",
|
||||
"hidden": 0,
|
||||
@@ -958,6 +950,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "column_break2",
|
||||
"fieldtype": "Column Break",
|
||||
"hidden": 0,
|
||||
@@ -989,6 +982,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "selling_price_list",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -1024,6 +1018,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "price_list_currency",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -1057,6 +1052,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"description": "Rate at which Price list currency is converted to company's base currency",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "plc_conversion_rate",
|
||||
"fieldtype": "Float",
|
||||
"hidden": 0,
|
||||
@@ -1089,6 +1085,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "ignore_pricing_rule",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 0,
|
||||
@@ -1120,6 +1117,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "items_section",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@@ -1153,6 +1151,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "items",
|
||||
"fieldtype": "Table",
|
||||
"hidden": 0,
|
||||
@@ -1188,6 +1187,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "sec_break23",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@@ -1218,6 +1218,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "total_qty",
|
||||
"fieldtype": "Float",
|
||||
"hidden": 0,
|
||||
@@ -1250,6 +1251,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "base_total",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
@@ -1283,6 +1285,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "base_net_total",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
@@ -1318,6 +1321,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "column_break_28",
|
||||
"fieldtype": "Column Break",
|
||||
"hidden": 0,
|
||||
@@ -1348,6 +1352,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "total",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
@@ -1381,6 +1386,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "net_total",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
@@ -1413,6 +1419,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "total_net_weight",
|
||||
"fieldtype": "Float",
|
||||
"hidden": 0,
|
||||
@@ -1445,6 +1452,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "taxes_section",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@@ -1478,6 +1486,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "taxes_and_charges",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -1512,6 +1521,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "column_break_34",
|
||||
"fieldtype": "Column Break",
|
||||
"hidden": 0,
|
||||
@@ -1542,6 +1552,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "shipping_rule",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -1575,6 +1586,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "section_break_36",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@@ -1605,6 +1617,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "taxes",
|
||||
"fieldtype": "Table",
|
||||
"hidden": 0,
|
||||
@@ -1639,6 +1652,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 1,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "sec_tax_breakup",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@@ -1671,6 +1685,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "other_charges_calculation",
|
||||
"fieldtype": "Text",
|
||||
"hidden": 0,
|
||||
@@ -1703,6 +1718,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "section_break_39",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@@ -1733,6 +1749,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "base_total_taxes_and_charges",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
@@ -1767,6 +1784,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "column_break_42",
|
||||
"fieldtype": "Column Break",
|
||||
"hidden": 0,
|
||||
@@ -1797,6 +1815,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "total_taxes_and_charges",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
@@ -1830,6 +1849,7 @@
|
||||
"collapsible": 1,
|
||||
"collapsible_depends_on": "discount_amount",
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "section_break_44",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@@ -1863,6 +1883,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"default": "Grand Total",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "apply_discount_on",
|
||||
"fieldtype": "Select",
|
||||
"hidden": 0,
|
||||
@@ -1896,6 +1917,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "base_discount_amount",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
@@ -1929,6 +1951,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "column_break_46",
|
||||
"fieldtype": "Column Break",
|
||||
"hidden": 0,
|
||||
@@ -1960,6 +1983,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "additional_discount_percentage",
|
||||
"fieldtype": "Float",
|
||||
"hidden": 0,
|
||||
@@ -1992,6 +2016,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "discount_amount",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
@@ -2024,6 +2049,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "totals",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@@ -2057,6 +2083,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "base_grand_total",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
@@ -2092,6 +2119,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "base_rounding_adjustment",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
@@ -2126,6 +2154,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"description": "In Words will be visible once you save the Quotation.",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "base_in_words",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
@@ -2160,6 +2189,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "base_rounded_total",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
@@ -2195,6 +2225,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "column_break3",
|
||||
"fieldtype": "Column Break",
|
||||
"hidden": 0,
|
||||
@@ -2227,6 +2258,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "grand_total",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
@@ -2262,6 +2294,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "rounding_adjustment",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
@@ -2295,6 +2328,7 @@
|
||||
"bold": 1,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "rounded_total",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
@@ -2330,6 +2364,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "in_words",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
@@ -2366,6 +2401,7 @@
|
||||
"collapsible_depends_on": "",
|
||||
"columns": 0,
|
||||
"depends_on": "",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "payment_schedule_section",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@@ -2398,6 +2434,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "payment_terms_template",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -2431,6 +2468,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "payment_schedule",
|
||||
"fieldtype": "Table",
|
||||
"hidden": 0,
|
||||
@@ -2465,6 +2503,7 @@
|
||||
"collapsible": 1,
|
||||
"collapsible_depends_on": "terms",
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "terms_section_break",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@@ -2498,6 +2537,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "tc_name",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -2532,6 +2572,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "terms",
|
||||
"fieldtype": "Text Editor",
|
||||
"hidden": 0,
|
||||
@@ -2565,6 +2606,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 1,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "print_settings",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@@ -2597,6 +2639,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "letter_head",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -2631,6 +2674,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "group_same_items",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 0,
|
||||
@@ -2663,6 +2707,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "column_break_73",
|
||||
"fieldtype": "Column Break",
|
||||
"hidden": 0,
|
||||
@@ -2694,6 +2739,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "select_print_heading",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -2728,6 +2774,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "language",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
@@ -2760,6 +2807,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "subscription_section",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@@ -2792,6 +2840,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "auto_repeat",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -2826,6 +2875,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "eval: doc.auto_repeat",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "update_auto_repeat_reference",
|
||||
"fieldtype": "Button",
|
||||
"hidden": 0,
|
||||
@@ -2858,6 +2908,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 1,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "more_info",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@@ -2891,6 +2942,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "campaign",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -2925,6 +2977,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "source",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -2960,6 +3013,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "eval:doc.status===\"Lost\"",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "order_lost_reason",
|
||||
"fieldtype": "Small Text",
|
||||
"hidden": 0,
|
||||
@@ -2993,6 +3047,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "column_break4",
|
||||
"fieldtype": "Column Break",
|
||||
"hidden": 0,
|
||||
@@ -3026,6 +3081,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"default": "Draft",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "status",
|
||||
"fieldtype": "Select",
|
||||
"hidden": 0,
|
||||
@@ -3060,6 +3116,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "enq_det",
|
||||
"fieldtype": "Text",
|
||||
"hidden": 1,
|
||||
@@ -3093,6 +3150,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "supplier_quotation",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -3126,6 +3184,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "opportunity",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -3165,7 +3224,7 @@
|
||||
"istable": 0,
|
||||
"max_attachments": 1,
|
||||
"menu_index": 0,
|
||||
"modified": "2019-01-07 16:51:55.604845",
|
||||
"modified": "2019-04-25 15:26:21.983298",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Selling",
|
||||
"name": "Quotation",
|
||||
@@ -3331,11 +3390,11 @@
|
||||
"quick_entry": 0,
|
||||
"read_only": 0,
|
||||
"read_only_onload": 1,
|
||||
"search_fields": "status,transaction_date,customer,lead,order_type",
|
||||
"search_fields": "status,transaction_date,party_name,order_type",
|
||||
"show_name_in_global_search": 1,
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"timeline_field": "customer",
|
||||
"timeline_field": "party_name",
|
||||
"title_field": "title",
|
||||
"track_changes": 0,
|
||||
"track_seen": 0,
|
||||
|
||||
@@ -28,11 +28,10 @@ class Quotation(SellingController):
|
||||
self.update_opportunity()
|
||||
self.validate_order_type()
|
||||
self.validate_uom_is_integer("stock_uom", "qty")
|
||||
self.validate_quotation_to()
|
||||
self.validate_valid_till()
|
||||
if self.items:
|
||||
self.with_items = 1
|
||||
|
||||
|
||||
def validate_valid_till(self):
|
||||
if self.valid_till and self.valid_till < self.transaction_date:
|
||||
frappe.throw(_("Valid till date cannot be before transaction date"))
|
||||
@@ -43,16 +42,9 @@ class Quotation(SellingController):
|
||||
def validate_order_type(self):
|
||||
super(Quotation, self).validate_order_type()
|
||||
|
||||
def validate_quotation_to(self):
|
||||
if self.customer:
|
||||
self.quotation_to = "Customer"
|
||||
self.lead = None
|
||||
elif self.lead:
|
||||
self.quotation_to = "Lead"
|
||||
|
||||
def update_lead(self):
|
||||
if self.lead:
|
||||
frappe.get_doc("Lead", self.lead).set_status(update=True)
|
||||
if self.quotation_to == "Lead" and self.party_name:
|
||||
frappe.get_doc("Lead", self.party_name).set_status(update=True)
|
||||
|
||||
def update_opportunity(self):
|
||||
for opportunity in list(set([d.prevdoc_docname for d in self.get("items")])):
|
||||
@@ -209,12 +201,12 @@ def _make_sales_invoice(source_name, target_doc=None, ignore_permissions=False):
|
||||
}
|
||||
}, target_doc, set_missing_values, ignore_permissions=ignore_permissions)
|
||||
|
||||
return doclist
|
||||
return doclist
|
||||
|
||||
def _make_customer(source_name, ignore_permissions=False):
|
||||
quotation = frappe.db.get_value("Quotation", source_name, ["lead", "order_type", "customer"])
|
||||
if quotation and quotation[0] and not quotation[2]:
|
||||
lead_name = quotation[0]
|
||||
quotation = frappe.db.get_value("Quotation", source_name, ["order_type", "party_name", "customer_name"])
|
||||
if quotation and quotation[1] and not quotation[2]:
|
||||
lead_name = quotation[1]
|
||||
customer_name = frappe.db.get_value("Customer", {"lead_name": lead_name},
|
||||
["name", "customer_name"], as_dict=True)
|
||||
if not customer_name:
|
||||
@@ -242,3 +234,5 @@ def _make_customer(source_name, ignore_permissions=False):
|
||||
frappe.throw(_("Please create Customer from Lead {0}").format(lead_name))
|
||||
else:
|
||||
return customer_name
|
||||
else:
|
||||
return frappe.get_doc("Customer",quotation[2])
|
||||
|
||||
@@ -203,15 +203,15 @@ class TestQuotation(unittest.TestCase):
|
||||
|
||||
test_records = frappe.get_test_records('Quotation')
|
||||
|
||||
def get_quotation_dict(customer=None, item_code=None):
|
||||
if not customer:
|
||||
customer = '_Test Customer'
|
||||
def get_quotation_dict(party_name=None, item_code=None):
|
||||
if not party_name:
|
||||
party_name = '_Test Customer'
|
||||
if not item_code:
|
||||
item_code = '_Test Item'
|
||||
|
||||
return {
|
||||
'doctype': 'Quotation',
|
||||
'customer': customer,
|
||||
'party_name': party_name,
|
||||
'items': [
|
||||
{
|
||||
'item_code': item_code,
|
||||
@@ -229,7 +229,7 @@ def make_quotation(**args):
|
||||
qo.transaction_date = args.transaction_date
|
||||
|
||||
qo.company = args.company or "_Test Company"
|
||||
qo.customer = args.customer or "_Test Customer"
|
||||
qo.party_name = args.party_name or "_Test Customer"
|
||||
qo.currency = args.currency or "INR"
|
||||
if args.selling_price_list:
|
||||
qo.selling_price_list = args.selling_price_list
|
||||
|
||||
@@ -1,37 +1,37 @@
|
||||
[
|
||||
{
|
||||
"company": "_Test Company",
|
||||
"conversion_rate": 1.0,
|
||||
"currency": "INR",
|
||||
"customer": "_Test Customer",
|
||||
"customer_group": "_Test Customer Group",
|
||||
"customer_name": "_Test Customer",
|
||||
"doctype": "Quotation",
|
||||
"base_grand_total": 1000.0,
|
||||
"grand_total": 1000.0,
|
||||
"order_type": "Sales",
|
||||
"plc_conversion_rate": 1.0,
|
||||
"price_list_currency": "INR",
|
||||
"items": [
|
||||
{
|
||||
"base_amount": 1000.0,
|
||||
"base_rate": 100.0,
|
||||
"description": "CPU",
|
||||
"doctype": "Quotation Item",
|
||||
"item_code": "_Test Item Home Desktop 100",
|
||||
"item_name": "CPU",
|
||||
"parentfield": "items",
|
||||
"qty": 10.0,
|
||||
"rate": 100.0,
|
||||
"uom": "_Test UOM 1",
|
||||
"stock_uom": "_Test UOM 1",
|
||||
"conversion_factor": 1.0
|
||||
}
|
||||
],
|
||||
"quotation_to": "Customer",
|
||||
"selling_price_list": "_Test Price List",
|
||||
"territory": "_Test Territory",
|
||||
"transaction_date": "2013-02-21",
|
||||
"valid_till": "2013-03-21"
|
||||
}
|
||||
{
|
||||
"company": "_Test Company",
|
||||
"conversion_rate": 1.0,
|
||||
"currency": "INR",
|
||||
"party_name": "_Test Customer",
|
||||
"customer_group": "_Test Customer Group",
|
||||
"customer_name": "_Test Customer",
|
||||
"doctype": "Quotation",
|
||||
"base_grand_total": 1000.0,
|
||||
"grand_total": 1000.0,
|
||||
"order_type": "Sales",
|
||||
"plc_conversion_rate": 1.0,
|
||||
"price_list_currency": "INR",
|
||||
"items": [
|
||||
{
|
||||
"base_amount": 1000.0,
|
||||
"base_rate": 100.0,
|
||||
"description": "CPU",
|
||||
"doctype": "Quotation Item",
|
||||
"item_code": "_Test Item Home Desktop 100",
|
||||
"item_name": "CPU",
|
||||
"parentfield": "items",
|
||||
"qty": 10.0,
|
||||
"rate": 100.0,
|
||||
"uom": "_Test UOM 1",
|
||||
"stock_uom": "_Test UOM 1",
|
||||
"conversion_factor": 1.0
|
||||
}
|
||||
],
|
||||
"quotation_to": "Customer",
|
||||
"selling_price_list": "_Test Price List",
|
||||
"territory": "_Test Territory",
|
||||
"transaction_date": "2013-02-21",
|
||||
"valid_till": "2013-03-21"
|
||||
}
|
||||
]
|
||||
@@ -33,7 +33,7 @@ def make_sample_data(domains, make_dependent = False):
|
||||
def make_opportunity(items, customer):
|
||||
b = frappe.get_doc({
|
||||
"doctype": "Opportunity",
|
||||
"enquiry_from": "Customer",
|
||||
"opportunity_from": "Customer",
|
||||
"customer": customer,
|
||||
"opportunity_type": _("Sales"),
|
||||
"with_items": 1
|
||||
|
||||
@@ -196,7 +196,7 @@ def _get_cart_quotation(party=None):
|
||||
party = get_party()
|
||||
|
||||
quotation = frappe.get_all("Quotation", fields=["name"], filters=
|
||||
{party.doctype.lower(): party.name, "order_type": "Shopping Cart", "docstatus": 0},
|
||||
{"party_name": party.name, "order_type": "Shopping Cart", "docstatus": 0},
|
||||
order_by="modified desc", limit_page_length=1)
|
||||
|
||||
if quotation:
|
||||
@@ -211,7 +211,7 @@ def _get_cart_quotation(party=None):
|
||||
"status": "Draft",
|
||||
"docstatus": 0,
|
||||
"__islocal": 1,
|
||||
(party.doctype.lower()): party.name
|
||||
"party_name": party.name
|
||||
})
|
||||
|
||||
qdoc.contact_person = frappe.db.get_value("Contact", {"email_id": frappe.session.user})
|
||||
@@ -291,9 +291,9 @@ def _set_price_list(quotation, cart_settings):
|
||||
|
||||
# check if customer price list exists
|
||||
selling_price_list = None
|
||||
if quotation.customer:
|
||||
if quotation.party_name:
|
||||
from erpnext.accounts.party import get_default_price_list
|
||||
selling_price_list = get_default_price_list(frappe.get_doc("Customer", quotation.customer))
|
||||
selling_price_list = get_default_price_list(frappe.get_doc("Customer", quotation.party_name))
|
||||
|
||||
# else check for territory based price list
|
||||
if not selling_price_list:
|
||||
@@ -305,9 +305,9 @@ def set_taxes(quotation, cart_settings):
|
||||
"""set taxes based on billing territory"""
|
||||
from erpnext.accounts.party import set_taxes
|
||||
|
||||
customer_group = frappe.db.get_value("Customer", quotation.customer, "customer_group")
|
||||
customer_group = frappe.db.get_value("Customer", quotation.party_name, "customer_group")
|
||||
|
||||
quotation.taxes_and_charges = set_taxes(quotation.customer, "Customer", \
|
||||
quotation.taxes_and_charges = set_taxes(quotation.party_name, "Customer", \
|
||||
quotation.transaction_date, quotation.company, customer_group, None, \
|
||||
quotation.customer_address, quotation.shipping_address_name, 1)
|
||||
#
|
||||
|
||||
@@ -33,7 +33,6 @@ class TestShoppingCart(unittest.TestCase):
|
||||
self.assertEqual(quotation.quotation_to, "Customer")
|
||||
self.assertEqual(quotation.contact_person,
|
||||
frappe.db.get_value("Contact", dict(email_id="test_cart_user@example.com")))
|
||||
self.assertEqual(quotation.lead, None)
|
||||
self.assertEqual(quotation.contact_email, frappe.session.user)
|
||||
|
||||
return quotation
|
||||
@@ -44,8 +43,7 @@ class TestShoppingCart(unittest.TestCase):
|
||||
# test if quotation with customer is fetched
|
||||
quotation = _get_cart_quotation()
|
||||
self.assertEqual(quotation.quotation_to, "Customer")
|
||||
self.assertEqual(quotation.customer, "_Test Customer")
|
||||
self.assertEqual(quotation.lead, None)
|
||||
self.assertEqual(quotation.party_name, "_Test Customer")
|
||||
self.assertEqual(quotation.contact_email, frappe.session.user)
|
||||
|
||||
return quotation
|
||||
@@ -107,7 +105,7 @@ class TestShoppingCart(unittest.TestCase):
|
||||
|
||||
from erpnext.accounts.party import set_taxes
|
||||
|
||||
tax_rule_master = set_taxes(quotation.customer, "Customer", \
|
||||
tax_rule_master = set_taxes(quotation.party_name, "Customer", \
|
||||
quotation.transaction_date, quotation.company, None, None, \
|
||||
quotation.customer_address, quotation.shipping_address_name, 1)
|
||||
self.assertEqual(quotation.taxes_and_charges, tax_rule_master)
|
||||
@@ -122,7 +120,7 @@ class TestShoppingCart(unittest.TestCase):
|
||||
"doctype": "Quotation",
|
||||
"quotation_to": "Customer",
|
||||
"order_type": "Shopping Cart",
|
||||
"customer": get_party(frappe.session.user).name,
|
||||
"party_name": get_party(frappe.session.user).name,
|
||||
"docstatus": 0,
|
||||
"contact_email": frappe.session.user,
|
||||
"selling_price_list": "_Test Price List Rest of the World",
|
||||
|
||||
@@ -431,7 +431,7 @@ def insert_item_price(args):
|
||||
def get_item_price(args, item_code, ignore_party=False):
|
||||
"""
|
||||
Get name, price_list_rate from Item Price based on conditions
|
||||
Check if the Derised qty is within the increment of the packing list.
|
||||
Check if the desired qty is within the increment of the packing list.
|
||||
:param args: dict (or frappe._dict) with mandatory fields price_list, uom
|
||||
optional fields min_qty, transaction_date, customer, supplier
|
||||
:param item_code: str, Item Doctype field item_code
|
||||
@@ -469,11 +469,11 @@ def get_price_list_rate_for(args, item_code):
|
||||
for min_qty 9 and min_qty 20. It returns Item Price Rate for qty 9 as
|
||||
the best fit in the range of avaliable min_qtyies
|
||||
|
||||
:param customer: link to Customer DocType
|
||||
:param supplier: link to Supplier DocType
|
||||
:param customer: link to Customer DocType
|
||||
:param supplier: link to Supplier DocType
|
||||
:param price_list: str (Standard Buying or Standard Selling)
|
||||
:param item_code: str, Item Doctype field item_code
|
||||
:param qty: Derised Qty
|
||||
:param qty: Desired Qty
|
||||
:param transaction_date: Date of the price
|
||||
"""
|
||||
item_price_args = {
|
||||
@@ -498,7 +498,7 @@ def get_price_list_rate_for(args, item_code):
|
||||
|
||||
general_price_list_rate = get_item_price(item_price_args, item_code, ignore_party=args.get("ignore_party"))
|
||||
if not general_price_list_rate and args.get("uom") != args.get("stock_uom"):
|
||||
item_price_args["args"] = args.get("stock_uom")
|
||||
item_price_args["uom"] = args.get("stock_uom")
|
||||
general_price_list_rate = get_item_price(item_price_args, item_code, ignore_party=args.get("ignore_party"))
|
||||
|
||||
if general_price_list_rate:
|
||||
@@ -514,11 +514,11 @@ def get_price_list_rate_for(args, item_code):
|
||||
|
||||
def check_packing_list(price_list_rate_name, desired_qty, item_code):
|
||||
"""
|
||||
Check if the Derised qty is within the increment of the packing list.
|
||||
Check if the desired qty is within the increment of the packing list.
|
||||
:param price_list_rate_name: Name of Item Price
|
||||
:param desired_qty: Derised Qt
|
||||
:param desired_qty: Desired Qt
|
||||
:param item_code: str, Item Doctype field item_code
|
||||
:param qty: Derised Qt
|
||||
:param qty: Desired Qt
|
||||
"""
|
||||
|
||||
flag = True
|
||||
|
||||
@@ -28,7 +28,7 @@ def send_message(subject="Website Query", message="", sender="", status="Open"):
|
||||
|
||||
opportunity = frappe.get_doc(dict(
|
||||
doctype ='Opportunity',
|
||||
enquiry_from = 'Customer' if customer else 'Lead',
|
||||
opportunity_from = 'Customer' if customer else 'Lead',
|
||||
status = 'Open',
|
||||
title = subject,
|
||||
contact_email = sender,
|
||||
|
||||
Reference in New Issue
Block a user