diff --git a/erpnext/__init__.py b/erpnext/__init__.py index 16629d9cf24..6b8704609b3 100644 --- a/erpnext/__init__.py +++ b/erpnext/__init__.py @@ -5,7 +5,7 @@ import frappe from erpnext.hooks import regional_overrides from frappe.utils import getdate -__version__ = '10.1.38' +__version__ = '10.1.39' def get_default_company(user=None): '''Get default company for user''' diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.js b/erpnext/accounts/doctype/payment_entry/payment_entry.js index ca50e2d0f65..daaf24f6b23 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.js +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.js @@ -584,6 +584,10 @@ frappe.ui.form.on('Payment Entry', { allocate_party_amount_against_ref_docs: function(frm, paid_amount) { var total_positive_outstanding_including_order = 0; var total_negative_outstanding = 0; + var total_deductions = frappe.utils.sum($.map(frm.doc.deductions || [], + function(d) { return flt(d.amount) })); + + paid_amount -= total_deductions; $.each(frm.doc.references || [], function(i, row) { if(flt(row.outstanding_amount) > 0) diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index e694c91f55e..db2db722dca 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -339,14 +339,15 @@ class PaymentEntry(AccountsController): total_negative_outstanding = sum([abs(flt(d.outstanding_amount)) for d in self.get("references") if flt(d.outstanding_amount) < 0]) - party_amount = self.paid_amount if self.payment_type=="Receive" else self.received_amount + paid_amount = self.paid_amount if self.payment_type=="Receive" else self.received_amount + additional_charges = sum([flt(d.amount) for d in self.deductions]) if not total_negative_outstanding: frappe.throw(_("Cannot {0} {1} {2} without any negative outstanding invoice") .format(self.payment_type, ("to" if self.party_type=="Customer" else "from"), self.party_type), InvalidPaymentEntry) - elif party_amount > total_negative_outstanding: + elif paid_amount - additional_charges > total_negative_outstanding: frappe.throw(_("Paid Amount cannot be greater than total negative outstanding amount {0}") .format(total_negative_outstanding), InvalidPaymentEntry) diff --git a/erpnext/assets/doctype/asset_maintenance_task/asset_maintenance_task.json b/erpnext/assets/doctype/asset_maintenance_task/asset_maintenance_task.json index 8ce67cfc5f5..20963e3fdc7 100644 --- a/erpnext/assets/doctype/asset_maintenance_task/asset_maintenance_task.json +++ b/erpnext/assets/doctype/asset_maintenance_task/asset_maintenance_task.json @@ -3,7 +3,7 @@ "allow_guest_to_view": 0, "allow_import": 0, "allow_rename": 0, - "autoname": "field:maintenance_task", + "autoname": "", "beta": 0, "creation": "2017-10-20 07:10:55.903571", "custom": 0, @@ -43,7 +43,7 @@ "search_index": 0, "set_only_once": 0, "translatable": 0, - "unique": 1 + "unique": 0 }, { "allow_bulk_edit": 0, @@ -646,7 +646,7 @@ "issingle": 0, "istable": 1, "max_attachments": 0, - "modified": "2018-05-16 22:42:44.609383", + "modified": "2018-06-18 16:12:04.330021", "modified_by": "Administrator", "module": "Assets", "name": "Asset Maintenance Task", diff --git a/erpnext/assets/doctype/asset_maintenance_task/asset_maintenance_task.py b/erpnext/assets/doctype/asset_maintenance_task/asset_maintenance_task.py index 2a5666d5064..d98cc310b3b 100644 --- a/erpnext/assets/doctype/asset_maintenance_task/asset_maintenance_task.py +++ b/erpnext/assets/doctype/asset_maintenance_task/asset_maintenance_task.py @@ -7,4 +7,5 @@ import frappe from frappe.model.document import Document class AssetMaintenanceTask(Document): - pass + def autoname(self): + self.name = self.maintenance_task diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py index 2f46d92b203..fc548cdd435 100644 --- a/erpnext/controllers/buying_controller.py +++ b/erpnext/controllers/buying_controller.py @@ -664,6 +664,7 @@ class BuyingController(StockController): def validate_items(self): # validate items to see if they have is_purchase_item or is_subcontracted_item enabled + if self.doctype=="Material Request": return if hasattr(self, "is_subcontracted") and self.is_subcontracted == 'Yes': validate_item_type(self, "is_sub_contracted_item", "subcontracted") diff --git a/erpnext/projects/doctype/timesheet/timesheet.py b/erpnext/projects/doctype/timesheet/timesheet.py index a2c4c1cbee5..7dc121c7e3b 100644 --- a/erpnext/projects/doctype/timesheet/timesheet.py +++ b/erpnext/projects/doctype/timesheet/timesheet.py @@ -428,9 +428,10 @@ def get_timesheets_list(doctype, txt, filters, limit_start, limit_page_length=20 # find customer name from contact. customer = frappe.db.sql('''SELECT dl.link_name FROM `tabContact` AS c inner join \ `tabDynamic Link` AS dl ON c.first_name=dl.link_name WHERE c.email_id=%s''',user) - # find list of Sales Invoice for made for customer. - sales_invoice = frappe.db.sql('''SELECT name FROM `tabSales Invoice` WHERE customer = %s''',customer) + if customer: + # find list of Sales Invoice for made for customer. + sales_invoice = frappe.db.sql('''SELECT name FROM `tabSales Invoice` WHERE customer = %s''',customer) # Return timesheet related data to web portal. return frappe. db.sql('''SELECT ts.name, tsd.activity_type, ts.status, ts.total_billable_hours, \ tsd.sales_invoice, tsd.project FROM `tabTimesheet` AS ts inner join `tabTimesheet Detail` \ diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js index cd32e3e8571..c24945ea98b 100644 --- a/erpnext/public/js/controllers/taxes_and_totals.js +++ b/erpnext/public/js/controllers/taxes_and_totals.js @@ -341,11 +341,7 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ set_item_wise_tax: function(item, tax, tax_rate, current_tax_amount) { // store tax breakup for each item let tax_detail = tax.item_wise_tax_detail; - - let key = item.item_code; - if(item.item_name && !Object.keys(tax_detail).includes(item.item_name)) { - key = item.item_name; - } + let key = item.item_code || item.item_name; let item_wise_tax_amount = current_tax_amount * this.frm.doc.conversion_rate; if (tax_detail && tax_detail[key]) diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py index dbb1e9f86e8..509685aaedd 100644 --- a/erpnext/selling/doctype/quotation/quotation.py +++ b/erpnext/selling/doctype/quotation/quotation.py @@ -185,6 +185,7 @@ def _make_sales_invoice(source_name, target_doc=None, ignore_permissions=False): target.run_method("calculate_taxes_and_totals") def update_item(obj, target, source_parent): + target.cost_center = None target.stock_qty = flt(obj.qty) * flt(obj.conversion_factor) doclist = get_mapped_doc("Quotation", source_name, { diff --git a/erpnext/selling/report/item_wise_sales_history/item_wise_sales_history.json b/erpnext/selling/report/item_wise_sales_history/item_wise_sales_history.json index 0eb6228077d..7f9ef884c6d 100644 --- a/erpnext/selling/report/item_wise_sales_history/item_wise_sales_history.json +++ b/erpnext/selling/report/item_wise_sales_history/item_wise_sales_history.json @@ -7,12 +7,12 @@ "doctype": "Report", "idx": 3, "is_standard": "Yes", - "modified": "2017-02-24 20:08:44.614482", + "modified": "2018-06-18 16:42:05.860309", "modified_by": "Administrator", "module": "Selling", "name": "Item-wise Sales History", "owner": "Administrator", - "query": "select\n so_item.item_code as \"Item Code:Link/Item:120\",\n\tso_item.item_name as \"Item Name::120\",\n so_item.item_group as \"Item Group:Link/Item Group:120\",\n\tso_item.description as \"Description::150\",\n\tso_item.qty as \"Qty:Float:100\",\n\tso_item.stock_uom as \"UOM:Link/UOM:80\",\n\tso_item.base_rate as \"Rate:Currency:120\",\n\tso_item.base_amount as \"Amount:Currency:120\",\n\tso.name as \"Sales Order:Link/Sales Order:120\",\n\tso.transaction_date as \"Transaction Date:Date:140\",\n\tso.customer as \"Customer:Link/Customer:130\",\n cu.customer_name as \"Customer Name::150\",\n\tso.territory as \"Territory:Link/Territory:130\",\n so.project as \"Project:Link/Project:130\",\n\tifnull(so_item.delivered_qty, 0) as \"Delivered Qty:Float:120\",\n\tifnull(so_item.billed_amt, 0) as \"Billed Amount:Currency:120\",\n\tso.company as \"Company:Link/Company:\"\nfrom\n\t`tabSales Order` so, `tabSales Order Item` so_item, `tabCustomer` cu\nwhere\n\tso.name = so_item.parent and so.customer=cu.name\n\tand so.docstatus = 1\norder by so.name desc", + "query": "select\n so_item.item_code as \"Item Code:Link/Item:120\",\n\tso_item.item_name as \"Item Name::120\",\n so_item.item_group as \"Item Group:Link/Item Group:120\",\n\tso_item.description as \"Description::150\",\n\tso_item.qty as \"Qty:Data:100\",\n\tso_item.uom as \"UOM:Link/UOM:80\",\n\tso_item.base_rate as \"Rate:Currency:120\",\n\tso_item.base_amount as \"Amount:Currency:120\",\n\tso.name as \"Sales Order:Link/Sales Order:120\",\n\tso.transaction_date as \"Transaction Date:Date:140\",\n\tso.customer as \"Customer:Link/Customer:130\",\n cu.customer_name as \"Customer Name::150\",\n\tso.territory as \"Territory:Link/Territory:130\",\n so.project as \"Project:Link/Project:130\",\n\tifnull(so_item.delivered_qty, 0) as \"Delivered Qty:Float:120\",\n\tifnull(so_item.billed_amt, 0) as \"Billed Amount:Currency:120\",\n\tso.company as \"Company:Link/Company:\"\nfrom\n\t`tabSales Order` so, `tabSales Order Item` so_item, `tabCustomer` cu\nwhere\n\tso.name = so_item.parent and so.customer=cu.name\n\tand so.docstatus = 1\norder by so.name desc", "ref_doctype": "Sales Order", "report_name": "Item-wise Sales History", "report_type": "Query Report", diff --git a/erpnext/setup/doctype/authorization_control/authorization_control.py b/erpnext/setup/doctype/authorization_control/authorization_control.py index 2240e0c28b5..b419850b0bb 100644 --- a/erpnext/setup/doctype/authorization_control/authorization_control.py +++ b/erpnext/setup/doctype/authorization_control/authorization_control.py @@ -40,7 +40,7 @@ class AuthorizationControl(TransactionBase): chk = 1 add_cond1,add_cond2 = '','' if based_on == 'Itemwise Discount': - add_cond1 += " and master_name = '"+cstr(frappe.db.escape(item)).replace("'", "\\'")+"'" + add_cond1 += " and master_name = '"+frappe.db.escape(cstr(item))+"'" itemwise_exists = frappe.db.sql("""select value from `tabAuthorization Rule` where transaction = %s and value <= %s and based_on = %s and company = %s and docstatus != 2 %s %s""" %