[purchase order] tests pass

This commit is contained in:
Rushabh Mehta 2013-07-08 12:37:59 +05:30
parent 886c9ef5d1
commit 436467a5c9
5 changed files with 17 additions and 5 deletions

View File

@ -244,7 +244,7 @@ class DocType(BuyingController):
raise Exception , " Validation Error "
def validate_reference_value(self):
# pass
pass
# Validate PO and PR
# -------------------

View File

@ -234,7 +234,6 @@ def make_purchase_receipt(source_name, target_doclist=None):
def make_purchase_invoice(source_name, target_doclist=None):
from webnotes.model.mapper import get_mapped_doclist
def set_missing_values(source, target):
bean = webnotes.bean(target)
bean.run_method("set_missing_values")

View File

@ -32,10 +32,13 @@ class TestPurchaseOrder(unittest.TestCase):
po = webnotes.bean("Purchase Order", po.doc.name)
po.submit()
pr = make_purchase_receipt(po.doc.name)
pr[0]["supplier_warehouse"] = "_Test Warehouse 1"
self.assertEquals(pr[0]["doctype"], "Purchase Receipt")
self.assertEquals(len(pr), len(test_records[0]))
webnotes.bean(pr).insert()
def test_make_purchase_invocie(self):
from buying.doctype.purchase_order.purchase_order import make_purchase_invoice
@ -50,10 +53,12 @@ class TestPurchaseOrder(unittest.TestCase):
self.assertEquals(pi[0]["doctype"], "Purchase Invoice")
self.assertEquals(len(pi), len(test_records[0]))
webnotes.bean(pi).insert()
def test_subcontracting(self):
po = webnotes.bean(copy=test_records[0])
po.insert()
po.insert()
self.assertEquals(len(po.doclist.get({"parentfield": "po_raw_material_details"})), 2)
def test_warehouse_company_validation(self):

View File

@ -52,9 +52,11 @@ class BuyingController(StockController):
self.doc.fields[fieldname] = val
self.set_missing_item_details(get_item_details)
def set_supplier_defaults(self):
self.doc.fields.update(self.get_default_supplier_address(self.doc.fields))
for fieldname, val in self.get_default_address_and_contact("supplier").items():
if self.meta.get_field(fieldname):
self.doc.fields[fieldname] = val
def get_purchase_tax_details(self):
self.doclist = self.doc.clear_table(self.doclist, "purchase_tax_details")

View File

@ -68,6 +68,12 @@ class DocType(BuyingController):
msgprint("Rejected Warehouse is necessary if there are rejections.")
raise Exception
if not flt(d.qty) and flt(d.rejected_qty):
d.qty = flt(d.received_qty) - flt(d.rejected_qty)
elif not flt(d.rejected_qty):
d.rejected_qty = flt(d.received_qty) - flt(d.qty)
# Check Received Qty = Accepted Qty + Rejected Qty
if ((flt(d.qty) + flt(d.rejected_qty)) != flt(d.received_qty)):