From fb237739358930b4057528203be4275aa3dd730a Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Mon, 12 Aug 2019 14:56:57 +0530 Subject: [PATCH 1/8] fix: reconciled entry has not clearance date set --- erpnext/accounts/doctype/bank_transaction/bank_transaction.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/bank_transaction/bank_transaction.py b/erpnext/accounts/doctype/bank_transaction/bank_transaction.py index f943b34581..716ec1f552 100644 --- a/erpnext/accounts/doctype/bank_transaction/bank_transaction.py +++ b/erpnext/accounts/doctype/bank_transaction/bank_transaction.py @@ -50,7 +50,7 @@ class BankTransaction(StatusUpdater): if paid_amount and allocated_amount: if flt(allocated_amount[0]["allocated_amount"]) > flt(paid_amount): frappe.throw(_("The total allocated amount ({0}) is greated than the paid amount ({1}).".format(flt(allocated_amount[0]["allocated_amount"]), flt(paid_amount)))) - elif flt(allocated_amount[0]["allocated_amount"]) == flt(paid_amount): + else: if payment_entry.payment_document in ["Payment Entry", "Journal Entry", "Purchase Invoice", "Expense Claim"]: self.clear_simple_entry(payment_entry) From 1008e6e45022217131503af9b826580bb0f5b18c Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Mon, 19 Aug 2019 20:21:36 +0530 Subject: [PATCH 2/8] fix: debit note not reconciled with another purchase invoice using payment reconciliation --- .../payment_reconciliation.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py index b74eed5841..4665d75510 100644 --- a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py +++ b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py @@ -93,7 +93,7 @@ class PaymentReconciliation(Document): and `tab{doc}`.is_return = 1 and `tabGL Entry`.against_voucher_type = %(voucher_type)s and `tab{doc}`.docstatus = 1 and `tabGL Entry`.party = %(party)s and `tabGL Entry`.party_type = %(party_type)s and `tabGL Entry`.account = %(account)s - GROUP BY `tabSales Invoice`.name + GROUP BY `tab{doc}`.name Having amount > 0 """.format(doc=voucher_type, dr_or_cr=dr_or_cr, reconciled_dr_or_cr=reconciled_dr_or_cr), { @@ -257,11 +257,8 @@ def reconcile_dr_cr_note(dr_cr_notes): voucher_type = ('Credit Note' if d.voucher_type == 'Sales Invoice' else 'Debit Note') - dr_or_cr = ('credit_in_account_currency' - if d.reference_type == 'Sales Invoice' else 'debit_in_account_currency') - reconcile_dr_or_cr = ('debit_in_account_currency' - if dr_or_cr == 'credit_in_account_currency' else 'credit_in_account_currency') + if d.dr_or_cr == 'credit_in_account_currency' else 'credit_in_account_currency') jv = frappe.get_doc({ "doctype": "Journal Entry", @@ -272,8 +269,7 @@ def reconcile_dr_cr_note(dr_cr_notes): 'account': d.account, 'party': d.party, 'party_type': d.party_type, - reconcile_dr_or_cr: (abs(d.allocated_amount) - if abs(d.unadjusted_amount) > abs(d.allocated_amount) else abs(d.unadjusted_amount)), + d.dr_or_cr: abs(d.allocated_amount), 'reference_type': d.against_voucher_type, 'reference_name': d.against_voucher }, @@ -281,7 +277,8 @@ def reconcile_dr_cr_note(dr_cr_notes): 'account': d.account, 'party': d.party, 'party_type': d.party_type, - dr_or_cr: abs(d.allocated_amount), + reconcile_dr_or_cr: (abs(d.allocated_amount) + if abs(d.unadjusted_amount) > abs(d.allocated_amount) else abs(d.unadjusted_amount)), 'reference_type': d.voucher_type, 'reference_name': d.voucher_no } From 6affeaa9c1a80b1ad5024435bcd814b38412873d Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Wed, 21 Aug 2019 09:14:56 +0530 Subject: [PATCH 3/8] fix: check if number exists after striping '0' - Absract number striping logic to separate method - Rename a confusing variable name - Remove leftout print statement --- .../doctype/call_log/call_log.py | 31 +++++++++++-------- erpnext/crm/doctype/utils.py | 9 ++++++ 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/erpnext/communication/doctype/call_log/call_log.py b/erpnext/communication/doctype/call_log/call_log.py index c9fdfbe447..00464170f3 100644 --- a/erpnext/communication/doctype/call_log/call_log.py +++ b/erpnext/communication/doctype/call_log/call_log.py @@ -6,15 +6,13 @@ from __future__ import unicode_literals import frappe from frappe import _ from frappe.model.document import Document -from erpnext.crm.doctype.utils import get_scheduled_employees_for_popup +from erpnext.crm.doctype.utils import get_scheduled_employees_for_popup, strip_number from frappe.contacts.doctype.contact.contact import get_contact_with_phone_number from erpnext.crm.doctype.lead.lead import get_lead_with_phone_number class CallLog(Document): def before_insert(self): - # strip 0 from the start of the number for proper number comparisions - # eg. 07888383332 should match with 7888383332 - number = self.get('from').lstrip('0') + number = strip_number(self.get('from')) self.contact = get_contact_with_phone_number(number) self.lead = get_lead_with_phone_number(number) @@ -48,13 +46,14 @@ def add_call_summary(call_log, summary): doc.add_comment('Comment', frappe.bold(_('Call Summary')) + '

' + summary) def get_employees_with_number(number): + number = strip_number(number) if not number: return [] employee_emails = frappe.cache().hget('employees_with_number', number) if employee_emails: return employee_emails employees = frappe.get_all('Employee', filters={ - 'cell_number': ['like', '%{}'.format(number.lstrip('0'))], + 'cell_number': ['like', '%{}'.format(number)], 'user_id': ['!=', ''] }, fields=['user_id']) @@ -64,23 +63,29 @@ def get_employees_with_number(number): return employee def set_caller_information(doc, state): - '''Called from hoooks on creation of Lead or Contact''' + '''Called from hooks on creation of Lead or Contact''' if doc.doctype not in ['Lead', 'Contact']: return numbers = [doc.get('phone'), doc.get('mobile_no')] - for_doc = doc.doctype.lower() + # contact for Contact and lead for Lead + fieldname = doc.doctype.lower() + + # contact_name or lead_name + display_name_field = '{}_name'.format(fieldname) for number in numbers: + number = strip_number(number) if not number: continue - print(number) + filters = frappe._dict({ - 'from': ['like', '%{}'.format(number.lstrip('0'))], - for_doc: '' + 'from': ['like', '%{}'.format(number)], + fieldname: '' }) logs = frappe.get_all('Call Log', filters=filters) for log in logs: - call_log = frappe.get_doc('Call Log', log.name) - call_log.set(for_doc, doc.name) - call_log.save(ignore_permissions=True) + frappe.db.set_value('Call Log', log.name, { + fieldname: doc.name, + display_name_field: doc.get_title() + }, update_modified=False) diff --git a/erpnext/crm/doctype/utils.py b/erpnext/crm/doctype/utils.py index 55532761c2..535458af21 100644 --- a/erpnext/crm/doctype/utils.py +++ b/erpnext/crm/doctype/utils.py @@ -54,6 +54,8 @@ def get_last_issue_from_customer(customer_name): def get_scheduled_employees_for_popup(communication_medium): + if not communication_medium: return [] + now_time = frappe.utils.nowtime() weekday = frappe.utils.get_weekday() @@ -73,3 +75,10 @@ def get_scheduled_employees_for_popup(communication_medium): employee_emails = set([employee.user_id for employee in employees]) return employee_emails + +def strip_number(number): + if not number: return + # strip 0 from the start of the number for proper number comparisions + # eg. 07888383332 should match with 7888383332 + number = number.lstrip('0') + return number \ No newline at end of file From e9e0c0e7d4b8eb40172bbf74e70fdef4bc02304d Mon Sep 17 00:00:00 2001 From: Deepesh Garg <42651287+deepeshgarg007@users.noreply.github.com> Date: Wed, 21 Aug 2019 14:40:35 +0530 Subject: [PATCH 4/8] fix: Minor fix in GSTR-1 report (#18797) --- erpnext/regional/report/gstr_1/gstr_1.py | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/erpnext/regional/report/gstr_1/gstr_1.py b/erpnext/regional/report/gstr_1/gstr_1.py index 2da1085732..c397133f33 100644 --- a/erpnext/regional/report/gstr_1/gstr_1.py +++ b/erpnext/regional/report/gstr_1/gstr_1.py @@ -156,33 +156,21 @@ class Gstr1Report(object): if self.filters.get("type_of_business") == "B2B": - customers = frappe.get_all("Customer", - filters={ - "gst_category": ["in", ["Registered Regular", "Deemed Export", "SEZ"]] - }) - - if customers: - conditions += """ and ifnull(gst_category, '') != 'Overseas' and is_return != 1 - and customer in ({0})""".format(", ".join([frappe.db.escape(c.name) for c in customers])) + conditions += "and ifnull(gst_category, '') in ('Registered Regular', 'Deemed Export', 'SEZ') and is_return != 1" if self.filters.get("type_of_business") in ("B2C Large", "B2C Small"): b2c_limit = frappe.db.get_single_value('GST Settings', 'b2c_limit') if not b2c_limit: frappe.throw(_("Please set B2C Limit in GST Settings.")) - customers = frappe.get_all("Customer", - filters={ - "gst_category": ["in", ["Unregistered"]] - }) - if self.filters.get("type_of_business") == "B2C Large" and customers: conditions += """ and SUBSTR(place_of_supply, 1, 2) != SUBSTR(company_gstin, 1, 2) - and grand_total > {0} and is_return != 1 and customer in ({1})""".\ + and grand_total > {0} and is_return != 1 and gst_category ='Unregistered' """.\ format(flt(b2c_limit), ", ".join([frappe.db.escape(c.name) for c in customers])) elif self.filters.get("type_of_business") == "B2C Small" and customers: conditions += """ and ( SUBSTR(place_of_supply, 1, 2) = SUBSTR(company_gstin, 1, 2) - or grand_total <= {0}) and is_return != 1 and customer in ({1})""".\ + or grand_total <= {0}) and is_return != 1 and gst_category ='Unregistered' """.\ format(flt(b2c_limit), ", ".join([frappe.db.escape(c.name) for c in customers])) elif self.filters.get("type_of_business") == "CDNR": From bcb0f6038e0742d73888720c2fafc4609ac3aa6a Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 21 Aug 2019 14:47:33 +0530 Subject: [PATCH 5/8] fix: Single gl entry should only be considered once either in opening or closing entry (#18792) --- .../report/accounts_receivable/accounts_receivable.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py index 97e710450c..0e4ee12548 100755 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py @@ -197,8 +197,10 @@ class ReceivablePayableReport(object): if self.filters.based_on_payment_terms and gl_entries_data: self.payment_term_map = self.get_payment_term_detail(voucher_nos) + self.gle_inclusion_map = {} for gle in gl_entries_data: if self.is_receivable_or_payable(gle, self.dr_or_cr, future_vouchers, return_entries): + self.gle_inclusion_map[gle.name] = True outstanding_amount, credit_note_amount, payment_amount = self.get_outstanding_amount( gle,self.filters.report_date, self.dr_or_cr, return_entries) temp_outstanding_amt = outstanding_amount @@ -409,7 +411,9 @@ class ReceivablePayableReport(object): for e in self.get_gl_entries_for(gle.party, gle.party_type, gle.voucher_type, gle.voucher_no): if getdate(e.posting_date) <= report_date \ and (e.name!=gle.name or (e.voucher_no in return_entries and not return_entries.get(e.voucher_no))): - + if e.name!=gle.name and self.gle_inclusion_map.get(e.name): + continue + self.gle_inclusion_map[e.name] = True amount = flt(e.get(reverse_dr_or_cr), self.currency_precision) - flt(e.get(dr_or_cr), self.currency_precision) if e.voucher_no not in return_entries: payment_amount += amount From 5619db28cba2b1e5dcf31e23ecfa193f09d5f732 Mon Sep 17 00:00:00 2001 From: Mangesh-Khairnar Date: Wed, 21 Aug 2019 14:49:24 +0530 Subject: [PATCH 6/8] fix: fetch capital work in progress as expense account (#18780) --- erpnext/controllers/queries.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/controllers/queries.py b/erpnext/controllers/queries.py index 57c063a72a..19ec053e74 100644 --- a/erpnext/controllers/queries.py +++ b/erpnext/controllers/queries.py @@ -371,7 +371,7 @@ def get_expense_account(doctype, txt, searchfield, start, page_len, filters): return frappe.db.sql("""select tabAccount.name from `tabAccount` where (tabAccount.report_type = "Profit and Loss" - or tabAccount.account_type in ("Expense Account", "Fixed Asset", "Temporary", "Asset Received But Not Billed")) + or tabAccount.account_type in ("Expense Account", "Fixed Asset", "Temporary", "Asset Received But Not Billed", "Capital Work in Progress")) and tabAccount.is_group=0 and tabAccount.docstatus!=2 and tabAccount.{key} LIKE %(txt)s From 109a07b8344df9c2420c2cea7f9bd6419284c920 Mon Sep 17 00:00:00 2001 From: Suraj Shetty <13928957+surajshetty3416@users.noreply.github.com> Date: Wed, 21 Aug 2019 15:19:08 +0530 Subject: [PATCH 7/8] fix: Fix get_employees_with_number query if the passed number is 7039392929 then it should match with the employee cell_number set as `7039392929, 0288382222` --- erpnext/communication/doctype/call_log/call_log.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/communication/doctype/call_log/call_log.py b/erpnext/communication/doctype/call_log/call_log.py index 00464170f3..2343632719 100644 --- a/erpnext/communication/doctype/call_log/call_log.py +++ b/erpnext/communication/doctype/call_log/call_log.py @@ -53,7 +53,7 @@ def get_employees_with_number(number): if employee_emails: return employee_emails employees = frappe.get_all('Employee', filters={ - 'cell_number': ['like', '%{}'.format(number)], + 'cell_number': ['like', '%{}%'.format(number)], 'user_id': ['!=', ''] }, fields=['user_id']) From a6c6e02c492568b65fe910a1f15966ae29d1e3cf Mon Sep 17 00:00:00 2001 From: Anastes Mp Date: Wed, 21 Aug 2019 16:53:06 +0530 Subject: [PATCH 8/8] Incorrect database table (#18558) Fixed Unknow Column tax_type error on offline pos --- erpnext/accounts/doctype/sales_invoice/pos.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/sales_invoice/pos.py b/erpnext/accounts/doctype/sales_invoice/pos.py index e2f99d6ea3..479548c6e3 100755 --- a/erpnext/accounts/doctype/sales_invoice/pos.py +++ b/erpnext/accounts/doctype/sales_invoice/pos.py @@ -307,7 +307,7 @@ def get_item_tax_data(): # example: {'Consulting Services': {'Excise 12 - TS': '12.000'}} itemwise_tax = {} - taxes = frappe.db.sql(""" select parent, tax_type, tax_rate from `tabItem Tax`""", as_dict=1) + taxes = frappe.db.sql(""" select parent, tax_type, tax_rate from `tabItem Tax Template Detail`""", as_dict=1) for tax in taxes: if tax.parent not in itemwise_tax: