frappe / erpnext

Free and Open Source Enterprise Resource Planning (ERP)
https://erpnext.com
GNU General Public License v3.0
21.78k stars 7.31k forks source link

Allow Financial Statements including Draft entries (Memorandum Journal Entry) #13712

Open rmehta opened 6 years ago

ahmad18189 commented 6 years ago

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

ahmad18189 commented 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
rmehta commented 2 years ago

@harshit-30 what is the reason for closing this? Can we please specify?

aakvatech commented 9 months ago

What is the objective of this requirement?