Merge branch 'develop' into t3

This commit is contained in:
Sagar Sharma 2022-09-05 13:56:21 +05:30 committed by GitHub
commit 74c2458bdb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 125 additions and 110 deletions

View File

@ -2,7 +2,7 @@
// For license information, please see license.txt // For license information, please see license.txt
frappe.ui.form.on("Journal Entry Template", { frappe.ui.form.on("Journal Entry Template", {
setup: function(frm) { refresh: function(frm) {
frappe.model.set_default_values(frm.doc); frappe.model.set_default_values(frm.doc);
frm.set_query("account" ,"accounts", function(){ frm.set_query("account" ,"accounts", function(){

View File

@ -43,6 +43,7 @@
"currency", "currency",
"write_off_account", "write_off_account",
"write_off_cost_center", "write_off_cost_center",
"write_off_limit",
"account_for_change_amount", "account_for_change_amount",
"disable_rounded_total", "disable_rounded_total",
"column_break_23", "column_break_23",
@ -360,6 +361,14 @@
"fieldtype": "Check", "fieldtype": "Check",
"label": "Validate Stock on Save" "label": "Validate Stock on Save"
}, },
{
"default": "1",
"description": "Auto write off precision loss while consolidation",
"fieldname": "write_off_limit",
"fieldtype": "Currency",
"label": "Write Off Limit",
"reqd": 1
},
{ {
"default": "0", "default": "0",
"description": "If enabled, the consolidated invoices will have rounded total disabled", "description": "If enabled, the consolidated invoices will have rounded total disabled",
@ -393,7 +402,7 @@
"link_fieldname": "pos_profile" "link_fieldname": "pos_profile"
} }
], ],
"modified": "2022-07-21 11:16:46.911173", "modified": "2022-08-10 12:57:06.241439",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "POS Profile", "name": "POS Profile",

View File

@ -4,7 +4,7 @@
frappe.query_reports["Gross Profit"] = { frappe.query_reports["Gross Profit"] = {
"filters": [ "filters": [
{ {
"fieldname":"company", "fieldname": "company",
"label": __("Company"), "label": __("Company"),
"fieldtype": "Link", "fieldtype": "Link",
"options": "Company", "options": "Company",
@ -12,32 +12,44 @@ frappe.query_reports["Gross Profit"] = {
"reqd": 1 "reqd": 1
}, },
{ {
"fieldname":"from_date", "fieldname": "from_date",
"label": __("From Date"), "label": __("From Date"),
"fieldtype": "Date", "fieldtype": "Date",
"default": frappe.defaults.get_user_default("year_start_date"), "default": frappe.defaults.get_user_default("year_start_date"),
"reqd": 1 "reqd": 1
}, },
{ {
"fieldname":"to_date", "fieldname": "to_date",
"label": __("To Date"), "label": __("To Date"),
"fieldtype": "Date", "fieldtype": "Date",
"default": frappe.defaults.get_user_default("year_end_date"), "default": frappe.defaults.get_user_default("year_end_date"),
"reqd": 1 "reqd": 1
}, },
{ {
"fieldname":"sales_invoice", "fieldname": "sales_invoice",
"label": __("Sales Invoice"), "label": __("Sales Invoice"),
"fieldtype": "Link", "fieldtype": "Link",
"options": "Sales Invoice" "options": "Sales Invoice"
}, },
{ {
"fieldname":"group_by", "fieldname": "group_by",
"label": __("Group By"), "label": __("Group By"),
"fieldtype": "Select", "fieldtype": "Select",
"options": "Invoice\nItem Code\nItem Group\nBrand\nWarehouse\nCustomer\nCustomer Group\nTerritory\nSales Person\nProject\nMonthly\nPayment Term", "options": "Invoice\nItem Code\nItem Group\nBrand\nWarehouse\nCustomer\nCustomer Group\nTerritory\nSales Person\nProject\nMonthly\nPayment Term",
"default": "Invoice" "default": "Invoice"
}, },
{
"fieldname": "item_group",
"label": __("Item Group"),
"fieldtype": "Link",
"options": "Item Group"
},
{
"fieldname": "sales_person",
"label": __("Sales Person"),
"fieldtype": "Link",
"options": "Sales Person"
},
], ],
"tree": true, "tree": true,
"name_field": "parent", "name_field": "parent",

View File

@ -7,6 +7,7 @@ from frappe import _, scrub
from frappe.utils import cint, flt, formatdate from frappe.utils import cint, flt, formatdate
from erpnext.controllers.queries import get_match_cond from erpnext.controllers.queries import get_match_cond
from erpnext.stock.report.stock_ledger.stock_ledger import get_item_group_condition
from erpnext.stock.utils import get_incoming_rate from erpnext.stock.utils import get_incoming_rate
@ -676,6 +677,17 @@ class GrossProfitGenerator(object):
if self.filters.to_date: if self.filters.to_date:
conditions += " and posting_date <= %(to_date)s" conditions += " and posting_date <= %(to_date)s"
if self.filters.item_group:
conditions += " and {0}".format(get_item_group_condition(self.filters.item_group))
if self.filters.sales_person:
conditions += """
and exists(select 1
from `tabSales Team` st
where st.parent = `tabSales Invoice`.name
and st.sales_person = %(sales_person)s)
"""
if self.filters.group_by == "Sales Person": if self.filters.group_by == "Sales Person":
sales_person_cols = ", sales.sales_person, sales.allocated_amount, sales.incentives" sales_person_cols = ", sales.sales_person, sales.allocated_amount, sales.incentives"
sales_team_table = "left join `tabSales Team` sales on sales.parent = `tabSales Invoice`.name" sales_team_table = "left join `tabSales Team` sales on sales.parent = `tabSales Invoice`.name"
@ -723,6 +735,7 @@ class GrossProfitGenerator(object):
from from
`tabSales Invoice` inner join `tabSales Invoice Item` `tabSales Invoice` inner join `tabSales Invoice Item`
on `tabSales Invoice Item`.parent = `tabSales Invoice`.name on `tabSales Invoice Item`.parent = `tabSales Invoice`.name
join `tabItem` item on item.name = `tabSales Invoice Item`.item_code
{sales_team_table} {sales_team_table}
{payment_term_table} {payment_term_table}
where where

View File

@ -770,6 +770,18 @@ class calculate_taxes_and_totals(object):
self.doc.precision("outstanding_amount"), self.doc.precision("outstanding_amount"),
) )
if (
self.doc.doctype == "Sales Invoice"
and self.doc.get("is_pos")
and self.doc.get("pos_profile")
and self.doc.get("is_consolidated")
):
write_off_limit = flt(
frappe.db.get_value("POS Profile", self.doc.pos_profile, "write_off_limit")
)
if write_off_limit and abs(self.doc.outstanding_amount) <= write_off_limit:
self.doc.write_off_outstanding_amount_automatically = 1
if ( if (
self.doc.doctype == "Sales Invoice" self.doc.doctype == "Sales Invoice"
and self.doc.get("is_pos") and self.doc.get("is_pos")

View File

@ -7,7 +7,7 @@ from collections import Counter
import frappe import frappe
from frappe import _ from frappe import _
from frappe.model.document import Document from frappe.model.document import Document
from frappe.utils import get_url, getdate from frappe.utils import get_url, getdate, now
from frappe.utils.verified_command import get_signed_params from frappe.utils.verified_command import get_signed_params
@ -104,16 +104,28 @@ class Appointment(Document):
# Return if already linked # Return if already linked
if self.party: if self.party:
return return
lead = frappe.get_doc( lead = frappe.get_doc(
{ {
"doctype": "Lead", "doctype": "Lead",
"lead_name": self.customer_name, "lead_name": self.customer_name,
"email_id": self.customer_email, "email_id": self.customer_email,
"notes": self.customer_details,
"phone": self.customer_phone_number, "phone": self.customer_phone_number,
} }
) )
if self.customer_details:
lead.append(
"notes",
{
"note": self.customer_details,
"added_by": frappe.session.user,
"added_on": now(),
},
)
lead.insert(ignore_permissions=True) lead.insert(ignore_permissions=True)
# Link lead # Link lead
self.party = lead.name self.party = lead.name

View File

@ -6,29 +6,20 @@ import unittest
import frappe import frappe
LEAD_EMAIL = "test_appointment_lead@example.com"
def create_test_lead():
test_lead = frappe.db.get_value("Lead", {"email_id": "test@example.com"})
if test_lead:
return frappe.get_doc("Lead", test_lead)
test_lead = frappe.get_doc(
{"doctype": "Lead", "lead_name": "Test Lead", "email_id": "test@example.com"}
)
test_lead.insert(ignore_permissions=True)
return test_lead
def create_test_appointments(): def create_test_appointment():
test_appointment = frappe.get_doc( test_appointment = frappe.get_doc(
{ {
"doctype": "Appointment", "doctype": "Appointment",
"email": "test@example.com",
"status": "Open", "status": "Open",
"customer_name": "Test Lead", "customer_name": "Test Lead",
"customer_phone_number": "666", "customer_phone_number": "666",
"customer_skype": "test", "customer_skype": "test",
"customer_email": "test@example.com", "customer_email": LEAD_EMAIL,
"scheduled_time": datetime.datetime.now(), "scheduled_time": datetime.datetime.now(),
"customer_details": "Hello, Friend!",
} }
) )
test_appointment.insert() test_appointment.insert()
@ -36,16 +27,16 @@ def create_test_appointments():
class TestAppointment(unittest.TestCase): class TestAppointment(unittest.TestCase):
test_appointment = test_lead = None def setUpClass():
frappe.db.delete("Lead", {"email_id": LEAD_EMAIL})
def setUp(self): def setUp(self):
self.test_lead = create_test_lead() self.test_appointment = create_test_appointment()
self.test_appointment = create_test_appointments() self.test_appointment.set_verified(self.test_appointment.customer_email)
def test_calendar_event_created(self): def test_calendar_event_created(self):
cal_event = frappe.get_doc("Event", self.test_appointment.calendar_event) cal_event = frappe.get_doc("Event", self.test_appointment.calendar_event)
self.assertEqual(cal_event.starts_on, self.test_appointment.scheduled_time) self.assertEqual(cal_event.starts_on, self.test_appointment.scheduled_time)
def test_lead_linked(self): def test_lead_linked(self):
lead = frappe.get_doc("Lead", self.test_lead.name) self.assertTrue(self.test_appointment.party)
self.assertIsNotNone(lead)

View File

@ -1,3 +1,4 @@
import click
import frappe import frappe
from frappe.utils import flt from frappe.utils import flt
@ -16,6 +17,19 @@ def execute():
for opportunity in opportunities: for opportunity in opportunities:
company_currency = erpnext.get_company_currency(opportunity.company) company_currency = erpnext.get_company_currency(opportunity.company)
if opportunity.currency is None or opportunity.currency == "":
opportunity.currency = company_currency
frappe.db.set_value(
"Opportunity",
opportunity.name,
{"currency": opportunity.currency},
update_modified=False,
)
click.secho(
f' Opportunity `{opportunity.name}` has no currency set. Setting it to company currency as default: `{opportunity.currency}`"\n',
fg="yellow",
)
# base total and total will be 0 only since item table did not have amount field earlier # base total and total will be 0 only since item table did not have amount field earlier
if opportunity.currency != company_currency: if opportunity.currency != company_currency:
conversion_rate = get_exchange_rate(opportunity.currency, company_currency) conversion_rate = get_exchange_rate(opportunity.currency, company_currency)

View File

@ -562,7 +562,7 @@ $.extend(erpnext.item, {
let selected_attributes = {}; let selected_attributes = {};
me.multiple_variant_dialog.$wrapper.find('.form-column').each((i, col) => { me.multiple_variant_dialog.$wrapper.find('.form-column').each((i, col) => {
if(i===0) return; if(i===0) return;
let attribute_name = $(col).find('label').html().trim(); let attribute_name = $(col).find('.control-label').html().trim();
selected_attributes[attribute_name] = []; selected_attributes[attribute_name] = [];
let checked_opts = $(col).find('.checkbox input'); let checked_opts = $(col).find('.checkbox input');
checked_opts.each((i, opt) => { checked_opts.each((i, opt) => {

View File

@ -48,41 +48,31 @@
"oldfieldtype": "Select", "oldfieldtype": "Select",
"options": "Item", "options": "Item",
"reqd": 1, "reqd": 1,
"search_index": 1, "search_index": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "uom", "fieldname": "uom",
"fieldtype": "Link", "fieldtype": "Link",
"label": "UOM", "label": "UOM",
"options": "UOM", "options": "UOM"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"default": "0", "default": "0",
"description": "Quantity that must be bought or sold per UOM", "description": "Quantity that must be bought or sold per UOM",
"fieldname": "packing_unit", "fieldname": "packing_unit",
"fieldtype": "Int", "fieldtype": "Int",
"label": "Packing Unit", "label": "Packing Unit"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "column_break_17", "fieldname": "column_break_17",
"fieldtype": "Column Break", "fieldtype": "Column Break"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "item_name", "fieldname": "item_name",
"fieldtype": "Data", "fieldtype": "Data",
"in_list_view": 1, "in_list_view": 1,
"label": "Item Name", "label": "Item Name",
"read_only": 1, "read_only": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fetch_from": "item_code.brand", "fetch_from": "item_code.brand",
@ -90,36 +80,29 @@
"fieldtype": "Read Only", "fieldtype": "Read Only",
"in_list_view": 1, "in_list_view": 1,
"label": "Brand", "label": "Brand",
"read_only": 1, "read_only": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "item_description", "fieldname": "item_description",
"fieldtype": "Text", "fieldtype": "Text",
"label": "Item Description", "label": "Item Description",
"read_only": 1, "read_only": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "price_list_details", "fieldname": "price_list_details",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "Price List", "label": "Price List",
"options": "fa fa-tags", "options": "fa fa-tags"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "price_list", "fieldname": "price_list",
"fieldtype": "Link", "fieldtype": "Link",
"in_global_search": 1, "in_global_search": 1,
"in_list_view": 1,
"in_standard_filter": 1, "in_standard_filter": 1,
"label": "Price List", "label": "Price List",
"options": "Price List", "options": "Price List",
"reqd": 1, "reqd": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"bold": 1, "bold": 1,
@ -127,49 +110,37 @@
"fieldname": "customer", "fieldname": "customer",
"fieldtype": "Link", "fieldtype": "Link",
"label": "Customer", "label": "Customer",
"options": "Customer", "options": "Customer"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"depends_on": "eval:doc.buying == 1", "depends_on": "eval:doc.buying == 1",
"fieldname": "supplier", "fieldname": "supplier",
"fieldtype": "Link", "fieldtype": "Link",
"label": "Supplier", "label": "Supplier",
"options": "Supplier", "options": "Supplier"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "column_break_3", "fieldname": "column_break_3",
"fieldtype": "Column Break", "fieldtype": "Column Break"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"default": "0", "default": "0",
"fieldname": "buying", "fieldname": "buying",
"fieldtype": "Check", "fieldtype": "Check",
"label": "Buying", "label": "Buying",
"read_only": 1, "read_only": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"default": "0", "default": "0",
"fieldname": "selling", "fieldname": "selling",
"fieldtype": "Check", "fieldtype": "Check",
"label": "Selling", "label": "Selling",
"read_only": 1, "read_only": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "item_details", "fieldname": "item_details",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"options": "fa fa-tag", "options": "fa fa-tag"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"bold": 1, "bold": 1,
@ -177,15 +148,11 @@
"fieldtype": "Link", "fieldtype": "Link",
"label": "Currency", "label": "Currency",
"options": "Currency", "options": "Currency",
"read_only": 1, "read_only": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "col_br_1", "fieldname": "col_br_1",
"fieldtype": "Column Break", "fieldtype": "Column Break"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "price_list_rate", "fieldname": "price_list_rate",
@ -197,80 +164,61 @@
"oldfieldname": "ref_rate", "oldfieldname": "ref_rate",
"oldfieldtype": "Currency", "oldfieldtype": "Currency",
"options": "currency", "options": "currency",
"reqd": 1, "reqd": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "section_break_15", "fieldname": "section_break_15",
"fieldtype": "Section Break", "fieldtype": "Section Break"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"default": "Today", "default": "Today",
"fieldname": "valid_from", "fieldname": "valid_from",
"fieldtype": "Date", "fieldtype": "Date",
"label": "Valid From", "label": "Valid From"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"default": "0", "default": "0",
"fieldname": "lead_time_days", "fieldname": "lead_time_days",
"fieldtype": "Int", "fieldtype": "Int",
"label": "Lead Time in days", "label": "Lead Time in days"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "column_break_18", "fieldname": "column_break_18",
"fieldtype": "Column Break", "fieldtype": "Column Break"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "valid_upto", "fieldname": "valid_upto",
"fieldtype": "Date", "fieldtype": "Date",
"label": "Valid Upto", "label": "Valid Upto"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "section_break_24", "fieldname": "section_break_24",
"fieldtype": "Section Break", "fieldtype": "Section Break"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "note", "fieldname": "note",
"fieldtype": "Text", "fieldtype": "Text",
"label": "Note", "label": "Note"
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fieldname": "reference", "fieldname": "reference",
"fieldtype": "Data", "fieldtype": "Data",
"in_list_view": 1, "in_list_view": 1,
"label": "Reference", "in_standard_filter": 1,
"show_days": 1, "label": "Reference"
"show_seconds": 1
}, },
{ {
"fieldname": "batch_no", "fieldname": "batch_no",
"fieldtype": "Link", "fieldtype": "Link",
"label": "Batch No", "label": "Batch No",
"options": "Batch", "options": "Batch"
"show_days": 1,
"show_seconds": 1
} }
], ],
"icon": "fa fa-flag", "icon": "fa fa-flag",
"idx": 1, "idx": 1,
"index_web_pages_for_search": 1, "index_web_pages_for_search": 1,
"links": [], "links": [],
"modified": "2020-12-08 18:12:15.395772", "modified": "2022-09-02 16:33:55.612992",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Stock", "module": "Stock",
"name": "Item Price", "name": "Item Price",
@ -307,6 +255,7 @@
"quick_entry": 1, "quick_entry": 1,
"sort_field": "modified", "sort_field": "modified",
"sort_order": "ASC", "sort_order": "ASC",
"states": [],
"title_field": "item_name", "title_field": "item_name",
"track_changes": 1 "track_changes": 1
} }

View File

@ -0,0 +1,3 @@
frappe.listview_settings['Item Price'] = {
hide_name_column: true,
};