fix: fetch JVs with no party selected in filters
This commit is contained in:
parent
5b62bbe073
commit
8f1e00906f
@ -257,7 +257,7 @@ def get_tds_docs(filters):
|
|||||||
}
|
}
|
||||||
|
|
||||||
party = frappe.get_all(filters.get("party_type"), pluck="name")
|
party = frappe.get_all(filters.get("party_type"), pluck="name")
|
||||||
query_filters.update({"against": ("in", party)})
|
or_filters.update({"against": ("in", party), "voucher_type": "Journal Entry"})
|
||||||
|
|
||||||
if filters.get("party"):
|
if filters.get("party"):
|
||||||
del query_filters["account"]
|
del query_filters["account"]
|
||||||
@ -294,7 +294,7 @@ def get_tds_docs(filters):
|
|||||||
|
|
||||||
if journal_entries:
|
if journal_entries:
|
||||||
journal_entry_party_map = get_journal_entry_party_map(journal_entries)
|
journal_entry_party_map = get_journal_entry_party_map(journal_entries)
|
||||||
get_doc_info(journal_entries, "Journal Entry", tax_category_map)
|
get_doc_info(journal_entries, "Journal Entry", tax_category_map, net_total_map)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
tds_documents,
|
tds_documents,
|
||||||
@ -309,7 +309,11 @@ def get_journal_entry_party_map(journal_entries):
|
|||||||
journal_entry_party_map = {}
|
journal_entry_party_map = {}
|
||||||
for d in frappe.db.get_all(
|
for d in frappe.db.get_all(
|
||||||
"Journal Entry Account",
|
"Journal Entry Account",
|
||||||
{"parent": ("in", journal_entries), "party_type": "Supplier", "party": ("is", "set")},
|
{
|
||||||
|
"parent": ("in", journal_entries),
|
||||||
|
"party_type": ("in", ("Supplier", "Customer")),
|
||||||
|
"party": ("is", "set"),
|
||||||
|
},
|
||||||
["parent", "party"],
|
["parent", "party"],
|
||||||
):
|
):
|
||||||
if d.parent not in journal_entry_party_map:
|
if d.parent not in journal_entry_party_map:
|
||||||
@ -320,41 +324,29 @@ def get_journal_entry_party_map(journal_entries):
|
|||||||
|
|
||||||
|
|
||||||
def get_doc_info(vouchers, doctype, tax_category_map, net_total_map=None):
|
def get_doc_info(vouchers, doctype, tax_category_map, net_total_map=None):
|
||||||
if doctype == "Purchase Invoice":
|
common_fields = ["name", "tax_withholding_category"]
|
||||||
fields = [
|
fields_dict = {
|
||||||
"name",
|
"Purchase Invoice": ["base_tax_withholding_net_total", "grand_total", "base_total"],
|
||||||
"tax_withholding_category",
|
"Sales Invoice": ["base_net_total", "grand_total", "base_total"],
|
||||||
"base_tax_withholding_net_total",
|
"Payment Entry": ["paid_amount", "paid_amount_after_tax", "base_paid_amount"],
|
||||||
"grand_total",
|
"Journal Entry": ["total_amount"],
|
||||||
"base_total",
|
}
|
||||||
]
|
|
||||||
elif doctype == "Sales Invoice":
|
|
||||||
fields = ["name", "base_net_total", "grand_total", "base_total"]
|
|
||||||
elif doctype == "Payment Entry":
|
|
||||||
fields = [
|
|
||||||
"name",
|
|
||||||
"tax_withholding_category",
|
|
||||||
"paid_amount",
|
|
||||||
"paid_amount_after_tax",
|
|
||||||
"base_paid_amount",
|
|
||||||
]
|
|
||||||
else:
|
|
||||||
fields = ["name", "tax_withholding_category"]
|
|
||||||
|
|
||||||
entries = frappe.get_all(doctype, filters={"name": ("in", vouchers)}, fields=fields)
|
entries = frappe.get_all(
|
||||||
|
doctype, filters={"name": ("in", vouchers)}, fields=common_fields + fields_dict[doctype]
|
||||||
|
)
|
||||||
|
|
||||||
for entry in entries:
|
for entry in entries:
|
||||||
tax_category_map.update({entry.name: entry.tax_withholding_category})
|
tax_category_map.update({entry.name: entry.tax_withholding_category})
|
||||||
if doctype == "Purchase Invoice":
|
if doctype == "Purchase Invoice":
|
||||||
net_total_map.update(
|
value = [entry.base_tax_withholding_net_total, entry.grand_total, entry.base_total]
|
||||||
{entry.name: [entry.base_tax_withholding_net_total, entry.grand_total, entry.base_total]}
|
|
||||||
)
|
|
||||||
elif doctype == "Sales Invoice":
|
elif doctype == "Sales Invoice":
|
||||||
net_total_map.update({entry.name: [entry.base_net_total, entry.grand_total, entry.base_total]})
|
value = [entry.base_net_total, entry.grand_total, entry.base_total]
|
||||||
elif doctype == "Payment Entry":
|
elif doctype == "Payment Entry":
|
||||||
net_total_map.update(
|
value = [entry.paid_amount, entry.paid_amount_after_tax, entry.base_paid_amount]
|
||||||
{entry.name: [entry.paid_amount, entry.paid_amount_after_tax, entry.base_paid_amount]}
|
else:
|
||||||
)
|
value = [entry.total_amount] * 3
|
||||||
|
net_total_map.update({entry.name: value})
|
||||||
|
|
||||||
|
|
||||||
def get_tax_rate_map(filters):
|
def get_tax_rate_map(filters):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user