From 28d85579059dbccf9292315cdfc50fc0730e54c3 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 22 Aug 2017 15:30:45 +0530 Subject: [PATCH 1/3] [fix] Taxes in itemised purchase register (#10494) --- .../item_wise_purchase_register.py | 2 +- .../item_wise_sales_register/item_wise_sales_register.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py b/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py index 8f9948e41c..0e5d12857e 100644 --- a/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py +++ b/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py @@ -18,7 +18,7 @@ def _execute(filters=None, additional_table_columns=None, additional_query_colum aii_account_map = get_aii_accounts() if item_list: itemised_tax, tax_columns = get_tax_accounts(item_list, columns, - tax_doctype="Purchase Taxes and Charges") + doctype="Purchase Invoice", tax_doctype="Purchase Taxes and Charges") columns.append({ "fieldname": "currency", diff --git a/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py b/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py index 30c545f58c..dfcade25ed 100644 --- a/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py +++ b/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py @@ -139,7 +139,7 @@ def get_delivery_notes_against_sales_order(item_list): return so_dn_map -def get_tax_accounts(item_list, columns, tax_doctype="Sales Taxes and Charges"): +def get_tax_accounts(item_list, columns, doctype="Sales Invoice", tax_doctype="Sales Taxes and Charges"): import json item_row_map = {} tax_columns = [] @@ -155,11 +155,12 @@ def get_tax_accounts(item_list, columns, tax_doctype="Sales Taxes and Charges"): charge_type, base_tax_amount_after_discount_amount from `tab%s` where - parenttype = 'Sales Invoice' and docstatus = 1 + parenttype = %s and docstatus = 1 and (description is not null and description != '') and parent in (%s) order by description - """ % (tax_doctype, ', '.join(['%s']*len(invoice_item_row))), tuple(invoice_item_row.keys())) + """ % (tax_doctype, '%s', ', '.join(['%s']*len(invoice_item_row))), + tuple([doctype] + invoice_item_row.keys())) for parent, description, item_wise_tax_detail, charge_type, tax_amount in tax_details: if description not in tax_columns and tax_amount: From 187cea3602ff360d0f47f27253c6c6d0d8581fdc Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Tue, 22 Aug 2017 15:38:32 +0530 Subject: [PATCH 2/3] [Fix] Accepting duplicate serial no is purchase receipt (#10469) * [Fix] Accepting duplicate serial no is purchase receipt * Fixed test cases --- .../purchase_receipt/test_purchase_receipt.py | 24 ++++++++++++++++++- erpnext/stock/doctype/serial_no/serial_no.py | 17 ++++++++++++- .../doctype/stock_entry/test_stock_entry.py | 3 ++- 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py index d8cd27174d..6af8c09568 100644 --- a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py @@ -6,9 +6,10 @@ from __future__ import unicode_literals import unittest import frappe, erpnext import frappe.defaults -from frappe.utils import cint, flt, cstr, today +from frappe.utils import cint, flt, cstr, today, random_string from erpnext.stock.doctype.purchase_receipt.purchase_receipt import make_purchase_invoice from erpnext import set_perpetual_inventory +from erpnext.stock.doctype.serial_no.serial_no import SerialNoDuplicateError from erpnext.accounts.doctype.account.test_account import get_inventory_account class TestPurchaseReceipt(unittest.TestCase): @@ -251,6 +252,27 @@ class TestPurchaseReceipt(unittest.TestCase): self.assertEqual(pr2.per_billed, 80) self.assertEqual(pr2.status, "To Bill") + def test_not_accept_duplicate_serial_no(self): + from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry + from erpnext.stock.doctype.item.test_item import make_item + from erpnext.stock.doctype.delivery_note.test_delivery_note import create_delivery_note + + item_code = frappe.db.get_value('Item', {'has_serial_no': 1}) + if not item_code: + item = make_item("Test Serial Item 1", dict(has_serial_no = 1)) + item_code = item.name + + serial_no = random_string(5) + make_purchase_receipt(item_code=item_code, qty=1, serial_no=serial_no) + create_delivery_note(item_code=item_code, qty=1, serial_no=serial_no) + + pr = make_purchase_receipt(item_code=item_code, qty=1, serial_no=serial_no, do_not_submit=True) + self.assertRaises(SerialNoDuplicateError, pr.submit) + + se = make_stock_entry(item_code=item_code, target="_Test Warehouse - _TC", qty=1, + serial_no=serial_no, basic_rate=100, do_not_submit=True) + self.assertRaises(SerialNoDuplicateError, se.submit) + def get_gl_entries(voucher_type, voucher_no): return frappe.db.sql("""select account, debit, credit from `tabGL Entry` where voucher_type=%s and voucher_no=%s diff --git a/erpnext/stock/doctype/serial_no/serial_no.py b/erpnext/stock/doctype/serial_no/serial_no.py index 76a0406f09..ca64b1eda2 100644 --- a/erpnext/stock/doctype/serial_no/serial_no.py +++ b/erpnext/stock/doctype/serial_no/serial_no.py @@ -213,7 +213,7 @@ def validate_serial_no(sle, item_det): frappe.throw(_("Serial No {0} does not belong to Item {1}").format(serial_no, sle.item_code), SerialNoItemError) - if sr.warehouse and sle.actual_qty > 0: + if sle.actual_qty > 0 and has_duplicate_serial_no(sr, sle): frappe.throw(_("Serial No {0} has already been received").format(serial_no), SerialNoDuplicateError) @@ -234,6 +234,21 @@ def validate_serial_no(sle, item_det): frappe.throw(_("Serial Nos Required for Serialized Item {0}").format(sle.item_code), SerialNoRequiredError) +def has_duplicate_serial_no(sn, sle): + if sn.warehouse: + return True + + status = False + if sn.purchase_document_no: + if sle.voucher_type in ['Purchase Receipt', 'Stock Entry']: + status = True + + if status and sle.voucher_type == 'Stock Entry' and \ + frappe.db.get_value('Stock Entry', sle.voucher_no, 'purpose') != 'Material Receipt': + status = False + + return status + def allow_serial_nos_with_different_item(sle_serial_no, sle): """ Allows same serial nos for raw materials and finished goods diff --git a/erpnext/stock/doctype/stock_entry/test_stock_entry.py b/erpnext/stock/doctype/stock_entry/test_stock_entry.py index 92de229a8c..7fa232e6f7 100644 --- a/erpnext/stock/doctype/stock_entry/test_stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/test_stock_entry.py @@ -395,7 +395,8 @@ class TestStockEntry(unittest.TestCase): def test_serial_item_error(self): se, serial_nos = self.test_serial_by_series() - make_serialized_item("_Test Serialized Item", "ABCD\nEFGH") + if not frappe.db.exists('Serial No', 'ABCD'): + make_serialized_item("_Test Serialized Item", "ABCD\nEFGH") se = frappe.copy_doc(test_records[0]) se.purpose = "Material Transfer" From 974cfd28953dd0d09f4bd7a3e5c3dc242d545314 Mon Sep 17 00:00:00 2001 From: mbauskar Date: Tue, 22 Aug 2017 16:12:09 +0600 Subject: [PATCH 3/3] bumped to version 8.8.6 --- erpnext/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/__init__.py b/erpnext/__init__.py index 8b868449d5..ecf0d35c6b 100644 --- a/erpnext/__init__.py +++ b/erpnext/__init__.py @@ -4,7 +4,7 @@ import inspect import frappe from erpnext.hooks import regional_overrides -__version__ = '8.8.5' +__version__ = '8.8.6' def get_default_company(user=None): '''Get default company for user'''