|
@ -18,10 +18,10 @@ class TestOpeningInvoiceCreationTool(unittest.TestCase): |
|
|
if not frappe.db.exists("Company", "_Test Opening Invoice Company"): |
|
|
if not frappe.db.exists("Company", "_Test Opening Invoice Company"): |
|
|
make_company() |
|
|
make_company() |
|
|
|
|
|
|
|
|
def make_invoices(self, invoice_type="Sales", company=None, party_1=None, party_2=None): |
|
|
def make_invoices(self, invoice_type="Sales", company=None, party_1=None, party_2=None, invoice_number=None): |
|
|
doc = frappe.get_single("Opening Invoice Creation Tool") |
|
|
doc = frappe.get_single("Opening Invoice Creation Tool") |
|
|
args = get_opening_invoice_creation_dict(invoice_type=invoice_type, company=company, |
|
|
args = get_opening_invoice_creation_dict(invoice_type=invoice_type, company=company, |
|
|
party_1=party_1, party_2=party_2) |
|
|
party_1=party_1, party_2=party_2, invoice_number=invoice_number) |
|
|
doc.update(args) |
|
|
doc.update(args) |
|
|
return doc.make_invoices() |
|
|
return doc.make_invoices() |
|
|
|
|
|
|
|
@ -92,6 +92,20 @@ class TestOpeningInvoiceCreationTool(unittest.TestCase): |
|
|
# teardown |
|
|
# teardown |
|
|
frappe.db.set_value("Company", company, "default_receivable_account", old_default_receivable_account) |
|
|
frappe.db.set_value("Company", company, "default_receivable_account", old_default_receivable_account) |
|
|
|
|
|
|
|
|
|
|
|
def test_renaming_of_invoice_using_invoice_number_field(self): |
|
|
|
|
|
company = "_Test Opening Invoice Company" |
|
|
|
|
|
party_1, party_2 = make_customer("Customer A"), make_customer("Customer B") |
|
|
|
|
|
self.make_invoices(company=company, party_1=party_1, party_2=party_2, invoice_number="TEST-NEW-INV-11") |
|
|
|
|
|
|
|
|
|
|
|
sales_inv1 = frappe.get_all('Sales Invoice', filters={'customer':'Customer A'})[0].get("name") |
|
|
|
|
|
sales_inv2 = frappe.get_all('Sales Invoice', filters={'customer':'Customer B'})[0].get("name") |
|
|
|
|
|
self.assertEqual(sales_inv1, "TEST-NEW-INV-11") |
|
|
|
|
|
|
|
|
|
|
|
#teardown |
|
|
|
|
|
for inv in [sales_inv1, sales_inv2]: |
|
|
|
|
|
doc = frappe.get_doc('Sales Invoice', inv) |
|
|
|
|
|
doc.cancel() |
|
|
|
|
|
|
|
|
def get_opening_invoice_creation_dict(**args): |
|
|
def get_opening_invoice_creation_dict(**args): |
|
|
party = "Customer" if args.get("invoice_type", "Sales") == "Sales" else "Supplier" |
|
|
party = "Customer" if args.get("invoice_type", "Sales") == "Sales" else "Supplier" |
|
|
company = args.get("company", "_Test Company") |
|
|
company = args.get("company", "_Test Company") |
|
@ -107,7 +121,8 @@ def get_opening_invoice_creation_dict(**args): |
|
|
"item_name": "Opening Item", |
|
|
"item_name": "Opening Item", |
|
|
"due_date": "2016-09-10", |
|
|
"due_date": "2016-09-10", |
|
|
"posting_date": "2016-09-05", |
|
|
"posting_date": "2016-09-05", |
|
|
"temporary_opening_account": get_temporary_opening_account(company) |
|
|
"temporary_opening_account": get_temporary_opening_account(company), |
|
|
|
|
|
"invoice_number": args.get("invoice_number") |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
"qty": 2.0, |
|
|
"qty": 2.0, |
|
@ -116,7 +131,8 @@ def get_opening_invoice_creation_dict(**args): |
|
|
"item_name": "Opening Item", |
|
|
"item_name": "Opening Item", |
|
|
"due_date": "2016-09-10", |
|
|
"due_date": "2016-09-10", |
|
|
"posting_date": "2016-09-05", |
|
|
"posting_date": "2016-09-05", |
|
|
"temporary_opening_account": get_temporary_opening_account(company) |
|
|
"temporary_opening_account": get_temporary_opening_account(company), |
|
|
|
|
|
"invoice_number": None |
|
|
} |
|
|
} |
|
|
] |
|
|
] |
|
|
}) |
|
|
}) |
|
|