69 lines
1.5 KiB
Python
Raw Normal View History

2019-01-07 14:49:41 +05:30
import unittest
import frappe
2019-01-07 14:49:41 +05:30
from frappe.utils import getdate
2019-01-07 14:49:41 +05:30
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
from erpnext.accounts.report.account_balance.account_balance import execute
2019-01-07 14:49:41 +05:30
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 = {
2022-03-28 18:52:46 +05:30
"company": "_Test Company 2",
"report_date": getdate(),
"root_type": "Income",
2019-01-07 14:49:41 +05:30
}
make_sales_invoice()
report = execute(filters)
expected_data = [
{
2022-03-28 18:52:46 +05:30
"account": "Direct Income - _TC2",
"currency": "EUR",
2019-01-07 14:49:41 +05:30
"balance": -100.0,
},
{
2022-03-28 18:52:46 +05:30
"account": "Income - _TC2",
"currency": "EUR",
2019-01-07 14:49:41 +05:30
"balance": -100.0,
},
{
2022-03-28 18:52:46 +05:30
"account": "Indirect Income - _TC2",
"currency": "EUR",
2019-01-07 14:49:41 +05:30
"balance": 0.0,
},
{
2022-03-28 18:52:46 +05:30
"account": "Sales - _TC2",
"currency": "EUR",
2019-01-07 14:49:41 +05:30
"balance": -100.0,
},
{
2022-03-28 18:52:46 +05:30
"account": "Service - _TC2",
"currency": "EUR",
2019-01-07 14:49:41 +05:30
"balance": 0.0,
2022-03-28 18:52:46 +05:30
},
2019-01-07 14:49:41 +05:30
]
self.assertEqual(expected_data, report[1])
2022-03-28 18:52:46 +05:30
2019-01-07 14:49:41 +05:30
def make_sales_invoice():
frappe.set_user("Administrator")
2022-03-28 18:52:46 +05:30
create_sales_invoice(
company="_Test Company 2",
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",
cost_center="Main - _TC2",
)