Skip to content

Commit

Permalink
Merge branch 'develop' into item-default-validation
Browse files Browse the repository at this point in the history
  • Loading branch information
ankush authored Sep 12, 2021
2 parents 7e20cf0 + d743c41 commit 58ced50
Show file tree
Hide file tree
Showing 38 changed files with 615 additions and 4,027 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
38 changes: 7 additions & 31 deletions .github/workflows/server-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,34 +99,10 @@ jobs:
CI_BUILD_ID: ${{ github.run_id }}
ORCHESTRATOR_URL: http://test-orchestrator.frappe.io

- name: Upload Coverage Data
run: |
cp ~/frappe-bench/sites/.coverage ${GITHUB_WORKSPACE}
cd ${GITHUB_WORKSPACE}
pip3 install coverage==5.5
pip3 install coveralls==3.0.1
coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
COVERALLS_FLAG_NAME: run-${{ matrix.container }}
COVERALLS_SERVICE_NAME: ${{ github.event_name == 'pull_request' && 'github' || 'github-actions' }}
COVERALLS_PARALLEL: true

coveralls:
name: Coverage Wrap Up
needs: test
container: python:3-slim
runs-on: ubuntu-latest
steps:
- name: Clone
uses: actions/checkout@v2

- name: Coveralls Finished
run: |
cd ${GITHUB_WORKSPACE}
pip3 install coverage==5.5
pip3 install coveralls==3.0.1
coveralls --finish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload coverage data
uses: codecov/codecov-action@v2
with:
name: MariaDB
fail_ci_if_error: true
files: /home/runner/frappe-bench/sites/coverage.xml
verbose: true
8 changes: 0 additions & 8 deletions .snyk

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

[![CI](https://github.com/frappe/erpnext/actions/workflows/server-tests.yml/badge.svg?branch=develop)](https://github.com/frappe/erpnext/actions/workflows/server-tests.yml)
[![Open Source Helpers](https://www.codetriage.com/frappe/erpnext/badges/users.svg)](https://www.codetriage.com/frappe/erpnext)
[![Coverage Status](https://coveralls.io/repos/github/frappe/erpnext/badge.svg?branch=develop)](https://coveralls.io/github/frappe/erpnext?branch=develop)
[![codecov](https://codecov.io/gh/frappe/erpnext/branch/develop/graph/badge.svg?token=0TwvyUg3I5)](https://codecov.io/gh/frappe/erpnext)

[https://erpnext.com](https://erpnext.com)

Expand Down
16 changes: 16 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
codecov:
require_ci_to_pass: yes

coverage:
status:
project:
default:
target: auto
threshold: 0.5%

comment:
layout: "diff, files"
require_changes: true

ignore:
- "erpnext/demo"
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,10 +287,11 @@
}
],
"links": [],
"modified": "2021-05-21 11:14:22.426672",
"modified": "2021-09-06 21:00:45.732505",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Process Statement Of Accounts",
"naming_rule": "Set by user",
"owner": "Administrator",
"permissions": [
{
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 @@ -1151,10 +1151,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 @@ -1226,16 +1227,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='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
9 changes: 0 additions & 9 deletions erpnext/accounts/doctype/sales_invoice/sales_invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,15 +445,6 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends e
this.frm.refresh_field("base_paid_amount");
}

currency() {
this._super();
$.each(cur_frm.doc.timesheets, function(i, d) {
let row = frappe.get_doc(d.doctype, d.name)
set_timesheet_detail_rate(row.doctype, row.name, cur_frm.doc.currency, row.timesheet_detail)
});
calculate_total_billing_amount(cur_frm)
}

currency() {
var me = this;
super.currency();
Expand Down
13 changes: 9 additions & 4 deletions erpnext/accounts/doctype/sales_invoice/sales_invoice.json
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@
"depends_on": "customer",
"fetch_from": "customer.customer_name",
"fieldname": "customer_name",
"fieldtype": "Data",
"fieldtype": "Small Text",
"hide_days": 1,
"hide_seconds": 1,
"in_global_search": 1,
Expand Down Expand Up @@ -1061,6 +1061,7 @@
"hide_days": 1,
"hide_seconds": 1,
"label": "Apply Additional Discount On",
"length": 15,
"options": "\nGrand Total\nNet Total",
"print_hide": 1
},
Expand Down Expand Up @@ -1147,7 +1148,7 @@
{
"description": "In Words will be visible once you save the Sales Invoice.",
"fieldname": "base_in_words",
"fieldtype": "Data",
"fieldtype": "Small Text",
"hide_days": 1,
"hide_seconds": 1,
"label": "In Words (Company Currency)",
Expand Down Expand Up @@ -1207,7 +1208,7 @@
},
{
"fieldname": "in_words",
"fieldtype": "Data",
"fieldtype": "Small Text",
"hide_days": 1,
"hide_seconds": 1,
"label": "In Words",
Expand Down Expand Up @@ -1560,6 +1561,7 @@
"hide_days": 1,
"hide_seconds": 1,
"label": "Print Language",
"length": 6,
"print_hide": 1,
"read_only": 1
},
Expand Down Expand Up @@ -1647,6 +1649,7 @@
"hide_seconds": 1,
"in_standard_filter": 1,
"label": "Status",
"length": 30,
"no_copy": 1,
"options": "\nDraft\nReturn\nCredit Note Issued\nSubmitted\nPaid\nUnpaid\nUnpaid and Discounted\nOverdue and Discounted\nOverdue\nCancelled\nInternal Transfer",
"print_hide": 1,
Expand Down Expand Up @@ -1706,6 +1709,7 @@
"hide_days": 1,
"hide_seconds": 1,
"label": "Is Opening Entry",
"length": 4,
"oldfieldname": "is_opening",
"oldfieldtype": "Select",
"options": "No\nYes",
Expand All @@ -1717,6 +1721,7 @@
"hide_days": 1,
"hide_seconds": 1,
"label": "C-Form Applicable",
"length": 4,
"no_copy": 1,
"options": "No\nYes",
"print_hide": 1
Expand Down Expand Up @@ -2017,7 +2022,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 @@ -400,6 +400,7 @@ def create_invoice(self, prorate):

invoice.flags.ignore_mandatory = True

invoice.set_missing_values()
invoice.save()

if self.submit_invoice:
Expand Down
Loading

0 comments on commit 58ced50

Please sign in to comment.