Skip to content

Commit

Permalink
chore: Clean up patches
Browse files Browse the repository at this point in the history
  • Loading branch information
deepeshgarg007 committed Apr 29, 2022
1 parent 2ee20d3 commit f25251b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 34 deletions.
39 changes: 14 additions & 25 deletions erpnext/accounts/doctype/payment_entry/payment_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,7 @@ def set_missing_values(self):
if not self.party:
frappe.throw(_("Party is mandatory"))

_party_name = (
"title" if self.party_type in ("Student", "Shareholder") else self.party_type.lower() + "_name"
)
_party_name = "title" if self.party_type == "Shareholder" else self.party_type.lower() + "_name"
self.party_name = frappe.db.get_value(self.party_type, self.party, _party_name)

if self.party:
Expand Down Expand Up @@ -298,9 +296,7 @@ def validate_mandatory(self):
frappe.throw(_("{0} is mandatory").format(self.meta.get_label(field)))

def validate_reference_documents(self):
if self.party_type == "Student":
valid_reference_doctypes = "Fees"
elif self.party_type == "Customer":
if self.party_type == "Customer":
valid_reference_doctypes = ("Sales Order", "Sales Invoice", "Journal Entry", "Dunning")
elif self.party_type == "Supplier":
valid_reference_doctypes = ("Purchase Order", "Purchase Invoice", "Journal Entry")
Expand Down Expand Up @@ -338,8 +334,6 @@ def validate_reference_documents(self):
ref_party_account = (
get_party_account_based_on_invoice_discounting(d.reference_name) or ref_doc.debit_to
)
elif self.party_type == "Student":
ref_party_account = ref_doc.receivable_account
elif self.party_type == "Supplier":
ref_party_account = ref_doc.credit_to
elif self.party_type == "Employee":
Expand Down Expand Up @@ -1259,20 +1253,19 @@ def get_outstanding_reference_documents(args):

# Get all SO / PO which are not fully billed or against which full advance not paid
orders_to_be_billed = []
if args.get("party_type") != "Student":
orders_to_be_billed = get_orders_to_be_billed(
args.get("posting_date"),
args.get("party_type"),
args.get("party"),
args.get("company"),
party_account_currency,
company_currency,
filters=args,
)
orders_to_be_billed = get_orders_to_be_billed(
args.get("posting_date"),
args.get("party_type"),
args.get("party"),
args.get("company"),
party_account_currency,
company_currency,
filters=args,
)

# Get negative outstanding sales /purchase invoices
negative_outstanding_invoices = []
if args.get("party_type") not in ["Student", "Employee"] and not args.get("voucher_no"):
if args.get("party_type") != "Employee" and not args.get("voucher_no"):
negative_outstanding_invoices = get_negative_outstanding_invoices(
args.get("party_type"),
args.get("party"),
Expand Down Expand Up @@ -1496,9 +1489,7 @@ def get_party_details(company, party_type, party, date, cost_center=None):

account_currency = get_account_currency(party_account)
account_balance = get_balance_on(party_account, date, cost_center=cost_center)
_party_name = (
"title" if party_type in ("Student", "Shareholder") else party_type.lower() + "_name"
)
_party_name = "title" if party_type == "Shareholder" else party_type.lower() + "_name"
party_name = frappe.db.get_value(party_type, party, _party_name)
party_balance = get_balance_on(party_type=party_type, party=party, cost_center=cost_center)
if party_type in ["Customer", "Supplier"]:
Expand Down Expand Up @@ -1560,7 +1551,7 @@ def get_company_defaults(company):
def get_outstanding_on_journal_entry(name):
res = frappe.db.sql(
"SELECT "
'CASE WHEN party_type IN ("Customer", "Student") '
'CASE WHEN party_type IN ("Customer") '
"THEN ifnull(sum(debit_in_account_currency - credit_in_account_currency), 0) "
"ELSE ifnull(sum(credit_in_account_currency - debit_in_account_currency), 0) "
"END as outstanding_amount "
Expand Down Expand Up @@ -1917,8 +1908,6 @@ def set_party_type(dt):
party_type = "Supplier"
elif dt in ("Expense Claim", "Employee Advance", "Gratuity"):
party_type = "Employee"
elif dt == "Fees":
party_type = "Student"
return party_type


Expand Down
2 changes: 0 additions & 2 deletions erpnext/patches/v11_0/refactor_autoname_naming.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@
"Soil Analysis": "AG-ANA-.YY.-.MM.-.#####",
"Soil Texture": "AG-TEX-.YYYY.-.#####",
"Stock Ledger Entry": "MAT-SLE-.YYYY.-.#####",
"Student Leave Application": "EDU-SLA-.YYYY.-.#####",
"Student Log": "EDU-SLOG-.YYYY.-.#####",
"Subscription": "ACC-SUB-.YYYY.-.#####",
"Task": "TASK-.YYYY.-.#####",
"Tax Rule": "ACC-TAX-RULE-.YYYY.-.#####",
Expand Down
2 changes: 0 additions & 2 deletions erpnext/patches/v11_0/refactor_naming_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@
"Shareholder": "ACC-SH-.YYYY.-",
"Stock Entry": "MAT-STE-.YYYY.-",
"Stock Reconciliation": "MAT-RECO-.YYYY.-",
"Student": "EDU-STU-.YYYY.-",
"Student Applicant": "EDU-APP-.YYYY.-",
"Supplier": "SUP-.YYYY.-",
"Supplier Quotation": "PUR-SQTN-.YYYY.-",
"Supplier Scorecard Period": "PU-SSP-.YYYY.-",
Expand Down
1 change: 0 additions & 1 deletion erpnext/patches/v11_0/update_account_type_in_party_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ def execute():
"Employee": "Payable",
"Member": "Receivable",
"Shareholder": "Payable",
"Student": "Receivable",
}

for party_type, account_type in party_types.items():
Expand Down
4 changes: 0 additions & 4 deletions erpnext/portal/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ def set_default_role(doc, method):
doc.add_roles("Customer")
elif link.link_doctype == "Supplier" and "Supplier" not in roles:
doc.add_roles("Supplier")
elif frappe.get_value("Student", dict(student_email_id=doc.email)) and "Student" not in roles:
doc.add_roles("Student")
elif frappe.get_value("Guardian", dict(email_address=doc.email)) and "Guardian" not in roles:
doc.add_roles("Guardian")


def create_customer_or_supplier():
Expand Down

0 comments on commit f25251b

Please sign in to comment.