Last active
January 10, 2023 12:59
-
-
Save itsyosefali/1df382d852be6e218c6481e6cb97bd5c to your computer and use it in GitHub Desktop.
الديون
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| party="" | |
| if filters.get("party"): | |
| escaped_input = frappe.db.escape(filters.get("party")) | |
| party = f" AND `tabGL Entry`.party = {escaped_input}" | |
| default_sales_partner="" | |
| if filters.get("default_sales_partner"): | |
| escaped_input = frappe.db.escape(filters.get("default_sales_partner")) | |
| default_sales_partner = f" AND `tabCustomer`.default_sales_partner = {escaped_input}" | |
| res = frappe.db.sql(f"""SELECT | |
| `tabGL Entry`.party, | |
| `tabGL Entry`.account, | |
| `tabGL Entry`.debit, | |
| `tabGL Entry`.credit, | |
| `tabCustomer`.default_sales_partner | |
| FROM `tabGL Entry` | |
| INNER JOIN `tabCustomer` | |
| on `tabCustomer`.name = `tabGL Entry`.party | |
| where | |
| `tabGL Entry`.party_type = 'Customer' | |
| AND | |
| `tabGL Entry`.is_cancelled = 0 | |
| {party} | |
| {default_sales_partner} | |
| group by | |
| `tabGL Entry`.party | |
| """, as_dict=True) | |
| for item in res: | |
| div_res = item.debit + (-item.credit) | |
| item.s = div_res | |
| item.s = item.s + (-item.s) | |
| result = res |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment