diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.js b/erpnext/accounts/doctype/payment_entry/payment_entry.js index 05f01475c1..a378a51cdf 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.js +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.js @@ -302,7 +302,7 @@ frappe.ui.form.on('Payment Entry', { frm.set_value("contact_email", ""); frm.set_value("contact_person", ""); } - if(frm.doc.payment_type && frm.doc.party_type && frm.doc.party) { + if(frm.doc.payment_type && frm.doc.party_type && frm.doc.party && frm.doc.company) { if(!frm.doc.posting_date) { frappe.msgprint(__("Please select Posting Date before selecting Party")) frm.set_value("party", ""); diff --git a/erpnext/accounts/report/gross_and_net_profit_report/gross_and_net_profit_report.py b/erpnext/accounts/report/gross_and_net_profit_report/gross_and_net_profit_report.py index 6550981a14..260f35f270 100644 --- a/erpnext/accounts/report/gross_and_net_profit_report/gross_and_net_profit_report.py +++ b/erpnext/accounts/report/gross_and_net_profit_report/gross_and_net_profit_report.py @@ -8,7 +8,6 @@ from frappe.utils import flt from erpnext.accounts.report.financial_statements import (get_period_list, get_columns, get_data) import copy - def execute(filters=None): period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year, filters.periodicity, filters.accumulated_values, filters.company) @@ -27,17 +26,19 @@ def execute(filters=None): gross_income = get_revenue(income, period_list) - gross_expense = get_revenue(expense, period_list) if(len(gross_income)==0 and len(gross_expense)== 0): - data.append({"account_name": "'" + _("Nothing is included in gross") + "'", - "account": "'" + _("Nothing is included in gross") + "'"}) - + data.append({ + "account_name": "'" + _("Nothing is included in gross") + "'", + "account": "'" + _("Nothing is included in gross") + "'" + }) return columns, data - data.append({"account_name": "'" + _("Included in Gross Profit") + "'", - "account": "'" + _("Included in Gross Profit") + "'"}) + data.append({ + "account_name": "'" + _("Included in Gross Profit") + "'", + "account": "'" + _("Included in Gross Profit") + "'" + }) data.append({}) data.extend(gross_income or []) @@ -111,7 +112,6 @@ def set_total(node, value, complete_list, totals): def get_profit(gross_income, gross_expense, period_list, company, profit_type, currency=None, consolidated=False): - profit_loss = { "account_name": "'" + _(profit_type) + "'", "account": "'" + _(profit_type) + "'", @@ -123,7 +123,9 @@ def get_profit(gross_income, gross_expense, period_list, company, profit_type, c for period in period_list: key = period if consolidated else period.key - profit_loss[key] = flt(gross_income[0].get(key, 0)) - flt(gross_expense[0].get(key, 0)) + gross_income_for_period = flt(gross_income[0].get(key, 0)) if gross_income else 0 + gross_expense_for_period = flt(gross_expense[0].get(key, 0)) if gross_expense else 0 + profit_loss[key] = gross_income_for_period - gross_expense_for_period if profit_loss[key]: has_value=True @@ -143,12 +145,18 @@ def get_net_profit(non_gross_income, gross_income, gross_expense, non_gross_expe for period in period_list: key = period if consolidated else period.key - total_income = flt(gross_income[0].get(key, 0)) + flt(non_gross_income[0].get(key, 0)) - total_expense = flt(gross_expense[0].get(key, 0)) + flt(non_gross_expense[0].get(key, 0)) + gross_income_for_period = flt(gross_income[0].get(key, 0)) if gross_income else 0 + non_gross_income_for_period = flt(non_gross_income[0].get(key, 0)) if non_gross_income else 0 + + gross_expense_for_period = flt(gross_expense[0].get(key, 0)) if gross_expense else 0 + non_gross_expense_for_period = flt(non_gross_expense[0].get(key, 0)) if non_gross_expense else 0 + + total_income = gross_income_for_period + non_gross_income_for_period + total_expense = gross_expense_for_period + non_gross_expense_for_period profit_loss[key] = flt(total_income) - flt(total_expense) if profit_loss[key]: has_value=True if has_value: - return profit_loss + return profit_loss \ No newline at end of file diff --git a/erpnext/erpnext_integrations/connectors/woocommerce_connection.py b/erpnext/erpnext_integrations/connectors/woocommerce_connection.py index 4422d23e38..618865200c 100644 --- a/erpnext/erpnext_integrations/connectors/woocommerce_connection.py +++ b/erpnext/erpnext_integrations/connectors/woocommerce_connection.py @@ -144,6 +144,10 @@ def create_sales_order(order, woocommerce_settings, customer_name, sys_lang): def set_items_in_sales_order(new_sales_order, woocommerce_settings, order, sys_lang): company_abbr = frappe.db.get_value('Company', woocommerce_settings.company, 'abbr') + default_warehouse = _("Stores - {0}", sys_lang).format(company_abbr) + if not frappe.db.exists("Warehouse", default_warehouse): + frappe.throw(_("Please set Warehouse in Woocommerce Settings")) + for item in order.get("line_items"): woocomm_item_id = item.get("product_id") found_item = frappe.get_doc("Item", {"woocommerce_id": woocomm_item_id}) @@ -158,7 +162,7 @@ def set_items_in_sales_order(new_sales_order, woocommerce_settings, order, sys_l "uom": woocommerce_settings.uom or _("Nos", sys_lang), "qty": item.get("quantity"), "rate": item.get("price"), - "warehouse": woocommerce_settings.warehouse or _("Stores - {0}", sys_lang).format(company_abbr) + "warehouse": woocommerce_settings.warehouse or default_warehouse }) add_tax_details(new_sales_order, ordered_items_tax, "Ordered Item tax", woocommerce_settings.tax_account) diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py index a83d193b6a..b1fc4deae9 100644 --- a/erpnext/manufacturing/doctype/bom/bom.py +++ b/erpnext/manufacturing/doctype/bom/bom.py @@ -193,7 +193,7 @@ class BOM(WebsiteGenerator): if self.rm_cost_as_per == 'Valuation Rate': rate = self.get_valuation_rate(arg) * (arg.get("conversion_factor") or 1) elif self.rm_cost_as_per == 'Last Purchase Rate': - rate = (arg.get('last_purchase_rate') \ + rate = flt(arg.get('last_purchase_rate') \ or frappe.db.get_value("Item", arg['item_code'], "last_purchase_rate")) \ * (arg.get("conversion_factor") or 1) elif self.rm_cost_as_per == "Price List":