chore: whitespace trimming

This commit is contained in:
Ankush Menat
2021-09-01 20:23:48 +05:30
parent 77aef302e4
commit f0bcb753fb
26 changed files with 83 additions and 83 deletions

View File

@@ -31,7 +31,7 @@ class ERPNextAddress(Address):
customers = frappe.db.get_all("Customer", filters=filters, as_list=True) customers = frappe.db.get_all("Customer", filters=filters, as_list=True)
for customer_name in customers: for customer_name in customers:
frappe.db.set_value("Customer", customer_name[0], "primary_address", address_display) frappe.db.set_value("Customer", customer_name[0], "primary_address", address_display)
@frappe.whitelist() @frappe.whitelist()
def get_shipping_address(company, address = None): def get_shipping_address(company, address = None):
filters = [ filters = [

View File

@@ -21,7 +21,7 @@ class BankTransaction(StatusUpdater):
self.update_allocations() self.update_allocations()
self.clear_linked_payment_entries() self.clear_linked_payment_entries()
self.set_status(update=True) self.set_status(update=True)
def on_cancel(self): def on_cancel(self):
self.clear_linked_payment_entries(for_cancel=True) self.clear_linked_payment_entries(for_cancel=True)
self.set_status(update=True) self.set_status(update=True)
@@ -45,7 +45,7 @@ class BankTransaction(StatusUpdater):
frappe.db.set_value(self.doctype, self.name, "status", "Reconciled") frappe.db.set_value(self.doctype, self.name, "status", "Reconciled")
self.reload() self.reload()
def clear_linked_payment_entries(self, for_cancel=False): def clear_linked_payment_entries(self, for_cancel=False):
for payment_entry in self.payment_entries: for payment_entry in self.payment_entries:
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"]:
@@ -77,7 +77,7 @@ class BankTransaction(StatusUpdater):
def get_reconciled_bank_transactions(payment_entry): def get_reconciled_bank_transactions(payment_entry):
reconciled_bank_transactions = frappe.get_all( reconciled_bank_transactions = frappe.get_all(
'Bank Transaction Payments', 'Bank Transaction Payments',
filters = { filters = {
'payment_entry': payment_entry.payment_entry 'payment_entry': payment_entry.payment_entry
}, },

View File

@@ -10,14 +10,14 @@ class PartyLink(Document):
if self.primary_role not in ['Customer', 'Supplier']: if self.primary_role not in ['Customer', 'Supplier']:
frappe.throw(_("Allowed primary roles are 'Customer' and 'Supplier'. Please select one of these roles only."), frappe.throw(_("Allowed primary roles are 'Customer' and 'Supplier'. Please select one of these roles only."),
title=_("Invalid Primary Role")) title=_("Invalid Primary Role"))
existing_party_link = frappe.get_all('Party Link', { existing_party_link = frappe.get_all('Party Link', {
'primary_party': self.secondary_party 'primary_party': self.secondary_party
}, pluck="primary_role") }, pluck="primary_role")
if existing_party_link: if existing_party_link:
frappe.throw(_('{} {} is already linked with another {}') frappe.throw(_('{} {} is already linked with another {}')
.format(self.secondary_role, self.secondary_party, existing_party_link[0])) .format(self.secondary_role, self.secondary_party, existing_party_link[0]))
existing_party_link = frappe.get_all('Party Link', { existing_party_link = frappe.get_all('Party Link', {
'secondary_party': self.primary_party 'secondary_party': self.primary_party
}, pluck="primary_role") }, pluck="primary_role")

View File

@@ -484,7 +484,7 @@ class PaymentEntry(AccountsController):
def validate_amounts(self): def validate_amounts(self):
self.validate_received_amount() self.validate_received_amount()
def validate_received_amount(self): def validate_received_amount(self):
if self.paid_from_account_currency == self.paid_to_account_currency: if self.paid_from_account_currency == self.paid_to_account_currency:
if self.paid_amount != self.received_amount: if self.paid_amount != self.received_amount:

View File

@@ -54,7 +54,7 @@ class PeriodClosingVoucher(AccountsController):
if gl_entries: if gl_entries:
from erpnext.accounts.general_ledger import make_gl_entries from erpnext.accounts.general_ledger import make_gl_entries
make_gl_entries(gl_entries) make_gl_entries(gl_entries)
def get_gl_entries(self): def get_gl_entries(self):
gl_entries = [] gl_entries = []
pl_accounts = self.get_pl_balances() pl_accounts = self.get_pl_balances()
@@ -77,7 +77,7 @@ class PeriodClosingVoucher(AccountsController):
gl_entries += gle_for_net_pl_bal gl_entries += gle_for_net_pl_bal
return gl_entries return gl_entries
def get_pnl_gl_entry(self, pl_accounts): def get_pnl_gl_entry(self, pl_accounts):
company_cost_center = frappe.db.get_value("Company", self.company, "cost_center") company_cost_center = frappe.db.get_value("Company", self.company, "cost_center")
gl_entries = [] gl_entries = []

View File

@@ -932,7 +932,7 @@ class SalesInvoice(SellingController):
if asset.calculate_depreciation: if asset.calculate_depreciation:
self.reset_depreciation_schedule(asset) self.reset_depreciation_schedule(asset)
else: else:
fixed_asset_gl_entries = get_gl_entries_on_asset_disposal(asset, fixed_asset_gl_entries = get_gl_entries_on_asset_disposal(asset,
item.base_net_amount, item.finance_book) item.base_net_amount, item.finance_book)
@@ -946,7 +946,7 @@ class SalesInvoice(SellingController):
gl_entries.append(self.get_gl_dict(gle, item=item)) gl_entries.append(self.get_gl_dict(gle, item=item))
self.set_asset_status(asset) self.set_asset_status(asset)
else: else:
# Do not book income for transfer within same company # Do not book income for transfer within same company
if not self.is_internal_transfer(): if not self.is_internal_transfer():
@@ -979,7 +979,7 @@ class SalesInvoice(SellingController):
asset = frappe.get_doc("Asset", item.asset) asset = frappe.get_doc("Asset", item.asset)
else: else:
frappe.throw(_( frappe.throw(_(
"Row #{0}: You must select an Asset for Item {1}.").format(item.idx, item.item_name), "Row #{0}: You must select an Asset for Item {1}.").format(item.idx, item.item_name),
title=_("Missing Asset") title=_("Missing Asset")
) )
@@ -996,7 +996,7 @@ class SalesInvoice(SellingController):
asset.flags.ignore_validate_update_after_submit = True asset.flags.ignore_validate_update_after_submit = True
asset.prepare_depreciation_data(self.posting_date) asset.prepare_depreciation_data(self.posting_date)
asset.save() asset.save()
post_depreciation_entries(self.posting_date) post_depreciation_entries(self.posting_date)
def reset_depreciation_schedule(self, asset): def reset_depreciation_schedule(self, asset):
@@ -1036,7 +1036,7 @@ class SalesInvoice(SellingController):
finance_book = schedule.finance_book finance_book = schedule.finance_book
else: else:
row += 1 row += 1
if schedule.schedule_date == posting_date_of_original_invoice: if schedule.schedule_date == posting_date_of_original_invoice:
if not self.sale_was_made_on_original_schedule_date(asset, schedule, row, posting_date_of_original_invoice): if not self.sale_was_made_on_original_schedule_date(asset, schedule, row, posting_date_of_original_invoice):
reverse_journal_entry = make_reverse_journal_entry(schedule.journal_entry) reverse_journal_entry = make_reverse_journal_entry(schedule.journal_entry)
@@ -1046,13 +1046,13 @@ class SalesInvoice(SellingController):
def get_posting_date_of_sales_invoice(self): def get_posting_date_of_sales_invoice(self):
return frappe.db.get_value('Sales Invoice', self.return_against, 'posting_date') return frappe.db.get_value('Sales Invoice', self.return_against, 'posting_date')
# if the invoice had been posted on the date the depreciation was initially supposed to happen, the depreciation shouldn't be undone # if the invoice had been posted on the date the depreciation was initially supposed to happen, the depreciation shouldn't be undone
def sale_was_made_on_original_schedule_date(self, asset, schedule, row, posting_date_of_original_invoice): def sale_was_made_on_original_schedule_date(self, asset, schedule, row, posting_date_of_original_invoice):
for finance_book in asset.get('finance_books'): for finance_book in asset.get('finance_books'):
if schedule.finance_book == finance_book.finance_book: if schedule.finance_book == finance_book.finance_book:
orginal_schedule_date = add_months(finance_book.depreciation_start_date, orginal_schedule_date = add_months(finance_book.depreciation_start_date,
row * cint(finance_book.frequency_of_depreciation)) row * cint(finance_book.frequency_of_depreciation))
if orginal_schedule_date == posting_date_of_original_invoice: if orginal_schedule_date == posting_date_of_original_invoice:
return True return True
return False return False

View File

@@ -1118,9 +1118,9 @@ class TestSalesInvoice(unittest.TestCase):
'qty': 1 'qty': 1
}) })
pi.set_missing_values() pi.set_missing_values()
asset = create_asset(item_code="Macbook Pro") asset = create_asset(item_code="Macbook Pro")
si = create_sales_invoice(item_code="Macbook Pro", asset=asset.name, qty=1, rate=90000) si = create_sales_invoice(item_code="Macbook Pro", asset=asset.name, qty=1, rate=90000)
return_si = create_sales_invoice(is_return=1, return_against=si.name, item_code="Macbook Pro", asset=asset.name, qty=-1, rate=90000) return_si = create_sales_invoice(is_return=1, return_against=si.name, item_code="Macbook Pro", asset=asset.name, qty=-1, rate=90000)
@@ -1128,7 +1128,7 @@ class TestSalesInvoice(unittest.TestCase):
# Asset value is 100,000 but it was sold for 90,000, so there should be a loss of 10,000 # Asset value is 100,000 but it was sold for 90,000, so there should be a loss of 10,000
loss_for_si = frappe.get_all( loss_for_si = frappe.get_all(
"GL Entry", "GL Entry",
filters = { filters = {
"voucher_no": si.name, "voucher_no": si.name,
"account": disposal_account "account": disposal_account
@@ -1137,7 +1137,7 @@ class TestSalesInvoice(unittest.TestCase):
)[0] )[0]
loss_for_return_si = frappe.get_all( loss_for_return_si = frappe.get_all(
"GL Entry", "GL Entry",
filters = { filters = {
"voucher_no": return_si.name, "voucher_no": return_si.name,
"account": disposal_account "account": disposal_account

View File

@@ -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): def get_tds_amount(ldc, parties, inv, tax_details, fiscal_year_details, tax_deducted, vouchers):
tds_amount = 0 tds_amount = 0
invoice_filters = { invoice_filters = {
'name': ('in', vouchers), 'name': ('in', vouchers),
'docstatus': 1, 'docstatus': 1,
'apply_tds': 1 'apply_tds': 1
} }

View File

@@ -321,10 +321,10 @@ class Asset(AccountsController):
def get_from_date(self, finance_book): def get_from_date(self, finance_book):
if not self.get('schedules'): if not self.get('schedules'):
return self.available_for_use_date return self.available_for_use_date
if len(self.finance_books) == 1: if len(self.finance_books) == 1:
return self.schedules[-1].schedule_date return self.schedules[-1].schedule_date
from_date = "" from_date = ""
for schedule in self.get('schedules'): for schedule in self.get('schedules'):
if schedule.finance_book == finance_book: if schedule.finance_book == finance_book:

View File

@@ -146,7 +146,7 @@ class LinkedInSettings(Document):
except Exception as e: except Exception as e:
self.api_error(response) self.api_error(response)
return response return response
def get_headers(self): def get_headers(self):
@@ -168,7 +168,7 @@ class LinkedInSettings(Document):
raise raise
except Exception: except Exception:
self.api_error(response) self.api_error(response)
def get_post(self, post_id): 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) 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)
@@ -176,7 +176,7 @@ class LinkedInSettings(Document):
response = requests.get(url=url, headers=self.get_headers()) response = requests.get(url=url, headers=self.get_headers())
if response.status_code !=200: if response.status_code !=200:
raise raise
except Exception: except Exception:
self.api_error(response) self.api_error(response)

View File

@@ -80,10 +80,10 @@ frappe.ui.form.on('Social Media Post', {
refresh: function(frm) { refresh: function(frm) {
frm.trigger('text'); frm.trigger('text');
if (frm.doc.docstatus === 1) { if (frm.doc.docstatus === 1) {
if (!['Posted', 'Deleted'].includes(frm.doc.post_status)) { if (!['Posted', 'Deleted'].includes(frm.doc.post_status)) {
frm.trigger('add_post_btn'); frm.trigger('add_post_btn');
} }
if (frm.doc.post_status !='Deleted') { if (frm.doc.post_status !='Deleted') {
frm.add_custom_button(('Delete Post'), function() { frm.add_custom_button(('Delete Post'), function() {

View File

@@ -53,10 +53,10 @@ class TwitterSettings(Document):
frappe.throw(_('Invalid Consumer Key or Consumer Secret Key')) frappe.throw(_('Invalid Consumer Key or Consumer Secret Key'))
def get_api(self): def get_api(self):
# authentication of consumer key and secret # authentication of consumer key and secret
auth = tweepy.OAuthHandler(self.consumer_key, self.get_password(fieldname="consumer_secret")) auth = tweepy.OAuthHandler(self.consumer_key, self.get_password(fieldname="consumer_secret"))
# authentication of access token and secret # authentication of access token and secret
auth.set_access_token(self.access_token, self.access_token_secret) auth.set_access_token(self.access_token, self.access_token_secret)
return tweepy.API(auth) return tweepy.API(auth)
@@ -90,20 +90,20 @@ class TwitterSettings(Document):
def delete_tweet(self, tweet_id): def delete_tweet(self, tweet_id):
api = self.get_api() api = self.get_api()
try: try:
api.destroy_status(tweet_id) api.destroy_status(tweet_id)
except TweepError as e: except TweepError as e:
self.api_error(e) self.api_error(e)
def get_tweet(self, tweet_id): def get_tweet(self, tweet_id):
api = self.get_api() api = self.get_api()
try: try:
response = api.get_status(tweet_id, trim_user=True, include_entities=True) response = api.get_status(tweet_id, trim_user=True, include_entities=True)
except TweepError as e: except TweepError as e:
self.api_error(e) self.api_error(e)
return response._json return response._json
def api_error(self, e): def api_error(self, e):
content = json.loads(e.response.content) content = json.loads(e.response.content)
content = content["errors"][0] content = content["errors"][0]

View File

@@ -31,7 +31,7 @@ class TestTherapyPlan(unittest.TestCase):
self.assertEqual(frappe.db.get_value('Therapy Plan', plan.name, 'status'), 'Completed') self.assertEqual(frappe.db.get_value('Therapy Plan', plan.name, 'status'), 'Completed')
patient, practitioner = create_healthcare_docs() 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 = make_therapy_session(plan.name, plan.patient, 'Basic Rehab', '_Test Company', appointment.name)
session = frappe.get_doc(session) session = frappe.get_doc(session)

View File

@@ -18,7 +18,7 @@ class TestEmployeeReminders(unittest.TestCase):
# Create a test holiday list # Create a test holiday list
test_holiday_dates = cls.get_test_holiday_dates() test_holiday_dates = cls.get_test_holiday_dates()
test_holiday_list = make_holiday_list( test_holiday_list = make_holiday_list(
'TestHolidayRemindersList', 'TestHolidayRemindersList',
holiday_dates=[ holiday_dates=[
{'holiday_date': test_holiday_dates[0], 'description': 'test holiday1'}, {'holiday_date': test_holiday_dates[0], 'description': 'test holiday1'},
{'holiday_date': test_holiday_dates[1], 'description': 'test holiday2'}, {'holiday_date': test_holiday_dates[1], 'description': 'test holiday2'},
@@ -49,8 +49,8 @@ class TestEmployeeReminders(unittest.TestCase):
def get_test_holiday_dates(cls): def get_test_holiday_dates(cls):
today_date = getdate() today_date = getdate()
return [ return [
today_date, today_date,
today_date-timedelta(days=4), today_date-timedelta(days=4),
today_date-timedelta(days=3), today_date-timedelta(days=3),
today_date+timedelta(days=1), today_date+timedelta(days=1),
today_date+timedelta(days=3), today_date+timedelta(days=3),
@@ -63,7 +63,7 @@ class TestEmployeeReminders(unittest.TestCase):
def test_is_holiday(self): def test_is_holiday(self):
from erpnext.hr.doctype.employee.employee import is_holiday 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))
self.assertTrue(is_holiday(self.test_employee.name, date=self.test_holiday_dates[1])) 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))) self.assertFalse(is_holiday(self.test_employee.name, date=getdate()-timedelta(days=1)))
@@ -118,7 +118,7 @@ class TestEmployeeReminders(unittest.TestCase):
email_queue = frappe.db.sql("""select * from `tabEmail Queue`""", as_dict=True) email_queue = frappe.db.sql("""select * from `tabEmail Queue`""", as_dict=True)
self.assertTrue("Subject: Work Anniversary Reminder" in email_queue[0].message) self.assertTrue("Subject: Work Anniversary Reminder" in email_queue[0].message)
def test_send_holidays_reminder_in_advance(self): def test_send_holidays_reminder_in_advance(self):
from erpnext.hr.utils import get_holidays_for_employee from erpnext.hr.utils import get_holidays_for_employee
from erpnext.hr.doctype.employee.employee_reminders import send_holidays_reminder_in_advance from erpnext.hr.doctype.employee.employee_reminders import send_holidays_reminder_in_advance
@@ -133,10 +133,10 @@ class TestEmployeeReminders(unittest.TestCase):
holidays = get_holidays_for_employee( holidays = get_holidays_for_employee(
self.test_employee.get('name'), self.test_employee.get('name'),
getdate(), getdate() + timedelta(days=3), getdate(), getdate() + timedelta(days=3),
only_non_weekly=True, only_non_weekly=True,
raise_exception=False raise_exception=False
) )
send_holidays_reminder_in_advance( send_holidays_reminder_in_advance(
self.test_employee.get('name'), self.test_employee.get('name'),
holidays holidays
@@ -158,7 +158,7 @@ class TestEmployeeReminders(unittest.TestCase):
email_queue = frappe.db.sql("""select * from `tabEmail Queue`""", as_dict=True) email_queue = frappe.db.sql("""select * from `tabEmail Queue`""", as_dict=True)
self.assertTrue(len(email_queue) > 0) self.assertTrue(len(email_queue) > 0)
def test_advance_holiday_reminders_weekly(self): def test_advance_holiday_reminders_weekly(self):
from erpnext.hr.doctype.employee.employee_reminders import send_reminders_in_advance_weekly from erpnext.hr.doctype.employee.employee_reminders import send_reminders_in_advance_weekly
# Get HR settings and enable advance holiday reminders # Get HR settings and enable advance holiday reminders

View File

@@ -144,20 +144,20 @@ class TestExpenseClaim(unittest.TestCase):
expense_claim = make_expense_claim(payable_account, 5500, 5500, "_Test Company", "Travel Expenses - _TC") expense_claim = make_expense_claim(payable_account, 5500, 5500, "_Test Company", "Travel Expenses - _TC")
expense_claim.save() expense_claim.save()
expense_claim.submit() expense_claim.submit()
# Payment entry 1: paying 500 # Payment entry 1: paying 500
make_payment_entry(expense_claim, payable_account,500) make_payment_entry(expense_claim, payable_account,500)
outstanding_amount, total_amount_reimbursed = get_outstanding_and_total_reimbursed_amounts(expense_claim) outstanding_amount, total_amount_reimbursed = get_outstanding_and_total_reimbursed_amounts(expense_claim)
self.assertEqual(outstanding_amount, 5000) self.assertEqual(outstanding_amount, 5000)
self.assertEqual(total_amount_reimbursed, 500) self.assertEqual(total_amount_reimbursed, 500)
# Payment entry 1: paying 2000 # Payment entry 1: paying 2000
make_payment_entry(expense_claim, payable_account,2000) make_payment_entry(expense_claim, payable_account,2000)
outstanding_amount, total_amount_reimbursed = get_outstanding_and_total_reimbursed_amounts(expense_claim) outstanding_amount, total_amount_reimbursed = get_outstanding_and_total_reimbursed_amounts(expense_claim)
self.assertEqual(outstanding_amount, 3000) self.assertEqual(outstanding_amount, 3000)
self.assertEqual(total_amount_reimbursed, 2500) self.assertEqual(total_amount_reimbursed, 2500)
# Payment entry 1: paying 3000 # Payment entry 1: paying 3000
make_payment_entry(expense_claim, payable_account,3000) make_payment_entry(expense_claim, payable_account,3000)
outstanding_amount, total_amount_reimbursed = get_outstanding_and_total_reimbursed_amounts(expense_claim) outstanding_amount, total_amount_reimbursed = get_outstanding_and_total_reimbursed_amounts(expense_claim)
self.assertEqual(outstanding_amount, 0) self.assertEqual(outstanding_amount, 0)
@@ -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")) - \ 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")) 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")) total_amount_reimbursed = flt(frappe.db.get_value("Expense Claim", expense_claim.name, "total_amount_reimbursed"))
return outstanding_amount,total_amount_reimbursed return outstanding_amount,total_amount_reimbursed
def make_payment_entry(expense_claim, payable_account, amt): def make_payment_entry(expense_claim, payable_account, amt):
@@ -234,5 +234,5 @@ def make_payment_entry(expense_claim, payable_account, amt):
pe.paid_to = payable_account pe.paid_to = payable_account
pe.references[0].allocated_amount = amt pe.references[0].allocated_amount = amt
pe.insert() pe.insert()
pe.submit() pe.submit()

View File

@@ -450,9 +450,9 @@ def get_sal_slip_total_benefit_given(employee, payroll_period, component=False):
def get_holiday_dates_for_employee(employee, start_date, end_date): def get_holiday_dates_for_employee(employee, start_date, end_date):
"""return a list of holiday dates for the given employee between start_date and end_date""" """return a list of holiday dates for the given employee between start_date and end_date"""
# return only date # return only date
holidays = get_holidays_for_employee(employee, start_date, end_date) holidays = get_holidays_for_employee(employee, start_date, end_date)
return [cstr(h.holiday_date) for h in holidays] return [cstr(h.holiday_date) for h in holidays]
@@ -465,7 +465,7 @@ def get_holidays_for_employee(employee, start_date, end_date, raise_exception=Tr
`raise_exception` (bool) `raise_exception` (bool)
`only_non_weekly` (bool) `only_non_weekly` (bool)
return: list of dicts with `holiday_date` and `description` return: list of dicts with `holiday_date` and `description`
""" """
holiday_list = get_holiday_list_for_employee(employee, raise_exception=raise_exception) holiday_list = get_holiday_list_for_employee(employee, raise_exception=raise_exception)
@@ -481,11 +481,11 @@ def get_holidays_for_employee(employee, start_date, end_date, raise_exception=Tr
filters['weekly_off'] = False filters['weekly_off'] = False
holidays = frappe.get_all( holidays = frappe.get_all(
'Holiday', 'Holiday',
fields=['description', 'holiday_date'], fields=['description', 'holiday_date'],
filters=filters filters=filters
) )
return holidays return holidays
@erpnext.allow_regional @erpnext.allow_regional

View File

@@ -7,17 +7,17 @@ def execute():
try: try:
# Rename the field # Rename the field
rename_field('HR Settings', 'stop_birthday_reminders', 'send_birthday_reminders') rename_field('HR Settings', 'stop_birthday_reminders', 'send_birthday_reminders')
# Reverse the value # Reverse the value
old_value = frappe.db.get_single_value('HR Settings', 'send_birthday_reminders') old_value = frappe.db.get_single_value('HR Settings', 'send_birthday_reminders')
frappe.db.set_value( frappe.db.set_value(
'HR Settings', 'HR Settings',
'HR Settings', 'HR Settings',
'send_birthday_reminders', 'send_birthday_reminders',
1 if old_value == 0 else 0 1 if old_value == 0 else 0
) )
except Exception as e: except Exception as e:
if e.args[0] != 1054: if e.args[0] != 1054:
raise raise

View File

@@ -35,10 +35,10 @@ def get_reconciled_bank_transactions(intra_company_pe):
for payment_entry in intra_company_pe: for payment_entry in intra_company_pe:
reconciled_bank_transactions[payment_entry] = frappe.get_all( reconciled_bank_transactions[payment_entry] = frappe.get_all(
'Bank Transaction Payments', 'Bank Transaction Payments',
filters = { filters = {
'payment_entry': payment_entry 'payment_entry': payment_entry
}, },
pluck='parent' pluck='parent'
) )

View File

@@ -3,11 +3,11 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
from frappe.model import data_field_options from frappe.model import data_field_options
def execute(): def execute():
for field in frappe.get_all('Custom Field', for field in frappe.get_all('Custom Field',
fields = ['name'], fields = ['name'],
filters = { filters = {
'fieldtype': 'Data', 'fieldtype': 'Data',
@@ -16,7 +16,7 @@ def execute():
if field not in data_field_options: if field not in data_field_options:
frappe.db.sql(""" frappe.db.sql("""
UPDATE UPDATE
`tabCustom Field` `tabCustom Field`
SET SET
options=NULL options=NULL

View File

@@ -86,9 +86,9 @@ $.extend(erpnext, {
proceed_save_with_reminders_frequency_change: () => { proceed_save_with_reminders_frequency_change: () => {
frappe.ui.hide_open_dialog(); frappe.ui.hide_open_dialog();
frappe.call({ frappe.call({
method: 'erpnext.hr.doctype.hr_settings.hr_settings.set_proceed_with_frequency_change', method: 'erpnext.hr.doctype.hr_settings.hr_settings.set_proceed_with_frequency_change',
callback: () => { callback: () => {
cur_frm.save(); cur_frm.save();
} }

View File

@@ -200,7 +200,7 @@ def get_transactions(filters, as_dict=1):
def run(params_method, filters): def run(params_method, filters):
extra_fields, extra_joins, extra_filters = params_method(filters) extra_fields, extra_joins, extra_filters = params_method(filters)
return run_query(filters, extra_fields, extra_joins, extra_filters, as_dict=as_dict) return run_query(filters, extra_fields, extra_joins, extra_filters, as_dict=as_dict)
def sort_by(row): def sort_by(row):
# "Belegdatum" is in the fifth column when list format is used # "Belegdatum" is in the fifth column when list format is used
return row["Belegdatum" if as_dict else 5] return row["Belegdatum" if as_dict else 5]
@@ -361,7 +361,7 @@ def run_query(filters, extra_fields, extra_joins, extra_filters, as_dict=1):
FROM `tabGL Entry` gl FROM `tabGL Entry` gl
/* Kontonummer */ /* Kontonummer */
LEFT JOIN `tabAccount` acc LEFT JOIN `tabAccount` acc
ON gl.account = acc.name ON gl.account = acc.name
LEFT JOIN `tabParty Account` par LEFT JOIN `tabParty Account` par

View File

@@ -190,7 +190,7 @@ class VATAuditReport(object):
row["posting_date"] = formatdate(inv_data.get("posting_date"), "dd-mm-yyyy") row["posting_date"] = formatdate(inv_data.get("posting_date"), "dd-mm-yyyy")
row["voucher_type"] = doctype row["voucher_type"] = doctype
row["voucher_no"] = inv row["voucher_no"] = inv
row["party_type"] = "Customer" if doctype == "Sales Invoice" else "Supplier" row["party_type"] = "Customer" if doctype == "Sales Invoice" else "Supplier"
row["party"] = inv_data.get("party") row["party"] = inv_data.get("party")
row["remarks"] = inv_data.get("remarks") row["remarks"] = inv_data.get("remarks")
row["gross_amount"]= item_details[0].get("gross_amount") row["gross_amount"]= item_details[0].get("gross_amount")

View File

@@ -24,7 +24,7 @@ def make_custom_fields(update=True):
'Sales Invoice Item': is_zero_rated, 'Sales Invoice Item': is_zero_rated,
'Purchase Invoice Item': is_zero_rated 'Purchase Invoice Item': is_zero_rated
} }
create_custom_fields(custom_fields, update=update) create_custom_fields(custom_fields, update=update)
def add_permissions(): def add_permissions():
@@ -36,7 +36,7 @@ def add_permissions():
add_permission(doctype, role, 0) add_permission(doctype, role, 0)
update_permission_property(doctype, role, 0, 'write', 1) update_permission_property(doctype, role, 0, 'write', 1)
update_permission_property(doctype, role, 0, 'create', 1) update_permission_property(doctype, role, 0, 'create', 1)
if not frappe.db.get_value('Custom Role', dict(report="VAT Audit Report")): if not frappe.db.get_value('Custom Role', dict(report="VAT Audit Report")):
frappe.get_doc(dict( frappe.get_doc(dict(

View File

@@ -92,7 +92,7 @@ def get_query_args(filters: Filters) -> QueryArgs:
def run_query(query_args: QueryArgs) -> Data: def run_query(query_args: QueryArgs) -> Data:
return frappe.db.sql(""" return frappe.db.sql("""
SELECT SELECT
wo.name, wo.status, wo.production_item, wo.qty, wo.name, wo.status, wo.production_item, wo.qty,
wo.produced_qty, wo.process_loss_qty, wo.produced_qty, wo.process_loss_qty,
(wo.produced_qty - wo.process_loss_qty) as actual_produced_qty, (wo.produced_qty - wo.process_loss_qty) as actual_produced_qty,

View File

@@ -533,7 +533,7 @@ def set_first_response_time(communication, method):
def is_first_response(issue): def is_first_response(issue):
responses = frappe.get_all('Communication', filters = {'reference_name': issue.name, 'sent_or_received': 'Sent'}) responses = frappe.get_all('Communication', filters = {'reference_name': issue.name, 'sent_or_received': 'Sent'})
if len(responses) == 1: if len(responses) == 1:
return True return True
return False return False
@@ -562,7 +562,7 @@ def calculate_first_response_time(issue, first_responded_on):
# both issue creation and first response were after working hours # both issue creation and first response were after working hours
else: else:
return 1.0 # this should ideally be zero, but it gets reset when the next response is sent if the value is zero return 1.0 # this should ideally be zero, but it gets reset when the next response is sent if the value is zero
else: else:
return 1.0 return 1.0

View File

@@ -120,7 +120,7 @@ class TestIssue(TestSetUp):
issue.reload() issue.reload()
self.assertEqual(flt(issue.total_hold_time, 2), 2700) self.assertEqual(flt(issue.total_hold_time, 2), 2700)
self.assertEqual(issue.resolution_by, get_datetime("2020-03-04 16:45")) self.assertEqual(issue.resolution_by, get_datetime("2020-03-04 16:45"))
creation = get_datetime("2020-03-04 5:05") creation = get_datetime("2020-03-04 5:05")
create_communication(issue.name, "test@admin.com", "Sent", creation) create_communication(issue.name, "test@admin.com", "Sent", creation)
@@ -176,7 +176,7 @@ class TestFirstResponseTime(TestSetUp):
# issue creation and first response are on consecutive days # issue creation and first response are on consecutive days
def test_first_response_time_case6(self): def test_first_response_time_case6(self):
""" """
Test frt when the issue was created before working hours and the first response is also sent before working hours, but on the next day. Test frt when the issue was created before working hours and the first response is also sent before working hours, but on the next day.
""" """
issue = create_issue_and_communication(get_datetime("06-28-2021 6:00"), get_datetime("06-29-2021 6:00")) issue = create_issue_and_communication(get_datetime("06-28-2021 6:00"), get_datetime("06-29-2021 6:00"))
self.assertEqual(issue.first_response_time, 28800.0) self.assertEqual(issue.first_response_time, 28800.0)
@@ -198,7 +198,7 @@ class TestFirstResponseTime(TestSetUp):
def test_first_response_time_case9(self): def test_first_response_time_case9(self):
""" """
Test frt when the issue was created before working hours and the first response is sent on the next day, which is not a work day. Test frt when the issue was created before working hours and the first response is sent on the next day, which is not a work day.
""" """
issue = create_issue_and_communication(get_datetime("06-25-2021 6:00"), get_datetime("06-26-2021 11:00")) issue = create_issue_and_communication(get_datetime("06-25-2021 6:00"), get_datetime("06-26-2021 11:00"))
self.assertEqual(issue.first_response_time, 28800.0) self.assertEqual(issue.first_response_time, 28800.0)
@@ -226,7 +226,7 @@ class TestFirstResponseTime(TestSetUp):
def test_first_response_time_case13(self): def test_first_response_time_case13(self):
""" """
Test frt when the issue was created during working hours and the first response is sent on the next day, which is not a work day. Test frt when the issue was created during working hours and the first response is sent on the next day, which is not a work day.
""" """
issue = create_issue_and_communication(get_datetime("06-25-2021 12:00"), get_datetime("06-26-2021 11:00")) issue = create_issue_and_communication(get_datetime("06-25-2021 12:00"), get_datetime("06-26-2021 11:00"))
self.assertEqual(issue.first_response_time, 21600.0) self.assertEqual(issue.first_response_time, 21600.0)
@@ -342,7 +342,7 @@ class TestFirstResponseTime(TestSetUp):
""" """
issue = create_issue_and_communication(get_datetime("06-25-2021 20:00"), get_datetime("06-27-2021 11:00")) issue = create_issue_and_communication(get_datetime("06-25-2021 20:00"), get_datetime("06-27-2021 11:00"))
self.assertEqual(issue.first_response_time, 1.0) self.assertEqual(issue.first_response_time, 1.0)
def create_issue_and_communication(issue_creation, first_responded_on): def create_issue_and_communication(issue_creation, first_responded_on):
issue = make_issue(issue_creation, index=1) issue = make_issue(issue_creation, index=1)
sender = create_user("test@admin.com") sender = create_user("test@admin.com")