67 lines
2.4 KiB
Python
67 lines
2.4 KiB
Python
# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors
|
|
# For license information, please see license.txt
|
|
|
|
from __future__ import unicode_literals
|
|
import unittest
|
|
from datetime import datetime
|
|
import frappe
|
|
from erpnext.buying.report.procurement_tracker.procurement_tracker import execute
|
|
from erpnext.stock.doctype.material_request.test_material_request import make_material_request
|
|
from erpnext.stock.doctype.material_request.material_request import make_purchase_order
|
|
from erpnext.buying.doctype.purchase_order.purchase_order import make_purchase_receipt
|
|
from erpnext.stock.doctype.warehouse.test_warehouse import create_warehouse
|
|
|
|
class TestProcurementTracker(unittest.TestCase):
|
|
def test_result_for_procurement_tracker(self):
|
|
filters = {
|
|
'company': '_Test Procurement Company',
|
|
'cost_center': '_Test Cost Center - _TC'
|
|
}
|
|
expected_data = self.generate_expected_data()
|
|
report = execute(filters)
|
|
|
|
length = len(report[1])
|
|
self.assertEqual(expected_data, report[1][length-1])
|
|
|
|
def generate_expected_data(self):
|
|
if not frappe.db.exists("Company", "_Test Procurement Company"):
|
|
frappe.get_doc(dict(
|
|
doctype="Company",
|
|
company_name="_Test Procurement Company",
|
|
abbr="_TPC",
|
|
default_currency="INR",
|
|
country="Pakistan"
|
|
)).insert()
|
|
warehouse = create_warehouse("_Test Procurement Warehouse", company="_Test Procurement Company")
|
|
mr = make_material_request(company="_Test Procurement Company", warehouse=warehouse)
|
|
po = make_purchase_order(mr.name)
|
|
po.supplier = "_Test Supplier"
|
|
po.get("items")[0].cost_center = "_Test Cost Center - _TC"
|
|
po.submit()
|
|
pr = make_purchase_receipt(po.name)
|
|
pr.submit()
|
|
frappe.db.commit()
|
|
date_obj = datetime.date(datetime.now())
|
|
|
|
expected_data = {
|
|
"material_request_date": date_obj,
|
|
"cost_center": "_Test Cost Center - _TC",
|
|
"project": None,
|
|
"requesting_site": "_Test Procurement Warehouse - _TPC",
|
|
"requestor": "Administrator",
|
|
"material_request_no": mr.name,
|
|
"description": '_Test Item 1',
|
|
"quantity": 10.0,
|
|
"unit_of_measurement": "_Test UOM",
|
|
"status": "To Bill",
|
|
"purchase_order_date": date_obj,
|
|
"purchase_order": po.name,
|
|
"supplier": "_Test Supplier",
|
|
"estimated_cost": 0.0,
|
|
"actual_cost": None,
|
|
"purchase_order_amt": 5000.0,
|
|
"purchase_order_amt_in_company_currency": 300000.0,
|
|
"expected_delivery_date": date_obj,
|
|
"actual_delivery_date": date_obj
|
|
}
|
|
return expected_data |