diff --git a/accounts/doctype/sales_invoice/sales_invoice.py b/accounts/doctype/sales_invoice/sales_invoice.py index 93fb47f9db1..76e87b65645 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.py +++ b/accounts/doctype/sales_invoice/sales_invoice.py @@ -374,22 +374,27 @@ class DocType(SellingController): "compare_fields": [["customer", "="], ["company", "="], ["project_name", "="], ["currency", "="]], }, - "Sales Order Item": { - "ref_dn_field": "so_detail", - "compare_fields": [["export_rate", "="]], - "is_child_table": True - }, "Delivery Note": { "ref_dn_field": "delivery_note", "compare_fields": [["customer", "="], ["company", "="], ["project_name", "="], ["currency", "="]], }, - "Delivery Note Item": { - "ref_dn_field": "dn_detail", - "compare_fields": [["export_rate", "="]], - "is_child_table": True - } }) + + if cint(webnotes.defaults.get_global_default('maintain_same_sales_rate')): + super(DocType, self).validate_with_previous_doc(self.tname, { + "Sales Order Item": { + "ref_dn_field": "so_detail", + "compare_fields": [["export_rate", "="]], + "is_child_table": True + }, + "Delivery Note Item": { + "ref_dn_field": "dn_detail", + "compare_fields": [["export_rate", "="]], + "is_child_table": True + } + }) + def set_aging_date(self): if self.doc.is_opening != 'Yes': @@ -975,4 +980,4 @@ def get_income_account(doctype, txt, searchfield, start, page_len, filters): and tabAccount.company = '%(company)s' and tabAccount.%(key)s LIKE '%(txt)s' %(mcond)s""" % {'company': filters['company'], 'key': searchfield, - 'txt': "%%%s%%" % txt, 'mcond':get_match_cond(doctype, searchfield)}) \ No newline at end of file + 'txt': "%%%s%%" % txt, 'mcond':get_match_cond(doctype, searchfield)}) diff --git a/accounts/report/purchase_register/purchase_register.py b/accounts/report/purchase_register/purchase_register.py index 09705413a65..aa55a3b076a 100644 --- a/accounts/report/purchase_register/purchase_register.py +++ b/accounts/report/purchase_register/purchase_register.py @@ -54,7 +54,7 @@ def execute(filters=None): row.append(expense_amount) # net total - row.append(net_total) + row.append(net_total or inv.net_total) # tax account total_tax = 0 @@ -121,7 +121,7 @@ def get_conditions(filters): def get_invoices(filters): conditions = get_conditions(filters) return webnotes.conn.sql("""select name, posting_date, credit_to, supplier, supplier_name, - bill_no, bill_date, remarks, grand_total, outstanding_amount + bill_no, bill_date, remarks, net_total, grand_total, outstanding_amount from `tabPurchase Invoice` where docstatus = 1 %s order by posting_date desc, name desc""" % conditions, filters, as_dict=1) diff --git a/accounts/report/sales_register/sales_register.py b/accounts/report/sales_register/sales_register.py index 91ad1c282f6..653b5e65a0e 100644 --- a/accounts/report/sales_register/sales_register.py +++ b/accounts/report/sales_register/sales_register.py @@ -54,7 +54,7 @@ def execute(filters=None): row.append(income_amount) # net total - row.append(net_total) + row.append(net_total or inv.net_total) # tax account total_tax = 0 @@ -120,7 +120,7 @@ def get_conditions(filters): def get_invoices(filters): conditions = get_conditions(filters) return webnotes.conn.sql("""select name, posting_date, debit_to, project_name, customer, - customer_name, remarks, grand_total, rounded_total, outstanding_amount + customer_name, remarks, net_total, grand_total, rounded_total, outstanding_amount from `tabSales Invoice` where docstatus = 1 %s order by posting_date desc, name desc""" % conditions, filters, as_dict=1) diff --git a/patches/july_2013/p01_same_sales_rate_patch.py b/patches/july_2013/p01_same_sales_rate_patch.py new file mode 100644 index 00000000000..82ec1dbd150 --- /dev/null +++ b/patches/july_2013/p01_same_sales_rate_patch.py @@ -0,0 +1,7 @@ +def execute(): + import webnotes + webnotes.reload_doc("setup", "doctype", "global_defaults") + + gd = webnotes.bean('Global Defaults') + gd.doc.maintain_same_sales_rate = 1 + gd.save() \ No newline at end of file diff --git a/patches/july_2013/p06_same_sales_rate.py b/patches/july_2013/p06_same_sales_rate.py new file mode 100644 index 00000000000..67c1055bcc9 --- /dev/null +++ b/patches/july_2013/p06_same_sales_rate.py @@ -0,0 +1,13 @@ +def execute(): + import webnotes + webnotes.reload_doc("selling", "doctype", "selling_settings") + ss = webnotes.bean("Selling Settings") + + same_rate = webnotes.conn.sql("""select field, value from `tabSingles` + where doctype = 'Global Defaults' and field = 'maintain_same_sales_rate'"""): + if same_rate: + ss.doc.maintain_same_sales_rate = same_rate[1] + else: + ss.doc.maintain_same_sales_rate = 1 + + ss.save() \ No newline at end of file diff --git a/patches/patch_list.py b/patches/patch_list.py index 0c2a523fb39..af02ebdedc9 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -253,4 +253,5 @@ patch_list = [ "execute:webnotes.bean('Style Settings').save() #2013-07-16", "patches.july_2013.p04_merge_duplicate_leads", "patches.july_2013.p05_custom_doctypes_in_list_view", + "patches.july_2013.p06_same_sales_rate", ] \ No newline at end of file diff --git a/selling/doctype/selling_settings/selling_settings.py b/selling/doctype/selling_settings/selling_settings.py index 5a5dc4c7898..47162287ab6 100644 --- a/selling/doctype/selling_settings/selling_settings.py +++ b/selling/doctype/selling_settings/selling_settings.py @@ -8,5 +8,5 @@ class DocType: self.doc, self.doclist = d, dl def validate(self): - for key in ["cust_master_name", "customer_group", "territory"]: + for key in ["cust_master_name", "customer_group", "territory", "allow_same_sales_rate"]: webnotes.conn.set_default(key, self.doc.fields.get(key, "")) diff --git a/selling/doctype/selling_settings/selling_settings.txt b/selling/doctype/selling_settings/selling_settings.txt index 35d256ec7b5..934cd41d27b 100644 --- a/selling/doctype/selling_settings/selling_settings.txt +++ b/selling/doctype/selling_settings/selling_settings.txt @@ -2,7 +2,7 @@ { "creation": "2013-06-25 10:25:16", "docstatus": 0, - "modified": "2013-07-05 14:54:47", + "modified": "2013-07-18 12:03:39", "modified_by": "Administrator", "owner": "Administrator" }, @@ -88,6 +88,12 @@ "label": "Delivery Note Required", "options": "No\nYes" }, + { + "doctype": "DocField", + "fieldname": "maintain_same_sales_rate", + "fieldtype": "Check", + "label": "Maintain Same Rate Throughout Sales Cycle" + }, { "doctype": "DocPerm" } diff --git a/setup/doctype/global_defaults/global_defaults.py b/setup/doctype/global_defaults/global_defaults.py index 52a291fdac0..9be849952fb 100644 --- a/setup/doctype/global_defaults/global_defaults.py +++ b/setup/doctype/global_defaults/global_defaults.py @@ -32,7 +32,8 @@ keydict = { 'float_precision': 'float_precision', 'account_url':'account_url', 'session_expiry': 'session_expiry', - 'disable_rounded_total': 'disable_rounded_total' + 'disable_rounded_total': 'disable_rounded_total', + 'maintain_same_sales_rate' : 'maintain_same_sales_rate', } class DocType: diff --git a/stock/doctype/delivery_note/delivery_note.py b/stock/doctype/delivery_note/delivery_note.py index 24df8789194..6cc54b071b4 100644 --- a/stock/doctype/delivery_note/delivery_note.py +++ b/stock/doctype/delivery_note/delivery_note.py @@ -118,12 +118,16 @@ class DocType(SellingController): "compare_fields": [["customer", "="], ["company", "="], ["project_name", "="], ["currency", "="]], }, - "Sales Order Item": { - "ref_dn_field": "prevdoc_detail_docname", - "compare_fields": [["export_rate", "="]], - "is_child_table": True - } }) + if cint(webnotes.defaults.get_global_default('maintain_same_sales_rate')): + super(DocType, self).validate_with_previous_doc(self.tname, { + "Sales Order Item": { + "ref_dn_field": "prevdoc_detail_docname", + "compare_fields": [["export_rate", "="]], + "is_child_table": True + } + }) + def validate_proj_cust(self): """check for does customer belong to same project as entered.."""