mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-26 08:24:47 +00:00
Merge branch 'version-13-hotfix' into fix-ecommerce-selling-price-with-rule
This commit is contained in:
@@ -680,7 +680,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
|||||||
var item = frappe.get_doc(cdt, cdn);
|
var item = frappe.get_doc(cdt, cdn);
|
||||||
frappe.model.round_floats_in(item, ["price_list_rate", "discount_percentage"]);
|
frappe.model.round_floats_in(item, ["price_list_rate", "discount_percentage"]);
|
||||||
|
|
||||||
// check if child doctype is Sales Order Item/Qutation Item and calculate the rate
|
// check if child doctype is Sales Order Item/Quotation Item and calculate the rate
|
||||||
if (in_list(["Quotation Item", "Sales Order Item", "Delivery Note Item", "Sales Invoice Item", "POS Invoice Item", "Purchase Invoice Item", "Purchase Order Item", "Purchase Receipt Item"]), cdt)
|
if (in_list(["Quotation Item", "Sales Order Item", "Delivery Note Item", "Sales Invoice Item", "POS Invoice Item", "Purchase Invoice Item", "Purchase Order Item", "Purchase Receipt Item"]), cdt)
|
||||||
this.apply_pricing_rule_on_item(item);
|
this.apply_pricing_rule_on_item(item);
|
||||||
else
|
else
|
||||||
@@ -1562,25 +1562,27 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
|||||||
|
|
||||||
_set_values_for_item_list: function(children) {
|
_set_values_for_item_list: function(children) {
|
||||||
var me = this;
|
var me = this;
|
||||||
var price_list_rate_changed = false;
|
|
||||||
var items_rule_dict = {};
|
var items_rule_dict = {};
|
||||||
|
|
||||||
for(var i=0, l=children.length; i<l; i++) {
|
for(var i=0, l=children.length; i<l; i++) {
|
||||||
var d = children[i];
|
var d = children[i] ;
|
||||||
|
let item_row = frappe.get_doc(d.doctype, d.name);
|
||||||
var existing_pricing_rule = frappe.model.get_value(d.doctype, d.name, "pricing_rules");
|
var existing_pricing_rule = frappe.model.get_value(d.doctype, d.name, "pricing_rules");
|
||||||
for(var k in d) {
|
for(var k in d) {
|
||||||
var v = d[k];
|
var v = d[k];
|
||||||
if (["doctype", "name"].indexOf(k)===-1) {
|
if (["doctype", "name"].indexOf(k)===-1) {
|
||||||
if(k=="price_list_rate") {
|
if(k=="price_list_rate") {
|
||||||
if(flt(v) != flt(d.price_list_rate)) price_list_rate_changed = true;
|
item_row['rate'] = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (k !== 'free_item_data') {
|
if (k !== 'free_item_data') {
|
||||||
frappe.model.set_value(d.doctype, d.name, k, v);
|
item_row[k] = v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
frappe.model.round_floats_in(item_row, ["price_list_rate", "discount_percentage"]);
|
||||||
|
|
||||||
// if pricing rule set as blank from an existing value, apply price_list
|
// if pricing rule set as blank from an existing value, apply price_list
|
||||||
if(!me.frm.doc.ignore_pricing_rule && existing_pricing_rule && !d.pricing_rules) {
|
if(!me.frm.doc.ignore_pricing_rule && existing_pricing_rule && !d.pricing_rules) {
|
||||||
me.apply_price_list(frappe.get_doc(d.doctype, d.name));
|
me.apply_price_list(frappe.get_doc(d.doctype, d.name));
|
||||||
@@ -1597,9 +1599,10 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
me.frm.refresh_field('items');
|
||||||
me.apply_rule_on_other_items(items_rule_dict);
|
me.apply_rule_on_other_items(items_rule_dict);
|
||||||
|
|
||||||
if(!price_list_rate_changed) me.calculate_taxes_and_totals();
|
me.calculate_taxes_and_totals();
|
||||||
},
|
},
|
||||||
|
|
||||||
apply_rule_on_other_items: function(args) {
|
apply_rule_on_other_items: function(args) {
|
||||||
|
|||||||
@@ -1098,7 +1098,7 @@ def apply_price_list(args, as_doc=False):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def apply_price_list_on_item(args):
|
def apply_price_list_on_item(args):
|
||||||
item_doc = frappe.get_doc("Item", args.item_code)
|
item_doc = frappe.db.get_value("Item", args.item_code, ['name', 'variant_of'], as_dict=1)
|
||||||
item_details = get_price_list_rate(args, item_doc)
|
item_details = get_price_list_rate(args, item_doc)
|
||||||
|
|
||||||
item_details.update(get_pricing_rule_for_item(args, item_details.price_list_rate))
|
item_details.update(get_pricing_rule_for_item(args, item_details.price_list_rate))
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ const DIFFERNCE_FIELD_NAMES = [
|
|||||||
"fifo_value_diff",
|
"fifo_value_diff",
|
||||||
"fifo_valuation_diff",
|
"fifo_valuation_diff",
|
||||||
"valuation_diff",
|
"valuation_diff",
|
||||||
"fifo_difference_diff"
|
"fifo_difference_diff",
|
||||||
|
"diff_value_diff"
|
||||||
];
|
];
|
||||||
|
|
||||||
frappe.query_reports["Stock Ledger Invariant Check"] = {
|
frappe.query_reports["Stock Ledger Invariant Check"] = {
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ def get_stock_ledger_entries(filters):
|
|||||||
|
|
||||||
def add_invariant_check_fields(sles):
|
def add_invariant_check_fields(sles):
|
||||||
balance_qty = 0.0
|
balance_qty = 0.0
|
||||||
|
balance_stock_value = 0.0
|
||||||
for idx, sle in enumerate(sles):
|
for idx, sle in enumerate(sles):
|
||||||
queue = json.loads(sle.stock_queue)
|
queue = json.loads(sle.stock_queue)
|
||||||
|
|
||||||
@@ -60,6 +61,7 @@ def add_invariant_check_fields(sles):
|
|||||||
fifo_value += qty * rate
|
fifo_value += qty * rate
|
||||||
|
|
||||||
balance_qty += sle.actual_qty
|
balance_qty += sle.actual_qty
|
||||||
|
balance_stock_value += sle.stock_value_difference
|
||||||
if sle.voucher_type == "Stock Reconciliation" and not sle.batch_no:
|
if sle.voucher_type == "Stock Reconciliation" and not sle.batch_no:
|
||||||
balance_qty = sle.qty_after_transaction
|
balance_qty = sle.qty_after_transaction
|
||||||
|
|
||||||
@@ -70,6 +72,7 @@ def add_invariant_check_fields(sles):
|
|||||||
sle.stock_value / sle.qty_after_transaction if sle.qty_after_transaction else None
|
sle.stock_value / sle.qty_after_transaction if sle.qty_after_transaction else None
|
||||||
)
|
)
|
||||||
sle.expected_qty_after_transaction = balance_qty
|
sle.expected_qty_after_transaction = balance_qty
|
||||||
|
sle.stock_value_from_diff = balance_stock_value
|
||||||
|
|
||||||
# set difference fields
|
# set difference fields
|
||||||
sle.difference_in_qty = sle.qty_after_transaction - sle.expected_qty_after_transaction
|
sle.difference_in_qty = sle.qty_after_transaction - sle.expected_qty_after_transaction
|
||||||
@@ -81,6 +84,7 @@ def add_invariant_check_fields(sles):
|
|||||||
sle.valuation_diff = (
|
sle.valuation_diff = (
|
||||||
sle.valuation_rate - sle.balance_value_by_qty if sle.balance_value_by_qty else None
|
sle.valuation_rate - sle.balance_value_by_qty if sle.balance_value_by_qty else None
|
||||||
)
|
)
|
||||||
|
sle.diff_value_diff = sle.stock_value_from_diff - sle.stock_value
|
||||||
|
|
||||||
if idx > 0:
|
if idx > 0:
|
||||||
sle.fifo_stock_diff = sle.fifo_stock_value - sles[idx - 1].fifo_stock_value
|
sle.fifo_stock_diff = sle.fifo_stock_value - sles[idx - 1].fifo_stock_value
|
||||||
@@ -191,12 +195,21 @@ def get_columns():
|
|||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
"label": "D - E",
|
"label": "D - E",
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"fieldname": "stock_value_difference",
|
"fieldname": "stock_value_difference",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
"label": "(F) Stock Value Difference",
|
"label": "(F) Stock Value Difference",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "stock_value_from_diff",
|
||||||
|
"fieldtype": "Float",
|
||||||
|
"label": "Balance Stock Value using (F)",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "diff_value_diff",
|
||||||
|
"fieldtype": "Float",
|
||||||
|
"label": "K - D",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "fifo_stock_diff",
|
"fieldname": "fifo_stock_diff",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
|
|||||||
Reference in New Issue
Block a user