mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-04 04:39:11 +00:00
[purchase order] tests pass
This commit is contained in:
@@ -244,7 +244,7 @@ class DocType(BuyingController):
|
|||||||
raise Exception , " Validation Error "
|
raise Exception , " Validation Error "
|
||||||
|
|
||||||
def validate_reference_value(self):
|
def validate_reference_value(self):
|
||||||
# pass
|
pass
|
||||||
|
|
||||||
# Validate PO and PR
|
# Validate PO and PR
|
||||||
# -------------------
|
# -------------------
|
||||||
|
|||||||
@@ -234,7 +234,6 @@ def make_purchase_receipt(source_name, target_doclist=None):
|
|||||||
def make_purchase_invoice(source_name, target_doclist=None):
|
def make_purchase_invoice(source_name, target_doclist=None):
|
||||||
from webnotes.model.mapper import get_mapped_doclist
|
from webnotes.model.mapper import get_mapped_doclist
|
||||||
|
|
||||||
|
|
||||||
def set_missing_values(source, target):
|
def set_missing_values(source, target):
|
||||||
bean = webnotes.bean(target)
|
bean = webnotes.bean(target)
|
||||||
bean.run_method("set_missing_values")
|
bean.run_method("set_missing_values")
|
||||||
|
|||||||
@@ -32,10 +32,13 @@ class TestPurchaseOrder(unittest.TestCase):
|
|||||||
po = webnotes.bean("Purchase Order", po.doc.name)
|
po = webnotes.bean("Purchase Order", po.doc.name)
|
||||||
po.submit()
|
po.submit()
|
||||||
pr = make_purchase_receipt(po.doc.name)
|
pr = make_purchase_receipt(po.doc.name)
|
||||||
|
pr[0]["supplier_warehouse"] = "_Test Warehouse 1"
|
||||||
|
|
||||||
self.assertEquals(pr[0]["doctype"], "Purchase Receipt")
|
self.assertEquals(pr[0]["doctype"], "Purchase Receipt")
|
||||||
self.assertEquals(len(pr), len(test_records[0]))
|
self.assertEquals(len(pr), len(test_records[0]))
|
||||||
|
|
||||||
|
webnotes.bean(pr).insert()
|
||||||
|
|
||||||
def test_make_purchase_invocie(self):
|
def test_make_purchase_invocie(self):
|
||||||
from buying.doctype.purchase_order.purchase_order import make_purchase_invoice
|
from buying.doctype.purchase_order.purchase_order import make_purchase_invoice
|
||||||
|
|
||||||
@@ -51,6 +54,8 @@ class TestPurchaseOrder(unittest.TestCase):
|
|||||||
self.assertEquals(pi[0]["doctype"], "Purchase Invoice")
|
self.assertEquals(pi[0]["doctype"], "Purchase Invoice")
|
||||||
self.assertEquals(len(pi), len(test_records[0]))
|
self.assertEquals(len(pi), len(test_records[0]))
|
||||||
|
|
||||||
|
webnotes.bean(pi).insert()
|
||||||
|
|
||||||
def test_subcontracting(self):
|
def test_subcontracting(self):
|
||||||
po = webnotes.bean(copy=test_records[0])
|
po = webnotes.bean(copy=test_records[0])
|
||||||
po.insert()
|
po.insert()
|
||||||
|
|||||||
@@ -54,7 +54,9 @@ class BuyingController(StockController):
|
|||||||
self.set_missing_item_details(get_item_details)
|
self.set_missing_item_details(get_item_details)
|
||||||
|
|
||||||
def set_supplier_defaults(self):
|
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):
|
def get_purchase_tax_details(self):
|
||||||
self.doclist = self.doc.clear_table(self.doclist, "purchase_tax_details")
|
self.doclist = self.doc.clear_table(self.doclist, "purchase_tax_details")
|
||||||
|
|||||||
@@ -68,6 +68,12 @@ class DocType(BuyingController):
|
|||||||
msgprint("Rejected Warehouse is necessary if there are rejections.")
|
msgprint("Rejected Warehouse is necessary if there are rejections.")
|
||||||
raise Exception
|
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
|
# Check Received Qty = Accepted Qty + Rejected Qty
|
||||||
if ((flt(d.qty) + flt(d.rejected_qty)) != flt(d.received_qty)):
|
if ((flt(d.qty) + flt(d.rejected_qty)) != flt(d.received_qty)):
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user