refactor(treewide): formatting and ruff fixes, + manually enabled F401

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
This commit is contained in:
Akhil Narang
2024-03-27 11:37:26 +05:30
parent c28d19cf7f
commit 4d34b1ead7
618 changed files with 4188 additions and 6384 deletions

View File

@@ -3,7 +3,7 @@
from json import loads
from typing import TYPE_CHECKING, List, Optional, Tuple
from typing import TYPE_CHECKING, Optional
import frappe
import frappe.defaults
@@ -31,7 +31,7 @@ from pypika.terms import ExistsCriterion
import erpnext
# imported to enable erpnext.accounts.utils.get_account_currency
from erpnext.accounts.doctype.account.account import get_account_currency # noqa
from erpnext.accounts.doctype.account.account import get_account_currency
from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_dimensions
from erpnext.stock import get_warehouse_account_map
from erpnext.stock.utils import get_stock_value_on
@@ -80,9 +80,7 @@ def get_fiscal_years(
FY = DocType("Fiscal Year")
query = (
frappe.qb.from_(FY)
.select(FY.name, FY.year_start_date, FY.year_end_date)
.where(FY.disabled == 0)
frappe.qb.from_(FY).select(FY.name, FY.year_start_date, FY.year_end_date).where(FY.disabled == 0)
)
if fiscal_year:
@@ -129,9 +127,7 @@ def get_fiscal_years(
else:
return ((fy.name, fy.year_start_date, fy.year_end_date),)
error_msg = _("""{0} {1} is not in any active Fiscal Year""").format(
label, formatdate(transaction_date)
)
error_msg = _("""{0} {1} is not in any active Fiscal Year""").format(label, formatdate(transaction_date))
if company:
error_msg = _("""{0} for {1}""").format(error_msg, frappe.bold(company))
@@ -207,12 +203,12 @@ def get_balance_on(
acc = frappe.get_doc("Account", account)
try:
year_start_date = get_fiscal_year(date, company=company, verbose=0)[1]
get_fiscal_year(date, company=company, verbose=0)[1]
except FiscalYearError:
if getdate(date) > getdate(nowdate()):
# if fiscal year not found and the date is greater than today
# get fiscal year for today's date and its corresponding year start date
year_start_date = get_fiscal_year(nowdate(), verbose=1)[1]
get_fiscal_year(nowdate(), verbose=1)[1]
else:
# this indicates that it is a date older than any existing fiscal year.
# hence, assuming balance as 0.0
@@ -227,29 +223,26 @@ def get_balance_on(
cc = frappe.get_doc("Cost Center", cost_center)
if cc.is_group:
cond.append(
""" exists (
f""" exists (
select 1 from `tabCost Center` cc where cc.name = gle.cost_center
and cc.lft >= %s and cc.rgt <= %s
and cc.lft >= {cc.lft} and cc.rgt <= {cc.rgt}
)"""
% (cc.lft, cc.rgt)
)
else:
cond.append("""gle.cost_center = %s """ % (frappe.db.escape(cost_center, percent=False),))
cond.append(f"""gle.cost_center = {frappe.db.escape(cost_center, percent=False)} """)
if account:
if not (frappe.flags.ignore_account_permission or ignore_account_permission):
acc.check_permission("read")
# different filter for group and ledger - improved performance
if acc.is_group:
cond.append(
"""exists (
f"""exists (
select name from `tabAccount` ac where ac.name = gle.account
and ac.lft >= %s and ac.rgt <= %s
and ac.lft >= {acc.lft} and ac.rgt <= {acc.rgt}
)"""
% (acc.lft, acc.rgt)
)
# If group and currency same as company,
@@ -257,12 +250,11 @@ def get_balance_on(
if acc.account_currency == frappe.get_cached_value("Company", acc.company, "default_currency"):
in_account_currency = False
else:
cond.append("""gle.account = %s """ % (frappe.db.escape(account, percent=False),))
cond.append(f"""gle.account = {frappe.db.escape(account, percent=False)} """)
if party_type and party:
cond.append(
"""gle.party_type = %s and gle.party = %s """
% (frappe.db.escape(party_type), frappe.db.escape(party, percent=False))
f"""gle.party_type = {frappe.db.escape(party_type)} and gle.party = {frappe.db.escape(party, percent=False)} """
)
if company:
@@ -275,11 +267,9 @@ def get_balance_on(
select_field = "sum(debit) - sum(credit)"
bal = frappe.db.sql(
"""
SELECT {0}
SELECT {}
FROM `tabGL Entry` gle
WHERE {1}""".format(
select_field, " and ".join(cond)
)
WHERE {}""".format(select_field, " and ".join(cond))
)[0][0]
# if bal is None, return 0
@@ -314,30 +304,25 @@ def get_count_on(account, fieldname, date):
# for pl accounts, get balance within a fiscal year
if acc.report_type == "Profit and Loss":
cond.append(
"posting_date >= '%s' and voucher_type != 'Period Closing Voucher'" % year_start_date
)
cond.append("posting_date >= '%s' and voucher_type != 'Period Closing Voucher'" % year_start_date)
# different filter for group and ledger - improved performance
if acc.is_group:
cond.append(
"""exists (
f"""exists (
select name from `tabAccount` ac where ac.name = gle.account
and ac.lft >= %s and ac.rgt <= %s
and ac.lft >= {acc.lft} and ac.rgt <= {acc.rgt}
)"""
% (acc.lft, acc.rgt)
)
else:
cond.append("""gle.account = %s """ % (frappe.db.escape(account, percent=False),))
cond.append(f"""gle.account = {frappe.db.escape(account, percent=False)} """)
entries = frappe.db.sql(
"""
SELECT name, posting_date, account, party_type, party,debit,credit,
voucher_type, voucher_no, against_voucher_type, against_voucher
FROM `tabGL Entry` gle
WHERE {0}""".format(
" and ".join(cond)
),
WHERE {}""".format(" and ".join(cond)),
as_dict=True,
)
@@ -360,13 +345,11 @@ def get_count_on(account, fieldname, date):
or (gle.against_voucher == gle.voucher_no and gle.get(dr_or_cr) > 0)
):
payment_amount = frappe.db.sql(
"""
SELECT {0}
f"""
SELECT {select_fields}
FROM `tabGL Entry` gle
WHERE docstatus < 2 and posting_date <= %(date)s and against_voucher = %(voucher_no)s
and party = %(party)s and name != %(name)s""".format(
select_fields
),
and party = %(party)s and name != %(name)s""",
{"date": date, "voucher_no": gle.voucher_no, "party": gle.party, "name": gle.name},
)[0][0]
@@ -421,7 +404,7 @@ def add_cc(args=None):
args = make_tree_args(**args)
if args.parent_cost_center == args.company:
args.parent_cost_center = "{0} - {1}".format(
args.parent_cost_center = "{} - {}".format(
args.parent_cost_center, frappe.get_cached_value("Company", args.company, "abbr")
)
@@ -437,7 +420,7 @@ def add_cc(args=None):
def _build_dimensions_dict_for_exc_gain_loss(
entry: dict | object = None, active_dimensions: list = None
entry: dict | object = None, active_dimensions: list | None = None
):
dimensions_dict = frappe._dict()
if entry and active_dimensions:
@@ -501,7 +484,11 @@ def reconcile_against_document(
# Only update outstanding for newly linked vouchers
for entry in entries:
update_voucher_outstanding(
entry.against_voucher_type, entry.against_voucher, entry.account, entry.party_type, entry.party
entry.against_voucher_type,
entry.against_voucher,
entry.account,
entry.party_type,
entry.party,
)
frappe.flags.ignore_party_validation = False
@@ -525,9 +512,7 @@ def check_if_advance_entry_modified(args):
and t2.party_type = %(party_type)s and t2.party = %(party)s
and (t2.reference_type is null or t2.reference_type in ('', 'Sales Order', 'Purchase Order'))
and t1.name = %(voucher_no)s and t2.name = %(voucher_detail_no)s
and t1.docstatus=1 """.format(
dr_or_cr=args.get("dr_or_cr")
),
and t1.docstatus=1 """.format(dr_or_cr=args.get("dr_or_cr")),
args,
)
else:
@@ -542,12 +527,10 @@ def check_if_advance_entry_modified(args):
where
t1.name = t2.parent and t1.docstatus = 1
and t1.name = %(voucher_no)s and t2.name = %(voucher_detail_no)s
and t1.party_type = %(party_type)s and t1.party = %(party)s and t1.{0} = %(account)s
and t1.party_type = %(party_type)s and t1.party = %(party)s and t1.{} = %(account)s
and t2.reference_doctype in ('', 'Sales Order', 'Purchase Order')
and t2.allocated_amount = %(unreconciled_amount)s
""".format(
party_account_field
),
""".format(party_account_field),
args,
)
else:
@@ -571,9 +554,7 @@ def check_if_advance_entry_modified(args):
def validate_allocated_amount(args):
precision = args.get("precision") or frappe.db.get_single_value(
"System Settings", "currency_precision"
)
precision = args.get("precision") or frappe.db.get_single_value("System Settings", "currency_precision")
if args.get("allocated_amount") < 0:
throw(_("Allocated amount cannot be negative"))
elif flt(args.get("allocated_amount"), precision) > flt(args.get("unadjusted_amount"), precision):
@@ -708,7 +689,7 @@ def update_reference_in_payment_entry(
def cancel_exchange_gain_loss_journal(
parent_doc: dict | object, referenced_dt: str = None, referenced_dn: str = None
parent_doc: dict | object, referenced_dt: str | None = None, referenced_dn: str | None = None
) -> None:
"""
Cancel Exchange Gain/Loss for Sales/Purchase Invoice, if they have any.
@@ -751,7 +732,7 @@ def cancel_exchange_gain_loss_journal(
def update_accounting_ledgers_after_reference_removal(
ref_type: str = None, ref_no: str = None, payment_name: str = None
ref_type: str | None = None, ref_no: str | None = None, payment_name: str | None = None
):
# General Ledger
gle = qb.DocType("GL Entry")
@@ -777,9 +758,7 @@ def update_accounting_ledgers_after_reference_removal(
.set(ple.modified, now())
.set(ple.modified_by, frappe.session.user)
.where(
(ple.against_voucher_type == ref_type)
& (ple.against_voucher_no == ref_no)
& (ple.delinked == 0)
(ple.against_voucher_type == ref_type) & (ple.against_voucher_no == ref_no) & (ple.delinked == 0)
)
)
@@ -796,7 +775,7 @@ def remove_ref_from_advance_section(ref_doc: object = None):
qb.from_(adv_type).delete().where(adv_type.parent == ref_doc.name).run()
def unlink_ref_doc_from_payment_entries(ref_doc: object = None, payment_name: str = None):
def unlink_ref_doc_from_payment_entries(ref_doc: object = None, payment_name: str | None = None):
remove_ref_doc_link_from_jv(ref_doc.doctype, ref_doc.name, payment_name)
remove_ref_doc_link_from_pe(ref_doc.doctype, ref_doc.name, payment_name)
update_accounting_ledgers_after_reference_removal(ref_doc.doctype, ref_doc.name, payment_name)
@@ -804,7 +783,7 @@ def unlink_ref_doc_from_payment_entries(ref_doc: object = None, payment_name: st
def remove_ref_doc_link_from_jv(
ref_type: str = None, ref_no: str = None, payment_name: str = None
ref_type: str | None = None, ref_no: str | None = None, payment_name: str | None = None
):
jea = qb.DocType("Journal Entry Account")
@@ -844,7 +823,7 @@ def convert_to_list(result):
def remove_ref_doc_link_from_pe(
ref_type: str = None, ref_no: str = None, payment_name: str = None
ref_type: str | None = None, ref_no: str | None = None, payment_name: str | None = None
):
per = qb.DocType("Payment Entry Reference")
pay = qb.DocType("Payment Entry")
@@ -852,9 +831,7 @@ def remove_ref_doc_link_from_pe(
linked_pe = (
qb.from_(per)
.select(per.parent)
.where(
(per.reference_doctype == ref_type) & (per.reference_name == ref_no) & (per.docstatus.lt(2))
)
.where((per.reference_doctype == ref_type) & (per.reference_name == ref_no) & (per.docstatus.lt(2)))
.run(as_list=1)
)
linked_pe = convert_to_list(linked_pe)
@@ -867,9 +844,7 @@ def remove_ref_doc_link_from_pe(
.set(per.allocated_amount, 0)
.set(per.modified, now())
.set(per.modified_by, frappe.session.user)
.where(
(per.docstatus.lt(2) & (per.reference_doctype == ref_type) & (per.reference_name == ref_no))
)
.where(per.docstatus.lt(2) & (per.reference_doctype == ref_type) & (per.reference_name == ref_no))
)
if payment_name:
@@ -883,7 +858,7 @@ def remove_ref_doc_link_from_pe(
pe_doc.set_amounts()
pe_doc.clear_unallocated_reference_document_rows()
pe_doc.validate_payment_type_with_outstanding()
except Exception as e:
except Exception:
msg = _("There were issues unlinking payment entry {0}.").format(pe_doc.name)
msg += "<br>"
msg += _("Please cancel payment entry manually first")
@@ -893,9 +868,7 @@ def remove_ref_doc_link_from_pe(
pay.base_total_allocated_amount, pe_doc.base_total_allocated_amount
).set(pay.unallocated_amount, pe_doc.unallocated_amount).set(pay.modified, now()).set(
pay.modified_by, frappe.session.user
).where(
pay.name == pe
).run()
).where(pay.name == pe).run()
frappe.msgprint(_("Payment Entries {0} are un-linked").format("\n".join(linked_pe)))
@@ -929,9 +902,10 @@ def fix_total_debit_credit():
dr_or_cr = d.voucher_type == "Sales Invoice" and "credit" or "debit"
frappe.db.sql(
"""update `tabGL Entry` set %s = %s + %s
where voucher_type = %s and voucher_no = %s and %s > 0 limit 1"""
% (dr_or_cr, dr_or_cr, "%s", "%s", "%s", dr_or_cr),
"""update `tabGL Entry` set {} = {} + {}
where voucher_type = {} and voucher_no = {} and {} > 0 limit 1""".format(
dr_or_cr, dr_or_cr, "%s", "%s", "%s", dr_or_cr
),
(d.diff, d.voucher_type, d.voucher_no),
)
@@ -956,20 +930,22 @@ def get_stock_rbnb_difference(posting_date, company):
"""
select sum(pr_item.valuation_rate * pr_item.qty * pr_item.conversion_factor)
from `tabPurchase Receipt Item` pr_item, `tabPurchase Receipt` pr
where pr.name = pr_item.parent and pr.docstatus=1 and pr.company=%s
and pr.posting_date <= %s and pr_item.item_code in (%s)"""
% ("%s", "%s", ", ".join(["%s"] * len(stock_items))),
tuple([company, posting_date] + stock_items),
where pr.name = pr_item.parent and pr.docstatus=1 and pr.company={}
and pr.posting_date <= {} and pr_item.item_code in ({})""".format(
"%s", "%s", ", ".join(["%s"] * len(stock_items))
),
tuple([company, posting_date, *stock_items]),
)[0][0]
pi_valuation_amount = frappe.db.sql(
"""
select sum(pi_item.valuation_rate * pi_item.qty * pi_item.conversion_factor)
from `tabPurchase Invoice Item` pi_item, `tabPurchase Invoice` pi
where pi.name = pi_item.parent and pi.docstatus=1 and pi.company=%s
and pi.posting_date <= %s and pi_item.item_code in (%s)"""
% ("%s", "%s", ", ".join(["%s"] * len(stock_items))),
tuple([company, posting_date] + stock_items),
where pi.name = pi_item.parent and pi.docstatus=1 and pi.company={}
and pi.posting_date <= {} and pi_item.item_code in ({})""".format(
"%s", "%s", ", ".join(["%s"] * len(stock_items))
),
tuple([company, posting_date, *stock_items]),
)[0][0]
# Balance should be
@@ -1014,15 +990,12 @@ def get_outstanding_invoices(
limit=None, # passed by reconciliation tool
voucher_no=None, # filter passed by reconciliation tool
):
ple = qb.DocType("Payment Ledger Entry")
outstanding_invoices = []
precision = frappe.get_precision("Sales Invoice", "outstanding_amount") or 2
if account:
root_type, account_type = frappe.get_cached_value(
"Account", account, ["root_type", "account_type"]
)
root_type, account_type = frappe.get_cached_value("Account", account, ["root_type", "account_type"])
party_account_type = "Receivable" if root_type == "Asset" else "Payable"
party_account_type = account_type or party_account_type
else:
@@ -1076,15 +1049,11 @@ def get_outstanding_invoices(
)
)
outstanding_invoices = sorted(
outstanding_invoices, key=lambda k: k["due_date"] or getdate(nowdate())
)
outstanding_invoices = sorted(outstanding_invoices, key=lambda k: k["due_date"] or getdate(nowdate()))
return outstanding_invoices
def get_account_name(
account_type=None, root_type=None, is_group=None, account_currency=None, company=None
):
def get_account_name(account_type=None, root_type=None, is_group=None, account_currency=None, company=None):
"""return account based on matching conditions"""
return frappe.db.get_value(
"Account",
@@ -1113,7 +1082,7 @@ def get_children(doctype, parent, company, is_root=False):
fields = ["name as value", "is_group as expandable"]
filters = [["docstatus", "<", 2]]
filters.append(['ifnull(`{0}`,"")'.format(parent_fieldname), "=", "" if is_root else parent])
filters.append([f'ifnull(`{parent_fieldname}`,"")', "=", "" if is_root else parent])
if is_root:
fields += ["root_type", "report_type", "account_currency"] if doctype == "Account" else []
@@ -1133,7 +1102,6 @@ def get_children(doctype, parent, company, is_root=False):
@frappe.whitelist()
def get_account_balances(accounts, company):
if isinstance(accounts, str):
accounts = loads(accounts)
@@ -1144,9 +1112,7 @@ def get_account_balances(accounts, company):
for account in accounts:
account["company_currency"] = company_currency
account["balance"] = flt(
get_balance_on(account["value"], in_account_currency=False, company=company)
)
account["balance"] = flt(get_balance_on(account["value"], in_account_currency=False, company=company))
if account["account_currency"] and account["account_currency"] != company_currency:
account["balance_in_account_currency"] = flt(get_balance_on(account["value"], company=company))
@@ -1296,20 +1262,17 @@ def update_gl_entries_after(
warehouse_account=None,
company=None,
):
stock_vouchers = get_future_stock_vouchers(
posting_date, posting_time, for_warehouses, for_items, company
)
stock_vouchers = get_future_stock_vouchers(posting_date, posting_time, for_warehouses, for_items, company)
repost_gle_for_stock_vouchers(stock_vouchers, posting_date, company, warehouse_account)
def repost_gle_for_stock_vouchers(
stock_vouchers: List[Tuple[str, str]],
stock_vouchers: list[tuple[str, str]],
posting_date: str,
company: Optional[str] = None,
company: str | None = None,
warehouse_account=None,
repost_doc: Optional["RepostItemValuation"] = None,
):
from erpnext.accounts.general_ledger import toggle_debit_credit_if_negative
if not stock_vouchers:
@@ -1355,16 +1318,12 @@ def repost_gle_for_stock_vouchers(
def _delete_pl_entries(voucher_type, voucher_no):
ple = qb.DocType("Payment Ledger Entry")
qb.from_(ple).delete().where(
(ple.voucher_type == voucher_type) & (ple.voucher_no == voucher_no)
).run()
qb.from_(ple).delete().where((ple.voucher_type == voucher_type) & (ple.voucher_no == voucher_no)).run()
def _delete_gl_entries(voucher_type, voucher_no):
gle = qb.DocType("GL Entry")
qb.from_(gle).delete().where(
(gle.voucher_type == voucher_type) & (gle.voucher_no == voucher_no)
).run()
qb.from_(gle).delete().where((gle.voucher_type == voucher_type) & (gle.voucher_no == voucher_no)).run()
def _delete_accounting_ledger_entries(voucher_type, voucher_no):
@@ -1375,9 +1334,7 @@ def _delete_accounting_ledger_entries(voucher_type, voucher_no):
_delete_pl_entries(voucher_type, voucher_no)
def sort_stock_vouchers_by_posting_date(
stock_vouchers: List[Tuple[str, str]]
) -> List[Tuple[str, str]]:
def sort_stock_vouchers_by_posting_date(stock_vouchers: list[tuple[str, str]]) -> list[tuple[str, str]]:
sle = frappe.qb.DocType("Stock Ledger Entry")
voucher_nos = [v[1] for v in stock_vouchers]
@@ -1398,10 +1355,7 @@ def sort_stock_vouchers_by_posting_date(
return sorted_vouchers
def get_future_stock_vouchers(
posting_date, posting_time, for_warehouses=None, for_items=None, company=None
):
def get_future_stock_vouchers(posting_date, posting_time, for_warehouses=None, for_items=None, company=None):
values = []
condition = ""
if for_items:
@@ -1417,16 +1371,14 @@ def get_future_stock_vouchers(
values.append(company)
future_stock_vouchers = frappe.db.sql(
"""select distinct sle.voucher_type, sle.voucher_no
f"""select distinct sle.voucher_type, sle.voucher_no
from `tabStock Ledger Entry` sle
where
timestamp(sle.posting_date, sle.posting_time) >= timestamp(%s, %s)
and is_cancelled = 0
{condition}
order by timestamp(sle.posting_date, sle.posting_time) asc, creation asc for update""".format(
condition=condition
),
tuple([posting_date, posting_time] + values),
order by timestamp(sle.posting_date, sle.posting_time) asc, creation asc for update""",
tuple([posting_date, posting_time, *values]),
as_dict=True,
)
@@ -1453,9 +1405,8 @@ def get_voucherwise_gl_entries(future_stock_vouchers, posting_date):
select name, account, credit, debit, cost_center, project, voucher_type, voucher_no
from `tabGL Entry`
where
posting_date >= %s and voucher_no in (%s)"""
% ("%s", ", ".join(["%s"] * len(voucher_nos))),
tuple([posting_date] + voucher_nos),
posting_date >= {} and voucher_no in ({})""".format("%s", ", ".join(["%s"] * len(voucher_nos))),
tuple([posting_date, *voucher_nos]),
as_dict=1,
)
@@ -1494,16 +1445,16 @@ def compare_existing_and_expected_gle(existing_gle, expected_gle, precision):
def get_stock_accounts(company, voucher_type=None, voucher_no=None):
stock_accounts = [
d.name
for d in frappe.db.get_all(
"Account", {"account_type": "Stock", "company": company, "is_group": 0}
)
for d in frappe.db.get_all("Account", {"account_type": "Stock", "company": company, "is_group": 0})
]
if voucher_type and voucher_no:
if voucher_type == "Journal Entry":
stock_accounts = [
d.account
for d in frappe.db.get_all(
"Journal Entry Account", {"parent": voucher_no, "account": ["in", stock_accounts]}, "account"
"Journal Entry Account",
{"parent": voucher_no, "account": ["in", stock_accounts]},
"account",
)
]
@@ -1512,7 +1463,11 @@ def get_stock_accounts(company, voucher_type=None, voucher_no=None):
d.account
for d in frappe.db.get_all(
"GL Entry",
{"voucher_type": voucher_type, "voucher_no": voucher_no, "account": ["in", stock_accounts]},
{
"voucher_type": voucher_type,
"voucher_no": voucher_no,
"account": ["in", stock_accounts],
},
"account",
)
]
@@ -1543,9 +1498,7 @@ def get_stock_and_account_balance(account=None, posting_date=None, company=None)
def get_journal_entry(account, stock_adjustment_account, amount):
db_or_cr_warehouse_account = (
"credit_in_account_currency" if amount < 0 else "debit_in_account_currency"
)
db_or_cr_warehouse_account = "credit_in_account_currency" if amount < 0 else "debit_in_account_currency"
db_or_cr_stock_adjustment_account = (
"debit_in_account_currency" if amount < 0 else "credit_in_account_currency"
)
@@ -1566,7 +1519,7 @@ def check_and_delete_linked_reports(report):
frappe.delete_doc("Desktop Icon", icon)
def create_err_and_its_journals(companies: list = None) -> None:
def create_err_and_its_journals(companies: list | None = None) -> None:
if companies:
for company in companies:
err = frappe.new_doc("Exchange Rate Revaluation")
@@ -1623,9 +1576,7 @@ def get_payment_ledger_entries(gl_entries, cancel=0):
accounts_with_types = (
qb.from_(account)
.select(account.name, account.account_type)
.where(
(account.account_type.isin(["Receivable", "Payable"]) & (account.company.isin(companies)))
)
.where(account.account_type.isin(["Receivable", "Payable"]) & (account.company.isin(companies)))
.run(as_dict=True)
)
receivable_or_payable_accounts = [y.name for y in accounts_with_types]
@@ -1692,7 +1643,6 @@ def create_payment_ledger_entry(
ple_map = get_payment_ledger_entries(gl_entries, cancel=cancel)
for entry in ple_map:
ple = frappe.get_doc(entry)
if cancel:
@@ -1770,7 +1720,7 @@ def delink_original_entry(pl_entry, partial_cancel=False):
query.run()
class QueryPaymentLedger(object):
class QueryPaymentLedger:
"""
Helper Class for Querying Payment Ledger Entry
"""
@@ -1938,7 +1888,8 @@ class QueryPaymentLedger(object):
Table("outstanding").amount_in_account_currency.as_("outstanding_in_account_currency"),
(Table("vouchers").amount - Table("outstanding").amount).as_("paid_amount"),
(
Table("vouchers").amount_in_account_currency - Table("outstanding").amount_in_account_currency
Table("vouchers").amount_in_account_currency
- Table("outstanding").amount_in_account_currency
).as_("paid_amount_in_account_currency"),
Table("vouchers").due_date,
Table("vouchers").currency,