fix failing tests

This commit is contained in:
tunde 2017-09-08 15:35:59 +01:00
parent 225ac0dac3
commit 96b8f223fd
2 changed files with 17 additions and 19 deletions

View File

@ -609,11 +609,14 @@ class AccountsController(TransactionBase):
def set_payment_schedule(self):
due_date = self.due_date or get_due_date(self.posting_date)
self.append("payment_schedule", {
"due_date": due_date,
"invoice_portion": 100,
"payment_amount": self.grand_total
})
if self.get("payment_terms_template"):
data = get_payment_terms(self.payment_terms_template, self.posting_date, self.grand_total)
for item in data:
self.append("payment_schedule", item)
else:
data = dict(due_date=due_date, invoice_portion=100, payment_amount=self.grand_total)
self.append("payment_schedule", data)
def set_due_date(self):
self.due_date = max([d.due_date for d in self.get("payment_schedule")])
@ -845,4 +848,4 @@ def get_due_date(posting_date, term):
elif term.due_date_based_on == "Month(s) after the end of the invoice month":
due_date = add_months(get_last_day(posting_date), term.credit_months)
return due_date
return due_date

View File

@ -9,9 +9,9 @@ from erpnext.stock.doctype.item.test_item import get_total_projected_qty
from erpnext.selling.doctype.sales_order.sales_order \
import make_material_request, make_delivery_note, make_sales_invoice, WarehouseRequired
from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
from erpnext.controllers.accounts_controller import get_payment_terms
from frappe.tests.test_permissions import set_user_permission_doctypes
class TestSalesOrder(unittest.TestCase):
def tearDown(self):
frappe.set_user("Administrator")
@ -64,25 +64,22 @@ class TestSalesOrder(unittest.TestCase):
self.assertRaises(frappe.ValidationError, make_sales_invoice, so.name)
so.update(
{"payment_schedule": get_payment_terms(
"_Test Payment Term Template", so.transaction_date, so.grand_total
)}
)
so.update({"payment_terms_template": "_Test Payment Term Template"})
so.save()
so.submit()
si = make_sales_invoice(so.name)
self.assertEqual(si.payment_schedule[0].payment_amount, 500.0)
self.assertEqual(si.payment_schedule[0].due_date.strftime(DATE_FORMAT), so.transaction_date)
self.assertEqual(si.payment_schedule[1].payment_amount, 500.0)
self.assertEqual(si.payment_schedule[1].due_date.strftime(DATE_FORMAT), add_days(so.transaction_date, 30))
self.assertEquals(len(si.get("items")), len(so.get("items")))
self.assertEquals(len(si.get("items")), 1)
si.insert()
self.assertEqual(si.payment_schedule[0].payment_amount, 500.0)
self.assertEqual(si.payment_schedule[0].due_date, so.transaction_date)
self.assertEqual(si.payment_schedule[1].payment_amount, 500.0)
self.assertEqual(si.payment_schedule[1].due_date, add_days(so.transaction_date, 30))
si.submit()
si1 = make_sales_invoice(so.name)
@ -153,7 +150,6 @@ class TestSalesOrder(unittest.TestCase):
so = make_sales_order()
self.assertEqual(get_reserved_qty(), existing_reserved_qty + 10)
dn = create_dn_against_so(so.name, 15)
self.assertEqual(get_reserved_qty(), existing_reserved_qty)
@ -209,7 +205,6 @@ class TestSalesOrder(unittest.TestCase):
make_stock_entry(target="_Test Warehouse - _TC", qty=10, rate=100)
make_stock_entry(item="_Test Item Home Desktop 100", target="_Test Warehouse - _TC", qty=10, rate=100)
existing_reserved_qty_item1 = get_reserved_qty("_Test Item")
existing_reserved_qty_item2 = get_reserved_qty("_Test Item Home Desktop 100")