2019-01-07 09:19:41 +00:00
|
|
|
import unittest
|
2021-09-02 11:14:59 +00:00
|
|
|
|
2019-01-07 09:19:41 +00:00
|
|
|
import frappe
|
|
|
|
from frappe.utils import getdate
|
2021-09-02 11:14:59 +00:00
|
|
|
|
2019-01-07 09:19:41 +00:00
|
|
|
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
|
|
|
|
from erpnext.accounts.report.account_balance.account_balance import execute
|
2021-09-02 11:14:59 +00:00
|
|
|
|
2019-01-07 09:19:41 +00:00
|
|
|
|
|
|
|
class TestAccountBalance(unittest.TestCase):
|
|
|
|
def test_account_balance(self):
|
|
|
|
frappe.db.sql("delete from `tabSales Invoice` where company='_Test Company 2'")
|
|
|
|
frappe.db.sql("delete from `tabGL Entry` where company='_Test Company 2'")
|
|
|
|
|
|
|
|
filters = {
|
|
|
|
"company": "_Test Company 2",
|
|
|
|
"report_date": getdate(),
|
|
|
|
"root_type": "Income",
|
|
|
|
}
|
|
|
|
|
|
|
|
make_sales_invoice()
|
|
|
|
|
|
|
|
report = execute(filters)
|
|
|
|
|
|
|
|
expected_data = [
|
|
|
|
{
|
2021-06-10 12:39:49 +00:00
|
|
|
"account": "Direct Income - _TC2",
|
2019-01-07 09:19:41 +00:00
|
|
|
"currency": "EUR",
|
|
|
|
"balance": -100.0,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"account": "Income - _TC2",
|
|
|
|
"currency": "EUR",
|
|
|
|
"balance": -100.0,
|
|
|
|
},
|
|
|
|
{
|
2021-06-10 12:39:49 +00:00
|
|
|
"account": "Indirect Income - _TC2",
|
2019-01-07 09:19:41 +00:00
|
|
|
"currency": "EUR",
|
|
|
|
"balance": 0.0,
|
|
|
|
},
|
|
|
|
{
|
2021-06-10 12:39:49 +00:00
|
|
|
"account": "Sales - _TC2",
|
2019-01-07 09:19:41 +00:00
|
|
|
"currency": "EUR",
|
|
|
|
"balance": -100.0,
|
|
|
|
},
|
|
|
|
{
|
2021-06-10 12:39:49 +00:00
|
|
|
"account": "Service - _TC2",
|
2019-01-07 09:19:41 +00:00
|
|
|
"currency": "EUR",
|
|
|
|
"balance": 0.0,
|
2021-06-10 12:39:49 +00:00
|
|
|
},
|
2019-01-07 09:19:41 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
self.assertEqual(expected_data, report[1])
|
|
|
|
|
2022-03-28 13:22:46 +00:00
|
|
|
|
2019-01-07 09:19:41 +00:00
|
|
|
def make_sales_invoice():
|
|
|
|
frappe.set_user("Administrator")
|
|
|
|
|
2019-01-07 09:26:22 +00:00
|
|
|
create_sales_invoice(
|
|
|
|
company="_Test Company 2",
|
2019-01-07 09:19:41 +00:00
|
|
|
customer="_Test Customer 2",
|
|
|
|
currency="EUR",
|
|
|
|
warehouse="Finished Goods - _TC2",
|
|
|
|
debit_to="Debtors - _TC2",
|
|
|
|
income_account="Sales - _TC2",
|
|
|
|
expense_account="Cost of Goods Sold - _TC2",
|
2020-06-20 07:02:30 +00:00
|
|
|
cost_center="Main - _TC2",
|
|
|
|
)
|