Merge develop into contacts-ref
This commit is contained in:
commit
447134d308
@ -50,7 +50,7 @@ class BankTransaction(StatusUpdater):
|
|||||||
if paid_amount and allocated_amount:
|
if paid_amount and allocated_amount:
|
||||||
if flt(allocated_amount[0]["allocated_amount"]) > flt(paid_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))))
|
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"]:
|
if payment_entry.payment_document in ["Payment Entry", "Journal Entry", "Purchase Invoice", "Expense Claim"]:
|
||||||
self.clear_simple_entry(payment_entry)
|
self.clear_simple_entry(payment_entry)
|
||||||
|
|
||||||
|
@ -257,11 +257,8 @@ def reconcile_dr_cr_note(dr_cr_notes):
|
|||||||
voucher_type = ('Credit Note'
|
voucher_type = ('Credit Note'
|
||||||
if d.voucher_type == 'Sales Invoice' else 'Debit 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'
|
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({
|
jv = frappe.get_doc({
|
||||||
"doctype": "Journal Entry",
|
"doctype": "Journal Entry",
|
||||||
@ -272,8 +269,7 @@ def reconcile_dr_cr_note(dr_cr_notes):
|
|||||||
'account': d.account,
|
'account': d.account,
|
||||||
'party': d.party,
|
'party': d.party,
|
||||||
'party_type': d.party_type,
|
'party_type': d.party_type,
|
||||||
reconcile_dr_or_cr: (abs(d.allocated_amount)
|
d.dr_or_cr: abs(d.allocated_amount),
|
||||||
if abs(d.unadjusted_amount) > abs(d.allocated_amount) else abs(d.unadjusted_amount)),
|
|
||||||
'reference_type': d.against_voucher_type,
|
'reference_type': d.against_voucher_type,
|
||||||
'reference_name': d.against_voucher
|
'reference_name': d.against_voucher
|
||||||
},
|
},
|
||||||
@ -281,7 +277,8 @@ def reconcile_dr_cr_note(dr_cr_notes):
|
|||||||
'account': d.account,
|
'account': d.account,
|
||||||
'party': d.party,
|
'party': d.party,
|
||||||
'party_type': d.party_type,
|
'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_type': d.voucher_type,
|
||||||
'reference_name': d.voucher_no
|
'reference_name': d.voucher_no
|
||||||
}
|
}
|
||||||
|
@ -307,7 +307,7 @@ def get_item_tax_data():
|
|||||||
# example: {'Consulting Services': {'Excise 12 - TS': '12.000'}}
|
# example: {'Consulting Services': {'Excise 12 - TS': '12.000'}}
|
||||||
|
|
||||||
itemwise_tax = {}
|
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:
|
for tax in taxes:
|
||||||
if tax.parent not in itemwise_tax:
|
if tax.parent not in itemwise_tax:
|
||||||
|
@ -197,8 +197,10 @@ class ReceivablePayableReport(object):
|
|||||||
if self.filters.based_on_payment_terms and gl_entries_data:
|
if self.filters.based_on_payment_terms and gl_entries_data:
|
||||||
self.payment_term_map = self.get_payment_term_detail(voucher_nos)
|
self.payment_term_map = self.get_payment_term_detail(voucher_nos)
|
||||||
|
|
||||||
|
self.gle_inclusion_map = {}
|
||||||
for gle in gl_entries_data:
|
for gle in gl_entries_data:
|
||||||
if self.is_receivable_or_payable(gle, self.dr_or_cr, future_vouchers, return_entries):
|
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(
|
outstanding_amount, credit_note_amount, payment_amount = self.get_outstanding_amount(
|
||||||
gle,self.filters.report_date, self.dr_or_cr, return_entries)
|
gle,self.filters.report_date, self.dr_or_cr, return_entries)
|
||||||
temp_outstanding_amt = outstanding_amount
|
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):
|
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 \
|
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))):
|
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)
|
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:
|
if e.voucher_no not in return_entries:
|
||||||
payment_amount += amount
|
payment_amount += amount
|
||||||
|
@ -6,15 +6,13 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.model.document import Document
|
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 frappe.contacts.doctype.contact.contact import get_contact_with_phone_number
|
||||||
from erpnext.crm.doctype.lead.lead import get_lead_with_phone_number
|
from erpnext.crm.doctype.lead.lead import get_lead_with_phone_number
|
||||||
|
|
||||||
class CallLog(Document):
|
class CallLog(Document):
|
||||||
def before_insert(self):
|
def before_insert(self):
|
||||||
# strip 0 from the start of the number for proper number comparisions
|
number = strip_number(self.get('from'))
|
||||||
# eg. 07888383332 should match with 7888383332
|
|
||||||
number = self.get('from').lstrip('0')
|
|
||||||
self.contact = get_contact_with_phone_number(number)
|
self.contact = get_contact_with_phone_number(number)
|
||||||
self.lead = get_lead_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')) + '<br><br>' + summary)
|
doc.add_comment('Comment', frappe.bold(_('Call Summary')) + '<br><br>' + summary)
|
||||||
|
|
||||||
def get_employees_with_number(number):
|
def get_employees_with_number(number):
|
||||||
|
number = strip_number(number)
|
||||||
if not number: return []
|
if not number: return []
|
||||||
|
|
||||||
employee_emails = frappe.cache().hget('employees_with_number', number)
|
employee_emails = frappe.cache().hget('employees_with_number', number)
|
||||||
if employee_emails: return employee_emails
|
if employee_emails: return employee_emails
|
||||||
|
|
||||||
employees = frappe.get_all('Employee', filters={
|
employees = frappe.get_all('Employee', filters={
|
||||||
'cell_number': ['like', '{}'.format(number.lstrip('0'))],
|
'cell_number': ['like', '%{}%'.format(number)],
|
||||||
'user_id': ['!=', '']
|
'user_id': ['!=', '']
|
||||||
}, fields=['user_id'])
|
}, fields=['user_id'])
|
||||||
|
|
||||||
@ -64,27 +63,33 @@ def get_employees_with_number(number):
|
|||||||
return employee
|
return employee
|
||||||
|
|
||||||
def set_caller_information(doc, state):
|
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
|
if doc.doctype not in ['Lead', 'Contact']: return
|
||||||
|
|
||||||
numbers = [doc.get('phone'), doc.get('mobile_no')]
|
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)
|
||||||
|
|
||||||
# Contact now has all the nos saved in child table
|
# Contact now has all the nos saved in child table
|
||||||
if doc.doctype == 'Contact':
|
if doc.doctype == 'Contact':
|
||||||
numbers = [nos.phone for nos in doc.phone_nos]
|
numbers = [nos.phone for nos in doc.phone_nos]
|
||||||
|
|
||||||
for number in numbers:
|
for number in numbers:
|
||||||
|
number = strip_number(number)
|
||||||
if not number: continue
|
if not number: continue
|
||||||
|
|
||||||
filters = frappe._dict({
|
filters = frappe._dict({
|
||||||
'from': ['like', '%{}'.format(number.lstrip('0'))],
|
'from': ['like', '%{}'.format(number)],
|
||||||
for_doc: ''
|
fieldname: ''
|
||||||
})
|
})
|
||||||
|
|
||||||
logs = frappe.get_all('Call Log', filters=filters)
|
logs = frappe.get_all('Call Log', filters=filters)
|
||||||
|
|
||||||
for log in logs:
|
for log in logs:
|
||||||
call_log = frappe.get_doc('Call Log', log.name)
|
frappe.db.set_value('Call Log', log.name, {
|
||||||
call_log.set(for_doc, doc.name)
|
fieldname: doc.name,
|
||||||
call_log.save(ignore_permissions=True)
|
display_name_field: doc.get_title()
|
||||||
|
}, update_modified=False)
|
||||||
|
@ -371,7 +371,7 @@ def get_expense_account(doctype, txt, searchfield, start, page_len, filters):
|
|||||||
|
|
||||||
return frappe.db.sql("""select tabAccount.name from `tabAccount`
|
return frappe.db.sql("""select tabAccount.name from `tabAccount`
|
||||||
where (tabAccount.report_type = "Profit and Loss"
|
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.is_group=0
|
||||||
and tabAccount.docstatus!=2
|
and tabAccount.docstatus!=2
|
||||||
and tabAccount.{key} LIKE %(txt)s
|
and tabAccount.{key} LIKE %(txt)s
|
||||||
|
@ -54,6 +54,8 @@ def get_last_issue_from_customer(customer_name):
|
|||||||
|
|
||||||
|
|
||||||
def get_scheduled_employees_for_popup(communication_medium):
|
def get_scheduled_employees_for_popup(communication_medium):
|
||||||
|
if not communication_medium: return []
|
||||||
|
|
||||||
now_time = frappe.utils.nowtime()
|
now_time = frappe.utils.nowtime()
|
||||||
weekday = frappe.utils.get_weekday()
|
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])
|
employee_emails = set([employee.user_id for employee in employees])
|
||||||
|
|
||||||
return employee_emails
|
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
|
@ -156,33 +156,21 @@ class Gstr1Report(object):
|
|||||||
|
|
||||||
|
|
||||||
if self.filters.get("type_of_business") == "B2B":
|
if self.filters.get("type_of_business") == "B2B":
|
||||||
customers = frappe.get_all("Customer",
|
conditions += "and ifnull(gst_category, '') in ('Registered Regular', 'Deemed Export', 'SEZ') and is_return != 1"
|
||||||
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]))
|
|
||||||
|
|
||||||
if self.filters.get("type_of_business") in ("B2C Large", "B2C Small"):
|
if self.filters.get("type_of_business") in ("B2C Large", "B2C Small"):
|
||||||
b2c_limit = frappe.db.get_single_value('GST Settings', 'b2c_limit')
|
b2c_limit = frappe.db.get_single_value('GST Settings', 'b2c_limit')
|
||||||
if not b2c_limit:
|
if not b2c_limit:
|
||||||
frappe.throw(_("Please set B2C Limit in GST Settings."))
|
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:
|
if self.filters.get("type_of_business") == "B2C Large" and customers:
|
||||||
conditions += """ and SUBSTR(place_of_supply, 1, 2) != SUBSTR(company_gstin, 1, 2)
|
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]))
|
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:
|
elif self.filters.get("type_of_business") == "B2C Small" and customers:
|
||||||
conditions += """ and (
|
conditions += """ and (
|
||||||
SUBSTR(place_of_supply, 1, 2) = SUBSTR(company_gstin, 1, 2)
|
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]))
|
format(flt(b2c_limit), ", ".join([frappe.db.escape(c.name) for c in customers]))
|
||||||
|
|
||||||
elif self.filters.get("type_of_business") == "CDNR":
|
elif self.filters.get("type_of_business") == "CDNR":
|
||||||
|
Loading…
Reference in New Issue
Block a user