From f00407773427375a1ec6ee069a3d55557df29893 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 11 Nov 2014 10:43:28 +0530 Subject: [PATCH 1/3] Map only pending qty from Material Request to Purchase Order/Stock Entry --- .../stock/doctype/material_request/material_request.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/erpnext/stock/doctype/material_request/material_request.py b/erpnext/stock/doctype/material_request/material_request.py index cb9552d1fc..e87ceb0a0e 100644 --- a/erpnext/stock/doctype/material_request/material_request.py +++ b/erpnext/stock/doctype/material_request/material_request.py @@ -205,7 +205,8 @@ def make_purchase_order(source_name, target_doc=None): ["uom", "stock_uom"], ["uom", "uom"] ], - "postprocess": update_item + "postprocess": update_item, + "condition": lambda doc: doc.ordered_qty < doc.qty } }, target_doc, set_missing_values) @@ -243,7 +244,8 @@ def make_purchase_order_based_on_supplier(source_name, target_doc=None): ["uom", "stock_uom"], ["uom", "uom"] ], - "postprocess": update_item + "postprocess": update_item, + "condition": lambda doc: doc.ordered_qty < doc.qty } }, target_doc, postprocess) @@ -315,7 +317,8 @@ def make_stock_entry(source_name, target_doc=None): "uom": "stock_uom", "warehouse": "t_warehouse" }, - "postprocess": update_item + "postprocess": update_item, + "condition": lambda doc: doc.ordered_qty < doc.qty } }, target_doc, set_missing_values) From 4215b3afc37fc76474ed1fff3d01b7a6f11ab1ca Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 14 Nov 2014 10:51:31 +0530 Subject: [PATCH 2/3] temporary fix in payment tool --- erpnext/accounts/doctype/payment_tool/payment_tool.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/erpnext/accounts/doctype/payment_tool/payment_tool.js b/erpnext/accounts/doctype/payment_tool/payment_tool.js index 3e0d2eec9f..473bc15ac3 100644 --- a/erpnext/accounts/doctype/payment_tool/payment_tool.js +++ b/erpnext/accounts/doctype/payment_tool/payment_tool.js @@ -42,9 +42,6 @@ frappe.ui.form.on("Payment Tool", "received_or_paid", function(frm) { erpnext.payment_tool.check_mandatory_to_set_button(frm); }); -// Fetch bank/cash account based on payment mode -cur_frm.add_fetch("payment_mode", "default_account", "payment_account"); - // Set party account name frappe.ui.form.on("Payment Tool", "customer", function(frm) { erpnext.payment_tool.set_party_account(frm); From ccd9fd3e94b316f6d75d3bb60d3eb2ad9deab334 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 14 Nov 2014 14:27:24 +0530 Subject: [PATCH 3/3] Rounding in totals calculation --- .../doctype/purchase_common/purchase_common.js | 9 +++++---- erpnext/controllers/buying_controller.py | 12 ++++++------ erpnext/controllers/selling_controller.py | 18 +++++++++--------- erpnext/selling/sales_common.js | 10 +++++----- 4 files changed, 25 insertions(+), 24 deletions(-) diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.js b/erpnext/buying/doctype/purchase_common/purchase_common.js index c2e76e2ab7..e21ff740a7 100644 --- a/erpnext/buying/doctype/purchase_common/purchase_common.js +++ b/erpnext/buying/doctype/purchase_common/purchase_common.js @@ -210,14 +210,15 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ calculate_totals: function() { var tax_count = this.frm.tax_doclist.length; this.frm.doc.grand_total = flt(tax_count ? - this.frm.tax_doclist[tax_count - 1].total : this.frm.doc.net_total, - precision("grand_total")); - this.frm.doc.grand_total_import = flt(this.frm.doc.grand_total / - this.frm.doc.conversion_rate, precision("grand_total_import")); + this.frm.tax_doclist[tax_count - 1].total : this.frm.doc.net_total); + this.frm.doc.grand_total_import = flt(this.frm.doc.grand_total / this.frm.doc.conversion_rate); this.frm.doc.total_tax = flt(this.frm.doc.grand_total - this.frm.doc.net_total, precision("total_tax")); + this.frm.doc.grand_total = flt(this.frm.doc.grand_total, precision("grand_total")); + this.frm.doc.grand_total_import = flt(this.frm.doc.grand_total_import, precision("grand_total_import")); + // rounded totals if(frappe.meta.get_docfield(this.frm.doc.doctype, "rounded_total", this.frm.doc.name)) { this.frm.doc.rounded_total = Math.round(this.frm.doc.grand_total); diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py index fc912c9f1b..1e6e65d86b 100644 --- a/erpnext/controllers/buying_controller.py +++ b/erpnext/controllers/buying_controller.py @@ -110,13 +110,13 @@ class BuyingController(StockController): self.round_floats_in(self, ["net_total", "net_total_import"]) def calculate_totals(self): - self.grand_total = flt(self.tax_doclist[-1].total if self.tax_doclist - else self.net_total, self.precision("grand_total")) - self.grand_total_import = flt(self.grand_total / self.conversion_rate, - self.precision("grand_total_import")) + self.grand_total = flt(self.tax_doclist[-1].total if self.tax_doclist else self.net_total) + self.grand_total_import = flt(self.grand_total / self.conversion_rate) - self.total_tax = flt(self.grand_total - self.net_total, - self.precision("total_tax")) + self.total_tax = flt(self.grand_total - self.net_total, self.precision("total_tax")) + + self.grand_total = flt(self.grand_total, self.precision("grand_total")) + self.grand_total_import = flt(self.grand_total_import, self.precision("grand_total_import")) if self.meta.get_field("rounded_total"): self.rounded_total = rounded(self.grand_total) diff --git a/erpnext/controllers/selling_controller.py b/erpnext/controllers/selling_controller.py index 86d883784b..6e93c30797 100644 --- a/erpnext/controllers/selling_controller.py +++ b/erpnext/controllers/selling_controller.py @@ -216,17 +216,17 @@ class SellingController(StockController): self.round_floats_in(self, ["net_total", "net_total_export"]) def calculate_totals(self): - self.grand_total = flt(self.tax_doclist and \ - self.tax_doclist[-1].total or self.net_total, self.precision("grand_total")) - self.grand_total_export = flt(self.grand_total / self.conversion_rate, - self.precision("grand_total_export")) + self.grand_total = flt(self.tax_doclist[-1].total if self.tax_doclist else self.net_total) - self.other_charges_total = flt(self.grand_total - self.net_total, - self.precision("other_charges_total")) + self.grand_total_export = flt(self.grand_total / self.conversion_rate) - self.other_charges_total_export = flt(self.grand_total_export - - self.net_total_export + flt(self.discount_amount), - self.precision("other_charges_total_export")) + self.other_charges_total = flt(self.grand_total - self.net_total, self.precision("other_charges_total")) + + self.other_charges_total_export = flt(self.grand_total_export - self.net_total_export + + flt(self.discount_amount), self.precision("other_charges_total_export")) + + self.grand_total = flt(self.grand_total, self.precision("grand_total")) + self.grand_total_export = flt(self.grand_total_export, self.precision("grand_total_export")) self.rounded_total = rounded(self.grand_total) self.rounded_total_export = rounded(self.grand_total_export) diff --git a/erpnext/selling/sales_common.js b/erpnext/selling/sales_common.js index fd16258d6f..783474c75f 100644 --- a/erpnext/selling/sales_common.js +++ b/erpnext/selling/sales_common.js @@ -341,11 +341,8 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ var me = this; var tax_count = this.frm.tax_doclist.length; - this.frm.doc.grand_total = flt( - tax_count ? this.frm.tax_doclist[tax_count - 1].total : this.frm.doc.net_total, - precision("grand_total")); - this.frm.doc.grand_total_export = flt(this.frm.doc.grand_total / this.frm.doc.conversion_rate, - precision("grand_total_export")); + this.frm.doc.grand_total = flt(tax_count ? this.frm.tax_doclist[tax_count - 1].total : this.frm.doc.net_total); + this.frm.doc.grand_total_export = flt(this.frm.doc.grand_total / this.frm.doc.conversion_rate); this.frm.doc.other_charges_total = flt(this.frm.doc.grand_total - this.frm.doc.net_total, precision("other_charges_total")); @@ -353,6 +350,9 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ this.frm.doc.net_total_export + flt(this.frm.doc.discount_amount), precision("other_charges_total_export")); + this.frm.doc.grand_total = flt(this.frm.doc.grand_total, precision("grand_total")); + this.frm.doc.grand_total_export = flt(this.frm.doc.grand_total_export, precision("grand_total_export")); + this.frm.doc.rounded_total = Math.round(this.frm.doc.grand_total); this.frm.doc.rounded_total_export = Math.round(this.frm.doc.grand_total_export); },