Merge pull request #16406 from rohitwaghchaure/newchanges_in_tds_reports

fix: Multiple fixes in the reports
This commit is contained in:
Nabin Hait
2019-01-23 12:05:36 +05:30
committed by GitHub
18 changed files with 551 additions and 74 deletions

View File

@@ -31,3 +31,13 @@ def make_bank_account(doctype, docname):
doc.is_default = 1 doc.is_default = 1
return doc return doc
@frappe.whitelist()
def get_party_bank_account(party_type, party):
return frappe.db.get_value(party_type,
party, 'default_bank_account')
@frappe.whitelist()
def get_bank_account_details(bank_account):
return frappe.db.get_value("Bank Account",
bank_account, ['account', 'bank', 'bank_account_no'], as_dict=1)

View File

@@ -284,7 +284,12 @@ frappe.ui.form.on('Payment Entry', {
() => frm.events.get_outstanding_documents(frm), () => frm.events.get_outstanding_documents(frm),
() => frm.events.hide_unhide_fields(frm), () => frm.events.hide_unhide_fields(frm),
() => frm.events.set_dynamic_labels(frm), () => frm.events.set_dynamic_labels(frm),
() => { frm.set_party_account_based_on_party = false; } () => {
frm.set_party_account_based_on_party = false;
if (r.message.bank_account) {
frm.set_value("bank_account", r.message.bank_account);
}
}
]); ]);
} }
} }
@@ -833,6 +838,25 @@ frappe.ui.form.on('Payment Entry', {
} }
}) })
} }
},
bank_account: function(frm) {
const field = frm.doc.payment_type == "Pay" ? "paid_from":"paid_to";
if (frm.doc.bank_account && in_list(['Pay', 'Receive'], frm.doc.payment_type)) {
frappe.call({
method: "erpnext.accounts.doctype.bank_account.bank_account.get_bank_account_details",
args: {
bank_account: frm.doc.bank_account
},
callback: function(r) {
if (r.message) {
frm.set_value(field, r.message.account);
frm.set_value('bank', r.message.bank);
frm.set_value('bank_account_no', r.message.bank_account_no);
}
}
});
}
} }
}); });

View File

