mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-25 16:04:46 +00:00
Merge branch 'develop' of https://github.com/frappe/erpnext into e_invoice_discounts
This commit is contained in:
@@ -2133,6 +2133,8 @@ def make_inter_company_transaction(doctype, source_name, target_doc=None):
|
|||||||
source_document_warehouse_field = "from_warehouse"
|
source_document_warehouse_field = "from_warehouse"
|
||||||
target_document_warehouse_field = "target_warehouse"
|
target_document_warehouse_field = "target_warehouse"
|
||||||
|
|
||||||
|
received_items = get_received_items(source_name, target_doctype, target_detail_field)
|
||||||
|
|
||||||
validate_inter_company_transaction(source_doc, doctype)
|
validate_inter_company_transaction(source_doc, doctype)
|
||||||
details = get_inter_company_details(source_doc, doctype)
|
details = get_inter_company_details(source_doc, doctype)
|
||||||
|
|
||||||
@@ -2197,12 +2199,17 @@ def make_inter_company_transaction(doctype, source_name, target_doc=None):
|
|||||||
shipping_address_name=target_doc.shipping_address_name,
|
shipping_address_name=target_doc.shipping_address_name,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def update_item(source, target, source_parent):
|
||||||
|
target.qty = flt(source.qty) - received_items.get(source.name, 0.0)
|
||||||
|
|
||||||
item_field_map = {
|
item_field_map = {
|
||||||
"doctype": target_doctype + " Item",
|
"doctype": target_doctype + " Item",
|
||||||
"field_no_map": ["income_account", "expense_account", "cost_center", "warehouse"],
|
"field_no_map": ["income_account", "expense_account", "cost_center", "warehouse"],
|
||||||
"field_map": {
|
"field_map": {
|
||||||
"rate": "rate",
|
"rate": "rate",
|
||||||
},
|
},
|
||||||
|
"postprocess": update_item,
|
||||||
|
"condition": lambda doc: doc.qty > 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
if doctype in ["Sales Invoice", "Sales Order"]:
|
if doctype in ["Sales Invoice", "Sales Order"]:
|
||||||
@@ -2240,6 +2247,28 @@ def make_inter_company_transaction(doctype, source_name, target_doc=None):
|
|||||||
return doclist
|
return doclist
|
||||||
|
|
||||||
|
|
||||||
|
def get_received_items(reference_name, doctype, reference_fieldname):
|
||||||
|
target_doctypes = frappe.get_all(
|
||||||
|
doctype,
|
||||||
|
filters={"inter_company_invoice_reference": reference_name, "docstatus": 1},
|
||||||
|
as_list=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
if target_doctypes:
|
||||||
|
target_doctypes = list(target_doctypes[0])
|
||||||
|
|
||||||
|
received_items_map = frappe._dict(
|
||||||
|
frappe.get_all(
|
||||||
|
doctype + " Item",
|
||||||
|
filters={"parent": ("in", target_doctypes)},
|
||||||
|
fields=[reference_fieldname, "qty"],
|
||||||
|
as_list=1,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
return received_items_map
|
||||||
|
|
||||||
|
|
||||||
def set_purchase_references(doc):
|
def set_purchase_references(doc):
|
||||||
# add internal PO or PR links if any
|
# add internal PO or PR links if any
|
||||||
if doc.is_internal_transfer():
|
if doc.is_internal_transfer():
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ def get_data():
|
|||||||
"Payment Request": "reference_name",
|
"Payment Request": "reference_name",
|
||||||
"Sales Invoice": "return_against",
|
"Sales Invoice": "return_against",
|
||||||
"Auto Repeat": "reference_document",
|
"Auto Repeat": "reference_document",
|
||||||
|
"Purchase Invoice": "inter_company_invoice_reference",
|
||||||
},
|
},
|
||||||
"internal_links": {
|
"internal_links": {
|
||||||
"Sales Order": ["items", "sales_order"],
|
"Sales Order": ["items", "sales_order"],
|
||||||
@@ -30,5 +31,6 @@ def get_data():
|
|||||||
{"label": _("Reference"), "items": ["Timesheet", "Delivery Note", "Sales Order"]},
|
{"label": _("Reference"), "items": ["Timesheet", "Delivery Note", "Sales Order"]},
|
||||||
{"label": _("Returns"), "items": ["Sales Invoice"]},
|
{"label": _("Returns"), "items": ["Sales Invoice"]},
|
||||||
{"label": _("Subscription"), "items": ["Auto Repeat"]},
|
{"label": _("Subscription"), "items": ["Auto Repeat"]},
|
||||||
|
{"label": _("Internal Transfers"), "items": ["Purchase Invoice"]},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1499,48 +1499,46 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
|||||||
}
|
}
|
||||||
|
|
||||||
_set_values_for_item_list(children) {
|
_set_values_for_item_list(children) {
|
||||||
var me = this;
|
const items_rule_dict = {};
|
||||||
var items_rule_dict = {};
|
|
||||||
|
|
||||||
for(var i=0, l=children.length; i<l; i++) {
|
for (const child of children) {
|
||||||
var d = children[i] ;
|
const existing_pricing_rule = frappe.model.get_value(child.doctype, child.name, "pricing_rules");
|
||||||
let item_row = frappe.get_doc(d.doctype, d.name);
|
|
||||||
var existing_pricing_rule = frappe.model.get_value(d.doctype, d.name, "pricing_rules");
|
for (const [key, value] of Object.entries(child)) {
|
||||||
for(var k in d) {
|
if (!["doctype", "name"].includes(key)) {
|
||||||
var v = d[k];
|
if (key === "price_list_rate") {
|
||||||
if (["doctype", "name"].indexOf(k)===-1) {
|
frappe.model.set_value(child.doctype, child.name, "rate", value);
|
||||||
if(k=="price_list_rate") {
|
|
||||||
item_row['rate'] = v;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (k !== 'free_item_data') {
|
if (key !== "free_item_data") {
|
||||||
item_row[k] = v;
|
frappe.model.set_value(child.doctype, child.name, key, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
frappe.model.round_floats_in(item_row, ["price_list_rate", "discount_percentage"]);
|
frappe.model.round_floats_in(
|
||||||
|
frappe.get_doc(child.doctype, child.name),
|
||||||
|
["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 (!this.frm.doc.ignore_pricing_rule && existing_pricing_rule && !child.pricing_rules) {
|
||||||
me.apply_price_list(frappe.get_doc(d.doctype, d.name));
|
this.apply_price_list(frappe.get_doc(child.doctype, child.name));
|
||||||
} else if(!d.pricing_rules) {
|
} else if (!child.pricing_rules) {
|
||||||
me.remove_pricing_rule(frappe.get_doc(d.doctype, d.name));
|
this.remove_pricing_rule(frappe.get_doc(child.doctype, child.name));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (d.free_item_data.length > 0) {
|
if (child.free_item_data.length > 0) {
|
||||||
me.apply_product_discount(d);
|
this.apply_product_discount(child);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (d.apply_rule_on_other_items) {
|
if (child.apply_rule_on_other_items) {
|
||||||
items_rule_dict[d.name] = d;
|
items_rule_dict[child.name] = child;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
me.frm.refresh_field('items');
|
this.apply_rule_on_other_items(items_rule_dict);
|
||||||
me.apply_rule_on_other_items(items_rule_dict);
|
this.calculate_taxes_and_totals();
|
||||||
|
|
||||||
me.calculate_taxes_and_totals();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
apply_rule_on_other_items(args) {
|
apply_rule_on_other_items(args) {
|
||||||
|
|||||||
Reference in New Issue
Block a user