Merge pull request #37876 from frappe/mergify/bp/version-15-hotfix/pr-37852
refactor: better ledger comparision report (backport #37852)
This commit is contained in:
commit
c29e22b3d1
@ -79,7 +79,9 @@ class General_Payment_Ledger_Comparison(object):
|
|||||||
.select(
|
.select(
|
||||||
gle.company,
|
gle.company,
|
||||||
gle.account,
|
gle.account,
|
||||||
|
gle.voucher_type,
|
||||||
gle.voucher_no,
|
gle.voucher_no,
|
||||||
|
gle.party_type,
|
||||||
gle.party,
|
gle.party,
|
||||||
outstanding,
|
outstanding,
|
||||||
)
|
)
|
||||||
@ -89,7 +91,9 @@ class General_Payment_Ledger_Comparison(object):
|
|||||||
& (gle.account.isin(val.accounts))
|
& (gle.account.isin(val.accounts))
|
||||||
)
|
)
|
||||||
.where(Criterion.all(filter_criterion))
|
.where(Criterion.all(filter_criterion))
|
||||||
.groupby(gle.company, gle.account, gle.voucher_no, gle.party)
|
.groupby(
|
||||||
|
gle.company, gle.account, gle.voucher_type, gle.voucher_no, gle.party_type, gle.party
|
||||||
|
)
|
||||||
.run()
|
.run()
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -112,7 +116,13 @@ class General_Payment_Ledger_Comparison(object):
|
|||||||
self.account_types[acc_type].ple = (
|
self.account_types[acc_type].ple = (
|
||||||
qb.from_(ple)
|
qb.from_(ple)
|
||||||
.select(
|
.select(
|
||||||
ple.company, ple.account, ple.voucher_no, ple.party, Sum(ple.amount).as_("outstanding")
|
ple.company,
|
||||||
|
ple.account,
|
||||||
|
ple.voucher_type,
|
||||||
|
ple.voucher_no,
|
||||||
|
ple.party_type,
|
||||||
|
ple.party,
|
||||||
|
Sum(ple.amount).as_("outstanding"),
|
||||||
)
|
)
|
||||||
.where(
|
.where(
|
||||||
(ple.company == self.filters.company)
|
(ple.company == self.filters.company)
|
||||||
@ -120,7 +130,9 @@ class General_Payment_Ledger_Comparison(object):
|
|||||||
& (ple.account.isin(val.accounts))
|
& (ple.account.isin(val.accounts))
|
||||||
)
|
)
|
||||||
.where(Criterion.all(filter_criterion))
|
.where(Criterion.all(filter_criterion))
|
||||||
.groupby(ple.company, ple.account, ple.voucher_no, ple.party)
|
.groupby(
|
||||||
|
ple.company, ple.account, ple.voucher_type, ple.voucher_no, ple.party_type, ple.party
|
||||||
|
)
|
||||||
.run()
|
.run()
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -138,12 +150,12 @@ class General_Payment_Ledger_Comparison(object):
|
|||||||
self.diff = frappe._dict({})
|
self.diff = frappe._dict({})
|
||||||
|
|
||||||
for x in self.variation_in_payment_ledger:
|
for x in self.variation_in_payment_ledger:
|
||||||
self.diff[(x[0], x[1], x[2], x[3])] = frappe._dict({"gl_balance": x[4]})
|
self.diff[(x[0], x[1], x[2], x[3], x[4], x[5])] = frappe._dict({"gl_balance": x[6]})
|
||||||
|
|
||||||
for x in self.variation_in_general_ledger:
|
for x in self.variation_in_general_ledger:
|
||||||
self.diff.setdefault((x[0], x[1], x[2], x[3]), frappe._dict({"gl_balance": 0.0})).update(
|
self.diff.setdefault(
|
||||||
frappe._dict({"pl_balance": x[4]})
|
(x[0], x[1], x[2], x[3], x[4], x[5]), frappe._dict({"gl_balance": 0.0})
|
||||||
)
|
).update(frappe._dict({"pl_balance": x[6]}))
|
||||||
|
|
||||||
def generate_data(self):
|
def generate_data(self):
|
||||||
self.data = []
|
self.data = []
|
||||||
@ -151,8 +163,12 @@ class General_Payment_Ledger_Comparison(object):
|
|||||||
self.data.append(
|
self.data.append(
|
||||||
frappe._dict(
|
frappe._dict(
|
||||||
{
|
{
|
||||||
"voucher_no": key[2],
|
"company": key[0],
|
||||||
"party": key[3],
|
"account": key[1],
|
||||||
|
"voucher_type": key[2],
|
||||||
|
"voucher_no": key[3],
|
||||||
|
"party_type": key[4],
|
||||||
|
"party": key[5],
|
||||||
"gl_balance": val.gl_balance,
|
"gl_balance": val.gl_balance,
|
||||||
"pl_balance": val.pl_balance,
|
"pl_balance": val.pl_balance,
|
||||||
}
|
}
|
||||||
@ -162,12 +178,52 @@ class General_Payment_Ledger_Comparison(object):
|
|||||||
def get_columns(self):
|
def get_columns(self):
|
||||||
self.columns = []
|
self.columns = []
|
||||||
options = None
|
options = None
|
||||||
|
self.columns.append(
|
||||||
|
dict(
|
||||||
|
label=_("Company"),
|
||||||
|
fieldname="company",
|
||||||
|
fieldtype="Link",
|
||||||
|
options="Company",
|
||||||
|
width="100",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
self.columns.append(
|
||||||
|
dict(
|
||||||
|
label=_("Account"),
|
||||||
|
fieldname="account",
|
||||||
|
fieldtype="Link",
|
||||||
|
options="Account",
|
||||||
|
width="100",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
self.columns.append(
|
||||||
|
dict(
|
||||||
|
label=_("Voucher Type"),
|
||||||
|
fieldname="voucher_type",
|
||||||
|
fieldtype="Link",
|
||||||
|
options="DocType",
|
||||||
|
width="100",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
self.columns.append(
|
self.columns.append(
|
||||||
dict(
|
dict(
|
||||||
label=_("Voucher No"),
|
label=_("Voucher No"),
|
||||||
fieldname="voucher_no",
|
fieldname="voucher_no",
|
||||||
fieldtype="Data",
|
fieldtype="Dynamic Link",
|
||||||
options=options,
|
options="voucher_type",
|
||||||
|
width="100",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
self.columns.append(
|
||||||
|
dict(
|
||||||
|
label=_("Party Type"),
|
||||||
|
fieldname="party_type",
|
||||||
|
fieldtype="Link",
|
||||||
|
options="DocType",
|
||||||
width="100",
|
width="100",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -176,8 +232,8 @@ class General_Payment_Ledger_Comparison(object):
|
|||||||
dict(
|
dict(
|
||||||
label=_("Party"),
|
label=_("Party"),
|
||||||
fieldname="party",
|
fieldname="party",
|
||||||
fieldtype="Data",
|
fieldtype="Dynamic Link",
|
||||||
options=options,
|
options="party_type",
|
||||||
width="100",
|
width="100",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
@ -50,7 +50,11 @@ class TestGeneralAndPaymentLedger(FrappeTestCase, AccountsTestMixin):
|
|||||||
self.assertEqual(len(data), 1)
|
self.assertEqual(len(data), 1)
|
||||||
|
|
||||||
expected = {
|
expected = {
|
||||||
|
"company": sinv.company,
|
||||||
|
"account": sinv.debit_to,
|
||||||
|
"voucher_type": sinv.doctype,
|
||||||
"voucher_no": sinv.name,
|
"voucher_no": sinv.name,
|
||||||
|
"party_type": "Customer",
|
||||||
"party": sinv.customer,
|
"party": sinv.customer,
|
||||||
"gl_balance": sinv.grand_total,
|
"gl_balance": sinv.grand_total,
|
||||||
"pl_balance": sinv.grand_total - 1,
|
"pl_balance": sinv.grand_total - 1,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user