@@ -1,5 +1,6 @@
{ {
"allow_copy": 0, "allow_copy": 0,
"allow_events_in_timeline": 0,
"allow_guest_to_view": 0, "allow_guest_to_view": 0,
"allow_import": 1, "allow_import": 1,
"allow_rename": 0, "allow_rename": 0,
@@ -379,24 +380,24 @@
{ {
"allow_bulk_edit": 0, "allow_bulk_edit": 0,
"allow_in_quick_entry": 0, "allow_in_quick_entry": 0,
"allow_on_submit": 0, "allow_on_submit": 1,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"depends_on": "party", "depends_on": "eval:in_list([\"Receive\", \"Pay\"], doc.payment_type) && doc.party_type",
"fieldname": "contact_person", "description": "",
"fieldtype": "Link", "fieldname": "party_name",
"fieldtype": "Data",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0, "in_global_search": 1,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0, "in_standard_filter": 0,
"label": "Contact", "label": "Party Name",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"options": "Contact",
"permlevel": 0, "permlevel": 0,
"precision": "", "precision": "",
"print_hide": 0, "print_hide": 0,
@@ -444,24 +445,24 @@
{ {
"allow_bulk_edit": 0, "allow_bulk_edit": 0,
"allow_in_quick_entry": 0, "allow_in_quick_entry": 0,
"allow_on_submit": 1, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"depends_on": "eval:in_list([\"Receive\", \"Pay\"], doc.payment_type) && doc.party_type", "depends_on": "party",
"description": "", "fieldname": "bank_account",
"fieldname": "party_name", "fieldtype": "Link",
"fieldtype": "Data",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 1, "in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0, "in_standard_filter": 0,
"label": "Party Name", "label": "Bank Account",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"options": "Bank Account",
"permlevel": 0, "permlevel": 0,
"precision": "", "precision": "",
"print_hide": 0, "print_hide": 0,
@@ -509,6 +510,40 @@
"translatable": 0, "translatable": 0,
"unique": 0 "unique": 0
}, },
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "party",
"fieldname": "contact_person",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Contact",
"length": 0,
"no_copy": 0,
"options": "Contact",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{ {
"allow_bulk_edit": 0, "allow_bulk_edit": 0,
"allow_in_quick_entry": 0, "allow_in_quick_entry": 0,
@@ -1867,6 +1902,72 @@
"translatable": 0, "translatable": 0,
"unique": 0 "unique": 0
}, },
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_from": "bank_account.bank",
"fieldname": "bank",
"fieldtype": "Read Only",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Bank",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_from": "bank_account.bank_account_no",
"fieldname": "bank_account_no",
"fieldtype": "Read Only",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Bank Account No",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{ {
"allow_bulk_edit": 0, "allow_bulk_edit": 0,
"allow_in_quick_entry": 0, "allow_in_quick_entry": 0,
@@ -2040,7 +2141,7 @@
"issingle": 0, "issingle": 0,
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 0,
"modified": "2018-09-25 14:38:48.312629", "modified": "2019-01-15 15:58:40.742601",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Payment Entry", "name": "Payment Entry",

View File

@@ -12,6 +12,7 @@ from erpnext.accounts.doctype.journal_entry.journal_entry import get_default_ban
from erpnext.setup.utils import get_exchange_rate from erpnext.setup.utils import get_exchange_rate
from erpnext.accounts.general_ledger import make_gl_entries from erpnext.accounts.general_ledger import make_gl_entries
from erpnext.hr.doctype.expense_claim.expense_claim import update_reimbursed_amount from erpnext.hr.doctype.expense_claim.expense_claim import update_reimbursed_amount
from erpnext.accounts.doctype.bank_account.bank_account import get_party_bank_account, get_bank_account_details
from erpnext.controllers.accounts_controller import AccountsController, get_supplier_block_status from erpnext.controllers.accounts_controller import AccountsController, get_supplier_block_status
from six import string_types, iteritems from six import string_types, iteritems
@@ -88,6 +89,16 @@ class PaymentEntry(AccountsController):
.format(d.idx, d.reference_doctype, d.reference_name)) .format(d.idx, d.reference_doctype, d.reference_name))
reference_names.append((d.reference_doctype, d.reference_name)) reference_names.append((d.reference_doctype, d.reference_name))
def set_bank_account_data(self):
if self.bank_account:
bank_data = get_bank_account_details(self.bank_account)
field = "paid_from" if self.payment_type == "Pay" else "paid_to"
self.bank = bank_data.bank
self.bank_account_no = bank_data.bank_account_no
self.set(field, bank_data.account)
def validate_allocated_amount(self): def validate_allocated_amount(self):
for d in self.get("references"): for d in self.get("references"):
if (flt(d.allocated_amount))> 0: if (flt(d.allocated_amount))> 0:
@@ -670,6 +681,7 @@ def get_negative_outstanding_invoices(party_type, party, party_account, party_ac
@frappe.whitelist() @frappe.whitelist()
def get_party_details(company, party_type, party, date, cost_center=None): def get_party_details(company, party_type, party, date, cost_center=None):
bank_account = ''
if not frappe.db.exists(party_type, party): if not frappe.db.exists(party_type, party):
frappe.throw(_("Invalid {0}: {1}").format(party_type, party)) frappe.throw(_("Invalid {0}: {1}").format(party_type, party))
@@ -680,13 +692,16 @@ def get_party_details(company, party_type, party, date, cost_center=None):
_party_name = "title" if party_type == "Student" else party_type.lower() + "_name" _party_name = "title" if party_type == "Student" else party_type.lower() + "_name"
party_name = frappe.db.get_value(party_type, party, _party_name) party_name = frappe.db.get_value(party_type, party, _party_name)
party_balance = get_balance_on(party_type=party_type, party=party, cost_center=cost_center) party_balance = get_balance_on(party_type=party_type, party=party, cost_center=cost_center)
if party_type in ["Customer", "Supplier"]:
bank_account = get_party_bank_account(party_type, party)
return { return {
"party_account": party_account, "party_account": party_account,
"party_name": party_name, "party_name": party_name,
"party_account_currency": account_currency, "party_account_currency": account_currency,
"party_balance": party_balance, "party_balance": party_balance,
"account_balance": account_balance "account_balance": account_balance,
"bank_account": bank_account
} }
@@ -890,6 +905,11 @@ def get_payment_entry(dt, dn, party_amount=None, bank_account=None, bank_amount=
pe.allocate_payment_amount = 1 pe.allocate_payment_amount = 1
pe.letter_head = doc.get("letter_head") pe.letter_head = doc.get("letter_head")
if pe.party_type in ["Customer", "Supplier"]:
bank_account = get_party_bank_account(pe.party_type, pe.party)
pe.set("bank_account", bank_account)
pe.set_bank_account_data()
# only Purchase Invoice can be blocked individually # only Purchase Invoice can be blocked individually
if doc.doctype == "Purchase Invoice" and doc.invoice_is_blocked(): if doc.doctype == "Purchase Invoice" and doc.invoice_is_blocked():
frappe.msgprint(_('{0} is on hold till {1}'.format(doc.name, doc.release_date))) frappe.msgprint(_('{0} is on hold till {1}'.format(doc.name, doc.release_date)))

View File

@@ -1,23 +1,34 @@
{ {
"allow_copy": 1, "allow_copy": 1,
"allow_events_in_timeline": 0,
"allow_guest_to_view": 0,
"allow_import": 0, "allow_import": 0,
"allow_rename": 0, "allow_rename": 0,
"beta": 0,
"creation": "2014-07-09 12:04:51.681583", "creation": "2014-07-09 12:04:51.681583",
"custom": 0, "custom": 0,
"docstatus": 0, "docstatus": 0,
"doctype": "DocType", "doctype": "DocType",
"document_type": "", "document_type": "",
"editable_grid": 0,
"engine": "InnoDB",
"fields": [ "fields": [
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0,
"fieldname": "company", "fieldname": "company",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Company", "label": "Company",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@@ -26,22 +37,30 @@
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 0, "read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 1, "reqd": 1,
"search_index": 0, "search_index": 0,
"set_only_once": 0, "set_only_once": 0,
"translatable": 0,
"unique": 0 "unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0,
"fieldname": "party_type", "fieldname": "party_type",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Party Type", "label": "Party Type",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@@ -50,23 +69,31 @@
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 0, "read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 1, "reqd": 1,
"search_index": 0, "search_index": 0,
"set_only_once": 0, "set_only_once": 0,
"translatable": 0,
"unique": 0 "unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0,
"depends_on": "", "depends_on": "",
"fieldname": "party", "fieldname": "party",
"fieldtype": "Dynamic Link", "fieldtype": "Dynamic Link",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Party", "label": "Party",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@@ -75,22 +102,30 @@
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 0, "read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 1, "reqd": 1,
"search_index": 0, "search_index": 0,
"set_only_once": 0, "set_only_once": 0,
"translatable": 0,
"unique": 0 "unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0,
"fieldname": "receivable_payable_account", "fieldname": "receivable_payable_account",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Receivable / Payable Account", "label": "Receivable / Payable Account",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@@ -100,22 +135,30 @@
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 0, "read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 1, "reqd": 1,
"search_index": 0, "search_index": 0,
"set_only_once": 0, "set_only_once": 0,
"translatable": 0,
"unique": 0 "unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0,
"fieldname": "bank_cash_account", "fieldname": "bank_cash_account",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 0,
"label": "Bank / Cash Account", "label": "Bank / Cash Account",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@@ -124,22 +167,30 @@
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 0, "read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 0, "reqd": 0,
"search_index": 0, "search_index": 0,
"set_only_once": 0, "set_only_once": 0,
"translatable": 0,
"unique": 0 "unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0,
"fieldname": "col_break1", "fieldname": "col_break1",
"fieldtype": "Column Break", "fieldtype": "Column Break",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "", "label": "",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@@ -147,22 +198,30 @@
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 0, "read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 0, "reqd": 0,
"search_index": 0, "search_index": 0,
"set_only_once": 0, "set_only_once": 0,
"translatable": 0,
"unique": 0 "unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0,
"fieldname": "from_date", "fieldname": "from_date",
"fieldtype": "Date", "fieldtype": "Date",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 0,
"label": "From Invoice Date", "label": "From Invoice Date",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@@ -170,22 +229,30 @@
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 0, "read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 0, "reqd": 0,
"search_index": 1, "search_index": 0,
"set_only_once": 0, "set_only_once": 0,
"translatable": 0,
"unique": 0 "unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0,
"fieldname": "to_date", "fieldname": "to_date",
"fieldtype": "Date", "fieldtype": "Date",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 0,
"label": "To Invoice Date", "label": "To Invoice Date",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@@ -193,22 +260,30 @@
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 0, "read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 0, "reqd": 0,
"search_index": 1, "search_index": 0,
"set_only_once": 0, "set_only_once": 0,
"translatable": 0,
"unique": 0 "unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0,
"fieldname": "minimum_amount", "fieldname": "minimum_amount",
"fieldtype": "Currency", "fieldtype": "Currency",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Minimum Invoice Amount", "label": "Minimum Invoice Amount",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@@ -216,22 +291,30 @@
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 0, "read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 0, "reqd": 0,
"search_index": 0, "search_index": 0,
"set_only_once": 0, "set_only_once": 0,
"translatable": 0,
"unique": 0 "unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0,
"fieldname": "maximum_amount", "fieldname": "maximum_amount",
"fieldtype": "Currency", "fieldtype": "Currency",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Maximum Invoice Amount", "label": "Maximum Invoice Amount",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@@ -239,22 +322,63 @@
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 0, "read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 0, "reqd": 0,
"search_index": 0, "search_index": 0,
"set_only_once": 0, "set_only_once": 0,
"translatable": 0,
"unique": 0 "unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0,
"description": "System will fetch all the entries if limit value is zero.",
"fieldname": "limit",
"fieldtype": "Int",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Limit",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "get_unreconciled_entries", "fieldname": "get_unreconciled_entries",
"fieldtype": "Button", "fieldtype": "Button",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Get Unreconciled Entries", "label": "Get Unreconciled Entries",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@@ -262,22 +386,30 @@
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 0, "read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 0, "reqd": 0,
"search_index": 0, "search_index": 0,
"set_only_once": 0, "set_only_once": 0,
"translatable": 0,
"unique": 0 "unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0,
"fieldname": "sec_break1", "fieldname": "sec_break1",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Unreconciled Payment Details", "label": "Unreconciled Payment Details",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@@ -285,22 +417,30 @@
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 0, "read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 0, "reqd": 0,
"search_index": 0, "search_index": 0,
"set_only_once": 0, "set_only_once": 0,
"translatable": 0,
"unique": 0 "unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0,
"fieldname": "payments", "fieldname": "payments",
"fieldtype": "Table", "fieldtype": "Table",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Payments", "label": "Payments",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@@ -309,22 +449,30 @@
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 0, "read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 0, "reqd": 0,
"search_index": 0, "search_index": 0,
"set_only_once": 0, "set_only_once": 0,
"translatable": 0,
"unique": 0 "unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0,
"fieldname": "reconcile", "fieldname": "reconcile",
"fieldtype": "Button", "fieldtype": "Button",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Reconcile", "label": "Reconcile",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@@ -332,22 +480,30 @@
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 0, "read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 0, "reqd": 0,
"search_index": 0, "search_index": 0,
"set_only_once": 0, "set_only_once": 0,
"translatable": 0,
"unique": 0 "unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0,
"fieldname": "sec_break2", "fieldname": "sec_break2",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Invoice/Journal Entry Details", "label": "Invoice/Journal Entry Details",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@@ -355,22 +511,30 @@
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 0, "read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 0, "reqd": 0,
"search_index": 0, "search_index": 0,
"set_only_once": 0, "set_only_once": 0,
"translatable": 0,
"unique": 0 "unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0,
"fieldname": "invoices", "fieldname": "invoices",
"fieldtype": "Table", "fieldtype": "Table",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Invoices", "label": "Invoices",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@@ -379,25 +543,28 @@
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 1, "read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 0, "reqd": 0,
"search_index": 0, "search_index": 0,
"set_only_once": 0, "set_only_once": 0,
"translatable": 0,
"unique": 0 "unique": 0
} }
], ],
"has_web_view": 0,
"hide_heading": 0, "hide_heading": 0,
"hide_toolbar": 1, "hide_toolbar": 1,
"icon": "fa fa-resize-horizontal", "icon": "icon-resize-horizontal",
"idx": 0, "idx": 0,
"image_view": 0,
"in_create": 0, "in_create": 0,
"is_submittable": 0, "is_submittable": 0,
"issingle": 1, "issingle": 1,
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 0,
"menu_index": 0, "menu_index": 0,
"modified": "2016-01-04 02:26:58.807921", "modified": "2019-01-15 17:42:21.135214",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Payment Reconciliation", "name": "Payment Reconciliation",
@@ -406,7 +573,6 @@
"permissions": [ "permissions": [
{ {
"amend": 0, "amend": 0,
"apply_user_permissions": 0,
"cancel": 0, "cancel": 0,
"create": 1, "create": 1,
"delete": 1, "delete": 1,
@@ -426,7 +592,6 @@
}, },
{ {
"amend": 0, "amend": 0,
"apply_user_permissions": 0,
"cancel": 0, "cancel": 0,
"create": 1, "create": 1,
"delete": 1, "delete": 1,
@@ -445,8 +610,13 @@
"write": 1 "write": 1
} }
], ],
"quick_entry": 0,
"read_only": 0, "read_only": 0,
"read_only_onload": 0, "read_only_onload": 0,
"show_name_in_global_search": 0,
"sort_field": "modified", "sort_field": "modified",
"sort_order": "DESC" "sort_order": "DESC",
"track_changes": 1,
"track_seen": 0,
"track_views": 0
} }

View File

@@ -25,7 +25,7 @@ class PaymentReconciliation(Document):
def get_payment_entries(self): def get_payment_entries(self):
order_doctype = "Sales Order" if self.party_type=="Customer" else "Purchase Order" order_doctype = "Sales Order" if self.party_type=="Customer" else "Purchase Order"
payment_entries = get_advance_payment_entries(self.party_type, self.party, payment_entries = get_advance_payment_entries(self.party_type, self.party,
self.receivable_payable_account, order_doctype, against_all_orders=True) self.receivable_payable_account, order_doctype, against_all_orders=True, limit=self.limit)
return payment_entries return payment_entries
@@ -36,6 +36,8 @@ class PaymentReconciliation(Document):
bank_account_condition = "t2.against_account like %(bank_cash_account)s" \ bank_account_condition = "t2.against_account like %(bank_cash_account)s" \
if self.bank_cash_account else "1=1" if self.bank_cash_account else "1=1"
limit_cond = "limit %s" % (self.limit or 1000)
journal_entries = frappe.db.sql(""" journal_entries = frappe.db.sql("""
select select
"Journal Entry" as reference_type, t1.name as reference_name, "Journal Entry" as reference_type, t1.name as reference_name,
@@ -55,10 +57,11 @@ class PaymentReconciliation(Document):
THEN 1=1 THEN 1=1
ELSE {bank_account_condition} ELSE {bank_account_condition}
END) END)
order by t1.posting_date order by t1.posting_date {limit_cond}
""".format(**{ """.format(**{
"dr_or_cr": dr_or_cr, "dr_or_cr": dr_or_cr,
"bank_account_condition": bank_account_condition, "bank_account_condition": bank_account_condition,
"limit_cond": limit_cond
}), { }), {
"party_type": self.party_type, "party_type": self.party_type,
"party": self.party, "party": self.party,
@@ -80,7 +83,7 @@ class PaymentReconciliation(Document):
condition = self.check_condition() condition = self.check_condition()
non_reconciled_invoices = get_outstanding_invoices(self.party_type, self.party, non_reconciled_invoices = get_outstanding_invoices(self.party_type, self.party,
self.receivable_payable_account, condition=condition) self.receivable_payable_account, condition=condition, limit=self.limit)
self.add_invoice_entries(non_reconciled_invoices) self.add_invoice_entries(non_reconciled_invoices)

View File

@@ -562,3 +562,12 @@ def get_party_shipping_address(doctype, name):
return out[0][0] return out[0][0]
else: else:
return '' return ''
def get_partywise_advanced_payment_amount(party_type="Customer"):
data = frappe.db.sql(""" SELECT party, sum({0}) as amount
FROM `tabGL Entry`
WHERE party_type = %s and against_voucher is null GROUP BY party"""
.format(("credit - debit") if party_type == "Customer" else "debit") , party_type)
if data:
return frappe._dict(data)

View File

@@ -5,6 +5,7 @@ from __future__ import unicode_literals
import frappe import frappe
from frappe import _, scrub from frappe import _, scrub
from frappe.utils import flt from frappe.utils import flt
from erpnext.accounts.party import get_partywise_advanced_payment_amount
from erpnext.accounts.report.accounts_receivable.accounts_receivable import ReceivablePayableReport from erpnext.accounts.report.accounts_receivable.accounts_receivable import ReceivablePayableReport
from six import iteritems from six import iteritems
@@ -24,6 +25,12 @@ class AccountsReceivableSummary(ReceivablePayableReport):
credit_debit_label = "Credit Note Amt" if args.get('party_type') == 'Customer' else "Debit Note Amt" credit_debit_label = "Credit Note Amt" if args.get('party_type') == 'Customer' else "Debit Note Amt"
columns += [{ columns += [{
"label": _("Advance Amount"),
"fieldname": "advance_amount",
"fieldtype": "Currency",
"options": "currency",
"width": 100
},{
"label": _("Total Invoiced Amt"), "label": _("Total Invoiced Amt"),
"fieldname": "total_invoiced_amt", "fieldname": "total_invoiced_amt",
"fieldtype": "Currency", "fieldtype": "Currency",
@@ -129,12 +136,15 @@ class AccountsReceivableSummary(ReceivablePayableReport):
partywise_total = self.get_partywise_total(party_naming_by, args) partywise_total = self.get_partywise_total(party_naming_by, args)
partywise_advance_amount = get_partywise_advanced_payment_amount(args.get("party_type")) or {}
for party, party_dict in iteritems(partywise_total): for party, party_dict in iteritems(partywise_total):
row = [party] row = [party]
if party_naming_by == "Naming Series": if party_naming_by == "Naming Series":
row += [self.get_party_name(args.get("party_type"), party)] row += [self.get_party_name(args.get("party_type"), party)]
row += [partywise_advance_amount.get(party, 0)]
row += [ row += [
party_dict.invoiced_amt, party_dict.paid_amt, party_dict.credit_amt, party_dict.outstanding_amt, party_dict.invoiced_amt, party_dict.paid_amt, party_dict.credit_amt, party_dict.outstanding_amt,
party_dict.range1, party_dict.range2, party_dict.range3, party_dict.range4, party_dict.range1, party_dict.range2, party_dict.range3, party_dict.range4,
@@ -185,6 +195,9 @@ class AccountsReceivableSummary(ReceivablePayableReport):
if party_naming_by == "Naming Series": if party_naming_by == "Naming Series":
cols += ["party_name"] cols += ["party_name"]
if args.get("party_type") == 'Customer':
cols += ["contact"]
cols += ["voucher_type", "voucher_no", "due_date"] cols += ["voucher_type", "voucher_no", "due_date"]
if args.get("party_type") == "Supplier": if args.get("party_type") == "Supplier":

View File

@@ -8,7 +8,9 @@ from erpnext.accounts.doctype.tax_withholding_category.tax_withholding_category
def execute(filters=None): def execute(filters=None):
validate_filters(filters) validate_filters(filters)
columns = get_columns() filters.naming_series = frappe.db.get_single_value('Buying Settings', 'supp_master_name')
columns = get_columns(filters)
res = get_result(filters) res = get_result(filters)
return columns, res return columns, res
@@ -29,7 +31,8 @@ def get_result(filters):
# if no supplier selected, fetch data for all tds applicable supplier # if no supplier selected, fetch data for all tds applicable supplier
# else fetch relevant data for selected supplier # else fetch relevant data for selected supplier
pan = "pan" if frappe.db.has_column("Supplier", "pan") else "tax_id" pan = "pan" if frappe.db.has_column("Supplier", "pan") else "tax_id"
fields = ["name", pan+" as pan", "tax_withholding_category", "supplier_type"] fields = ["name", pan+" as pan", "tax_withholding_category", "supplier_type", "supplier_name"]
if filters.supplier: if filters.supplier:
filters.supplier = frappe.db.get_list('Supplier', filters.supplier = frappe.db.get_list('Supplier',
{"name": filters.supplier}, fields) {"name": filters.supplier}, fields)
@@ -49,8 +52,13 @@ def get_result(filters):
filters.company, filters.from_date, filters.to_date) filters.company, filters.from_date, filters.to_date)
if total_invoiced_amount or tds_deducted: if total_invoiced_amount or tds_deducted:
out.append([supplier.pan, supplier.name, tds.name, supplier.supplier_type, row = [supplier.pan, supplier.name]
rate, total_invoiced_amount, tds_deducted])
if filters.naming_series == 'Naming Series':
row.append(supplier.supplier_name)
row.extend([tds.name, supplier.supplier_type, rate, total_invoiced_amount, tds_deducted])
out.append(row)
return out return out
@@ -86,7 +94,7 @@ def get_invoice_and_tds_amount(supplier, account, company, from_date, to_date):
return total_invoiced_amount, tds_deducted return total_invoiced_amount, tds_deducted
def get_columns(): def get_columns(filters):
columns = [ columns = [
{ {
"label": _("PAN"), "label": _("PAN"),
@@ -100,7 +108,17 @@ def get_columns():
"fieldname": "supplier", "fieldname": "supplier",
"fieldtype": "Link", "fieldtype": "Link",
"width": 180 "width": 180
}, }]
if filters.naming_series == 'Naming Series':
columns.append({
"label": _("Supplier Name"),
"fieldname": "supplier_name",
"fieldtype": "Data",
"width": 180
})
columns.extend([
{ {
"label": _("Section Code"), "label": _("Section Code"),
"options": "Tax Withholding Category", "options": "Tax Withholding Category",
@@ -132,6 +150,6 @@ def get_columns():
"fieldtype": "Float", "fieldtype": "Float",
"width": 90 "width": 90
} }
] ])
return columns return columns

View File

@@ -11,7 +11,7 @@ def execute(filters=None):
validate_filters(filters) validate_filters(filters)
set_filters(filters) set_filters(filters)
columns = get_columns() columns = get_columns(filters)
if not filters["invoices"]: if not filters["invoices"]:
return columns, [] return columns, []
@@ -43,6 +43,7 @@ def set_filters(filters):
invoices.append(d) invoices.append(d)
filters["invoices"] = invoices if invoices else filters["invoices"] filters["invoices"] = invoices if invoices else filters["invoices"]
filters.naming_series = frappe.db.get_single_value('Buying Settings', 'supp_master_name')
def get_result(filters): def get_result(filters):
supplier_map, tds_docs = get_supplier_map(filters) supplier_map, tds_docs = get_supplier_map(filters)
@@ -71,9 +72,14 @@ def get_result(filters):
if getdate(filters.from_date) <= gle_map[d][0].posting_date \ if getdate(filters.from_date) <= gle_map[d][0].posting_date \
and getdate(filters.to_date) >= gle_map[d][0].posting_date: and getdate(filters.to_date) >= gle_map[d][0].posting_date:
out.append([supplier.pan, supplier.name, tds_doc.name, row = [supplier.pan, supplier.name]
supplier.supplier_type, rate, total_amount_credited, tds_deducted,
gle_map[d][0].posting_date, "Purchase Invoice", d]) if filters.naming_series == 'Naming Series':
row.append(supplier.supplier_name)
row.extend([tds_doc.name, supplier.supplier_type, rate, total_amount_credited,
tds_deducted, gle_map[d][0].posting_date, "Purchase Invoice", d])
out.append(row)
return out return out
@@ -84,7 +90,7 @@ def get_supplier_map(filters):
pan = "pan" if frappe.db.has_column("Supplier", "pan") else "tax_id" pan = "pan" if frappe.db.has_column("Supplier", "pan") else "tax_id"
supplier_detail = frappe.db.get_all('Supplier', supplier_detail = frappe.db.get_all('Supplier',
{"name": ["in", [d.supplier for d in filters["invoices"]]]}, {"name": ["in", [d.supplier for d in filters["invoices"]]]},
["tax_withholding_category", "name", pan+" as pan", "supplier_type"]) ["tax_withholding_category", "name", pan+" as pan", "supplier_type", "supplier_name"])
for d in filters["invoices"]: for d in filters["invoices"]:
supplier_map[d.get("name")] = [k for k in supplier_detail supplier_map[d.get("name")] = [k for k in supplier_detail
@@ -113,7 +119,7 @@ def get_gle_map(filters):
return gle_map return gle_map
def get_columns(): def get_columns(filters):
pan = "pan" if frappe.db.has_column("Supplier", "pan") else "tax_id" pan = "pan" if frappe.db.has_column("Supplier", "pan") else "tax_id"
columns = [ columns = [
{ {
@@ -128,7 +134,17 @@ def get_columns():
"fieldname": "supplier", "fieldname": "supplier",
"fieldtype": "Link", "fieldtype": "Link",
"width": 180 "width": 180
}, }]
if filters.naming_series == 'Naming Series':
columns.append({
"label": _("Supplier Name"),
"fieldname": "supplier_name",
"fieldtype": "Data",
"width": 180
})
columns.extend([
{ {
"label": _("Section Code"), "label": _("Section Code"),
"options": "Tax Withholding Category", "options": "Tax Withholding Category",
@@ -178,7 +194,7 @@ def get_columns():
"options": "transaction_type", "options": "transaction_type",
"width": 90 "width": 90
} }
] ])
return columns return columns

View File

@@ -12,21 +12,6 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
"default": frappe.defaults.get_user_default("Company"), "default": frappe.defaults.get_user_default("Company"),
"reqd": 1 "reqd": 1
}, },
{
"fieldname":"cost_center",
"label": __("Cost Center"),
"fieldtype": "Link",
"options": "Cost Center",
"get_query": function() {
var company = frappe.query_report.get_filter_value('company');
return {
"doctype": "Cost Center",
"filters": {
"company": company,
}
}
}
},
{ {
"fieldname": "fiscal_year", "fieldname": "fiscal_year",
"label": __("Fiscal Year"), "label": __("Fiscal Year"),
@@ -60,6 +45,27 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
"fieldtype": "Date", "fieldtype": "Date",
"default": frappe.defaults.get_user_default("year_end_date"), "default": frappe.defaults.get_user_default("year_end_date"),
}, },
{
"fieldname":"cost_center",
"label": __("Cost Center"),
"fieldtype": "Link",
"options": "Cost Center",
"get_query": function() {
var company = frappe.query_report.get_filter_value('company');
return {
"doctype": "Cost Center",
"filters": {
"company": company,
}
}
}
},
{
"fieldname":"finance_book",
"label": __("Finance Book"),
"fieldtype": "Link",
"options": "Finance Book",
},
{ {
"fieldname": "with_period_closing_entry", "fieldname": "with_period_closing_entry",
"label": __("Period Closing Entry"), "label": __("Period Closing Entry"),
@@ -75,6 +81,11 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
"fieldname": "show_unclosed_fy_pl_balances", "fieldname": "show_unclosed_fy_pl_balances",
"label": __("Show unclosed fiscal year's P&L balances"), "label": __("Show unclosed fiscal year's P&L balances"),
"fieldtype": "Check" "fieldtype": "Check"
},
{
"fieldname": "include_default_book_entries",
"label": __("Include Default Book Entries"),
"fieldtype": "Check"
} }
], ],
"formatter": erpnext.financial_statements.formatter, "formatter": erpnext.financial_statements.formatter,

View File

@@ -67,11 +67,10 @@ def get_data(filters):
gl_entries_by_account = {} gl_entries_by_account = {}
opening_balances = get_opening_balances(filters)
set_gl_entries_by_account(filters.company, filters.from_date, set_gl_entries_by_account(filters.company, filters.from_date,
filters.to_date, min_lft, max_rgt, filters, gl_entries_by_account, ignore_closing_entries=not flt(filters.with_period_closing_entry)) filters.to_date, min_lft, max_rgt, filters, gl_entries_by_account, ignore_closing_entries=not flt(filters.with_period_closing_entry))
opening_balances = get_opening_balances(filters)
total_row = calculate_values(accounts, gl_entries_by_account, opening_balances, filters, company_currency) total_row = calculate_values(accounts, gl_entries_by_account, opening_balances, filters, company_currency)
accumulate_values_into_parents(accounts, accounts_by_name) accumulate_values_into_parents(accounts, accounts_by_name)
@@ -98,6 +97,18 @@ def get_rootwise_opening_balances(filters, report_type):
if not flt(filters.with_period_closing_entry): if not flt(filters.with_period_closing_entry):
additional_conditions += " and ifnull(voucher_type, '')!='Period Closing Voucher'" additional_conditions += " and ifnull(voucher_type, '')!='Period Closing Voucher'"
if filters.cost_center:
lft, rgt = frappe.db.get_value('Cost Center', filters.cost_center, ['lft', 'rgt'])
additional_conditions += """ and cost_center in (select name from `tabCost Center`
where lft >= %s and rgt <= %s)""" % (lft, rgt)
if filters.finance_book:
fb_conditions = " and finance_book = %(finance_book)s"
if filters.include_default_book_entries:
fb_conditions = " and (finance_book in (%(finance_book)s, %(company_fb)s) or finance_book is null)"
additional_conditions += fb_conditions
gle = frappe.db.sql(""" gle = frappe.db.sql("""
select select
account, sum(debit) as opening_debit, sum(credit) as opening_credit account, sum(debit) as opening_debit, sum(credit) as opening_credit
@@ -112,7 +123,9 @@ def get_rootwise_opening_balances(filters, report_type):
"company": filters.company, "company": filters.company,
"from_date": filters.from_date, "from_date": filters.from_date,
"report_type": report_type, "report_type": report_type,
"year_start_date": filters.year_start_date "year_start_date": filters.year_start_date,
"finance_book": filters.finance_book,
"company_fb": frappe.db.get_value("Company", filters.company, 'default_finance_book')
}, },
as_dict=True) as_dict=True)

