pull from hotfix

This commit is contained in:
Himanshu Warekar 2019-04-04 15:19:44 +05:30
commit 7f253b679a
6 changed files with 2167 additions and 2105 deletions

View File

@ -232,6 +232,13 @@ frappe.ui.form.on('Payment Entry', {
},
party_type: function(frm) {
let party_types = Object.keys(frappe.boot.party_account_types);
if(frm.doc.party_type && !party_types.includes(frm.doc.party_type)){
frm.set_value("party_type", "");
frappe.throw(__("Party can only be one of "+ party_types.join(", ")));
}
if(frm.doc.party) {
$.each(["party", "party_balance", "paid_from", "paid_to",
"paid_from_account_currency", "paid_from_account_balance",

View File

@ -20,6 +20,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "type_of_payment",
"fieldtype": "Section Break",
"hidden": 0,
@ -53,6 +54,7 @@
"collapsible": 0,
"columns": 0,
"default": "",
"fetch_if_empty": 0,
"fieldname": "naming_series",
"fieldtype": "Select",
"hidden": 0,
@ -86,6 +88,7 @@
"bold": 1,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "payment_type",
"fieldtype": "Select",
"hidden": 0,
@ -119,6 +122,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "column_break_5",
"fieldtype": "Column Break",
"hidden": 0,
@ -151,6 +155,7 @@
"collapsible": 0,
"columns": 0,
"default": "Today",
"fetch_if_empty": 0,
"fieldname": "posting_date",
"fieldtype": "Date",
"hidden": 0,
@ -183,6 +188,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "company",
"fieldtype": "Link",
"hidden": 0,
@ -216,6 +222,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "cost_center",
"fieldtype": "Link",
"hidden": 0,
@ -249,6 +256,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "mode_of_payment",
"fieldtype": "Link",
"hidden": 0,
@ -283,6 +291,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "eval:in_list([\"Receive\", \"Pay\"], doc.payment_type)",
"fetch_if_empty": 0,
"fieldname": "party_section",
"fieldtype": "Section Break",
"hidden": 0,
@ -317,6 +326,7 @@
"columns": 0,
"default": "",
"depends_on": "eval:in_list([\"Receive\", \"Pay\"], doc.payment_type) && doc.docstatus==0",
"fetch_if_empty": 0,
"fieldname": "party_type",
"fieldtype": "Link",
"hidden": 0,
@ -351,6 +361,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "eval:in_list([\"Receive\", \"Pay\"], doc.payment_type) && doc.party_type",
"fetch_if_empty": 0,
"fieldname": "party",
"fieldtype": "Dynamic Link",
"hidden": 0,
@ -386,6 +397,7 @@
"columns": 0,
"depends_on": "eval:in_list([\"Receive\", \"Pay\"], doc.payment_type) && doc.party_type",
"description": "",
"fetch_if_empty": 0,
"fieldname": "party_name",
"fieldtype": "Data",
"hidden": 0,
@ -418,6 +430,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "column_break_11",
"fieldtype": "Column Break",
"hidden": 0,
@ -450,6 +463,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "party",
"fetch_if_empty": 0,
"fieldname": "bank_account",
"fieldtype": "Link",
"hidden": 0,
@ -476,40 +490,6 @@
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "contact_person",
"fieldname": "contact_email",
"fieldtype": "Data",
"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": "Email",
"length": 0,
"no_copy": 0,
"options": "Email",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"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,
@ -518,6 +498,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "party",
"fetch_if_empty": 0,
"fieldname": "contact_person",
"fieldtype": "Link",
"hidden": 0,
@ -544,6 +525,41 @@
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "contact_person",
"fetch_if_empty": 0,
"fieldname": "contact_email",
"fieldtype": "Data",
"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": "Email",
"length": 0,
"no_copy": 0,
"options": "Email",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"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,
@ -551,6 +567,7 @@
"bold": 0,
"collapsible": 1,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "payment_accounts_section",
"fieldtype": "Section Break",
"hidden": 0,
@ -584,6 +601,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "party",
"fetch_if_empty": 0,
"fieldname": "party_balance",
"fieldtype": "Currency",
"hidden": 0,
@ -617,6 +635,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "eval:(in_list([\"Internal Transfer\", \"Pay\"], doc.payment_type) || doc.party)",
"fetch_if_empty": 0,
"fieldname": "paid_from",
"fieldtype": "Link",
"hidden": 0,
@ -651,6 +670,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "paid_from",
"fetch_if_empty": 0,
"fieldname": "paid_from_account_currency",
"fieldtype": "Link",
"hidden": 0,
@ -685,6 +705,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "paid_from",
"fetch_if_empty": 0,
"fieldname": "paid_from_account_balance",
"fieldtype": "Currency",
"hidden": 0,
@ -718,6 +739,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "column_break_18",
"fieldtype": "Column Break",
"hidden": 0,
@ -750,6 +772,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "eval:(in_list([\"Internal Transfer\", \"Receive\"], doc.payment_type) || doc.party)",
"fetch_if_empty": 0,
"fieldname": "paid_to",
"fieldtype": "Link",
"hidden": 0,
@ -784,6 +807,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "paid_to",
"fetch_if_empty": 0,
"fieldname": "paid_to_account_currency",
"fieldtype": "Link",
"hidden": 0,
@ -818,6 +842,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "paid_to",
"fetch_if_empty": 0,
"fieldname": "paid_to_account_balance",
"fieldtype": "Currency",
"hidden": 0,
@ -853,6 +878,7 @@
"collapsible_depends_on": "",
"columns": 0,
"depends_on": "eval:(doc.paid_to && doc.paid_from)",
"fetch_if_empty": 0,
"fieldname": "payment_amounts_section",
"fieldtype": "Section Break",
"hidden": 0,
@ -886,6 +912,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "",
"fetch_if_empty": 0,
"fieldname": "paid_amount",
"fieldtype": "Currency",
"hidden": 0,
@ -920,6 +947,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "",
"fetch_if_empty": 0,
"fieldname": "source_exchange_rate",
"fieldtype": "Float",
"hidden": 0,
@ -953,6 +981,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "",
"fetch_if_empty": 0,
"fieldname": "base_paid_amount",
"fieldtype": "Currency",
"hidden": 0,
@ -986,6 +1015,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "column_break_21",
"fieldtype": "Column Break",
"hidden": 0,
@ -1018,6 +1048,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "",
"fetch_if_empty": 0,
"fieldname": "received_amount",
"fieldtype": "Currency",
"hidden": 0,
@ -1052,6 +1083,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "",
"fetch_if_empty": 0,
"fieldname": "target_exchange_rate",
"fieldtype": "Float",
"hidden": 0,
@ -1085,6 +1117,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "",
"fetch_if_empty": 0,
"fieldname": "base_received_amount",
"fieldtype": "Currency",
"hidden": 0,
@ -1120,6 +1153,7 @@
"collapsible_depends_on": "references",
"columns": 0,
"depends_on": "eval:(doc.party && doc.paid_from && doc.paid_to && doc.paid_amount && doc.received_amount)",
"fetch_if_empty": 0,
"fieldname": "section_break_14",
"fieldtype": "Section Break",
"hidden": 0,
@ -1154,6 +1188,7 @@
"columns": 0,
"default": "1",
"depends_on": "eval:in_list(['Pay', 'Receive'], doc.payment_type)",
"fetch_if_empty": 0,
"fieldname": "allocate_payment_amount",
"fieldtype": "Check",
"hidden": 0,
@ -1187,6 +1222,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "",
"fetch_if_empty": 0,
"fieldname": "references",
"fieldtype": "Table",
"hidden": 0,
@ -1221,6 +1257,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "",
"fetch_if_empty": 0,
"fieldname": "section_break_34",
"fieldtype": "Section Break",
"hidden": 0,
@ -1254,6 +1291,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "eval:(doc.paid_amount && doc.received_amount && doc.references)",
"fetch_if_empty": 0,
"fieldname": "total_allocated_amount",
"fieldtype": "Currency",
"hidden": 0,
@ -1287,6 +1325,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "",
"fetch_if_empty": 0,
"fieldname": "base_total_allocated_amount",
"fieldtype": "Currency",
"hidden": 0,
@ -1320,6 +1359,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "set_exchange_gain_loss",
"fieldtype": "Button",
"hidden": 0,
@ -1352,6 +1392,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "column_break_36",
"fieldtype": "Column Break",
"hidden": 0,
@ -1384,6 +1425,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "eval:(doc.paid_amount && doc.received_amount && doc.references)",
"fetch_if_empty": 0,
"fieldname": "unallocated_amount",
"fieldtype": "Currency",
"hidden": 0,
@ -1417,6 +1459,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "eval:(doc.paid_amount && doc.received_amount)",
"fetch_if_empty": 0,
"fieldname": "difference_amount",
"fieldtype": "Currency",
"hidden": 0,
@ -1451,6 +1494,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "difference_amount",
"fetch_if_empty": 0,
"fieldname": "write_off_difference_amount",
"fieldtype": "Button",
"hidden": 0,
@ -1485,6 +1529,7 @@
"collapsible_depends_on": "deductions",
"columns": 0,
"depends_on": "eval:(doc.paid_amount && doc.received_amount)",
"fetch_if_empty": 0,
"fieldname": "deductions_or_loss_section",
"fieldtype": "Section Break",
"hidden": 0,
@ -1517,6 +1562,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "deductions",
"fieldtype": "Table",
"hidden": 0,
@ -1550,6 +1596,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "transaction_references",
"fieldtype": "Section Break",
"hidden": 0,
@ -1583,6 +1630,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "eval:(doc.paid_from && doc.paid_to)",
"fetch_if_empty": 0,
"fieldname": "reference_no",
"fieldtype": "Data",
"hidden": 0,
@ -1615,6 +1663,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "column_break_23",
"fieldtype": "Column Break",
"hidden": 0,
@ -1647,6 +1696,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "eval:(doc.paid_from && doc.paid_to)",
"fetch_if_empty": 0,
"fieldname": "reference_date",
"fieldtype": "Date",
"hidden": 0,
@ -1680,6 +1730,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "eval:doc.docstatus==1",
"fetch_if_empty": 0,
"fieldname": "clearance_date",
"fieldtype": "Date",
"hidden": 0,
@ -1714,6 +1765,7 @@
"collapsible_depends_on": "",
"columns": 0,
"depends_on": "eval:(doc.paid_from && doc.paid_to && doc.paid_amount && doc.received_amount)",
"fetch_if_empty": 0,
"fieldname": "section_break_12",
"fieldtype": "Section Break",
"hidden": 0,
@ -1747,6 +1799,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "",
"fetch_if_empty": 0,
"fieldname": "project",
"fieldtype": "Link",
"hidden": 0,
@ -1780,6 +1833,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "remarks",
"fieldtype": "Small Text",
"hidden": 0,
@ -1812,6 +1866,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "column_break_16",
"fieldtype": "Column Break",
"hidden": 0,
@ -1843,6 +1898,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "letter_head",
"fieldtype": "Link",
"hidden": 0,
@ -1876,6 +1932,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "print_heading",
"fieldtype": "Link",
"hidden": 0,
@ -1910,6 +1967,7 @@
"collapsible": 0,
"columns": 0,
"fetch_from": "bank_account.bank",
"fetch_if_empty": 0,
"fieldname": "bank",
"fieldtype": "Read Only",
"hidden": 0,
@ -1943,6 +2001,7 @@
"collapsible": 0,
"columns": 0,
"fetch_from": "bank_account.bank_account_no",
"fetch_if_empty": 0,
"fieldname": "bank_account_no",
"fieldtype": "Read Only",
"hidden": 0,
@ -1975,6 +2034,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "payment_order",
"fieldtype": "Link",
"hidden": 0,
@ -2008,6 +2068,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "subscription_section",
"fieldtype": "Section Break",
"hidden": 0,
@ -2040,6 +2101,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "auto_repeat",
"fieldtype": "Link",
"hidden": 0,
@ -2073,6 +2135,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "amended_from",
"fieldtype": "Link",
"hidden": 0,
@ -2105,6 +2168,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "title",
"fieldtype": "Data",
"hidden": 1,
@ -2141,7 +2205,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2019-01-15 15:58:40.742601",
"modified": "2019-03-27 17:39:54.163016",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Payment Entry",

View File

@ -468,7 +468,7 @@ cur_frm.fields_dict["items"].grid.get_field("cost_center").get_query = function(
cur_frm.cscript.cost_center = function(doc, cdt, cdn){
var d = locals[cdt][cdn];
if(d.idx == 1 && d.cost_center){
if(d.cost_center){
var cl = doc.items || [];
for(var i = 0; i < cl.length; i++){
if(!cl[i].cost_center) cl[i].cost_center = d.cost_center;

View File

@ -4,7 +4,7 @@
from __future__ import unicode_literals
import frappe
import erpnext
from frappe import _
from frappe import _, scrub
from frappe.utils import getdate, nowdate
from six import iteritems, itervalues
@ -14,6 +14,9 @@ class PartyLedgerSummaryReport(object):
self.filters.from_date = getdate(self.filters.from_date or nowdate())
self.filters.to_date = getdate(self.filters.to_date or nowdate())
if not self.filters.get("company"):
self.filters["company"] = frappe.db.get_single_value('Global Defaults', 'default_company')
def run(self, args):
if self.filters.from_date > self.filters.to_date:
frappe.throw(_("From Date must be before To Date"))
@ -21,10 +24,9 @@ class PartyLedgerSummaryReport(object):
self.filters.party_type = args.get("party_type")
self.party_naming_by = frappe.db.get_value(args.get("naming_by")[0], None, args.get("naming_by")[1])
discount_account_field = "discount_allowed_account" if self.filters.party_type == "Customer" \
else "discount_received_account"
self.round_off_account, self.write_off_account, self.discount_account = frappe.get_cached_value('Company',
self.filters.company, ["round_off_account", "write_off_account", discount_account_field])
self.get_gl_entries()
self.get_return_invoices()
self.get_party_adjustment_amounts()
columns = self.get_columns()
data = self.get_data()
@ -48,7 +50,6 @@ class PartyLedgerSummaryReport(object):
})
credit_or_debit_note = "Credit Note" if self.filters.party_type == "Customer" else "Debit Note"
discount_allowed_or_received = "Discount Allowed" if self.filters.party_type == "Customer" else "Discount Received"
columns += [
{
@ -79,27 +80,19 @@ class PartyLedgerSummaryReport(object):
"options": "currency",
"width": 120
},
{
"label": _(discount_allowed_or_received),
"fieldname": "discount_amount",
]
for account in self.party_adjustment_accounts:
columns.append({
"label": account,
"fieldname": "adj_" + scrub(account),
"fieldtype": "Currency",
"options": "currency",
"width": 120
},
{
"label": _("Write Off Amount"),
"fieldname": "write_off_amount",
"fieldtype": "Currency",
"options": "currency",
"width": 120
},
{
"label": _("Other Adjustments"),
"fieldname": "adjustment_amount",
"fieldtype": "Currency",
"options": "currency",
"width": 120
},
"width": 120,
"is_adjustment": 1
})
columns += [
{
"label": _("Closing Balance"),
"fieldname": "closing_balance",
@ -119,17 +112,10 @@ class PartyLedgerSummaryReport(object):
return columns
def get_data(self):
if not self.filters.get("company"):
self.filters["company"] = frappe.db.get_single_value('Global Defaults', 'default_company')
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"
self.get_gl_entries()
self.get_return_invoices()
self.get_party_adjustment_amounts()
self.party_data = frappe._dict({})
for gle in self.gl_entries:
self.party_data.setdefault(gle.party, frappe._dict({
@ -146,7 +132,7 @@ class PartyLedgerSummaryReport(object):
amount = gle.get(invoice_dr_or_cr) - gle.get(reverse_dr_or_cr)
self.party_data[gle.party].closing_balance += amount
if gle.posting_date < self.filters.from_date:
if gle.posting_date < self.filters.from_date or gle.is_opening == "Yes":
self.party_data[gle.party].opening_balance += amount
else:
if amount > 0:
@ -161,9 +147,10 @@ class PartyLedgerSummaryReport(object):
if row.opening_balance or row.invoiced_amount or row.paid_amount or row.return_amount or row.closing_amount:
total_party_adjustment = sum([amount for amount in itervalues(self.party_adjustment_details.get(party, {}))])
row.paid_amount -= total_party_adjustment
row.discount_amount = self.party_adjustment_details.get(party, {}).get(self.discount_account, 0)
row.write_off_amount = self.party_adjustment_details.get(party, {}).get(self.write_off_account, 0)
row.adjustment_amount = total_party_adjustment - row.discount_amount - row.write_off_amount
adjustments = self.party_adjustment_details.get(party, {})
for account in self.party_adjustment_accounts:
row["adj_" + scrub(account)] = adjustments.get(account, 0)
out.append(row)
@ -182,7 +169,7 @@ class PartyLedgerSummaryReport(object):
self.gl_entries = frappe.db.sql("""
select
gle.posting_date, gle.party, gle.voucher_type, gle.voucher_no, gle.against_voucher_type,
gle.against_voucher, gle.debit, gle.credit {join_field}
gle.against_voucher, gle.debit, gle.credit, gle.is_opening {join_field}
from `tabGL Entry` gle
{join}
where
@ -254,9 +241,10 @@ class PartyLedgerSummaryReport(object):
def get_party_adjustment_amounts(self):
conditions = self.prepare_conditions()
income_or_expense = "Expense" if self.filters.party_type == "Customer" else "Income"
income_or_expense = "Expense Account" if self.filters.party_type == "Customer" else "Income Account"
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"
round_off_account = frappe.get_cached_value('Company', self.filters.company, "round_off_account")
gl_entries = frappe.db.sql("""
select
@ -267,7 +255,7 @@ class PartyLedgerSummaryReport(object):
docstatus < 2
and (voucher_type, voucher_no) in (
select voucher_type, voucher_no from `tabGL Entry` gle, `tabAccount` acc
where acc.name = gle.account and acc.root_type = '{income_or_expense}'
where acc.name = gle.account and acc.account_type = '{income_or_expense}'
and gle.posting_date between %(from_date)s and %(to_date)s and gle.docstatus < 2
) and (voucher_type, voucher_no) in (
select voucher_type, voucher_no from `tabGL Entry` gle
@ -277,6 +265,7 @@ class PartyLedgerSummaryReport(object):
""".format(conditions=conditions, income_or_expense=income_or_expense), self.filters, as_dict=True)
self.party_adjustment_details = {}
self.party_adjustment_accounts = set()
adjustment_voucher_entries = {}
for gle in gl_entries:
adjustment_voucher_entries.setdefault((gle.voucher_type, gle.voucher_no), [])
@ -288,12 +277,12 @@ class PartyLedgerSummaryReport(object):
has_irrelevant_entry = False
for gle in voucher_gl_entries:
if gle.account == self.round_off_account:
if gle.account == round_off_account:
continue
elif gle.party:
parties.setdefault(gle.party, 0)
parties[gle.party] += gle.get(reverse_dr_or_cr) - gle.get(invoice_dr_or_cr)
elif frappe.get_cached_value("Account", gle.account, "root_type") == income_or_expense:
elif frappe.get_cached_value("Account", gle.account, "account_type") == income_or_expense:
accounts.setdefault(gle.account, 0)
accounts[gle.account] += gle.get(invoice_dr_or_cr) - gle.get(reverse_dr_or_cr)
else:
@ -303,11 +292,13 @@ class PartyLedgerSummaryReport(object):
if len(parties) == 1:
party = parties.keys()[0]
for account, amount in iteritems(accounts):
self.party_adjustment_accounts.add(account)
self.party_adjustment_details.setdefault(party, {})
self.party_adjustment_details[party].setdefault(account, 0)
self.party_adjustment_details[party][account] += amount
elif len(accounts) == 1 and not has_irrelevant_entry:
account = accounts.keys()[0]
self.party_adjustment_accounts.add(account)
for party, amount in iteritems(parties):
self.party_adjustment_details.setdefault(party, {})
self.party_adjustment_details[party].setdefault(account, 0)

View File

@ -377,7 +377,7 @@ def replace_abbr(company, old, new):
for d in doc:
_rename_record(d)
for dt in ["Warehouse", "Account", "Cost Center", "Department", "Location",
for dt in ["Warehouse", "Account", "Cost Center", "Department",
"Sales Taxes and Charges Template", "Purchase Taxes and Charges Template"]:
_rename_records(dt)
frappe.db.commit()