Skip to content

Commit

Permalink
chore: whitespace / eof fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ankush committed Sep 1, 2021
1 parent 9777e1d commit 1d917a5
Show file tree
Hide file tree
Showing 44 changed files with 86 additions and 98 deletions.
2 changes: 1 addition & 1 deletion erpnext/accounts/custom/address.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def on_update(self):
customers = frappe.db.get_all("Customer", filters=filters, as_list=True)
for customer_name in customers:
frappe.db.set_value("Customer", customer_name[0], "primary_address", address_display)

@frappe.whitelist()
def get_shipping_address(company, address = None):
filters = [
Expand Down
6 changes: 3 additions & 3 deletions erpnext/accounts/doctype/bank_transaction/bank_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def on_update_after_submit(self):
self.update_allocations()
self.clear_linked_payment_entries()
self.set_status(update=True)

def on_cancel(self):
self.clear_linked_payment_entries(for_cancel=True)
self.set_status(update=True)
Expand All @@ -45,7 +45,7 @@ def update_allocations(self):
frappe.db.set_value(self.doctype, self.name, "status", "Reconciled")

self.reload()

def clear_linked_payment_entries(self, for_cancel=False):
for payment_entry in self.payment_entries:
if payment_entry.payment_document in ["Payment Entry", "Journal Entry", "Purchase Invoice", "Expense Claim"]:
Expand Down Expand Up @@ -77,7 +77,7 @@ def clear_sales_invoice(self, payment_entry, for_cancel=False):

def get_reconciled_bank_transactions(payment_entry):
reconciled_bank_transactions = frappe.get_all(
'Bank Transaction Payments',
'Bank Transaction Payments',
filters = {
'payment_entry': payment_entry.payment_entry
},
Expand Down
2 changes: 1 addition & 1 deletion erpnext/accounts/doctype/finance_book/test_finance_book.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ def create_finance_book():
else:
finance_book = frappe.get_doc("Finance Book", "_Test Finance Book")

return finance_book
return finance_book
4 changes: 2 additions & 2 deletions erpnext/accounts/doctype/party_link/party_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ def validate(self):
if self.primary_role not in ['Customer', 'Supplier']:
frappe.throw(_("Allowed primary roles are 'Customer' and 'Supplier'. Please select one of these roles only."),
title=_("Invalid Primary Role"))

existing_party_link = frappe.get_all('Party Link', {
'primary_party': self.secondary_party
}, pluck="primary_role")
if existing_party_link:
frappe.throw(_('{} {} is already linked with another {}')
.format(self.secondary_role, self.secondary_party, existing_party_link[0]))

existing_party_link = frappe.get_all('Party Link', {
'secondary_party': self.primary_party
}, pluck="primary_role")
Expand Down
2 changes: 1 addition & 1 deletion erpnext/accounts/doctype/payment_entry/payment_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ def set_amounts(self):

def validate_amounts(self):
self.validate_received_amount()

def validate_received_amount(self):
if self.paid_from_account_currency == self.paid_to_account_currency:
if self.paid_amount != self.received_amount:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def make_gl_entries(self):
if gl_entries:
from erpnext.accounts.general_ledger import make_gl_entries
make_gl_entries(gl_entries)

def get_gl_entries(self):
gl_entries = []
pl_accounts = self.get_pl_balances()
Expand All @@ -77,7 +77,7 @@ def get_gl_entries(self):
gl_entries += gle_for_net_pl_bal

return gl_entries

def get_pnl_gl_entry(self, pl_accounts):
company_cost_center = frappe.db.get_value("Company", self.company, "cost_center")
gl_entries = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@
cur_frm.cscript.tax_table = "Sales Taxes and Charges";

{% include "erpnext/public/js/controllers/accounts.js" %}

Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def get_deducted_tax(taxable_vouchers, fiscal_year, tax_details):
def get_tds_amount(ldc, parties, inv, tax_details, fiscal_year_details, tax_deducted, vouchers):
tds_amount = 0
invoice_filters = {
'name': ('in', vouchers),
'name': ('in', vouchers),
'docstatus': 1,
'apply_tds': 1
}
Expand Down
2 changes: 1 addition & 1 deletion erpnext/controllers/taxes_and_totals.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ def set_total_amount_to_default_mop(self, total_amount_to_pay):
'mode_of_payment': default_mode_of_payment.mode_of_payment,
'amount': total_amount_to_pay,
'default': 1
})
})

