fixed test cases

This commit is contained in:
Anand Doshi 2015-04-08 21:22:08 +05:30
parent 2f87fb41fa
commit c994647704
5 changed files with 237 additions and 241 deletions

View File

@ -469,7 +469,7 @@ class TestSalesInvoice(unittest.TestCase):
pos = copy.deepcopy(test_records[1])
pos["is_pos"] = 1
pos["update_stock"] = 1
pos["posting_time"] = "12:05"
# pos["posting_time"] = "12:05"
pos["cash_bank_account"] = "_Test Account Bank Account - _TC"
pos["paid_amount"] = 600.0
@ -555,7 +555,7 @@ class TestSalesInvoice(unittest.TestCase):
si_doc = copy.deepcopy(test_records[1])
si_doc["update_stock"] = 1
si_doc["posting_time"] = "12:05"
# si_doc["posting_time"] = "12:05"
si_doc.get("items")[0]["warehouse"] = "_Test Warehouse No Account - _TC"
si = frappe.copy_doc(si_doc)

View File

@ -19,7 +19,7 @@ from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos, SerialNoSt
class TestDeliveryNote(unittest.TestCase):
def test_over_billing_against_dn(self):
frappe.db.set_value("Stock Settings", None, "allow_negative_stock", 1)
dn = create_delivery_note(do_not_submit=True)
self.assertRaises(frappe.ValidationError, make_sales_invoice, dn.name)
@ -36,18 +36,18 @@ class TestDeliveryNote(unittest.TestCase):
self.assertEqual(cint(frappe.defaults.get_global_default("auto_accounting_for_stock")), 0)
make_stock_entry(target="_Test Warehouse - _TC", qty=5, incoming_rate=100)
stock_queue = json.loads(get_previous_sle({
"item_code": "_Test Item",
"warehouse": "_Test Warehouse - _TC",
"posting_date": nowdate(),
"posting_time": nowtime()
}).stock_queue or "[]")
dn = create_delivery_note()
sle = frappe.get_doc("Stock Ledger Entry", {"voucher_type": "Delivery Note", "voucher_no": dn.name})
self.assertEqual(sle.stock_value_difference, -1*stock_queue[0][1])
self.assertFalse(get_gl_entries("Delivery Note", dn.name))
@ -61,15 +61,15 @@ class TestDeliveryNote(unittest.TestCase):
stock_in_hand_account = frappe.db.get_value("Account", {"warehouse": "_Test Warehouse - _TC"})
prev_bal = get_balance_on(stock_in_hand_account)
dn = create_delivery_note()
gl_entries = get_gl_entries("Delivery Note", dn.name)
self.assertTrue(gl_entries)
stock_value_difference = abs(frappe.db.get_value("Stock Ledger Entry",
stock_value_difference = abs(frappe.db.get_value("Stock Ledger Entry",
{"voucher_type": "Delivery Note", "voucher_no": dn.name}, "stock_value_difference"))
expected_values = {
stock_in_hand_account: [0.0, stock_value_difference],
"Cost of Goods Sold - _TC": [stock_value_difference, 0.0]
@ -82,15 +82,15 @@ class TestDeliveryNote(unittest.TestCase):
self.assertEquals(bal, prev_bal - stock_value_difference)
# back dated incoming entry
make_stock_entry(posting_date=add_days(nowdate(), -2), target="_Test Warehouse - _TC",
make_stock_entry(posting_date=add_days(nowdate(), -2), target="_Test Warehouse - _TC",
qty=5, incoming_rate=100)
gl_entries = get_gl_entries("Delivery Note", dn.name)
self.assertTrue(gl_entries)
stock_value_difference = abs(frappe.db.get_value("Stock Ledger Entry",
stock_value_difference = abs(frappe.db.get_value("Stock Ledger Entry",
{"voucher_type": "Delivery Note", "voucher_no": dn.name}, "stock_value_difference"))
expected_values = {
stock_in_hand_account: [0.0, stock_value_difference],
"Cost of Goods Sold - _TC": [stock_value_difference, 0.0]
@ -106,22 +106,22 @@ class TestDeliveryNote(unittest.TestCase):
set_perpetual_inventory()
make_stock_entry(item_code="_Test Item", target="_Test Warehouse - _TC", qty=10, incoming_rate=100)
make_stock_entry(item_code="_Test Item Home Desktop 100",
make_stock_entry(item_code="_Test Item Home Desktop 100",
target="_Test Warehouse - _TC", qty=10, incoming_rate=100)
stock_in_hand_account = frappe.db.get_value("Account", {"warehouse": "_Test Warehouse - _TC"})
prev_bal = get_balance_on(stock_in_hand_account)
dn = create_delivery_note(item_code="_Test Sales BOM Item")
stock_value_diff_rm1 = abs(frappe.db.get_value("Stock Ledger Entry",
{"voucher_type": "Delivery Note", "voucher_no": dn.name, "item_code": "_Test Item"},
stock_value_diff_rm1 = abs(frappe.db.get_value("Stock Ledger Entry",
{"voucher_type": "Delivery Note", "voucher_no": dn.name, "item_code": "_Test Item"},
"stock_value_difference"))
stock_value_diff_rm2 = abs(frappe.db.get_value("Stock Ledger Entry",
{"voucher_type": "Delivery Note", "voucher_no": dn.name,
stock_value_diff_rm2 = abs(frappe.db.get_value("Stock Ledger Entry",
{"voucher_type": "Delivery Note", "voucher_no": dn.name,
"item_code": "_Test Item Home Desktop 100"}, "stock_value_difference"))
stock_value_diff = stock_value_diff_rm1 + stock_value_diff_rm2
gl_entries = get_gl_entries("Delivery Note", dn.name)
@ -156,7 +156,7 @@ class TestDeliveryNote(unittest.TestCase):
})
dn.cancel()
self.check_serial_no_values(serial_no, {
"status": "Available",
"warehouse": "_Test Warehouse - _TC",
@ -166,14 +166,14 @@ class TestDeliveryNote(unittest.TestCase):
def test_serialize_status(self):
se = make_serialized_item()
serial_no = get_serial_nos(se.get("items")[0].serial_no)[0]
frappe.db.set_value("Serial No", serial_no, "status", "Not Available")
dn = create_delivery_note(item_code="_Test Serialized Item With Series",
dn = create_delivery_note(item_code="_Test Serialized Item With Series",
serial_no=serial_no, do_not_submit=True)
self.assertRaises(SerialNoStatusError, dn.submit)
def check_serial_no_values(self, serial_no, field_values):
for field, value in field_values.items():
self.assertEquals(cstr(frappe.db.get_value("Serial No", serial_no, field)), value)
@ -186,11 +186,11 @@ def create_delivery_note(**args):
dn.posting_date = args.posting_date
if args.posting_time:
dn.posting_time = args.posting_time
dn.company = args.company or "_Test Company"
dn.customer = args.customer or "_Test Customer"
dn.currency = args.currency or "INR"
dn.append("items", {
"item_code": args.item or args.item_code or "_Test Item",
"warehouse": args.warehouse or "_Test Warehouse - _TC",
@ -201,11 +201,11 @@ def create_delivery_note(**args):
"cost_center": "_Test Cost Center - _TC",
"serial_no": args.serial_no
})
if not args.do_not_save:
dn.insert()
if not args.do_not_submit:
dn.submit()
return dn
test_dependencies = ["Sales BOM"]
test_dependencies = ["Sales BOM"]

View File

@ -1,39 +1,38 @@
[
{
"company": "_Test Company",
"conversion_rate": 1.0,
"currency": "INR",
"customer": "_Test Customer",
"customer_name": "_Test Customer",
"company": "_Test Company",
"conversion_rate": 1.0,
"currency": "INR",
"customer": "_Test Customer",
"customer_name": "_Test Customer",
"items": [
{
"base_amount": 100.0,
"base_rate": 100.0,
"cost_center": "Main - _TC",
"description": "CPU",
"doctype": "Delivery Note Item",
"expense_account": "Cost of Goods Sold - _TC",
"item_code": "_Test Item",
"item_name": "_Test Item",
"parentfield": "items",
"qty": 1.0,
"rate": 100.0,
"stock_uom": "_Test UOM",
"base_amount": 100.0,
"base_rate": 100.0,
"cost_center": "Main - _TC",
"description": "CPU",
"doctype": "Delivery Note Item",
"expense_account": "Cost of Goods Sold - _TC",
"item_code": "_Test Item",
"item_name": "_Test Item",
"parentfield": "items",
"qty": 1.0,
"rate": 100.0,
"stock_uom": "_Test UOM",
"warehouse": "_Test Warehouse - _TC"
}
],
"doctype": "Delivery Note",
"fiscal_year": "_Test Fiscal Year 2013",
"base_grand_total": 100.0,
"grand_total": 100.0,
"naming_series": "_T-Delivery Note-",
"base_net_total": 100.0,
"plc_conversion_rate": 1.0,
"posting_date": "2013-02-21",
"posting_time": "9:00:00",
"price_list_currency": "INR",
"selling_price_list": "_Test Price List",
"status": "Draft",
],
"doctype": "Delivery Note",
"fiscal_year": "_Test Fiscal Year 2013",
"base_grand_total": 100.0,
"grand_total": 100.0,
"naming_series": "_T-Delivery Note-",
"base_net_total": 100.0,
"plc_conversion_rate": 1.0,
"posting_date": "2013-02-21",
"price_list_currency": "INR",
"selling_price_list": "_Test Price List",
"status": "Draft",
"territory": "_Test Territory"
}
]
]

View File

@ -1,123 +1,122 @@
[
{
"buying_price_list": "_Test Price List",
"company": "_Test Company",
"conversion_rate": 1.0,
"currency": "INR",
"doctype": "Purchase Receipt",
"base_grand_total": 720.0,
"naming_series": "_T-Purchase Receipt-",
"base_net_total": 500.0,
"buying_price_list": "_Test Price List",
"company": "_Test Company",
"conversion_rate": 1.0,
"currency": "INR",
"doctype": "Purchase Receipt",
"base_grand_total": 720.0,
"naming_series": "_T-Purchase Receipt-",
"base_net_total": 500.0,
"taxes": [
{
"account_head": "_Test Account Shipping Charges - _TC",
"add_deduct_tax": "Add",
"category": "Valuation and Total",
"charge_type": "Actual",
"description": "Shipping Charges",
"doctype": "Purchase Taxes and Charges",
"parentfield": "taxes",
"rate": 100.0,
"account_head": "_Test Account Shipping Charges - _TC",
"add_deduct_tax": "Add",
"category": "Valuation and Total",
"charge_type": "Actual",
"description": "Shipping Charges",
"doctype": "Purchase Taxes and Charges",
"parentfield": "taxes",
"rate": 100.0,
"tax_amount": 100.0,
"cost_center": "Main - _TC"
},
},
{
"account_head": "_Test Account VAT - _TC",
"add_deduct_tax": "Add",
"category": "Total",
"charge_type": "Actual",
"description": "VAT",
"doctype": "Purchase Taxes and Charges",
"parentfield": "taxes",
"rate": 120.0,
"account_head": "_Test Account VAT - _TC",
"add_deduct_tax": "Add",
"category": "Total",
"charge_type": "Actual",
"description": "VAT",
"doctype": "Purchase Taxes and Charges",
"parentfield": "taxes",
"rate": 120.0,
"tax_amount": 120.0,
"cost_center": "Main - _TC"
},
},
{
"account_head": "_Test Account Customs Duty - _TC",
"add_deduct_tax": "Add",
"category": "Valuation",
"charge_type": "Actual",
"description": "Customs Duty",
"doctype": "Purchase Taxes and Charges",
"parentfield": "taxes",
"rate": 150.0,
"account_head": "_Test Account Customs Duty - _TC",
"add_deduct_tax": "Add",
"category": "Valuation",
"charge_type": "Actual",
"description": "Customs Duty",
"doctype": "Purchase Taxes and Charges",
"parentfield": "taxes",
"rate": 150.0,
"tax_amount": 150.0,
"cost_center": "Main - _TC"
}
],
],
"items": [
{
"base_amount": 250.0,
"conversion_factor": 1.0,
"description": "_Test Item",
"doctype": "Purchase Receipt Item",
"item_code": "_Test Item",
"item_name": "_Test Item",
"parentfield": "items",
"qty": 5.0,
"rate": 50.0,
"received_qty": 5.0,
"rejected_qty": 0.0,
"stock_uom": "_Test UOM",
"uom": "_Test UOM",
"base_amount": 250.0,
"conversion_factor": 1.0,
"description": "_Test Item",
"doctype": "Purchase Receipt Item",
"item_code": "_Test Item",
"item_name": "_Test Item",
"parentfield": "items",
"qty": 5.0,
"rate": 50.0,
"received_qty": 5.0,
"rejected_qty": 0.0,
"stock_uom": "_Test UOM",
"uom": "_Test UOM",
"warehouse": "_Test Warehouse - _TC",
"cost_center": "Main - _TC"
},
},
{
"base_amount": 250.0,
"conversion_factor": 1.0,
"description": "_Test Item",
"doctype": "Purchase Receipt Item",
"item_code": "_Test Item",
"item_name": "_Test Item",
"parentfield": "items",
"qty": 5.0,
"rate": 50.0,
"received_qty": 5.0,
"rejected_qty": 0.0,
"stock_uom": "_Test UOM",
"uom": "_Test UOM",
"base_amount": 250.0,
"conversion_factor": 1.0,
"description": "_Test Item",
"doctype": "Purchase Receipt Item",
"item_code": "_Test Item",
"item_name": "_Test Item",
"parentfield": "items",
"qty": 5.0,
"rate": 50.0,
"received_qty": 5.0,
"rejected_qty": 0.0,
"stock_uom": "_Test UOM",
"uom": "_Test UOM",
"warehouse": "_Test Warehouse 1 - _TC",
"cost_center": "Main - _TC"
}
],
],
"supplier": "_Test Supplier"
},
},
{
"buying_price_list": "_Test Price List",
"company": "_Test Company",
"conversion_rate": 1.0,
"currency": "INR",
"doctype": "Purchase Receipt",
"fiscal_year": "_Test Fiscal Year 2013",
"base_grand_total": 5000.0,
"is_subcontracted": "Yes",
"base_net_total": 5000.0,
"posting_date": "2013-02-12",
"posting_time": "15:33:30",
"buying_price_list": "_Test Price List",
"company": "_Test Company",
"conversion_rate": 1.0,
"currency": "INR",
"doctype": "Purchase Receipt",
"fiscal_year": "_Test Fiscal Year 2013",
"base_grand_total": 5000.0,
"is_subcontracted": "Yes",
"base_net_total": 5000.0,
"posting_date": "2013-02-12",
"items": [
{
"base_amount": 5000.0,
"conversion_factor": 1.0,
"description": "_Test FG Item",
"doctype": "Purchase Receipt Item",
"item_code": "_Test FG Item",
"item_name": "_Test FG Item",
"parentfield": "items",
"qty": 10.0,
"rate": 500.0,
"received_qty": 10.0,
"rejected_qty": 0.0,
"stock_uom": "_Test UOM",
"uom": "_Test UOM",
"base_amount": 5000.0,
"conversion_factor": 1.0,
"description": "_Test FG Item",
"doctype": "Purchase Receipt Item",
"item_code": "_Test FG Item",
"item_name": "_Test FG Item",
"parentfield": "items",
"qty": 10.0,
"rate": 500.0,
"received_qty": 10.0,
"rejected_qty": 0.0,
"stock_uom": "_Test UOM",
"uom": "_Test UOM",
"warehouse": "_Test Warehouse - _TC",
"cost_center": "Main - _TC"
}
],
"supplier": "_Test Supplier",
],
"supplier": "_Test Supplier",
"supplier_warehouse": "_Test Warehouse - _TC"
}
]
]

View File

@ -1,114 +1,112 @@
[
{
"company": "_Test Company",
"doctype": "Stock Entry",
"company": "_Test Company",
"doctype": "Stock Entry",
"items": [
{
"conversion_factor": 1.0,
"cost_center": "_Test Cost Center - _TC",
"doctype": "Stock Entry Detail",
"expense_account": "Stock Adjustment - _TC",
"conversion_factor": 1.0,
"cost_center": "_Test Cost Center - _TC",
"doctype": "Stock Entry Detail",
"expense_account": "Stock Adjustment - _TC",
"incoming_rate": 100,
"item_code": "_Test Item",
"parentfield": "items",
"qty": 50.0,
"stock_uom": "_Test UOM",
"t_warehouse": "_Test Warehouse - _TC",
"transfer_qty": 50.0,
"item_code": "_Test Item",
"parentfield": "items",
"qty": 50.0,
"stock_uom": "_Test UOM",
"t_warehouse": "_Test Warehouse - _TC",
"transfer_qty": 50.0,
"uom": "_Test UOM"
}
],
],
"purpose": "Material Receipt"
},
},
{
"company": "_Test Company",
"doctype": "Stock Entry",
"fiscal_year": "_Test Fiscal Year 2013",
"company": "_Test Company",
"doctype": "Stock Entry",
"fiscal_year": "_Test Fiscal Year 2013",
"items": [
{
"conversion_factor": 1.0,
"cost_center": "_Test Cost Center - _TC",
"doctype": "Stock Entry Detail",
"expense_account": "Stock Adjustment - _TC",
"incoming_rate": 100,
"item_code": "_Test Item",
"parentfield": "items",
"qty": 40.0,
"s_warehouse": "_Test Warehouse - _TC",
"stock_uom": "_Test UOM",
"transfer_qty": 40.0,
"conversion_factor": 1.0,
"cost_center": "_Test Cost Center - _TC",
"doctype": "Stock Entry Detail",
"expense_account": "Stock Adjustment - _TC",
"incoming_rate": 100,
"item_code": "_Test Item",
"parentfield": "items",
"qty": 40.0,
"s_warehouse": "_Test Warehouse - _TC",
"stock_uom": "_Test UOM",
"transfer_qty": 40.0,
"uom": "_Test UOM"
}
],
"posting_date": "2013-01-25",
"posting_time": "17:15",
],
"posting_date": "2013-01-25",
"purpose": "Material Issue"
},
},
{
"company": "_Test Company",
"doctype": "Stock Entry",
"fiscal_year": "_Test Fiscal Year 2013",
"company": "_Test Company",
"doctype": "Stock Entry",
"fiscal_year": "_Test Fiscal Year 2013",
"items": [
{
"conversion_factor": 1.0,
"cost_center": "_Test Cost Center - _TC",
"doctype": "Stock Entry Detail",
"expense_account": "Stock Adjustment - _TC",
"incoming_rate": 100,
"item_code": "_Test Item",
"parentfield": "items",
"qty": 45.0,
"s_warehouse": "_Test Warehouse - _TC",
"stock_uom": "_Test UOM",
"t_warehouse": "_Test Warehouse 1 - _TC",
"transfer_qty": 45.0,
"conversion_factor": 1.0,
"cost_center": "_Test Cost Center - _TC",
"doctype": "Stock Entry Detail",
"expense_account": "Stock Adjustment - _TC",
"incoming_rate": 100,
"item_code": "_Test Item",
"parentfield": "items",
"qty": 45.0,
"s_warehouse": "_Test Warehouse - _TC",
"stock_uom": "_Test UOM",
"t_warehouse": "_Test Warehouse 1 - _TC",
"transfer_qty": 45.0,
"uom": "_Test UOM"
}
],
"posting_date": "2013-01-25",
"posting_time": "17:14:24",
],
"posting_date": "2013-01-25",
"purpose": "Material Transfer"
},
},
{
"company": "_Test Company",
"doctype": "Stock Entry",
"fiscal_year": "_Test Fiscal Year 2013",
"company": "_Test Company",
"doctype": "Stock Entry",
"fiscal_year": "_Test Fiscal Year 2013",
"items": [
{
"conversion_factor": 1.0,
"cost_center": "_Test Cost Center - _TC",
"doctype": "Stock Entry Detail",
"expense_account": "Stock Adjustment - _TC",
"incoming_rate": 100,
"item_code": "_Test Item",
"parentfield": "items",
"qty": 50.0,
"s_warehouse": "_Test Warehouse - _TC",
"stock_uom": "_Test UOM",
"transfer_qty": 50.0,
"conversion_factor": 1.0,
"cost_center": "_Test Cost Center - _TC",
"doctype": "Stock Entry Detail",
"expense_account": "Stock Adjustment - _TC",
"incoming_rate": 100,
"item_code": "_Test Item",
"parentfield": "items",
"qty": 50.0,
"s_warehouse": "_Test Warehouse - _TC",
"stock_uom": "_Test UOM",
"transfer_qty": 50.0,
"uom": "_Test UOM"
},
},
{
"conversion_factor": 1.0,
"cost_center": "_Test Cost Center - _TC",
"doctype": "Stock Entry Detail",
"expense_account": "Stock Adjustment - _TC",
"incoming_rate": 5000,
"item_code": "_Test Item Home Desktop 100",
"parentfield": "items",
"qty": 1,
"stock_uom": "_Test UOM",
"t_warehouse": "_Test Warehouse - _TC",
"transfer_qty": 1,
"conversion_factor": 1.0,
"cost_center": "_Test Cost Center - _TC",
"doctype": "Stock Entry Detail",
"expense_account": "Stock Adjustment - _TC",
"incoming_rate": 5000,
"item_code": "_Test Item Home Desktop 100",
"parentfield": "items",
"qty": 1,
"stock_uom": "_Test UOM",
"t_warehouse": "_Test Warehouse - _TC",
"transfer_qty": 1,
"uom": "_Test UOM"
}
],
],
"purpose": "Repack"
}
]
]