Merge pull request #30453 from rahib-hassan/fix-paymentorder-row-delete

fix: enable row deletion in reference table
This commit is contained in:
Saqib Ansari 2022-03-30 15:00:16 +05:30 committed by Nabin Hait
commit 5408980223
5 changed files with 64 additions and 14 deletions

View File

@ -12,7 +12,6 @@ frappe.ui.form.on('Payment Order', {
});
frm.set_df_property('references', 'cannot_add_rows', true);
frm.set_df_property('references', 'cannot_delete_rows', true);
},
refresh: function(frm) {
if (frm.doc.docstatus == 0) {

View File

@ -53,6 +53,22 @@ frappe.query_reports["Accounts Payable"] = {
}
}
},
{
"fieldname": "party_account",
"label": __("Payable Account"),
"fieldtype": "Link",
"options": "Account",
get_query: () => {
var company = frappe.query_report.get_filter_value('company');
return {
filters: {
'company': company,
'account_type': 'Payable',
'is_group': 0
}
};
}
},
{
"fieldname": "ageing_based_on",
"label": __("Ageing Based On"),

View File

@ -66,6 +66,22 @@ frappe.query_reports["Accounts Receivable"] = {
}
}
},
{
"fieldname": "party_account",
"label": __("Receivable Account"),
"fieldtype": "Link",
"options": "Account",
get_query: () => {
var company = frappe.query_report.get_filter_value('company');
return {
filters: {
'company': company,
'account_type': 'Receivable',
'is_group': 0
}
};
}
},
{
"fieldname": "ageing_based_on",
"label": __("Ageing Based On"),

View File

@ -111,6 +111,7 @@ class ReceivablePayableReport(object):
voucher_type=gle.voucher_type,
voucher_no=gle.voucher_no,
party=gle.party,
party_account=gle.account,
posting_date=gle.posting_date,
account_currency=gle.account_currency,
remarks=gle.remarks if self.filters.get("show_remarks") else None,
@ -777,18 +778,22 @@ class ReceivablePayableReport(object):
conditions.append("party=%s")
values.append(self.filters.get(party_type_field))
# get GL with "receivable" or "payable" account_type
account_type = "Receivable" if self.party_type == "Customer" else "Payable"
accounts = [
d.name
for d in frappe.get_all(
"Account", filters={"account_type": account_type, "company": self.filters.company}
)
]
if self.filters.party_account:
conditions.append("account =%s")
values.append(self.filters.party_account)
else:
# get GL with "receivable" or "payable" account_type
account_type = "Receivable" if self.party_type == "Customer" else "Payable"
accounts = [
d.name
for d in frappe.get_all(
"Account", filters={"account_type": account_type, "company": self.filters.company}
)
]
if accounts:
conditions.append("account in (%s)" % ",".join(["%s"] * len(accounts)))
values += accounts
if accounts:
conditions.append("account in (%s)" % ",".join(["%s"] * len(accounts)))
values += accounts
def add_customer_filters(self, conditions, values):
if self.filters.get("customer_group"):
@ -888,6 +893,13 @@ class ReceivablePayableReport(object):
options=self.party_type,
width=180,
)
self.add_column(
label="Receivable Account" if self.party_type == "Customer" else "Payable Account",
fieldname="party_account",
fieldtype="Link",
options="Account",
width=180,
)
if self.party_naming_by == "Naming Series":
self.add_column(

View File

@ -50,12 +50,19 @@ class TestAccountsReceivable(unittest.TestCase):
make_credit_note(name)
report = execute(filters)
expected_data_after_credit_note = [100, 0, 0, 40, -40]
expected_data_after_credit_note = [100, 0, 0, 40, -40, "Debtors - _TC2"]
row = report[1][0]
self.assertEqual(
expected_data_after_credit_note,
[row.invoice_grand_total, row.invoiced, row.paid, row.credit_note, row.outstanding],
[
row.invoice_grand_total,
row.invoiced,
row.paid,
row.credit_note,
row.outstanding,
row.party_account,
],
)