View File

@@ -6,13 +6,13 @@
"doctype": "Report", "doctype": "Report",
"idx": 0, "idx": 0,
"is_standard": "Yes", "is_standard": "Yes",
"modified": "2018-11-22 17:40:11.317567", "modified": "2019-01-17 17:20:42.374958",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Trial Balance (Simple)", "name": "Trial Balance (Simple)",
"owner": "Administrator", "owner": "Administrator",
"prepared_report": 0, "prepared_report": 0,
"query": "select fiscal_year as \"Fiscal Year:Data:80\",\n\tcompany as \"Company:Data:220\",\n\tposting_date as \"Posting Date:Date:100\",\n\taccount as \"Account:Data:380\",\n\tsum(debit) as \"Debit:Currency:140\",\n\tsum(credit) as \"Credit:Currency:140\"\nfrom `tabGL Entry`\ngroup by fiscal_year, company, posting_date, account\norder by fiscal_year, company, posting_date, account", "query": "select fiscal_year as \"Fiscal Year:Data:80\",\n\tcompany as \"Company:Data:220\",\n\tposting_date as \"Posting Date:Date:100\",\n\taccount as \"Account:Data:380\",\n\tsum(debit) as \"Debit:Currency:140\",\n\tsum(credit) as \"Credit:Currency:140\",\n\tfinance_book as \"Finance Book:Link/Finance Book:140\"\nfrom `tabGL Entry`\ngroup by fiscal_year, company, posting_date, account\norder by fiscal_year, company, posting_date, account",
"ref_doctype": "GL Entry", "ref_doctype": "GL Entry",
"report_name": "Trial Balance (Simple)", "report_name": "Trial Balance (Simple)",
"report_type": "Query Report", "report_type": "Query Report",

