From 1b5afe737fe73668daaeae5ccc391e7155f4fb21 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 25 Nov 2014 15:29:23 +0530 Subject: [PATCH 1/2] Fixes in authorization rule based on average discount --- erpnext/selling/doctype/sales_order/sales_order.py | 13 +------------ .../authorization_control/authorization_control.py | 7 +++++-- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py index 498aec12b60..8153d8d8391 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.py +++ b/erpnext/selling/doctype/sales_order/sales_order.py @@ -157,7 +157,7 @@ class SalesOrder(SellingController): self.check_credit(self.grand_total) - frappe.get_doc('Authorization Control').validate_approving_authority(self.doctype, self.grand_total, self) + frappe.get_doc('Authorization Control').validate_approving_authority(self.doctype, self.company, self.grand_total, self) self.update_prevdoc_status('submit') frappe.db.set(self, 'status', 'Submitted') @@ -357,17 +357,6 @@ def make_sales_invoice(source_name, target_doc=None): } }, target_doc, postprocess) - def set_advance_vouchers(source, target): - advance_voucher_list = [] - - advance_voucher = frappe.db.sql(""" - select - t1.name as voucher_no, t1.posting_date, t1.remark, t2.account, - t2.name as voucher_detail_no, {amount_query} as payment_amount, t2.is_advance - from - `tabJournal Voucher` t1, `tabJournal Voucher Detail` t2 - """) - return doclist @frappe.whitelist() diff --git a/erpnext/setup/doctype/authorization_control/authorization_control.py b/erpnext/setup/doctype/authorization_control/authorization_control.py index 8e7b0cefb06..fbf4b1cb361 100644 --- a/erpnext/setup/doctype/authorization_control/authorization_control.py +++ b/erpnext/setup/doctype/authorization_control/authorization_control.py @@ -98,9 +98,12 @@ class AuthorizationControl(TransactionBase): if doc_obj: price_list_rate, base_rate = 0, 0 for d in doc_obj.get(doc_obj.fname): - if d.base_price_list_rate and d.base_rate: - price_list_rate += flt(d.base_price_list_rate) + if d.base_rate: + price_list_rate += flt(d.base_price_list_rate) or flt(d.base_rate) base_rate += flt(d.base_rate) + if doc_obj.get("discount_amount"): + base_rate -= flt(doc_obj.discount_amount) + if price_list_rate: av_dis = 100 - flt(base_rate * 100 / price_list_rate) final_based_on = ['Grand Total','Average Discount','Customerwise Discount','Itemwise Discount'] From cc11045fd3ea86de19f4b78f509cc7eb68d3c3bb Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 28 Nov 2014 15:53:07 +0530 Subject: [PATCH 2/2] minor fix --- erpnext/controllers/accounts_controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index af0a96ef67c..49845f68683 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -437,7 +437,7 @@ class AccountsController(TransactionBase): for order, jv_list in order_jv_map.items(): for jv in jv_list: if not advance_jv_against_si or jv not in advance_jv_against_si: - frappe.throw(_("Journal Voucher {0} is linked against Order {1}, hence it must be fetched as advance in Invoice as well.") + frappe.msgprint(_("Journal Voucher {0} is linked against Order {1}, check if it should be pulled as advance in this invoice.") .format(jv, order))