Price list rate fix multiple uom and validation with prev doc (#8718)

This commit is contained in:
Nabin Hait 2017-05-06 12:47:14 +05:30 committed by GitHub
parent 7228e1af6e
commit 3257aeeb55
4 changed files with 44 additions and 19 deletions

View File

@ -341,13 +341,23 @@ class SalesInvoice(SellingController):
super(SalesInvoice, self).validate_with_previous_doc({ super(SalesInvoice, self).validate_with_previous_doc({
"Sales Order": { "Sales Order": {
"ref_dn_field": "sales_order", "ref_dn_field": "sales_order",
"compare_fields": [["customer", "="], ["company", "="], ["project", "="], "compare_fields": [["customer", "="], ["company", "="], ["project", "="], ["currency", "="]]
["currency", "="]], },
"Sales Order Item": {
"ref_dn_field": "so_detail",
"compare_fields": [["item_code", "="], ["uom", "="], ["conversion_factor", "="]],
"is_child_table": True,
"allow_duplicate_prev_row_id": True
}, },
"Delivery Note": { "Delivery Note": {
"ref_dn_field": "delivery_note", "ref_dn_field": "delivery_note",
"compare_fields": [["customer", "="], ["company", "="], ["project", "="], "compare_fields": [["customer", "="], ["company", "="], ["project", "="], ["currency", "="]]
["currency", "="]], },
"Delivery Note Item": {
"ref_dn_field": "dn_detail",
"compare_fields": [["item_code", "="], ["uom", "="], ["conversion_factor", "="]],
"is_child_table": True,
"allow_duplicate_prev_row_id": True
}, },
}) })

View File

@ -59,7 +59,8 @@ class PurchaseOrder(BuyingController):
}, },
"Supplier Quotation Item": { "Supplier Quotation Item": {
"ref_dn_field": "supplier_quotation_item", "ref_dn_field": "supplier_quotation_item",
"compare_fields": [["rate", "="], ["project", "="], ["item_code", "="]], "compare_fields": [["rate", "="], ["project", "="], ["item_code", "="],
["uom", "="], ["conversion_factor", "="]],
"is_child_table": True "is_child_table": True
} }
}) })

View File

@ -564,14 +564,14 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
} }
}, },
conversion_factor: function(doc, cdt, cdn) { conversion_factor: function(doc, cdt, cdn, dont_fetch_price_list_rate) {
if(frappe.meta.get_docfield(cdt, "stock_qty", cdn)) { if(frappe.meta.get_docfield(cdt, "stock_qty", cdn)) {
var item = frappe.get_doc(cdt, cdn); var item = frappe.get_doc(cdt, cdn);
frappe.model.round_floats_in(item, ["qty", "conversion_factor"]); frappe.model.round_floats_in(item, ["qty", "conversion_factor"]);
item.stock_qty = flt(item.qty * item.conversion_factor, precision("stock_qty", item)); item.stock_qty = flt(item.qty * item.conversion_factor, precision("stock_qty", item));
refresh_field("stock_qty", item.name, item.parentfield); refresh_field("stock_qty", item.name, item.parentfield);
this.toggle_conversion_factor(item); this.toggle_conversion_factor(item);
this.apply_price_list(item, true); if(!dont_fetch_price_list_rate) this.apply_price_list(item, true);
} }
}, },
@ -582,7 +582,8 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
}, },
qty: function(doc, cdt, cdn) { qty: function(doc, cdt, cdn) {
this.conversion_factor(doc, cdt, cdn); this.conversion_factor(doc, cdt, cdn, true);
this.apply_pricing_rule(frappe.get_doc(cdt, cdn), true);
}, },
set_dynamic_labels: function() { set_dynamic_labels: function() {

View File

@ -117,18 +117,31 @@ class DeliveryNote(SellingController):
if not self.installation_status: self.installation_status = 'Not Installed' if not self.installation_status: self.installation_status = 'Not Installed'
def validate_with_previous_doc(self): def validate_with_previous_doc(self):
for fn in (("Sales Order", "against_sales_order", "so_detail"), super(DeliveryNote, self).validate_with_previous_doc({
("Sales Invoice", "against_sales_invoice", "si_detail")): "Sales Order": {
if filter(None, [getattr(d, fn[1], None) for d in self.get("items")]): "ref_dn_field": "against_sales_order",
super(DeliveryNote, self).validate_with_previous_doc({ "compare_fields": [["customer", "="], ["company", "="], ["project", "="], ["currency", "="]]
fn[0]: { },
"ref_dn_field": fn[1], "Sales Order Item": {
"compare_fields": [["customer", "="], ["company", "="], ["project", "="], "ref_dn_field": "so_detail",
["currency", "="]], "compare_fields": [["item_code", "="], ["uom", "="], ["conversion_factor", "="]],
}, "is_child_table": True,
}) "allow_duplicate_prev_row_id": True
},
"Sales Invoice": {
"ref_dn_field": "against_sales_invoice",
"compare_fields": [["customer", "="], ["company", "="], ["project", "="], ["currency", "="]]
},
"Sales Invoice Item": {
"ref_dn_field": "si_detail",
"compare_fields": [["item_code", "="], ["uom", "="], ["conversion_factor", "="]],
"is_child_table": True,
"allow_duplicate_prev_row_id": True
},
})
if cint(frappe.db.get_single_value('Selling Settings', 'maintain_same_sales_rate')) and not self.is_return: if cint(frappe.db.get_single_value('Selling Settings', 'maintain_same_sales_rate')) \
and not self.is_return:
self.validate_rate_with_reference_doc([["Sales Order", "against_sales_order", "so_detail"], self.validate_rate_with_reference_doc([["Sales Order", "against_sales_order", "so_detail"],
["Sales Invoice", "against_sales_invoice", "si_detail"]]) ["Sales Invoice", "against_sales_invoice", "si_detail"]])