diff --git a/lending/api.py b/lending/api.py new file mode 100644 index 00000000..117b52e7 --- /dev/null +++ b/lending/api.py @@ -0,0 +1,31 @@ +import frappe + +@frappe.whitelist() +def get_loan_list(hub=None,loan_account_number=None,customer_urn=None,customer_name=None): + filters = {} + loan = '' + if hub != None: + filters["hub"] = hub + if loan_account_number != None: + filters["loan_account_number"] = loan_account_number + if customer_name: + customer_name = frappe.db.get_value('Customer',{'customer_name':customer_name},'customer_urn') + if not customer_urn and customer_name: + filters["applicant"] = customer_name + if customer_urn and not customer_name: + filters["applicant"] = customer_urn + if (customer_urn and customer_name) and (customer_urn == customer_name): + filters["applicant"] = customer_urn + if filters != {}: + loan = frappe.db.get_list('Loan',filters = filters, pluck='name') + if (customer_urn and customer_name) and (customer_urn != customer_name): + a = [] + loan_urn = frappe.db.get_list('Loan',filters = {'applicant':customer_urn}, pluck='name') + a.extend(loan_urn) + loan_name = frappe.db.get_list('Loan',filters = {'applicant':customer_name}, pluck='name') + a.extend(loan_name) + if loan: + loan.extend(a) + else: + loan = a + return loan \ No newline at end of file diff --git a/lending/fixtures/property_setter.json b/lending/fixtures/property_setter.json new file mode 100644 index 00000000..ff74df4d --- /dev/null +++ b/lending/fixtures/property_setter.json @@ -0,0 +1,18 @@ +[ + { + "default_value": null, + "doc_type": "Customer", + "docstatus": 0, + "doctype": "Property Setter", + "doctype_or_field": "DocField", + "field_name": "customer_type", + "is_system_generated": 0, + "modified": "2023-11-20 10:04:12.810886", + "module": null, + "name": "Customer-customer_type-options", + "property": "options", + "property_type": "Text", + "row_name": null, + "value": "Company\nIndividual" + } +] \ No newline at end of file diff --git a/lending/hooks.py b/lending/hooks.py index 503ed4c8..e85349a5 100644 --- a/lending/hooks.py +++ b/lending/hooks.py @@ -229,3 +229,13 @@ # auth_hooks = [ # "lending.auth.validate" # ] + +fixtures = [ + {"dt": "Property Setter", "filters": [ + [ + "name", "in", [ + "Customer-customer_type-options", + ] + ] + ]} +] \ No newline at end of file