View File

@@ -615,7 +615,7 @@ def get_held_invoices(party_type, party):
return held_invoices return held_invoices
def get_outstanding_invoices(party_type, party, account, condition=None): def get_outstanding_invoices(party_type, party, account, condition=None, limit=1000):
outstanding_invoices = [] outstanding_invoices = []
precision = frappe.get_precision("Sales Invoice", "outstanding_amount") precision = frappe.get_precision("Sales Invoice", "outstanding_amount")
@@ -628,6 +628,7 @@ def get_outstanding_invoices(party_type, party, account, condition=None):
invoice = 'Sales Invoice' if erpnext.get_party_account_type(party_type) == 'Receivable' else 'Purchase Invoice' invoice = 'Sales Invoice' if erpnext.get_party_account_type(party_type) == 'Receivable' else 'Purchase Invoice'
held_invoices = get_held_invoices(party_type, party) held_invoices = get_held_invoices(party_type, party)
limit_cond = "limit %s" % (limit or 1000)
invoice_list = frappe.db.sql(""" invoice_list = frappe.db.sql("""
select select
@@ -655,11 +656,12 @@ def get_outstanding_invoices(party_type, party, account, condition=None):
or (voucher_type not in ('Journal Entry', 'Payment Entry'))) or (voucher_type not in ('Journal Entry', 'Payment Entry')))
group by voucher_type, voucher_no group by voucher_type, voucher_no
having (invoice_amount - payment_amount) > 0.005 having (invoice_amount - payment_amount) > 0.005
order by posting_date, name""".format( order by posting_date, name {limit_cond}""".format(
dr_or_cr=dr_or_cr, dr_or_cr=dr_or_cr,
invoice = invoice, invoice = invoice,
payment_dr_or_cr=payment_dr_or_cr, payment_dr_or_cr=payment_dr_or_cr,
condition=condition or "" condition=condition or "",
limit_cond = limit_cond
), { ), {
"party_type": party_type, "party_type": party_type,
"party": party, "party": party,

View File

@@ -149,6 +149,39 @@
"translatable": 0, "translatable": 0,
"unique": 0 "unique": 0
}, },
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "default_bank_account",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Default Bank Account",
"length": 0,
"no_copy": 0,
"options": "Bank Account",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{ {
"allow_bulk_edit": 0, "allow_bulk_edit": 0,
"allow_in_quick_entry": 0, "allow_in_quick_entry": 0,
@@ -1463,7 +1496,7 @@
"issingle": 0, "issingle": 0,
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 0,
"modified": "2019-01-07 16:52:04.660271", "modified": "2019-01-17 13:58:08.597792",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Buying", "module": "Buying",
"name": "Supplier", "name": "Supplier",

View File

@@ -953,11 +953,12 @@ def get_advance_journal_entries(party_type, party, party_account, amount_field,
return list(journal_entries) return list(journal_entries)
def get_advance_payment_entries(party_type, party, party_account, def get_advance_payment_entries(party_type, party, party_account, order_doctype,
order_doctype, order_list=None, include_unallocated=True, against_all_orders=False): order_list=None, include_unallocated=True, against_all_orders=False, limit=1000):
party_account_field = "paid_from" if party_type == "Customer" else "paid_to" party_account_field = "paid_from" if party_type == "Customer" else "paid_to"
payment_type = "Receive" if party_type == "Customer" else "Pay" payment_type = "Receive" if party_type == "Customer" else "Pay"
payment_entries_against_order, unallocated_payment_entries = [], [] payment_entries_against_order, unallocated_payment_entries = [], []
limit_cond = "limit %s" % (limit or 1000)
if order_list or against_all_orders: if order_list or against_all_orders:
if order_list: if order_list:
@@ -977,8 +978,8 @@ def get_advance_payment_entries(party_type, party, party_account,
t1.name = t2.parent and t1.{0} = %s and t1.payment_type = %s t1.name = t2.parent and t1.{0} = %s and t1.payment_type = %s
and t1.party_type = %s and t1.party = %s and t1.docstatus = 1 and t1.party_type = %s and t1.party = %s and t1.docstatus = 1
and t2.reference_doctype = %s {1} and t2.reference_doctype = %s {1}
order by t1.posting_date order by t1.posting_date {2}
""".format(party_account_field, reference_condition), """.format(party_account_field, reference_condition, limit_cond),
[party_account, payment_type, party_type, party, [party_account, payment_type, party_type, party,
order_doctype] + order_list, as_dict=1) order_doctype] + order_list, as_dict=1)
@@ -990,8 +991,8 @@ def get_advance_payment_entries(party_type, party, party_account,
where where
{0} = %s and party_type = %s and party = %s and payment_type = %s {0} = %s and party_type = %s and party = %s and payment_type = %s
and docstatus = 1 and unallocated_amount > 0 and docstatus = 1 and unallocated_amount > 0
order by posting_date order by posting_date {1}
""".format(party_account_field), (party_account, party_type, party, payment_type), as_dict=1) """.format(party_account_field, limit_cond), (party_account, party_type, party, payment_type), as_dict=1)
return list(payment_entries_against_order) + list(unallocated_payment_entries) return list(payment_entries_against_order) + list(unallocated_payment_entries)

View File

@@ -217,6 +217,39 @@
"translatable": 0, "translatable": 0,
"unique": 0 "unique": 0
}, },
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "default_bank_account",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Default Bank Account",
"length": 0,
"no_copy": 0,
"options": "Bank Account",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{ {
"allow_bulk_edit": 0, "allow_bulk_edit": 0,
"allow_in_quick_entry": 0, "allow_in_quick_entry": 0,
@@ -1873,7 +1906,7 @@
"issingle": 0, "issingle": 0,
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 0,
"modified": "2018-10-01 10:07:34.510264", "modified": "2019-01-17 13:10:24.360875",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Selling", "module": "Selling",
"name": "Customer", "name": "Customer",