feat: Supplier Ledger Summary

This commit is contained in:
Saif Ur Rehman 2018-12-12 05:45:49 +05:00
parent 41236ed0e5
commit b07d108bee
6 changed files with 156 additions and 5 deletions

View File

@ -39,9 +39,9 @@ frappe.query_reports["Customer Ledger Summary"] = {
"fieldtype": "Link",
"options": "Customer",
on_change: () => {
var customer = frappe.query_report.get_filter_value('customer');
if (customer) {
frappe.db.get_value('Customer', customer, ["tax_id", "customer_name", "credit_limit", "payment_terms"], function(value) {
var party = frappe.query_report.get_filter_value('party');
if (party) {
frappe.db.get_value('Customer', party, ["tax_id", "customer_name"], function(value) {
frappe.query_report.set_filter_value('tax_id', value["tax_id"]);
frappe.query_report.set_filter_value('customer_name', value["customer_name"]);
});

View File

@ -47,37 +47,50 @@ class PartyLedgerSummaryReport(object):
"label": _("Opening Balance"),
"fieldname": "opening_balance",
"fieldtype": "Currency",
"options": "currency",
"width": 120
},
{
"label": _("Invoiced Amount"),
"fieldname": "invoiced_amount",
"fieldtype": "Currency",
"options": "currency",
"width": 120
},
{
"label": _("Paid Amount"),
"fieldname": "paid_amount",
"fieldtype": "Currency",
"options": "currency",
"width": 120
},
{
"label": _(credit_or_debit_note),
"fieldname": "return_amount",
"fieldtype": "Currency",
"options": "currency",
"width": 120
},
{
"label": _("Write Off Amount"),
"fieldname": "write_off_amount",
"fieldtype": "Currency",
"options": "currency",
"width": 120
},
{
"label": _("Closing Balance"),
"fieldname": "closing_balance",
"fieldtype": "Currency",
"options": "currency",
"width": 120
},
{
"label": _("Currency"),
"fieldname": "currency",
"fieldtype": "Link",
"options": "Currency",
"width": 50
}
]
@ -87,7 +100,7 @@ class PartyLedgerSummaryReport(object):
if not self.filters.get("company"):
self.filters["company"] = frappe.db.get_single_value('Global Defaults', 'default_company')
credit_or_debit_note = "Credit Note" if self.filters.party_type == "Customer" else "Debit Note"
company_currency = frappe.get_cached_value('Company', self.filters.get("company"), "default_currency")
invoice_dr_or_cr = "debit" if self.filters.party_type == "Customer" else "credit"
reverse_dr_or_cr = "credit" if self.filters.party_type == "Customer" else "debit"
@ -105,7 +118,8 @@ class PartyLedgerSummaryReport(object):
"paid_amount": -self.party_write_off_amounts.get(gle.party, 0),
"return_amount": 0,
"write_off_amount": self.party_write_off_amounts.get(gle.party, 0),
"closing_balance": 0
"closing_balance": 0,
"currency": company_currency
}))
amount = gle.get(invoice_dr_or_cr) - gle.get(reverse_dr_or_cr)

View File

@ -0,0 +1,97 @@
// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
/* eslint-disable */
frappe.query_reports["Supplier Ledger Summary"] = {
"filters": [
{
"fieldname":"company",
"label": __("Company"),
"fieldtype": "Link",
"options": "Company",
"default": frappe.defaults.get_user_default("Company")
},
{
"fieldname":"from_date",
"label": __("From Date"),
"fieldtype": "Date",
"default": frappe.datetime.add_months(frappe.datetime.get_today(), -1),
"reqd": 1,
"width": "60px"
},
{
"fieldname":"to_date",
"label": __("To Date"),
"fieldtype": "Date",
"default": frappe.datetime.get_today(),
"reqd": 1,
"width": "60px"
},
{
"fieldname":"finance_book",
"label": __("Finance Book"),
"fieldtype": "Link",
"options": "Finance Book"
},
{
"fieldname":"party",
"label": __("Customer"),
"fieldtype": "Link",
"options": "Customer",
on_change: () => {
var party = frappe.query_report.get_filter_value('party');
if (party) {
frappe.db.get_value('Supplier', party, ["tax_id", "supplier_name"], function(value) {
frappe.query_report.set_filter_value('tax_id', value["tax_id"]);
frappe.query_report.set_filter_value('supplier_name', value["supplier_name"]);
});
} else {
frappe.query_report.set_filter_value('tax_id', "");
frappe.query_report.set_filter_value('supplier_name', "");
}
}
},
{
"fieldname":"supplier_group",
"label": __("Supplier Group"),
"fieldtype": "Link",
"options": "Supplier Group"
},
{
"fieldname":"payment_terms_template",
"label": __("Payment Terms Template"),
"fieldtype": "Link",
"options": "Payment Terms Template"
},
{
"fieldname":"territory",
"label": __("Territory"),
"fieldtype": "Link",
"options": "Territory"
},
{
"fieldname":"sales_partner",
"label": __("Sales Partner"),
"fieldtype": "Link",
"options": "Sales Partner"
},
{
"fieldname":"sales_person",
"label": __("Sales Person"),
"fieldtype": "Link",
"options": "Sales Person"
},
{
"fieldname":"tax_id",
"label": __("Tax Id"),
"fieldtype": "Data",
"hidden": 1
},
{
"fieldname":"supplier_name",
"label": __("Supplier Name"),
"fieldtype": "Data",
"hidden": 1
}
]
};

View File

@ -0,0 +1,27 @@
{
"add_total_row": 1,
"creation": "2018-12-12 05:10:02.987274",
"disabled": 0,
"docstatus": 0,
"doctype": "Report",
"idx": 0,
"is_standard": "Yes",
"letter_head": "Capital Traders",
"modified": "2018-12-12 05:10:02.987274",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Supplier Ledger Summary",
"owner": "Administrator",
"prepared_report": 0,
"ref_doctype": "Purchase Invoice",
"report_name": "Supplier Ledger Summary",
"report_type": "Script Report",
"roles": [
{
"role": "Accounts Manager"
},
{
"role": "Accounts User"
}
]
}

View File

@ -0,0 +1,13 @@
# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
import frappe
from erpnext.accounts.report.customer_ledger_summary.customer_ledger_summary import PartyLedgerSummaryReport
def execute(filters=None):
args = {
"party_type": "Supplier",
"naming_by": ["Buying Settings", "supp_master_name"],
}
return PartyLedgerSummaryReport(filters).run(args)