Open rmehta opened 6 years ago
def get_draft_gl_entries(filters,from_date,to_date):
from frappe.utils import cint, getdate, formatdate
target_docs_list = ["Payment Entry","Purchase Invoice","Expense Claim","Journal Entry",
"Sales Invoice","Purchase Receipt","Delivery Note"]
gl_entries = []
for target_doc in target_docs_list :
get_all_docs = frappe.get_list(target_doc,fields=['name'],
filters=[
['docstatus',"=", 0],
['company',"=", filters.get('company')],
["posting_date",">=",getdate(from_date)],
["posting_date","<=",getdate(to_date)]
])
for doc_name in get_all_docs :
doc = frappe.get_doc(target_doc,doc_name["name"])
if target_doc == "Payment Entry":
if doc.payment_type in ("Receive", "Pay") and not doc.get("party_account_field"):
doc.setup_party_account_field()
doc.add_party_gl_entries(gl_entries)
doc.add_bank_gl_entries(gl_entries)
doc.add_deductions_gl_entries(gl_entries)
if target_doc == "Journal Entry":
gl_map = []
for d in doc.get("accounts"):
if d.debit or d.credit:
gl_map.append(
doc.get_gl_dict({
"account": d.account,
"party_type": d.party_type,
"party": d.party,
"against": d.against_account,
"debit": flt(d.debit, d.precision("debit")),
"credit": flt(d.credit, d.precision("credit")),
"account_currency": d.account_currency,
"debit_in_account_currency": flt(d.debit_in_account_currency, d.precision("debit_in_account_currency")),
"credit_in_account_currency": flt(d.credit_in_account_currency, d.precision("credit_in_account_currency")),
"against_voucher_type": d.reference_type,
"against_voucher": d.reference_name,
"remarks": doc.remark,
"cost_center": d.cost_center,
"project": d.project
})
)
gl_entries.extend(gl_map)
if target_doc in ["Purchase Receipt"]:
from erpnext.stock import get_warehouse_account_map
warehouse_account = get_warehouse_account_map()
gl_entries.extend(doc.get_gl_entries(warehouse_account))
if target_doc in ["Purchase Invoice","Expense Claim","Sales Invoice","Delivery Note"]:
gl_entries.extend(doc.get_gl_entries())
return gl_entries
@harshit-30 what is the reason for closing this? Can we please specify?
What is the objective of this requirement?
If you can check my app , the task needs more explaining
draft_balance_sheet draft_cash_flow draft_general_ledger draft_profit_and_loss_statement draft_trial_balance
its show draft and/or submitted docs
https://github.com/ahmad18189/reporting