def get_itemised_tax_breakup_html(doc):
if not doc.taxes:
Expand Down
1 change: 0 additions & 1 deletion erpnext/crm/doctype/lead/lead.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,4 +371,3 @@ def add_lead_to_prospect(lead, prospect):
prospect.save(ignore_permissions=True)
frappe.msgprint(_('Lead {0} has been added to prospect {1}.').format(frappe.bold(lead), frappe.bold(prospect.name)),
title=_('Lead Added'), indicator='green')

6 changes: 3 additions & 3 deletions erpnext/crm/doctype/linkedin_settings/linkedin_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def http_post(self, url, headers=None, body=None, data=None):

except Exception as e:
self.api_error(response)

return response

def get_headers(self):
Expand All @@ -168,15 +168,15 @@ def delete_post(self, post_id):
raise
except Exception:
self.api_error(response)

def get_post(self, post_id):
url = "https://api.linkedin.com/v2/organizationalEntityShareStatistics?q=organizationalEntity&organizationalEntity=urn:li:organization:{0}&shares[0]=urn:li:share:{1}".format(self.company_id, post_id)

try:
response = requests.get(url=url, headers=self.get_headers())
if response.status_code !=200:
raise

except Exception:
self.api_error(response)

Expand Down
2 changes: 1 addition & 1 deletion erpnext/crm/doctype/prospect/prospect.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def validate(self):

def on_update(self):
self.link_with_lead_contact_and_address()

def on_trash(self):
self.unlink_dynamic_links()

