fix: Valid warehouse in woocommerce syncing and other small fixes (#21407)
* fix: Valid warehouse in woocommerce syncing * fix: dmall fixes in gross & net profit report * fix: company is required for getting party details * fix: None issue while getting raw material rate based on last purchase rate
This commit is contained in:
parent
454b1cf48d
commit
ad16e61bc2
@ -302,7 +302,7 @@ frappe.ui.form.on('Payment Entry', {
|
|||||||
frm.set_value("contact_email", "");
|
frm.set_value("contact_email", "");
|
||||||
frm.set_value("contact_person", "");
|
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) {
|
if(!frm.doc.posting_date) {
|
||||||
frappe.msgprint(__("Please select Posting Date before selecting Party"))
|
frappe.msgprint(__("Please select Posting Date before selecting Party"))
|
||||||
frm.set_value("party", "");
|
frm.set_value("party", "");
|
||||||
|
@ -8,7 +8,6 @@ from frappe.utils import flt
|
|||||||
from erpnext.accounts.report.financial_statements import (get_period_list, get_columns, get_data)
|
from erpnext.accounts.report.financial_statements import (get_period_list, get_columns, get_data)
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
|
|
||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year,
|
period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year,
|
||||||
filters.periodicity, filters.accumulated_values, filters.company)
|
filters.periodicity, filters.accumulated_values, filters.company)
|
||||||
@ -27,17 +26,19 @@ def execute(filters=None):
|
|||||||
|
|
||||||
|
|
||||||
gross_income = get_revenue(income, period_list)
|
gross_income = get_revenue(income, period_list)
|
||||||
|
|
||||||
gross_expense = get_revenue(expense, period_list)
|
gross_expense = get_revenue(expense, period_list)
|
||||||
|
|
||||||
if(len(gross_income)==0 and len(gross_expense)== 0):
|
if(len(gross_income)==0 and len(gross_expense)== 0):
|
||||||
data.append({"account_name": "'" + _("Nothing is included in gross") + "'",
|
data.append({
|
||||||
"account": "'" + _("Nothing is included in gross") + "'"})
|
"account_name": "'" + _("Nothing is included in gross") + "'",
|
||||||
|
"account": "'" + _("Nothing is included in gross") + "'"
|
||||||
|
})
|
||||||
return columns, data
|
return columns, data
|
||||||
|
|
||||||
data.append({"account_name": "'" + _("Included in Gross Profit") + "'",
|
data.append({
|
||||||
"account": "'" + _("Included in Gross Profit") + "'"})
|
"account_name": "'" + _("Included in Gross Profit") + "'",
|
||||||
|
"account": "'" + _("Included in Gross Profit") + "'"
|
||||||
|
})
|
||||||
|
|
||||||
data.append({})
|
data.append({})
|
||||||
data.extend(gross_income or [])
|
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):
|
def get_profit(gross_income, gross_expense, period_list, company, profit_type, currency=None, consolidated=False):
|
||||||
|
|
||||||
profit_loss = {
|
profit_loss = {
|
||||||
"account_name": "'" + _(profit_type) + "'",
|
"account_name": "'" + _(profit_type) + "'",
|
||||||
"account": "'" + _(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:
|
for period in period_list:
|
||||||
key = period if consolidated else period.key
|
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]:
|
if profit_loss[key]:
|
||||||
has_value=True
|
has_value=True
|
||||||
@ -143,8 +145,14 @@ def get_net_profit(non_gross_income, gross_income, gross_expense, non_gross_expe
|
|||||||
|
|
||||||
for period in period_list:
|
for period in period_list:
|
||||||
key = period if consolidated else period.key
|
key = period if consolidated else period.key
|
||||||
total_income = flt(gross_income[0].get(key, 0)) + flt(non_gross_income[0].get(key, 0))
|
gross_income_for_period = flt(gross_income[0].get(key, 0)) if gross_income else 0
|
||||||
total_expense = flt(gross_expense[0].get(key, 0)) + flt(non_gross_expense[0].get(key, 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)
|
profit_loss[key] = flt(total_income) - flt(total_expense)
|
||||||
|
|
||||||
if profit_loss[key]:
|
if profit_loss[key]:
|
||||||
|
@ -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):
|
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')
|
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"):
|
for item in order.get("line_items"):
|
||||||
woocomm_item_id = item.get("product_id")
|
woocomm_item_id = item.get("product_id")
|
||||||
found_item = frappe.get_doc("Item", {"woocommerce_id": woocomm_item_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),
|
"uom": woocommerce_settings.uom or _("Nos", sys_lang),
|
||||||
"qty": item.get("quantity"),
|
"qty": item.get("quantity"),
|
||||||
"rate": item.get("price"),
|
"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)
|
add_tax_details(new_sales_order, ordered_items_tax, "Ordered Item tax", woocommerce_settings.tax_account)
|
||||||
|
@ -193,7 +193,7 @@ class BOM(WebsiteGenerator):
|
|||||||
if self.rm_cost_as_per == 'Valuation Rate':
|
if self.rm_cost_as_per == 'Valuation Rate':
|
||||||
rate = self.get_valuation_rate(arg) * (arg.get("conversion_factor") or 1)
|
rate = self.get_valuation_rate(arg) * (arg.get("conversion_factor") or 1)
|
||||||
elif self.rm_cost_as_per == 'Last Purchase Rate':
|
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")) \
|
or frappe.db.get_value("Item", arg['item_code'], "last_purchase_rate")) \
|
||||||
* (arg.get("conversion_factor") or 1)
|
* (arg.get("conversion_factor") or 1)
|
||||||
elif self.rm_cost_as_per == "Price List":
|
elif self.rm_cost_as_per == "Price List":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user