Skip to content

Commit

Permalink
Merge branch 'version-13-hotfix' into backport-fix-selling-settings
Browse files Browse the repository at this point in the history
  • Loading branch information
nextchamp-saqib authored Sep 16, 2021
2 parents b26da04 + adc5bf7 commit 24c08f5
Show file tree
Hide file tree
Showing 104 changed files with 6,209 additions and 4,403 deletions.
13 changes: 13 additions & 0 deletions .github/helper/semgrep_rules/report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,16 @@ rules:
languages: [python]
severity: ERROR

- id: frappe-translated-values-in-business-logic
paths:
include:
- "**/report"
patterns:
- pattern-inside: |
{..., filters: [...], ...}
- pattern: |
{..., options: [..., __("..."), ...], ...}
message: |
Using translated values in options field will require you to translate the values while comparing in business logic. Instead of passing translated labels provide objects that contain both label and value. e.g. { label: __("Option value"), value: "Option value"}
languages: [javascript]
severity: ERROR
8 changes: 0 additions & 8 deletions .snyk

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def get_data():
},
{
'label': _('References'),
'items': ['Period Closing Voucher', 'Tax Withholding Category']
'items': ['Period Closing Voucher']
},
{
'label': _('Target Details'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@
},
{
"default": "1",
"description": "A customer must have primary contact email.",
"fieldname": "primary_mandatory",
"fieldtype": "Check",
"label": "Send To Primary Contact"
Expand Down Expand Up @@ -286,7 +287,7 @@
}
],
"links": [],
"modified": "2021-05-21 10:14:22.426672",
"modified": "2021-09-06 21:00:45.732505",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Process Statement Of Accounts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,10 @@ def fetch_customers(customer_collection, collection_name, primary_mandatory):
primary_email = customer.get('email_id') or ''
billing_email = get_customer_emails(customer.name, 1, billing_and_primary=False)

if billing_email == '' or (primary_email == '' and int(primary_mandatory)):
if int(primary_mandatory):
if (primary_email == ''):
continue
elif (billing_email == '') and (primary_email == ''):
continue

customer_list.append({
Expand All @@ -208,10 +211,29 @@ def fetch_customers(customer_collection, collection_name, primary_mandatory):

@frappe.whitelist()
def get_customer_emails(customer_name, primary_mandatory, billing_and_primary=True):
""" Returns first email from Contact Email table as a Billing email
when Is Billing Contact checked
and Primary email- email with Is Primary checked """

billing_email = frappe.db.sql("""
SELECT c.email_id FROM `tabContact` AS c JOIN `tabDynamic Link` AS l ON c.name=l.parent
WHERE l.link_doctype='Customer' and l.link_name=%s and c.is_billing_contact=1
order by c.creation desc""", customer_name)
SELECT
email.email_id
FROM
`tabContact Email` AS email
JOIN
`tabDynamic Link` AS link
ON
email.parent=link.parent
JOIN
`tabContact` AS contact
ON
contact.name=link.parent
WHERE
link.link_doctype='Customer'
and link.link_name=%s
and contact.is_billing_contact=1
ORDER BY
contact.creation desc""", customer_name)

if len(billing_email) == 0 or (billing_email[0][0] is None):
if billing_and_primary:
Expand Down
17 changes: 11 additions & 6 deletions erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -1128,10 +1128,11 @@ def test_purchase_invoice_advance_taxes(self):
tax_withholding_category = 'TDS - 194 - Dividends - Individual')

# Update tax withholding category with current fiscal year and rate details
update_tax_witholding_category('_Test Company', 'TDS Payable - _TC', nowdate())
update_tax_witholding_category('_Test Company', 'TDS Payable - _TC')

# Create Purchase Order with TDS applied
po = create_purchase_order(do_not_save=1, supplier=supplier.name, rate=3000, item='_Test Non Stock Item')
po = create_purchase_order(do_not_save=1, supplier=supplier.name, rate=3000, item='_Test Non Stock Item',
posting_date='2021-09-15')
po.apply_tds = 1
po.tax_withholding_category = 'TDS - 194 - Dividends - Individual'
po.save()
Expand Down Expand Up @@ -1203,16 +1204,20 @@ def check_gl_entries(doc, voucher_no, expected_gle, posting_date):
doc.assertEqual(expected_gle[i][2], gle.credit)
doc.assertEqual(getdate(expected_gle[i][3]), gle.posting_date)

def update_tax_witholding_category(company, account, date):
def update_tax_witholding_category(company, account):
from erpnext.accounts.utils import get_fiscal_year

fiscal_year = get_fiscal_year(date=date, company=company)
fiscal_year = get_fiscal_year(fiscal_year='_Test Fiscal Year 2021')

if not frappe.db.get_value('Tax Withholding Rate',
{'parent': 'TDS - 194 - Dividends - Individual', 'fiscal_year': fiscal_year[0]}):
{'parent': 'TDS - 194 - Dividends - Individual', 'from_date': ('>=', fiscal_year[1]),
'to_date': ('<=', fiscal_year[2])}):
tds_category = frappe.get_doc('Tax Withholding Category', 'TDS - 194 - Dividends - Individual')
tds_category.set('rates', [])

tds_category.append('rates', {
'fiscal_year': fiscal_year[0],
'from_date': fiscal_year[1],
'to_date': fiscal_year[2],
'tax_withholding_rate': 10,
'single_threshold': 2500,
'cumulative_threshold': 0
Expand Down
3 changes: 1 addition & 2 deletions erpnext/accounts/doctype/sales_invoice/sales_invoice.json
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,6 @@
"hide_days": 1,
"hide_seconds": 1,
"label": "Scan Barcode",
"length": 1,
"options": "Barcode"
},
{
Expand Down Expand Up @@ -2033,7 +2032,7 @@
"link_fieldname": "consolidated_invoice"
}
],
"modified": "2021-08-27 20:13:40.456462",
"modified": "2021-09-08 15:24:25.486499",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Sales Invoice",
Expand Down
1 change: 1 addition & 0 deletions erpnext/accounts/doctype/subscription/subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ def create_invoice(self, prorate):
invoice.to_date = self.current_invoice_end

invoice.flags.ignore_mandatory = True
invoice.set_missing_values()
invoice.save()

if self.submit_invoice:
Expand Down
Loading

0 comments on commit 24c08f5

Please sign in to comment.