Expand Down
4 changes: 2 additions & 2 deletions erpnext/crm/doctype/social_media_post/social_media_post.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ frappe.ui.form.on('Social Media Post', {

refresh: function(frm) {
frm.trigger('text');

if (frm.doc.docstatus === 1) {
if (!['Posted', 'Deleted'].includes(frm.doc.post_status)) {
frm.trigger('add_post_btn');
frm.trigger('add_post_btn');
}
if (frm.doc.post_status !='Deleted') {
frm.add_custom_button(('Delete Post'), function() {
Expand Down
16 changes: 8 additions & 8 deletions erpnext/crm/doctype/twitter_settings/twitter_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ def get_access_token(self, oauth_token, oauth_verifier):
frappe.throw(_('Invalid Consumer Key or Consumer Secret Key'))

def get_api(self):
# authentication of consumer key and secret
auth = tweepy.OAuthHandler(self.consumer_key, self.get_password(fieldname="consumer_secret"))
# authentication of access token and secret
auth.set_access_token(self.access_token, self.access_token_secret)
# authentication of consumer key and secret
auth = tweepy.OAuthHandler(self.consumer_key, self.get_password(fieldname="consumer_secret"))
# authentication of access token and secret
auth.set_access_token(self.access_token, self.access_token_secret)

return tweepy.API(auth)

Expand Down Expand Up @@ -90,20 +90,20 @@ def send_tweet(self, text, media_id=None):

def delete_tweet(self, tweet_id):
api = self.get_api()
try:
try:
api.destroy_status(tweet_id)
except TweepError as e:
self.api_error(e)

def get_tweet(self, tweet_id):
api = self.get_api()
try:
try:
response = api.get_status(tweet_id, trim_user=True, include_entities=True)
except TweepError as e:
self.api_error(e)

return response._json

def api_error(self, e):
content = json.loads(e.response.content)
content = content["errors"][0]
Expand Down
16 changes: 8 additions & 8 deletions erpnext/erpnext_integrations/taxjar_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"SE", "SI", "SK", "US"]
SUPPORTED_STATE_CODES = ['AL', 'AK', 'AZ', 'AR', 'CA', 'CO', 'CT', 'DE', 'DC', 'FL', 'GA', 'HI', 'ID', 'IL',
'IN', 'IA', 'KS', 'KY', 'LA', 'ME', 'MD', 'MA', 'MI', 'MN', 'MS', 'MO', 'MT', 'NE',
'NV', 'NH', 'NJ', 'NM', 'NY', 'NC', 'ND', 'OH', 'OK', 'OR', 'PA', 'RI', 'SC', 'SD',
'NV', 'NH', 'NJ', 'NM', 'NY', 'NC', 'ND', 'OH', 'OK', 'OR', 'PA', 'RI', 'SC', 'SD',
'TN', 'TX', 'UT', 'VT', 'VA', 'WA', 'WV', 'WI', 'WY']


Expand Down Expand Up @@ -66,7 +66,7 @@ def create_transaction(doc, method):
try:
if doc.is_return:
client.create_refund(tax_dict)
else:
else:
client.create_order(tax_dict)
except taxjar.exceptions.TaxJarResponseError as err:
frappe.throw(_(sanitize_error_response(err)))
Expand Down Expand Up @@ -108,7 +108,7 @@ def get_tax_data(doc):

if to_shipping_state not in SUPPORTED_STATE_CODES:
to_shipping_state = get_state_code(to_address, 'Shipping')

tax_dict = {
'from_country': from_country_code,
'from_zip': from_address.pincode,
Expand All @@ -125,7 +125,7 @@ def get_tax_data(doc):
'plugin': 'erpnext',
'line_items': line_items
}
return tax_dict
return tax_dict

def get_state_code(address, location):
if address is not None:
Expand All @@ -134,16 +134,16 @@ def get_state_code(address, location):
frappe.throw(_("Please enter a valid State in the {0} Address").format(location))
else:
frappe.throw(_("Please enter a valid State in the {0} Address").format(location))

return state_code

def get_line_item_dict(item):
return dict(
return dict(
id = item.get('idx'),
quantity = item.get('qty'),
unit_price = item.get('rate'),
product_tax_code = item.get('product_tax_category')
)
)

def set_sales_tax(doc, method):
if not TAXJAR_CALCULATE_TAX:
Expand Down Expand Up @@ -202,7 +202,7 @@ def check_sales_tax_exemption(doc):
break
doc.run_method("calculate_taxes_and_totals")
return True
else:
else:
return False

def validate_tax_request(tax_dict):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_status(self):
self.assertEqual(frappe.db.get_value('Therapy Plan', plan.name, 'status'), 'Completed')

patient, practitioner = create_healthcare_docs()
appointment = create_appointment(patient, practitioner, nowdate())
appointment = create_appointment(patient, practitioner, nowdate())

session = make_therapy_session(plan.name, plan.patient, 'Basic Rehab', '_Test Company', appointment.name)
session = frappe.get_doc(session)
Expand Down
2 changes: 1 addition & 1 deletion erpnext/healthcare/page/patient_history/patient_history.js
Original file line number Diff line number Diff line change
Expand Up @@ -452,4 +452,4 @@ class PatientHistory {
}
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@
<div class="patient-details">
</div>
</div>

16 changes: 8 additions & 8 deletions erpnext/hr/doctype/employee/test_employee_reminders.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def setUpClass(cls):
# Create a test holiday list
test_holiday_dates = cls.get_test_holiday_dates()
test_holiday_list = make_holiday_list(
'TestHolidayRemindersList',
'TestHolidayRemindersList',
holiday_dates=[
{'holiday_date': test_holiday_dates[0], 'description': 'test holiday1'},
{'holiday_date': test_holiday_dates[1], 'description': 'test holiday2'},
Expand Down Expand Up @@ -49,8 +49,8 @@ def setUpClass(cls):
def get_test_holiday_dates(cls):
today_date = getdate()
return [
today_date,
today_date-timedelta(days=4),
today_date,
today_date-timedelta(days=4),
today_date-timedelta(days=3),
today_date+timedelta(days=1),
today_date+timedelta(days=3),
Expand All @@ -63,7 +63,7 @@ def setUp(self):

def test_is_holiday(self):
from erpnext.hr.doctype.employee.employee import is_holiday

self.assertTrue(is_holiday(self.test_employee.name))
self.assertTrue(is_holiday(self.test_employee.name, date=self.test_holiday_dates[1]))
self.assertFalse(is_holiday(self.test_employee.name, date=getdate()-timedelta(days=1)))
Expand Down Expand Up @@ -118,7 +118,7 @@ def test_work_anniversary_reminders(self):

email_queue = frappe.db.sql("""select * from `tabEmail Queue`""", as_dict=True)
self.assertTrue("Subject: Work Anniversary Reminder" in email_queue[0].message)

def test_send_holidays_reminder_in_advance(self):
from erpnext.hr.utils import get_holidays_for_employee
from erpnext.hr.doctype.employee.employee_reminders import send_holidays_reminder_in_advance
Expand All @@ -133,10 +133,10 @@ def test_send_holidays_reminder_in_advance(self):
holidays = get_holidays_for_employee(
self.test_employee.get('name'),
getdate(), getdate() + timedelta(days=3),
only_non_weekly=True,
only_non_weekly=True,
raise_exception=False
)

send_holidays_reminder_in_advance(
self.test_employee.get('name'),
holidays
Expand All @@ -158,7 +158,7 @@ def test_advance_holiday_reminders_monthly(self):

email_queue = frappe.db.sql("""select * from `tabEmail Queue`""", as_dict=True)
self.assertTrue(len(email_queue) > 0)

def test_advance_holiday_reminders_weekly(self):
from erpnext.hr.doctype.employee.employee_reminders import send_reminders_in_advance_weekly
# Get HR settings and enable advance holiday reminders
Expand Down
13 changes: 6 additions & 7 deletions erpnext/hr/doctype/expense_claim/test_expense_claim.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,20 +144,20 @@ def test_multiple_payment_entries_against_expense(self):
expense_claim = make_expense_claim(payable_account, 5500, 5500, "_Test Company", "Travel Expenses - _TC")
expense_claim.save()
expense_claim.submit()

# Payment entry 1: paying 500
make_payment_entry(expense_claim, payable_account,500)
outstanding_amount, total_amount_reimbursed = get_outstanding_and_total_reimbursed_amounts(expense_claim)
self.assertEqual(outstanding_amount, 5000)
self.assertEqual(total_amount_reimbursed, 500)

# Payment entry 1: paying 2000
make_payment_entry(expense_claim, payable_account,2000)
outstanding_amount, total_amount_reimbursed = get_outstanding_and_total_reimbursed_amounts(expense_claim)
self.assertEqual(outstanding_amount, 3000)
self.assertEqual(total_amount_reimbursed, 2500)
# Payment entry 1: paying 3000

# Payment entry 1: paying 3000
make_payment_entry(expense_claim, payable_account,3000)
outstanding_amount, total_amount_reimbursed = get_outstanding_and_total_reimbursed_amounts(expense_claim)
self.assertEqual(outstanding_amount, 0)
Expand Down Expand Up @@ -221,7 +221,7 @@ def get_outstanding_and_total_reimbursed_amounts(expense_claim):
outstanding_amount = flt(frappe.db.get_value("Expense Claim", expense_claim.name, "total_sanctioned_amount")) - \
flt(frappe.db.get_value("Expense Claim", expense_claim.name, "total_amount_reimbursed"))
total_amount_reimbursed = flt(frappe.db.get_value("Expense Claim", expense_claim.name, "total_amount_reimbursed"))

return outstanding_amount,total_amount_reimbursed

def make_payment_entry(expense_claim, payable_account, amt):
Expand All @@ -234,5 +234,4 @@ def make_payment_entry(expense_claim, payable_account, amt):
pe.paid_to = payable_account
pe.references[0].allocated_amount = amt
pe.insert()
pe.submit()

pe.submit()
Loading

0 comments on commit 1d917a5

Please sign in to comment.