mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-27 02:28:30 +00:00
Co-authored-by: ljain112 <ljain112@gmail.com>
This commit is contained in:
@@ -34,6 +34,17 @@ frappe.query_reports["Accounts Payable"] = {
|
|||||||
},
|
},
|
||||||
options: "Cost Center",
|
options: "Cost Center",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
fieldname: "project",
|
||||||
|
label: __("Project"),
|
||||||
|
fieldtype: "MultiSelectList",
|
||||||
|
options: "Project",
|
||||||
|
get_data: function (txt) {
|
||||||
|
return frappe.db.get_link_options("Project", txt, {
|
||||||
|
company: frappe.query_report.get_filter_value("company"),
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
fieldname: "party_account",
|
fieldname: "party_account",
|
||||||
label: __("Payable Account"),
|
label: __("Payable Account"),
|
||||||
|
|||||||
@@ -117,3 +117,49 @@ class TestAccountsPayable(ERPNextTestSuite, AccountsTestMixin):
|
|||||||
|
|
||||||
self.assertEqual(len(report[1]), 2)
|
self.assertEqual(len(report[1]), 2)
|
||||||
self.assertEqual([pi.name, payment_term1.payment_term_name], [row.voucher_no, row.payment_term])
|
self.assertEqual([pi.name, payment_term1.payment_term_name], [row.voucher_no, row.payment_term])
|
||||||
|
|
||||||
|
def test_project_filter(self):
|
||||||
|
project = frappe.get_doc(
|
||||||
|
{"doctype": "Project", "project_name": "_Test AP Project", "company": self.company}
|
||||||
|
).insert()
|
||||||
|
|
||||||
|
pi = self.create_purchase_invoice(do_not_submit=True)
|
||||||
|
pi.project = project.name
|
||||||
|
pi.save().submit()
|
||||||
|
|
||||||
|
filters = {
|
||||||
|
"company": self.company,
|
||||||
|
"report_date": today(),
|
||||||
|
"range": "30, 60, 90, 120",
|
||||||
|
"project": [project.name],
|
||||||
|
}
|
||||||
|
|
||||||
|
report = execute(filters)[1]
|
||||||
|
self.assertEqual(len(report), 1)
|
||||||
|
row = report[0]
|
||||||
|
self.assertEqual(row.project, project.name)
|
||||||
|
self.assertEqual(row.invoiced, 300.0)
|
||||||
|
|
||||||
|
def test_project_on_report_output(self):
|
||||||
|
"""
|
||||||
|
Report row must carry the invoice's project.
|
||||||
|
"""
|
||||||
|
filters = {
|
||||||
|
"company": self.company,
|
||||||
|
"report_date": today(),
|
||||||
|
"range": "30, 60, 90, 120",
|
||||||
|
}
|
||||||
|
|
||||||
|
project = frappe.get_doc(
|
||||||
|
{"doctype": "Project", "project_name": "_Test AP Project Output", "company": self.company}
|
||||||
|
).insert()
|
||||||
|
|
||||||
|
pi = self.create_purchase_invoice(do_not_submit=True)
|
||||||
|
pi.project = project.name
|
||||||
|
pi.save().submit()
|
||||||
|
|
||||||
|
report = execute(filters)
|
||||||
|
|
||||||
|
self.assertEqual(len(report[1]), 1)
|
||||||
|
row = report[1][0]
|
||||||
|
self.assertEqual([pi.name, project.name, 300], [row.voucher_no, row.project, row.outstanding])
|
||||||
|
|||||||
@@ -53,6 +53,17 @@ frappe.query_reports["Accounts Payable Summary"] = {
|
|||||||
},
|
},
|
||||||
options: "Cost Center",
|
options: "Cost Center",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
fieldname: "project",
|
||||||
|
label: __("Project"),
|
||||||
|
fieldtype: "MultiSelectList",
|
||||||
|
options: "Project",
|
||||||
|
get_data: function (txt) {
|
||||||
|
return frappe.db.get_link_options("Project", txt, {
|
||||||
|
company: frappe.query_report.get_filter_value("company"),
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
fieldname: "party_type",
|
fieldname: "party_type",
|
||||||
label: __("Party Type"),
|
label: __("Party Type"),
|
||||||
|
|||||||
@@ -36,6 +36,17 @@ frappe.query_reports["Accounts Receivable"] = {
|
|||||||
},
|
},
|
||||||
options: "Cost Center",
|
options: "Cost Center",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
fieldname: "project",
|
||||||
|
label: __("Project"),
|
||||||
|
fieldtype: "MultiSelectList",
|
||||||
|
options: "Project",
|
||||||
|
get_data: function (txt) {
|
||||||
|
return frappe.db.get_link_options("Project", txt, {
|
||||||
|
company: frappe.query_report.get_filter_value("company"),
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
fieldname: "party_type",
|
fieldname: "party_type",
|
||||||
label: __("Party Type"),
|
label: __("Party Type"),
|
||||||
|
|||||||
@@ -196,6 +196,7 @@ class ReceivablePayableReport:
|
|||||||
and ple.against_voucher_type in self.advance_payment_doctypes
|
and ple.against_voucher_type in self.advance_payment_doctypes
|
||||||
):
|
):
|
||||||
self.voucher_balance[key].cost_center = ple.cost_center
|
self.voucher_balance[key].cost_center = ple.cost_center
|
||||||
|
self.voucher_balance[key].project = ple.project
|
||||||
|
|
||||||
self.get_invoices(ple)
|
self.get_invoices(ple)
|
||||||
|
|
||||||
@@ -362,6 +363,7 @@ class ReceivablePayableReport:
|
|||||||
posting_date,
|
posting_date,
|
||||||
account_currency,
|
account_currency,
|
||||||
cost_center,
|
cost_center,
|
||||||
|
project,
|
||||||
sum(invoiced) `invoiced`,
|
sum(invoiced) `invoiced`,
|
||||||
sum(paid) `paid`,
|
sum(paid) `paid`,
|
||||||
sum(credit_note) `credit_note`,
|
sum(credit_note) `credit_note`,
|
||||||
@@ -390,6 +392,7 @@ class ReceivablePayableReport:
|
|||||||
"credit_note_in_account_currency",
|
"credit_note_in_account_currency",
|
||||||
"outstanding_in_account_currency",
|
"outstanding_in_account_currency",
|
||||||
"cost_center",
|
"cost_center",
|
||||||
|
"project",
|
||||||
]:
|
]:
|
||||||
_d[field] = x.get(field)
|
_d[field] = x.get(field)
|
||||||
|
|
||||||
@@ -931,6 +934,7 @@ class ReceivablePayableReport:
|
|||||||
ple.against_voucher_no,
|
ple.against_voucher_no,
|
||||||
ple.party_type,
|
ple.party_type,
|
||||||
ple.cost_center,
|
ple.cost_center,
|
||||||
|
ple.project,
|
||||||
ple.party,
|
ple.party,
|
||||||
ple.posting_date,
|
ple.posting_date,
|
||||||
ple.due_date,
|
ple.due_date,
|
||||||
@@ -998,6 +1002,9 @@ class ReceivablePayableReport:
|
|||||||
if self.filters.cost_center:
|
if self.filters.cost_center:
|
||||||
self.get_cost_center_conditions()
|
self.get_cost_center_conditions()
|
||||||
|
|
||||||
|
if self.filters.project:
|
||||||
|
self.qb_selection_filter.append(self.ple.project.isin(self.filters.project))
|
||||||
|
|
||||||
self.add_accounting_dimensions_filters()
|
self.add_accounting_dimensions_filters()
|
||||||
|
|
||||||
def get_cost_center_conditions(self):
|
def get_cost_center_conditions(self):
|
||||||
@@ -1237,6 +1244,7 @@ class ReceivablePayableReport:
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.add_column(label=_("Cost Center"), fieldname="cost_center", fieldtype="Data")
|
self.add_column(label=_("Cost Center"), fieldname="cost_center", fieldtype="Data")
|
||||||
|
self.add_column(label=_("Project"), fieldname="project", fieldtype="Link", options="Project")
|
||||||
self.add_column(label=_("Voucher Type"), fieldname="voucher_type", fieldtype="Data")
|
self.add_column(label=_("Voucher Type"), fieldname="voucher_type", fieldtype="Data")
|
||||||
self.add_column(
|
self.add_column(
|
||||||
label=_("Voucher No"),
|
label=_("Voucher No"),
|
||||||
@@ -1413,6 +1421,7 @@ class InitSQLProceduresForAR:
|
|||||||
posting_date date,
|
posting_date date,
|
||||||
account_currency {_varchar_type},
|
account_currency {_varchar_type},
|
||||||
cost_center {_varchar_type},
|
cost_center {_varchar_type},
|
||||||
|
project {_varchar_type},
|
||||||
invoiced {_currency_type},
|
invoiced {_currency_type},
|
||||||
paid {_currency_type},
|
paid {_currency_type},
|
||||||
credit_note {_currency_type},
|
credit_note {_currency_type},
|
||||||
@@ -1432,6 +1441,7 @@ class InitSQLProceduresForAR:
|
|||||||
against_voucher_no {_varchar_type},
|
against_voucher_no {_varchar_type},
|
||||||
party_type {_varchar_type},
|
party_type {_varchar_type},
|
||||||
cost_center {_varchar_type},
|
cost_center {_varchar_type},
|
||||||
|
project {_varchar_type},
|
||||||
party {_varchar_type},
|
party {_varchar_type},
|
||||||
posting_date date,
|
posting_date date,
|
||||||
due_date date,
|
due_date date,
|
||||||
@@ -1447,7 +1457,7 @@ class InitSQLProceduresForAR:
|
|||||||
begin
|
begin
|
||||||
if not exists (select name from `{_voucher_balance_name}` where name = sha1(concat_ws(',', ple.account, ple.against_voucher_type, ple.against_voucher_no, ple.party)))
|
if not exists (select name from `{_voucher_balance_name}` where name = sha1(concat_ws(',', ple.account, ple.against_voucher_type, ple.against_voucher_no, ple.party)))
|
||||||
then
|
then
|
||||||
insert into `{_voucher_balance_name}` values (sha1(concat_ws(',', ple.account, ple.against_voucher_type, ple.against_voucher_no, ple.party)), ple.voucher_type, ple.voucher_no, ple.party, ple.account, ple.posting_date, ple.account_currency, ple.cost_center, 0, 0, 0, 0, 0, 0);
|
insert into `{_voucher_balance_name}` values (sha1(concat_ws(',', ple.account, ple.against_voucher_type, ple.against_voucher_no, ple.party)), ple.voucher_type, ple.voucher_no, ple.party, ple.account, ple.posting_date, ple.account_currency, ple.cost_center, ple.project, 0, 0, 0, 0, 0, 0);
|
||||||
end if;
|
end if;
|
||||||
end;
|
end;
|
||||||
"""
|
"""
|
||||||
@@ -1489,7 +1499,7 @@ class InitSQLProceduresForAR:
|
|||||||
|
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
insert into `{_voucher_balance_name}` values (sha1(concat_ws(',', ple.account, ple.voucher_type, ple.voucher_no, ple.party)), ple.against_voucher_type, ple.against_voucher_no, ple.party, ple.account, ple.posting_date, ple.account_currency,'', invoiced, paid, 0, invoiced_in_account_currency, paid_in_account_currency, 0);
|
insert into `{_voucher_balance_name}` values (sha1(concat_ws(',', ple.account, ple.voucher_type, ple.voucher_no, ple.party)), ple.against_voucher_type, ple.against_voucher_no, ple.party, ple.account, ple.posting_date, ple.account_currency,'', '', invoiced, paid, 0, invoiced_in_account_currency, paid_in_account_currency, 0);
|
||||||
end;
|
end;
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|||||||
@@ -1204,3 +1204,52 @@ class TestAccountsReceivable(ERPNextTestSuite, AccountsTestMixin):
|
|||||||
|
|
||||||
self.assertEqual(len(report[1]), 2)
|
self.assertEqual(len(report[1]), 2)
|
||||||
self.assertEqual([si.name, payment_term1.payment_term_name], [row.voucher_no, row.payment_term])
|
self.assertEqual([si.name, payment_term1.payment_term_name], [row.voucher_no, row.payment_term])
|
||||||
|
|
||||||
|
def test_project_filter(self):
|
||||||
|
project = frappe.get_doc(
|
||||||
|
{"doctype": "Project", "project_name": "_Test AR Project", "company": self.company}
|
||||||
|
).insert()
|
||||||
|
|
||||||
|
si = self.create_sales_invoice(no_payment_schedule=True, do_not_submit=True)
|
||||||
|
si.project = project.name
|
||||||
|
si.save().submit()
|
||||||
|
|
||||||
|
filters = {
|
||||||
|
"company": self.company,
|
||||||
|
"report_date": today(),
|
||||||
|
"range": "30, 60, 90, 120",
|
||||||
|
"project": [project.name],
|
||||||
|
}
|
||||||
|
|
||||||
|
report = execute(filters)[1]
|
||||||
|
self.assertEqual(len(report), 1)
|
||||||
|
row = report[0]
|
||||||
|
self.assertEqual(row.project, project.name)
|
||||||
|
self.assertEqual(row.invoiced, 100.0)
|
||||||
|
|
||||||
|
def test_project_on_report_output(self):
|
||||||
|
"""
|
||||||
|
Report row must carry the invoice's project even when the payment entry
|
||||||
|
has no project set.
|
||||||
|
"""
|
||||||
|
filters = {
|
||||||
|
"company": self.company,
|
||||||
|
"report_date": today(),
|
||||||
|
"range": "30, 60, 90, 120",
|
||||||
|
}
|
||||||
|
|
||||||
|
project = frappe.get_doc(
|
||||||
|
{"doctype": "Project", "project_name": "_Test AR Project Output", "company": self.company}
|
||||||
|
).insert()
|
||||||
|
|
||||||
|
si = self.create_sales_invoice(no_payment_schedule=True, do_not_submit=True)
|
||||||
|
si.project = project.name
|
||||||
|
si.save().submit()
|
||||||
|
|
||||||
|
# payment has no project — report row must still show the invoice's project
|
||||||
|
self.create_payment_entry(si.name)
|
||||||
|
report = execute(filters)
|
||||||
|
|
||||||
|
self.assertEqual(len(report[1]), 1)
|
||||||
|
row = report[1][0]
|
||||||
|
self.assertEqual([si.name, project.name, 60], [row.voucher_no, row.project, row.outstanding])
|
||||||
|
|||||||
@@ -53,6 +53,17 @@ frappe.query_reports["Accounts Receivable Summary"] = {
|
|||||||
},
|
},
|
||||||
options: "Cost Center",
|
options: "Cost Center",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
fieldname: "project",
|
||||||
|
label: __("Project"),
|
||||||
|
fieldtype: "MultiSelectList",
|
||||||
|
options: "Project",
|
||||||
|
get_data: function (txt) {
|
||||||
|
return frappe.db.get_link_options("Project", txt, {
|
||||||
|
company: frappe.query_report.get_filter_value("company"),
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
fieldname: "party_type",
|
fieldname: "party_type",
|
||||||
label: __("Party Type"),
|
label: __("Party Type"),
|
||||||
|
|||||||
Reference in New Issue
Block a user